nashorn/test/script/sandbox/nashorninternals.js
author hannesw
Wed, 25 Jun 2014 14:36:24 +0200
changeset 25243 7a1edca6ce94
parent 24778 2ff5d7041566
child 34447 ec4c069f9436
permissions -rw-r--r--
8048079: Persistent code store is broken after optimistic types merge Reviewed-by: sundar, jlaskey, attila
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16226
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
     1
/*
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 19097
diff changeset
     4
 *
16226
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
     7
 * published by the Free Software Foundation.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 19097
diff changeset
     8
 *
16226
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    13
 * accompanied this code).
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 19097
diff changeset
    14
 *
16226
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 19097
diff changeset
    18
 *
16226
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    21
 * questions.
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    22
 */
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    23
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    24
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    25
/**
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 19097
diff changeset
    26
 * Test to check that nashorn "internal" classes in codegen, parser, ir
16226
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    27
 * packages cannot * be accessed from sandbox scripts.
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    28
 *
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    29
 * @test
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    30
 * @run
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    31
 * @security
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    32
 */
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    33
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    34
function checkClass(name) {
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    35
    try {
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    36
        Java.type(name);
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    37
        fail("should have thrown exception for: " + name);
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    38
    } catch (e) {
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    39
        if (! (e instanceof java.lang.SecurityException)) {
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    40
            fail("Expected SecurityException, but got " + e);
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    41
        }
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    42
    }
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    43
}
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    44
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    45
// Not exhaustive - but a representative list of classes
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    46
checkClass("jdk.nashorn.internal.codegen.Compiler");
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    47
checkClass("jdk.nashorn.internal.codegen.types.Type");
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    48
checkClass("jdk.nashorn.internal.ir.Node");
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    49
checkClass("jdk.nashorn.internal.ir.FunctionNode");
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    50
checkClass("jdk.nashorn.internal.ir.debug.JSONWriter");
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    51
checkClass("jdk.nashorn.internal.ir.visitor.NodeVisitor");
19097
f544a2ea40ef 8021262: Make nashorn access checks consistent with underlying dynalink
sundar
parents: 16234
diff changeset
    52
checkClass("jdk.nashorn.internal.lookup.MethodHandleFactory");
f544a2ea40ef 8021262: Make nashorn access checks consistent with underlying dynalink
sundar
parents: 16234
diff changeset
    53
checkClass("jdk.nashorn.internal.objects.Global");
16226
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    54
checkClass("jdk.nashorn.internal.parser.AbstractParser");
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    55
checkClass("jdk.nashorn.internal.parser.Parser");
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    56
checkClass("jdk.nashorn.internal.parser.JSONParser");
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    57
checkClass("jdk.nashorn.internal.parser.Lexer");
0e4f37e6cc40 8007915: Nashorn IR, codegen, parser packages and Context instance should be inaccessible to user code
sundar
parents:
diff changeset
    58
checkClass("jdk.nashorn.internal.parser.Scanner");
19097
f544a2ea40ef 8021262: Make nashorn access checks consistent with underlying dynalink
sundar
parents: 16234
diff changeset
    59
checkClass("jdk.nashorn.internal.runtime.Context");
f544a2ea40ef 8021262: Make nashorn access checks consistent with underlying dynalink
sundar
parents: 16234
diff changeset
    60
checkClass("jdk.nashorn.internal.runtime.arrays.ArrayData");
f544a2ea40ef 8021262: Make nashorn access checks consistent with underlying dynalink
sundar
parents: 16234
diff changeset
    61
checkClass("jdk.nashorn.internal.runtime.linker.Bootstrap");
f544a2ea40ef 8021262: Make nashorn access checks consistent with underlying dynalink
sundar
parents: 16234
diff changeset
    62
checkClass("jdk.nashorn.internal.runtime.options.Option");
f544a2ea40ef 8021262: Make nashorn access checks consistent with underlying dynalink
sundar
parents: 16234
diff changeset
    63
checkClass("jdk.nashorn.internal.runtime.regexp.RegExp");
f544a2ea40ef 8021262: Make nashorn access checks consistent with underlying dynalink
sundar
parents: 16234
diff changeset
    64
checkClass("jdk.nashorn.internal.scripts.JO");
f544a2ea40ef 8021262: Make nashorn access checks consistent with underlying dynalink
sundar
parents: 16234
diff changeset
    65
checkClass("jdk.nashorn.tools.Shell");
16234
86cb162cec6c 8008085: Integrate Dynalink source code into Nashorn codebase
attila
parents: 16226
diff changeset
    66
checkClass("jdk.internal.dynalink.CallSiteDescriptor");
86cb162cec6c 8008085: Integrate Dynalink source code into Nashorn codebase
attila
parents: 16226
diff changeset
    67
checkClass("jdk.internal.dynalink.beans.StaticClass");
86cb162cec6c 8008085: Integrate Dynalink source code into Nashorn codebase
attila
parents: 16226
diff changeset
    68
checkClass("jdk.internal.dynalink.linker.LinkRequest");
86cb162cec6c 8008085: Integrate Dynalink source code into Nashorn codebase
attila
parents: 16226
diff changeset
    69
checkClass("jdk.internal.dynalink.support.AbstractRelinkableCallSite");