8009757: Package access clean up and refactoring
authorsundar
Tue, 12 Mar 2013 18:12:42 +0530
changeset 16522 d643e3ee819c
parent 16346 5e8c55025644
child 16523 af8b30edebce
8009757: Package access clean up and refactoring Reviewed-by: jlaskey, lagergren, attila
nashorn/docs/JavaScriptingProgrammersGuide.html
nashorn/docs/source/javaarray.js
nashorn/make/build.xml
nashorn/make/java.security.override
nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java
nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java
nashorn/src/jdk/nashorn/internal/objects/Global.java
nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java
nashorn/src/jdk/nashorn/internal/objects/NativeJava.java
nashorn/src/jdk/nashorn/internal/runtime/Context.java
nashorn/src/jdk/nashorn/internal/runtime/NashornLoader.java
nashorn/src/jdk/nashorn/internal/runtime/ScriptLoader.java
nashorn/src/jdk/nashorn/internal/runtime/StructureLoader.java
nashorn/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java
nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java
nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java
nashorn/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js
nashorn/src/jdk/nashorn/internal/runtime/resources/parser.js
nashorn/test/script/basic/JDK-8008448.js
nashorn/test/script/basic/NASHORN-401.js
nashorn/test/script/basic/consstring.js
nashorn/test/script/basic/fileline.js
nashorn/test/script/basic/javainnerclasses.js
nashorn/test/script/basic/list.js
nashorn/test/script/basic/map.js
nashorn/test/script/basic/stdin.js
nashorn/test/script/sandbox/javaextend.js
nashorn/test/script/sandbox/javaextend.js.EXPECTED
nashorn/test/script/sandbox/reflection.js
nashorn/test/script/sandbox/reflection.js.EXPECTED
nashorn/test/script/sandbox/unsafe.js
nashorn/test/script/sandbox/unsafe.js.EXPECTED
nashorn/test/script/trusted/urlreader.js
nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java
nashorn/test/src/jdk/nashorn/internal/runtime/Nashorn401TestSubject.java
nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java
nashorn/test/src/jdk/nashorn/internal/test/models/ConstructorWithArgument.java
nashorn/test/src/jdk/nashorn/internal/test/models/DessertTopping.java
nashorn/test/src/jdk/nashorn/internal/test/models/DessertToppingFloorWaxDriver.java
nashorn/test/src/jdk/nashorn/internal/test/models/FinalClass.java
nashorn/test/src/jdk/nashorn/internal/test/models/FloorWax.java
nashorn/test/src/jdk/nashorn/internal/test/models/NoAccessibleConstructorClass.java
nashorn/test/src/jdk/nashorn/internal/test/models/NonPublicClass.java
nashorn/test/src/jdk/nashorn/internal/test/models/OuterClass.java
nashorn/test/src/jdk/nashorn/internal/test/models/OverloadedSam.java
nashorn/test/src/jdk/nashorn/internal/test/models/OverrideObject.java
nashorn/test/src/jdk/nashorn/internal/test/models/StringArgs.java
nashorn/test/src/jdk/nashorn/internal/test/models/Toothpaste.java
nashorn/test/src/jdk/nashorn/test/models/ConstructorWithArgument.java
nashorn/test/src/jdk/nashorn/test/models/DessertTopping.java
nashorn/test/src/jdk/nashorn/test/models/DessertToppingFloorWaxDriver.java
nashorn/test/src/jdk/nashorn/test/models/FinalClass.java
nashorn/test/src/jdk/nashorn/test/models/FloorWax.java
nashorn/test/src/jdk/nashorn/test/models/Nashorn401TestSubject.java
nashorn/test/src/jdk/nashorn/test/models/NoAccessibleConstructorClass.java
nashorn/test/src/jdk/nashorn/test/models/NonPublicClass.java
nashorn/test/src/jdk/nashorn/test/models/OuterClass.java
nashorn/test/src/jdk/nashorn/test/models/OverloadedSam.java
nashorn/test/src/jdk/nashorn/test/models/OverrideObject.java
nashorn/test/src/jdk/nashorn/test/models/SourceHelper.java
nashorn/test/src/jdk/nashorn/test/models/StringArgs.java
nashorn/test/src/jdk/nashorn/test/models/Toothpaste.java
--- a/nashorn/docs/JavaScriptingProgrammersGuide.html	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/docs/JavaScriptingProgrammersGuide.html	Tue Mar 12 18:12:42 2013 +0530
@@ -533,9 +533,8 @@
 <hr>
 <a name="jsarrays" id="jsarrays"></a>
 <h3>Creating, Converting and Using Java Arrays</h3>
-<p>While creating a Java object is the same as in Java, to create
-Java arrays in JavaScript we can use Java reflection
-explicitly. But once created the element access or length access is
+<p>
+Array element access or length access is
 the same as in Java. Also, a script array can be used when a Java
 method expects a Java array (auto conversion). So in most cases we
 don't have to create Java arrays explicitly.</p>
@@ -543,7 +542,8 @@
 // <a href="source/javaarray.js">javaarray.js</a>
 
 // create Java String array of 5 elements
-var a = java.lang.reflect.Array.newInstance(java.lang.String.class, 5);
+var StringArray = Java.type("java.lang.String[]");
+var a = new StringArray(5);
 
 // Accessing elements and length access is by usual Java syntax
 a[0] = "scripting is great!";
--- a/nashorn/docs/source/javaarray.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/docs/source/javaarray.js	Tue Mar 12 18:12:42 2013 +0530
@@ -30,7 +30,8 @@
  */
 
 // create Java String array of 5 elements
-var a = java.lang.reflect.Array.newInstance(java.lang.String.class, 5);
+var StringArray = Java.type("java.lang.String[]");
+var a = new StringArray(5);
 
 // Accessing elements and length access is by usual Java syntax
 a[0] = "scripting is great!";
--- a/nashorn/make/build.xml	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/make/build.xml	Tue Mar 12 18:12:42 2013 +0530
@@ -191,12 +191,12 @@
 
     <!-- tests that check nashorn internals and internal API -->
     <jar jarfile="${nashorn.internal.tests.jar}">
-      <fileset dir="${build.test.classes.dir}" excludes="**/api/*"/>
+      <fileset dir="${build.test.classes.dir}" excludes="**/api/**"/>
     </jar>
 
     <!-- tests that check nashorn script engine (jsr-223) API -->
     <jar jarfile="${nashorn.api.tests.jar}">
-      <fileset dir="${build.test.classes.dir}" includes="**/api/*"/>
+      <fileset dir="${build.test.classes.dir}" includes="**/api/**"/>
     </jar>
 
   </target>
--- a/nashorn/make/java.security.override	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/make/java.security.override	Tue Mar 12 18:12:42 2013 +0530
@@ -3,7 +3,7 @@
 # We ensure that by overriding "package.access" security property.
 
 # The following "package.access" value was copied from  default java.security 
-# of jre/lib/security and appended with nashorn IR, Codegen and Parser packages.
+# of jre/lib/security and appended with nashorn sensitive packages.
 
 #
 # List of comma-separated packages that start with or equal this string
@@ -11,4 +11,4 @@
 # passed to checkPackageAccess unless the
 # corresponding RuntimePermission ("accessClassInPackage."+package) has
 # been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal.,jdk.internal.,jdk.nashorn.internal.ir., jdk.nashorn.internal.codegen., jdk.nashorn.internal.lookup., jdk.nashorn.internal.parser.
+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.,com.sun.org.glassfish.external.,com.sun.org.glassfish.gmbal.,jdk.internal.,jdk.nashorn.internal.,jdk.nashorn.tools.
--- a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java	Tue Mar 12 18:12:42 2013 +0530
@@ -147,6 +147,7 @@
      * @return newly created script engine.
      */
     public ScriptEngine getScriptEngine(final ClassLoader appLoader) {
+        checkConfigPermission();
         return new NashornScriptEngine(this, appLoader);
     }
 
@@ -157,6 +158,7 @@
      * @return newly created script engine.
      */
     public ScriptEngine getScriptEngine(final String[] args) {
+        checkConfigPermission();
         return new NashornScriptEngine(this, args, getAppClassLoader());
     }
 
@@ -168,11 +170,19 @@
      * @return newly created script engine.
      */
     public ScriptEngine getScriptEngine(final String[] args, final ClassLoader appLoader) {
+        checkConfigPermission();
         return new NashornScriptEngine(this, args, appLoader);
     }
 
     // -- Internals only below this point
 
+    private void checkConfigPermission() {
+        final SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkPermission(new RuntimePermission("nashorn.setConfig"));
+        }
+    }
+
     private static final List<String> names;
     private static final List<String> mimeTypes;
     private static final List<String> extensions;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/src/jdk/nashorn/api/scripting/ScriptUtils.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.scripting;
+
+import jdk.nashorn.internal.runtime.ScriptRuntime;
+
+/**
+ * Utilities that are to be called from script code
+ */
+public final class ScriptUtils {
+    private ScriptUtils() {}
+
+    /**
+     * Returns AST as JSON compatible string. This is used to
+     * implement "parse" function in resources/parse.js script.
+     *
+     * @param code code to be parsed
+     * @param name name of the code source (used for location)
+     * @param includeLoc tells whether to include location information for nodes or not
+     * @return JSON string representation of AST of the supplied code
+     */
+    public static String parse(final String code, final String name, final boolean includeLoc) {
+        return ScriptRuntime.parse(code, name, includeLoc);
+    }
+}
--- a/nashorn/src/jdk/nashorn/internal/objects/Global.java	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/src/jdk/nashorn/internal/objects/Global.java	Tue Mar 12 18:12:42 2013 +0530
@@ -34,6 +34,9 @@
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.ref.SoftReference;
+import java.lang.reflect.Field;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -1503,8 +1506,10 @@
         addOwnProperty("echo", Attribute.NOT_ENUMERABLE, value);
 
         // Nashorn extension: global.$OPTIONS (scripting-mode-only)
-        value = context.getEnv();
-        addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, value);
+        final ScriptObject options = newEmptyInstance();
+        final ScriptEnvironment scriptEnv = context.getEnv();
+        copyOptions(options, scriptEnv);
+        addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, options);
 
         // Nashorn extension: global.$ENV (scripting-mode-only)
         if (System.getSecurityManager() == null) {
@@ -1523,6 +1528,21 @@
         addOwnProperty(ScriptingFunctions.EXIT_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED);
     }
 
+    private void copyOptions(final ScriptObject options, final ScriptEnvironment scriptEnv) {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+            public Void run() {
+                for (Field f : scriptEnv.getClass().getFields()) {
+                    try {
+                        options.set(f.getName(), f.get(scriptEnv), false);
+                    } catch (final IllegalArgumentException | IllegalAccessException exp) {
+                        throw new RuntimeException(exp);
+                    }
+                }
+                return null;
+            }
+        });
+    }
+
     private void initTypedArray() {
         this.builtinArrayBuffer       = initConstructor("ArrayBuffer");
         this.builtinInt8Array         = initConstructor("Int8Array");
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeDebug.java	Tue Mar 12 18:12:42 2013 +0530
@@ -66,7 +66,7 @@
     public static Object getContext(final Object self) {
         final SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            sm.checkPermission(new RuntimePermission("getNashornContext"));
+            sm.checkPermission(new RuntimePermission("nashorn.getContext"));
         }
         return Global.getThisContext();
     }
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java	Tue Mar 12 18:12:42 2013 +0530
@@ -223,6 +223,23 @@
     }
 
     /**
+     * Returns name of a java type {@link StaticClass}.
+     * @param self not used
+     * @param type the type whose name is returned
+     * @return name of the given type
+     */
+    @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
+    public static Object typeName(final Object self, final Object type) {
+        if (type instanceof StaticClass) {
+            return ((StaticClass)type).getRepresentedClass().getName();
+        } else if (type instanceof Class) {
+            return ((Class<?>)type).getName();
+        } else {
+            return UNDEFINED;
+        }
+    }
+
+    /**
      * Given a JavaScript array and a Java type, returns a Java array with the same initial contents, and with the
      * specified component type. Example:
      * <pre>
--- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java	Tue Mar 12 18:12:42 2013 +0530
@@ -39,10 +39,13 @@
 import java.lang.reflect.Constructor;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.security.AccessControlContext;
 import java.security.AccessController;
 import java.security.CodeSigner;
 import java.security.CodeSource;
+import java.security.Permissions;
 import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
 import jdk.internal.org.objectweb.asm.ClassReader;
 import jdk.internal.org.objectweb.asm.util.CheckClassAdapter;
 import jdk.nashorn.internal.codegen.Compiler;
@@ -123,7 +126,7 @@
             if (callerLoader != myLoader &&
                 !(callerLoader instanceof StructureLoader) &&
                 !(JavaAdapterFactory.isAdapterClass(caller))) {
-                sm.checkPermission(new RuntimePermission("getNashornGlobal"));
+                sm.checkPermission(new RuntimePermission("nashorn.getGlobal"));
             }
         }
 
@@ -137,7 +140,7 @@
     public static void setGlobal(final ScriptObject global) {
         final SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            sm.checkPermission(new RuntimePermission("setNashornGlobal"));
+            sm.checkPermission(new RuntimePermission("nashorn.setGlobal"));
         }
 
         if (global != null && !(global instanceof GlobalObject)) {
@@ -154,7 +157,7 @@
     public static Context getContext() {
         final SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            sm.checkPermission(new RuntimePermission("getNashornContext"));
+            sm.checkPermission(new RuntimePermission("nashorn.getContext"));
         }
         return getContextTrusted();
     }
@@ -267,7 +270,7 @@
     public Context(final Options options, final ErrorManager errors, final PrintWriter out, final PrintWriter err, final ClassLoader appLoader) {
         final SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            sm.checkPermission(new RuntimePermission("createNashornContext"));
+            sm.checkPermission(new RuntimePermission("nashorn.createContext"));
         }
 
         this.env       = new ScriptEnvironment(options, out, err);
@@ -533,7 +536,13 @@
         if (index != -1) {
             final SecurityManager sm = System.getSecurityManager();
             if (sm != null) {
-                sm.checkPackageAccess(fullName.substring(0, index));
+                AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                    @Override
+                    public Void run() {
+                        sm.checkPackageAccess(fullName.substring(0, index));
+                        return null;
+                    }
+                }, createNoPermissionsContext());
             }
         }
 
@@ -599,7 +608,7 @@
     public ScriptObject newGlobal() {
         final SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            sm.checkPermission(new RuntimePermission("createNashornGlobal"));
+            sm.checkPermission(new RuntimePermission("nashorn.newGlobal"));
         }
 
         return newGlobalTrusted();
@@ -676,6 +685,10 @@
         return (context != null) ? context : Context.getContextTrusted();
     }
 
+    private static AccessControlContext createNoPermissionsContext() {
+        return new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, new Permissions()) });
+    }
+
     private Object evaluateSource(final Source source, final ScriptObject scope, final ScriptObject thiz) {
         ScriptFunction script = null;
 
--- a/nashorn/src/jdk/nashorn/internal/runtime/NashornLoader.java	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/NashornLoader.java	Tue Mar 12 18:12:42 2013 +0530
@@ -30,6 +30,10 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
 import java.security.SecureClassLoader;
 import jdk.nashorn.tools.Shell;
 
@@ -40,6 +44,28 @@
  *
  */
 abstract class NashornLoader extends SecureClassLoader {
+    private static final String OBJECTS_PKG = "jdk.nashorn.internal.objects";
+    private static final String RUNTIME_PKG = "jdk.nashorn.internal.runtime";
+    private static final String RUNTIME_LINKER_PKG = "jdk.nashorn.internal.runtime.linker";
+    private static final String SCRIPTS_PKG = "jdk.nashorn.internal.scripts";
+
+    private static final Permission[] SCRIPT_PERMISSIONS;
+    static {
+        SCRIPT_PERMISSIONS = new Permission[4];
+
+        /*
+         * Generated classes get access to runtime, runtime.linker, objects, scripts packages.
+         * Note that the actual scripts can not access these because Java.type, Packages
+         * prevent these restricted packages. And Java reflection and JSR292 access is prevented
+         * for scripts. In other words, nashorn generated portions of script classes can access
+         * clases in these implementation packages.
+         */
+        SCRIPT_PERMISSIONS[0] = new RuntimePermission("accessClassInPackage." + RUNTIME_PKG);
+        SCRIPT_PERMISSIONS[1] = new RuntimePermission("accessClassInPackage." + RUNTIME_LINKER_PKG);
+        SCRIPT_PERMISSIONS[2] = new RuntimePermission("accessClassInPackage." + OBJECTS_PKG);
+        SCRIPT_PERMISSIONS[3] = new RuntimePermission("accessClassInPackage." + SCRIPTS_PKG);
+    }
+
     private final Context context;
 
     final Context getContext() {
@@ -68,11 +94,30 @@
         if (i != -1) {
             final SecurityManager sm = System.getSecurityManager();
             if (sm != null) {
-                sm.checkPackageAccess(name.substring(0, i));
+                final String pkgName = name.substring(0, i);
+                switch (pkgName) {
+                    case RUNTIME_PKG:
+                    case RUNTIME_LINKER_PKG:
+                    case OBJECTS_PKG:
+                    case SCRIPTS_PKG:
+                        // allow it.
+                        break;
+                    default:
+                        sm.checkPackageAccess(pkgName);
+                }
             }
         }
     }
 
+    @Override
+    protected PermissionCollection getPermissions(CodeSource codesource) {
+        final Permissions permCollection = new Permissions();
+        for (final Permission perm : SCRIPT_PERMISSIONS) {
+            permCollection.add(perm);
+        }
+        return permCollection;
+    }
+
     /**
      * Create a secure URL class loader for the given classpath
      * @param classPath classpath for the loader to search from
--- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptLoader.java	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptLoader.java	Tue Mar 12 18:12:42 2013 +0530
@@ -26,6 +26,7 @@
 package jdk.nashorn.internal.runtime;
 
 import java.security.CodeSource;
+import java.security.ProtectionDomain;
 
 /**
  * Responsible for loading script generated classes.
@@ -57,6 +58,10 @@
      * @return Installed class.
      */
     synchronized Class<?> installClass(final String name, final byte[] data, final CodeSource cs) {
-        return defineClass(name, data, 0, data.length, cs);
+        if (cs == null) {
+            return defineClass(name, data, 0, data.length, new ProtectionDomain(null, getPermissions(null)));
+        } else {
+            return defineClass(name, data, 0, data.length, cs);
+        }
     }
 }
--- a/nashorn/src/jdk/nashorn/internal/runtime/StructureLoader.java	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/StructureLoader.java	Tue Mar 12 18:12:42 2013 +0530
@@ -38,6 +38,7 @@
 import java.security.CodeSource;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.security.ProtectionDomain;
 import jdk.nashorn.internal.codegen.ObjectClassGenerator;
 
 /**
@@ -129,6 +130,6 @@
         }
 
         final byte[] code = new ObjectClassGenerator(context).generate(descriptor);
-        return defineClass(name, code, 0, code.length);
+        return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
     }
 }
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java	Tue Mar 12 18:12:42 2013 +0530
@@ -57,7 +57,7 @@
     static {
         final DynamicLinkerFactory factory = new DynamicLinkerFactory();
         factory.setPrioritizedLinkers(new NashornLinker(), new NashornPrimitiveLinker(), new NashornStaticClassLinker(),
-                new JSObjectLinker());
+                new JSObjectLinker(), new ReflectionCheckLinker());
         factory.setFallbackLinkers(new BeansLinker(), new NashornBottomLinker());
         factory.setSyncOnRelink(true);
         final int relinkThreshold = Options.getIntProperty("nashorn.unstable.relink.threshold", -1);
--- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java	Tue Mar 12 18:12:42 2013 +0530
@@ -54,6 +54,7 @@
 import java.security.CodeSource;
 import java.security.Permissions;
 import java.security.PrivilegedAction;
+import java.security.PrivilegedExceptionAction;
 import java.security.ProtectionDomain;
 import java.security.SecureClassLoader;
 import java.security.SecureRandom;
@@ -410,9 +411,13 @@
      */
     public static MethodHandle getConstructor(final Class<?> sourceType, final Class<?> targetType) throws Exception {
         final StaticClass adapterClass = getAdapterClassFor(new Class<?>[] { targetType });
-        return MH.bindTo(Bootstrap.getLinkerServices().getGuardedInvocation(new LinkRequestImpl(NashornCallSiteDescriptor.get(
-                "dyn:new", MethodType.methodType(targetType, StaticClass.class, sourceType), 0), false,
-                adapterClass, null)).getInvocation(), adapterClass);
+        return AccessController.doPrivileged(new PrivilegedExceptionAction<MethodHandle>() {
+            public MethodHandle run() throws Exception {
+                return  MH.bindTo(Bootstrap.getLinkerServices().getGuardedInvocation(new LinkRequestImpl(NashornCallSiteDescriptor.get(
+                    "dyn:new", MethodType.methodType(targetType, StaticClass.class, sourceType), 0), false,
+                    adapterClass, null)).getInvocation(), adapterClass);
+            }
+        });
     }
 
     /**
@@ -456,9 +461,26 @@
     private static ClassLoader createClassLoader(final ClassLoader parentLoader, final String className,
             final byte[] classBytes, final String privilegedActionClassName) {
         return new AdapterLoader(parentLoader) {
+            private final ClassLoader myLoader = getClass().getClassLoader();
             private final ProtectionDomain myProtectionDomain = getClass().getProtectionDomain();
 
             @Override
+            public Class<?> loadClass(final String name, final boolean resolve) throws ClassNotFoundException {
+                try {
+                    return super.loadClass(name, resolve);
+                } catch (final SecurityException se) {
+                    // we may be implementing an interface or extending a class that was
+                    // loaded by a loader that prevents package.access. If so, it'd throw
+                    // SecurityException for nashorn's classes!. For adapter's to work, we
+                    // should be able to refer to nashorn classes.
+                    if (name.startsWith("jdk.nashorn.internal.")) {
+                        return myLoader.loadClass(name);
+                    }
+                    throw se;
+                }
+            }
+
+            @Override
             protected Class<?> findClass(final String name) throws ClassNotFoundException {
                 if(name.equals(className)) {
                     final byte[] bytes = classBytes;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.runtime.linker;
+
+import jdk.internal.dynalink.linker.GuardedInvocation;
+import jdk.internal.dynalink.linker.LinkRequest;
+import jdk.internal.dynalink.linker.LinkerServices;
+import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker;
+
+/**
+ * Check java reflection permission for java reflective and java.lang.invoke access from scripts
+ */
+final class ReflectionCheckLinker implements TypeBasedGuardingDynamicLinker{
+    @Override
+    public boolean canLinkType(final Class<?> type) {
+        return canLinkTypeStatic(type);
+    }
+
+    private static boolean canLinkTypeStatic(final Class<?> type) {
+        if (type == Class.class || ClassLoader.class.isAssignableFrom(type)) {
+            return true;
+        }
+        final String name = type.getName();
+        return name.startsWith("java.lang.reflect.") || name.startsWith("java.lang.invoke.");
+    }
+
+    @Override
+    public GuardedInvocation getGuardedInvocation(final LinkRequest origRequest, final LinkerServices linkerServices)
+            throws Exception {
+        final SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkPermission(new RuntimePermission("nashorn.JavaReflection"));
+        }
+        // let the next linker deal with actual linking
+        return null;
+    }
+}
--- a/nashorn/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js	Tue Mar 12 18:12:42 2013 +0530
@@ -1,21 +1,21 @@
 /*
  * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
@@ -34,7 +34,7 @@
         if (arguments.length < 2) {
             throw new TypeError("JavaAdapter requires atleast two arguments");
         }
-            
+
         var types = Array.prototype.slice.call(arguments, 0, arguments.length - 1);
         var NewType = Java.extend.apply(Java, types);
         return new NewType(arguments[arguments.length - 1]);
@@ -56,10 +56,10 @@
                     return type;
                 } catch (e) {}
             }
-            
+
             return oldNoSuchProperty? oldNoSuchProperty(name) : undefined;
         }
-        
+
         var prefix = "[JavaPackage ";
         return function() {
             for (var i in arguments) {
@@ -343,7 +343,9 @@
     configurable: true, enumerable: false, writable: true,
     value: function(clazz) {
         if (Java.isType(clazz)) {
-            this[clazz.class.getSimpleName()] = clazz;
+            var className = Java.typeName(clazz);
+            var simpleName = className.substring(className.lastIndexOf('.') + 1);
+            this[simpleName] = clazz;
         } else {
             throw new TypeError(clazz + " is not a Java class");
         }
--- a/nashorn/src/jdk/nashorn/internal/runtime/resources/parser.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/parser.js	Tue Mar 12 18:12:42 2013 +0530
@@ -1,21 +1,21 @@
 /*
  * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.
- * 
+ *
  * This code is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
- * 
+ *
  * You should have received a copy of the GNU General Public License version
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- * 
+ *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
@@ -47,7 +47,7 @@
             code = arguments[0];
     }
 
-    var jsonStr = Packages.jdk.nashorn.internal.runtime.ScriptRuntime.parse(code, name, location);
+    var jsonStr = Packages.jdk.nashorn.api.scripting.ScriptUtils.parse(code, name, location);
     return JSON.parse(jsonStr,
         function (prop, value) {
             if (typeof(value) == 'string' && prop == "value") {
--- a/nashorn/test/script/basic/JDK-8008448.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/script/basic/JDK-8008448.js	Tue Mar 12 18:12:42 2013 +0530
@@ -32,7 +32,7 @@
 
 var File = Java.type("java.io.File");
 var FilenameFilter = Java.type("java.io.FilenameFilter");
-var Source = Java.type("jdk.nashorn.internal.runtime.Source")
+var SourceHelper = Java.type("jdk.nashorn.test.models.SourceHelper")
 
 // Filter out non .js files
 var files = new File(__DIR__).listFiles(new FilenameFilter() {
@@ -44,5 +44,5 @@
 
 // parse each file to make sure it does not result in exception
 for each (var f in files) {
-    parse(new Source(f.toString(), f).getString());
+    parse(SourceHelper.readFully(f));
 }
--- a/nashorn/test/script/basic/NASHORN-401.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/script/basic/NASHORN-401.js	Tue Mar 12 18:12:42 2013 +0530
@@ -28,7 +28,7 @@
  * @run
  */
 
-var t = new Packages.jdk.nashorn.internal.runtime.Nashorn401TestSubject();
+var t = new Packages.jdk.nashorn.test.models.Nashorn401TestSubject();
 
 print(t.method2(10));
 print(t.method2(10.2));
--- a/nashorn/test/script/basic/consstring.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/script/basic/consstring.js	Tue Mar 12 18:12:42 2013 +0530
@@ -37,4 +37,4 @@
 list.add((str + "3").toString());            // toString() called on primitive string
 list.add(new String(str + "4").toString());  // toString() called on String object
 
-Packages.jdk.nashorn.internal.test.models.StringArgs.checkString(list);
+Packages.jdk.nashorn.test.models.StringArgs.checkString(list);
--- a/nashorn/test/script/basic/fileline.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/script/basic/fileline.js	Tue Mar 12 18:12:42 2013 +0530
@@ -41,8 +41,8 @@
 load(__DIR__ + "loadedfile.js");
 
 // Add check for base part of a URL. We can't test __DIR__ inside
-// a script that is downloaded from a URL. check for Source.baseURL
+// a script that is downloaded from a URL. check for SourceHelper.baseURL
 // which is exposed as __DIR__ for URL case.
 
 var url = new java.net.URL("http://www.acme.com:8080/foo/bar.js");
-print(Packages.jdk.nashorn.internal.runtime.Source.baseURL(url));
+print(Packages.jdk.nashorn.test.models.SourceHelper.baseURL(url));
--- a/nashorn/test/script/basic/javainnerclasses.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/script/basic/javainnerclasses.js	Tue Mar 12 18:12:42 2013 +0530
@@ -29,25 +29,25 @@
  */
  
 // Do it with Java.type()
-var outer = new (Java.type("jdk.nashorn.internal.test.models.OuterClass"))("apple")
+var outer = new (Java.type("jdk.nashorn.test.models.OuterClass"))("apple")
 print(outer)
-var innerStatic = new (Java.type("jdk.nashorn.internal.test.models.OuterClass$InnerStaticClass"))("orange")
+var innerStatic = new (Java.type("jdk.nashorn.test.models.OuterClass$InnerStaticClass"))("orange")
 print(innerStatic)
-var innerNonStatic = new (Java.type("jdk.nashorn.internal.test.models.OuterClass$InnerNonStaticClass"))(outer, "pear")
+var innerNonStatic = new (Java.type("jdk.nashorn.test.models.OuterClass$InnerNonStaticClass"))(outer, "pear")
 print(innerNonStatic)
 
 // Now do it with Packages and explicit $ names
-var outer = new Packages.jdk.nashorn.internal.test.models.OuterClass("red")
+var outer = new Packages.jdk.nashorn.test.models.OuterClass("red")
 print(outer)
-var innerStatic = new Packages.jdk.nashorn.internal.test.models.OuterClass$InnerStaticClass("green")
+var innerStatic = new Packages.jdk.nashorn.test.models.OuterClass$InnerStaticClass("green")
 print(innerStatic)
-var innerNonStatic = new Packages.jdk.nashorn.internal.test.models.OuterClass$InnerNonStaticClass(outer, "blue")
+var innerNonStatic = new Packages.jdk.nashorn.test.models.OuterClass$InnerNonStaticClass(outer, "blue")
 print(innerNonStatic)
 
 // Now do it with Packages and nested properties
-var outer = new Packages.jdk.nashorn.internal.test.models.OuterClass("sweet")
+var outer = new Packages.jdk.nashorn.test.models.OuterClass("sweet")
 print(outer)
-var innerStatic = new Packages.jdk.nashorn.internal.test.models.OuterClass.InnerStaticClass("sour")
+var innerStatic = new Packages.jdk.nashorn.test.models.OuterClass.InnerStaticClass("sour")
 print(innerStatic)
-var innerNonStatic = new Packages.jdk.nashorn.internal.test.models.OuterClass.InnerNonStaticClass(outer, "bitter")
+var innerNonStatic = new Packages.jdk.nashorn.test.models.OuterClass.InnerNonStaticClass(outer, "bitter")
 print(innerNonStatic)
--- a/nashorn/test/script/basic/list.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/script/basic/list.js	Tue Mar 12 18:12:42 2013 +0530
@@ -28,7 +28,7 @@
  * @run
  */
 var l = new java.util.ArrayList();
-print("l.class.name=" + l.class.name) // Has "class" property like any POJO
+print("l.class.name=" + Java.typeName(l.class)) // Has "class" property like any POJO
 
 l.add("foo")
 l.add("bar")
--- a/nashorn/test/script/basic/map.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/script/basic/map.js	Tue Mar 12 18:12:42 2013 +0530
@@ -28,7 +28,7 @@
  * @run
  */
 var m = new (Java.type("java.util.LinkedHashMap"));
-print("m.class.name=" + m.class.name) // Has "class" property like any POJO
+print("m.class.name=" + Java.typeName(m.class)) // Has "class" property like any POJO
 
 var empty_key = "empty"
 
--- a/nashorn/test/script/basic/stdin.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/script/basic/stdin.js	Tue Mar 12 18:12:42 2013 +0530
@@ -28,8 +28,8 @@
  * @run
  */
 
-print(java.lang.System.in.class.name);
+print(Java.typeName(java.lang.System.in.class));
 var prop = "in";
-print(java.lang.System[prop].class.name);
-print(java.lang.System["in"].class.name);
+print(Java.typeName(java.lang.System[prop].class));
+print(Java.typeName(java.lang.System["in"].class));
 
--- a/nashorn/test/script/sandbox/javaextend.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/script/sandbox/javaextend.js	Tue Mar 12 18:12:42 2013 +0530
@@ -27,7 +27,7 @@
  */
 
 function model(n) {
-  return Java.type("jdk.nashorn.internal.test.models." + n)
+  return Java.type("jdk.nashorn.test.models." + n)
 }
 
 // Can't extend a final class  
--- a/nashorn/test/script/sandbox/javaextend.js.EXPECTED	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/script/sandbox/javaextend.js.EXPECTED	Tue Mar 12 18:12:42 2013 +0530
@@ -1,6 +1,6 @@
-TypeError: Can not extend final class jdk.nashorn.internal.test.models.FinalClass.
-TypeError: Can not extend class jdk.nashorn.internal.test.models.NoAccessibleConstructorClass as it has no public or protected constructors.
-TypeError: Can not extend/implement non-public class/interface jdk.nashorn.internal.test.models.NonPublicClass.
+TypeError: Can not extend final class jdk.nashorn.test.models.FinalClass.
+TypeError: Can not extend class jdk.nashorn.test.models.NoAccessibleConstructorClass as it has no public or protected constructors.
+TypeError: Can not extend/implement non-public class/interface jdk.nashorn.test.models.NonPublicClass.
 TypeError: Can not extend multiple classes java.lang.Number and java.lang.Thread. At most one of the specified types can be a class, the rest must all be interfaces.
 abcdabcd
 run-object
--- a/nashorn/test/script/sandbox/reflection.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/script/sandbox/reflection.js	Tue Mar 12 18:12:42 2013 +0530
@@ -30,9 +30,7 @@
  */
 
 function check(e) {
-    if (e instanceof java.lang.SecurityException) {
-        print(e);
-    } else {
+    if (! (e instanceof java.lang.SecurityException)) {
         fail("expected SecurityException, got " + e);
     }
 }
--- a/nashorn/test/script/sandbox/reflection.js.EXPECTED	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
--- a/nashorn/test/script/sandbox/unsafe.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/script/sandbox/unsafe.js	Tue Mar 12 18:12:42 2013 +0530
@@ -30,9 +30,7 @@
  */
 
 function check(e) {
-   if (e instanceof java.lang.SecurityException) {
-       print(e);
-   } else {
+   if (! (e instanceof java.lang.SecurityException)) {
        fail("expected SecurityException, got " + e);
    }
 }
--- a/nashorn/test/script/sandbox/unsafe.js.EXPECTED	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.misc")
-java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.misc")
-java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun")
-java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")
--- a/nashorn/test/script/trusted/urlreader.js	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/script/trusted/urlreader.js	Tue Mar 12 18:12:42 2013 +0530
@@ -9,7 +9,7 @@
 var URL = Java.type("java.net.URL");
 var File = Java.type("java.io.File");
 var JString = Java.type("java.lang.String");
-var Source = Java.type("jdk.nashorn.internal.runtime.Source");
+var SourceHelper = Java.type("jdk.nashorn.test.models.SourceHelper");
 
 var url = new File(__FILE__).toURI().toURL();
 var reader = new URLReader(url);
@@ -19,9 +19,9 @@
 
 // check URL read
 // read URL content by directly reading from URL
-var str = new Source(url.toString(), url).getString();
+var str = SourceHelper.readFully(url);
 // read URL content via URLReader
-var content = new JString(Source.readFully(reader));
+var content = new JString(SourceHelper.readFully(reader));
 
 // assert that the content is same
 Assert.assertEquals(str, content);
--- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java	Tue Mar 12 18:12:42 2013 +0530
@@ -47,7 +47,6 @@
 import javax.script.ScriptEngineManager;
 import javax.script.ScriptException;
 import javax.script.SimpleScriptContext;
-import jdk.nashorn.internal.runtime.Version;
 import netscape.javascript.JSObject;
 import org.testng.Assert;
 import org.testng.annotations.Test;
@@ -129,7 +128,6 @@
         assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");
         assertEquals(fac.getLanguageVersion(), "ECMA - 262 Edition 5.1");
         assertEquals(fac.getEngineName(), "Oracle Nashorn");
-        assertEquals(fac.getEngineVersion(), Version.version());
         assertEquals(fac.getOutputStatement("context"), "print(context)");
         assertEquals(fac.getProgram("print('hello')", "print('world')"), "print('hello');print('world');");
         assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");
@@ -313,27 +311,6 @@
         }
     }
 
-    public static void alert(final Object msg) {
-        System.out.println(msg);
-    }
-
-    @Test
-    public void exposeMethodTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-
-        try {
-            final Method alert = ScriptEngineTest.class.getMethod("alert", Object.class);
-            // expose a Method object as global var.
-            e.put("alert", alert);
-            // call the global var.
-            e.eval("alert.invoke(null, 'alert! alert!!')");
-        } catch (final NoSuchMethodException | SecurityException | ScriptException exp) {
-            exp.printStackTrace();
-            fail(exp.getMessage());
-        }
-    }
-
     @Test
     public void putGlobalFunctionTest() {
         final ScriptEngineManager m = new ScriptEngineManager();
@@ -593,13 +570,6 @@
     }
 
     @Test
-    public void versionTest() {
-        final ScriptEngineManager m = new ScriptEngineManager();
-        final ScriptEngine e = m.getEngineByName("nashorn");
-        assertEquals(e.getFactory().getEngineVersion(), Version.version());
-    }
-
-    @Test
     public void noEnumerablePropertiesTest() {
         final ScriptEngineManager m = new ScriptEngineManager();
         final ScriptEngine e = m.getEngineByName("nashorn");
@@ -874,26 +844,4 @@
             fail(se.getMessage());
         }
     }
-
-    @Test
-    public void factoryOptionsTest() {
-        final ScriptEngineManager sm = new ScriptEngineManager();
-        for (ScriptEngineFactory fac : sm.getEngineFactories()) {
-            if (fac instanceof NashornScriptEngineFactory) {
-                final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
-                // specify --no-syntax-extensions flag
-                final String[] options = new String[] { "--no-syntax-extensions" };
-                final ScriptEngine e = nfac.getScriptEngine(options);
-                try {
-                    // try nashorn specific extension
-                    e.eval("var f = funtion(x) 2*x;");
-                    fail("should have thrown exception!");
-                } catch (final ScriptException se) {
-                }
-                return;
-            }
-        }
-
-        fail("Cannot find nashorn factory!");
-    }
 }
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/Nashorn401TestSubject.java	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.runtime;
-
-public class Nashorn401TestSubject {
-    public String method2(int arg) {
-        return "int method 2";
-    }
-
-    public String method2(double arg) {
-        return "double method 2";
-    }
-
-    public String method2(String arg) {
-        return "string method 2";
-    }
-
-    public String method3(double arg) {
-        return "double method 3: " + arg;
-    }
-
-    public String method3(int arg) {
-        return "int method 3: " + arg;
-    }
-
-    public String method4(Double arg) {
-        return "double method 4: " + arg;
-    }
-
-    public String method4(int arg) {
-        return "int method 4: " + arg;
-    }
-
-}
--- a/nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java	Wed Jul 05 18:46:02 2017 +0200
+++ b/nashorn/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java	Tue Mar 12 18:12:42 2013 +0530
@@ -25,7 +25,7 @@
 
 package jdk.nashorn.internal.runtime;
 
-
+import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
@@ -40,6 +40,13 @@
  * Tests for trusted client usage of nashorn script engine factory extension API
  */
 public class TrustedScriptEngineTest {
+    @Test
+    public void versionTest() {
+        final ScriptEngineManager m = new ScriptEngineManager();
+        final ScriptEngine e = m.getEngineByName("nashorn");
+        assertEquals(e.getFactory().getEngineVersion(), Version.version());
+    }
+
     private static class MyClassLoader extends ClassLoader {
         // to check if script engine uses the specified class loader
         private final boolean[] reached = new boolean[1];
@@ -116,4 +123,26 @@
 
         fail("Cannot find nashorn factory!");
     }
+
+    @Test
+    public void factoryOptionsTest() {
+        final ScriptEngineManager sm = new ScriptEngineManager();
+        for (ScriptEngineFactory fac : sm.getEngineFactories()) {
+            if (fac instanceof NashornScriptEngineFactory) {
+                final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac;
+                // specify --no-syntax-extensions flag
+                final String[] options = new String[] { "--no-syntax-extensions" };
+                final ScriptEngine e = nfac.getScriptEngine(options);
+                try {
+                    // try nashorn specific extension
+                    e.eval("var f = funtion(x) 2*x;");
+                    fail("should have thrown exception!");
+                } catch (final ScriptException se) {
+                }
+                return;
+            }
+        }
+
+        fail("Cannot find nashorn factory!");
+    }
 }
--- a/nashorn/test/src/jdk/nashorn/internal/test/models/ConstructorWithArgument.java	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.test.models;
-
-public abstract class ConstructorWithArgument {
-    private final String token;
-
-    protected ConstructorWithArgument(String token) {
-        this.token = token;
-    }
-
-    public String getToken() {
-        return token;
-    }
-
-    protected abstract void doSomething();
-}
--- a/nashorn/test/src/jdk/nashorn/internal/test/models/DessertTopping.java	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.test.models;
-
-public interface DessertTopping {
-    public String pourOnDessert();
-}
--- a/nashorn/test/src/jdk/nashorn/internal/test/models/DessertToppingFloorWaxDriver.java	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.test.models;
-
-public class DessertToppingFloorWaxDriver {
-    public void decorateDessert(DessertTopping dt) {
-        dt.pourOnDessert();
-    }
-
-    public void waxFloor(FloorWax fw) {
-        fw.shineUpTheFloor();
-    }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/test/models/FinalClass.java	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.test.models;
-
-public final class FinalClass {
-    //empty
-}
--- a/nashorn/test/src/jdk/nashorn/internal/test/models/FloorWax.java	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.test.models;
-
-public interface FloorWax {
-    public String shineUpTheFloor();
-}
--- a/nashorn/test/src/jdk/nashorn/internal/test/models/NoAccessibleConstructorClass.java	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.test.models;
-
-public class NoAccessibleConstructorClass {
-    NoAccessibleConstructorClass() { }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/test/models/NonPublicClass.java	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.test.models;
-
-class NonPublicClass {
-    public NonPublicClass() { }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/test/models/OuterClass.java	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.test.models;
-
-public class OuterClass {
-    private final String value;
-
-    public OuterClass(String value) {
-        this.value = value;
-    }
-
-    public static class InnerStaticClass {
-        private final String value;
-
-        public InnerStaticClass(String value) {
-            this.value = value;
-        }
-
-        @Override
-        public String toString() {
-            return "InnerStaticClass[value=" + value + "]";
-        }
-    }
-
-    public class InnerNonStaticClass {
-        private final String value;
-
-        public InnerNonStaticClass(String value) {
-            this.value = value;
-        }
-
-        @Override
-        public String toString() {
-            return "InnerNonStaticClass[value=" + value + ", outer=" + OuterClass.this + "]";
-        }
-    }
-
-    @Override
-    public String toString() {
-        return "OuterClass[value=" + value + "]";
-    }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/test/models/OverloadedSam.java	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.test.models;
-
-public interface OverloadedSam {
-    public void sam(String s);
-    public void sam(String s1, String s2);
-}
--- a/nashorn/test/src/jdk/nashorn/internal/test/models/OverrideObject.java	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.test.models;
-
-public class OverrideObject {
-    @Override
-    public int hashCode() {
-        return 5;
-    }
-
-    @Override
-    public String toString() {
-        return "override-object";
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        // TODO: add a FindBugs annotation to ignore EQ_ALWAYS_FALSE here. This is just a test.
-        return false;
-    }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/test/models/StringArgs.java	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.test.models;
-
-import java.util.List;
-
-public class StringArgs {
-
-    public static void checkString(List<?> list) {
-        for (Object s : list) {
-            if (!(s instanceof String)) {
-                throw new AssertionError("Not a String: " + s);
-            }
-        }
-    }
-}
--- a/nashorn/test/src/jdk/nashorn/internal/test/models/Toothpaste.java	Wed Jul 05 18:46:02 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.nashorn.internal.test.models;
-
-public abstract class Toothpaste {
-    public void applyToBrush() {
-        applyToBrushImpl();
-    }
-
-    protected abstract void applyToBrushImpl();
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/ConstructorWithArgument.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+public abstract class ConstructorWithArgument {
+    private final String token;
+
+    protected ConstructorWithArgument(String token) {
+        this.token = token;
+    }
+
+    public String getToken() {
+        return token;
+    }
+
+    protected abstract void doSomething();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/DessertTopping.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+public interface DessertTopping {
+    public String pourOnDessert();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/DessertToppingFloorWaxDriver.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+public class DessertToppingFloorWaxDriver {
+    public void decorateDessert(DessertTopping dt) {
+        dt.pourOnDessert();
+    }
+
+    public void waxFloor(FloorWax fw) {
+        fw.shineUpTheFloor();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/FinalClass.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+public final class FinalClass {
+    //empty
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/FloorWax.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+public interface FloorWax {
+    public String shineUpTheFloor();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/Nashorn401TestSubject.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+public class Nashorn401TestSubject {
+    public String method2(int arg) {
+        return "int method 2";
+    }
+
+    public String method2(double arg) {
+        return "double method 2";
+    }
+
+    public String method2(String arg) {
+        return "string method 2";
+    }
+
+    public String method3(double arg) {
+        return "double method 3: " + arg;
+    }
+
+    public String method3(int arg) {
+        return "int method 3: " + arg;
+    }
+
+    public String method4(Double arg) {
+        return "double method 4: " + arg;
+    }
+
+    public String method4(int arg) {
+        return "int method 4: " + arg;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/NoAccessibleConstructorClass.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+public class NoAccessibleConstructorClass {
+    NoAccessibleConstructorClass() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/NonPublicClass.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+class NonPublicClass {
+    public NonPublicClass() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/OuterClass.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+public class OuterClass {
+    private final String value;
+
+    public OuterClass(String value) {
+        this.value = value;
+    }
+
+    public static class InnerStaticClass {
+        private final String value;
+
+        public InnerStaticClass(String value) {
+            this.value = value;
+        }
+
+        @Override
+        public String toString() {
+            return "InnerStaticClass[value=" + value + "]";
+        }
+    }
+
+    public class InnerNonStaticClass {
+        private final String value;
+
+        public InnerNonStaticClass(String value) {
+            this.value = value;
+        }
+
+        @Override
+        public String toString() {
+            return "InnerNonStaticClass[value=" + value + ", outer=" + OuterClass.this + "]";
+        }
+    }
+
+    @Override
+    public String toString() {
+        return "OuterClass[value=" + value + "]";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/OverloadedSam.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+public interface OverloadedSam {
+    public void sam(String s);
+    public void sam(String s1, String s2);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/OverrideObject.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+public class OverrideObject {
+    @Override
+    public int hashCode() {
+        return 5;
+    }
+
+    @Override
+    public String toString() {
+        return "override-object";
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        // TODO: add a FindBugs annotation to ignore EQ_ALWAYS_FALSE here. This is just a test.
+        return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/SourceHelper.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.net.URL;
+import jdk.nashorn.internal.runtime.Source;
+
+/**
+ * Helper class to facilitate script access of nashorn Source class.
+ */
+public final class SourceHelper {
+    private SourceHelper() {}
+
+    public static String baseURL(final URL url) {
+        return Source.baseURL(url);
+    }
+
+    public static String readFully(final File file) throws IOException {
+        return new String(Source.readFully(file));
+    }
+
+    public static String readFully(final URL url) throws IOException {
+        return new Source(url.toString(), url).getString();
+    }
+
+    public static String readFully(final Reader reader) throws IOException {
+        return new String(Source.readFully(reader));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/StringArgs.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+import java.util.List;
+
+public class StringArgs {
+
+    public static void checkString(List<?> list) {
+        for (Object s : list) {
+            if (!(s instanceof String)) {
+                throw new AssertionError("Not a String: " + s);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/Toothpaste.java	Tue Mar 12 18:12:42 2013 +0530
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.test.models;
+
+public abstract class Toothpaste {
+    public void applyToBrush() {
+        applyToBrushImpl();
+    }
+
+    protected abstract void applyToBrushImpl();
+}