Tue, 12 Mar 2013 18:12:42 +0530
8009757: Package access clean up and refactoring
Reviewed-by: jlaskey, lagergren, attila
1.1 --- a/docs/JavaScriptingProgrammersGuide.html Sat Mar 09 21:49:32 2013 +0530 1.2 +++ b/docs/JavaScriptingProgrammersGuide.html Tue Mar 12 18:12:42 2013 +0530 1.3 @@ -533,9 +533,8 @@ 1.4 <hr> 1.5 <a name="jsarrays" id="jsarrays"></a> 1.6 <h3>Creating, Converting and Using Java Arrays</h3> 1.7 -<p>While creating a Java object is the same as in Java, to create 1.8 -Java arrays in JavaScript we can use Java reflection 1.9 -explicitly. But once created the element access or length access is 1.10 +<p> 1.11 +Array element access or length access is 1.12 the same as in Java. Also, a script array can be used when a Java 1.13 method expects a Java array (auto conversion). So in most cases we 1.14 don't have to create Java arrays explicitly.</p> 1.15 @@ -543,7 +542,8 @@ 1.16 // <a href="source/javaarray.js">javaarray.js</a> 1.17 1.18 // create Java String array of 5 elements 1.19 -var a = java.lang.reflect.Array.newInstance(java.lang.String.class, 5); 1.20 +var StringArray = Java.type("java.lang.String[]"); 1.21 +var a = new StringArray(5); 1.22 1.23 // Accessing elements and length access is by usual Java syntax 1.24 a[0] = "scripting is great!";
2.1 --- a/docs/source/javaarray.js Sat Mar 09 21:49:32 2013 +0530 2.2 +++ b/docs/source/javaarray.js Tue Mar 12 18:12:42 2013 +0530 2.3 @@ -30,7 +30,8 @@ 2.4 */ 2.5 2.6 // create Java String array of 5 elements 2.7 -var a = java.lang.reflect.Array.newInstance(java.lang.String.class, 5); 2.8 +var StringArray = Java.type("java.lang.String[]"); 2.9 +var a = new StringArray(5); 2.10 2.11 // Accessing elements and length access is by usual Java syntax 2.12 a[0] = "scripting is great!";
3.1 --- a/make/build.xml Sat Mar 09 21:49:32 2013 +0530 3.2 +++ b/make/build.xml Tue Mar 12 18:12:42 2013 +0530 3.3 @@ -191,12 +191,12 @@ 3.4 3.5 <!-- tests that check nashorn internals and internal API --> 3.6 <jar jarfile="${nashorn.internal.tests.jar}"> 3.7 - <fileset dir="${build.test.classes.dir}" excludes="**/api/*"/> 3.8 + <fileset dir="${build.test.classes.dir}" excludes="**/api/**"/> 3.9 </jar> 3.10 3.11 <!-- tests that check nashorn script engine (jsr-223) API --> 3.12 <jar jarfile="${nashorn.api.tests.jar}"> 3.13 - <fileset dir="${build.test.classes.dir}" includes="**/api/*"/> 3.14 + <fileset dir="${build.test.classes.dir}" includes="**/api/**"/> 3.15 </jar> 3.16 3.17 </target>
4.1 --- a/make/java.security.override Sat Mar 09 21:49:32 2013 +0530 4.2 +++ b/make/java.security.override Tue Mar 12 18:12:42 2013 +0530 4.3 @@ -3,7 +3,7 @@ 4.4 # We ensure that by overriding "package.access" security property. 4.5 4.6 # The following "package.access" value was copied from default java.security 4.7 -# of jre/lib/security and appended with nashorn IR, Codegen and Parser packages. 4.8 +# of jre/lib/security and appended with nashorn sensitive packages. 4.9 4.10 # 4.11 # List of comma-separated packages that start with or equal this string 4.12 @@ -11,4 +11,4 @@ 4.13 # passed to checkPackageAccess unless the 4.14 # corresponding RuntimePermission ("accessClassInPackage."+package) has 4.15 # been granted. 4.16 -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. 4.17 +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.
5.1 --- a/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java Sat Mar 09 21:49:32 2013 +0530 5.2 +++ b/src/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java Tue Mar 12 18:12:42 2013 +0530 5.3 @@ -147,6 +147,7 @@ 5.4 * @return newly created script engine. 5.5 */ 5.6 public ScriptEngine getScriptEngine(final ClassLoader appLoader) { 5.7 + checkConfigPermission(); 5.8 return new NashornScriptEngine(this, appLoader); 5.9 } 5.10 5.11 @@ -157,6 +158,7 @@ 5.12 * @return newly created script engine. 5.13 */ 5.14 public ScriptEngine getScriptEngine(final String[] args) { 5.15 + checkConfigPermission(); 5.16 return new NashornScriptEngine(this, args, getAppClassLoader()); 5.17 } 5.18 5.19 @@ -168,11 +170,19 @@ 5.20 * @return newly created script engine. 5.21 */ 5.22 public ScriptEngine getScriptEngine(final String[] args, final ClassLoader appLoader) { 5.23 + checkConfigPermission(); 5.24 return new NashornScriptEngine(this, args, appLoader); 5.25 } 5.26 5.27 // -- Internals only below this point 5.28 5.29 + private void checkConfigPermission() { 5.30 + final SecurityManager sm = System.getSecurityManager(); 5.31 + if (sm != null) { 5.32 + sm.checkPermission(new RuntimePermission("nashorn.setConfig")); 5.33 + } 5.34 + } 5.35 + 5.36 private static final List<String> names; 5.37 private static final List<String> mimeTypes; 5.38 private static final List<String> extensions;
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/src/jdk/nashorn/api/scripting/ScriptUtils.java Tue Mar 12 18:12:42 2013 +0530 6.3 @@ -0,0 +1,48 @@ 6.4 +/* 6.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.7 + * 6.8 + * This code is free software; you can redistribute it and/or modify it 6.9 + * under the terms of the GNU General Public License version 2 only, as 6.10 + * published by the Free Software Foundation. Oracle designates this 6.11 + * particular file as subject to the "Classpath" exception as provided 6.12 + * by Oracle in the LICENSE file that accompanied this code. 6.13 + * 6.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 6.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 6.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6.17 + * version 2 for more details (a copy is included in the LICENSE file that 6.18 + * accompanied this code). 6.19 + * 6.20 + * You should have received a copy of the GNU General Public License version 6.21 + * 2 along with this work; if not, write to the Free Software Foundation, 6.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 6.23 + * 6.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 6.25 + * or visit www.oracle.com if you need additional information or have any 6.26 + * questions. 6.27 + */ 6.28 + 6.29 +package jdk.nashorn.api.scripting; 6.30 + 6.31 +import jdk.nashorn.internal.runtime.ScriptRuntime; 6.32 + 6.33 +/** 6.34 + * Utilities that are to be called from script code 6.35 + */ 6.36 +public final class ScriptUtils { 6.37 + private ScriptUtils() {} 6.38 + 6.39 + /** 6.40 + * Returns AST as JSON compatible string. This is used to 6.41 + * implement "parse" function in resources/parse.js script. 6.42 + * 6.43 + * @param code code to be parsed 6.44 + * @param name name of the code source (used for location) 6.45 + * @param includeLoc tells whether to include location information for nodes or not 6.46 + * @return JSON string representation of AST of the supplied code 6.47 + */ 6.48 + public static String parse(final String code, final String name, final boolean includeLoc) { 6.49 + return ScriptRuntime.parse(code, name, includeLoc); 6.50 + } 6.51 +}
7.1 --- a/src/jdk/nashorn/internal/objects/Global.java Sat Mar 09 21:49:32 2013 +0530 7.2 +++ b/src/jdk/nashorn/internal/objects/Global.java Tue Mar 12 18:12:42 2013 +0530 7.3 @@ -34,6 +34,9 @@ 7.4 import java.lang.invoke.MethodHandle; 7.5 import java.lang.invoke.MethodHandles; 7.6 import java.lang.ref.SoftReference; 7.7 +import java.lang.reflect.Field; 7.8 +import java.security.AccessController; 7.9 +import java.security.PrivilegedAction; 7.10 import java.util.LinkedHashMap; 7.11 import java.util.List; 7.12 import java.util.Map; 7.13 @@ -1503,8 +1506,10 @@ 7.14 addOwnProperty("echo", Attribute.NOT_ENUMERABLE, value); 7.15 7.16 // Nashorn extension: global.$OPTIONS (scripting-mode-only) 7.17 - value = context.getEnv(); 7.18 - addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, value); 7.19 + final ScriptObject options = newEmptyInstance(); 7.20 + final ScriptEnvironment scriptEnv = context.getEnv(); 7.21 + copyOptions(options, scriptEnv); 7.22 + addOwnProperty("$OPTIONS", Attribute.NOT_ENUMERABLE, options); 7.23 7.24 // Nashorn extension: global.$ENV (scripting-mode-only) 7.25 if (System.getSecurityManager() == null) { 7.26 @@ -1523,6 +1528,21 @@ 7.27 addOwnProperty(ScriptingFunctions.EXIT_NAME, Attribute.NOT_ENUMERABLE, UNDEFINED); 7.28 } 7.29 7.30 + private void copyOptions(final ScriptObject options, final ScriptEnvironment scriptEnv) { 7.31 + AccessController.doPrivileged(new PrivilegedAction<Void>() { 7.32 + public Void run() { 7.33 + for (Field f : scriptEnv.getClass().getFields()) { 7.34 + try { 7.35 + options.set(f.getName(), f.get(scriptEnv), false); 7.36 + } catch (final IllegalArgumentException | IllegalAccessException exp) { 7.37 + throw new RuntimeException(exp); 7.38 + } 7.39 + } 7.40 + return null; 7.41 + } 7.42 + }); 7.43 + } 7.44 + 7.45 private void initTypedArray() { 7.46 this.builtinArrayBuffer = initConstructor("ArrayBuffer"); 7.47 this.builtinInt8Array = initConstructor("Int8Array");
8.1 --- a/src/jdk/nashorn/internal/objects/NativeDebug.java Sat Mar 09 21:49:32 2013 +0530 8.2 +++ b/src/jdk/nashorn/internal/objects/NativeDebug.java Tue Mar 12 18:12:42 2013 +0530 8.3 @@ -66,7 +66,7 @@ 8.4 public static Object getContext(final Object self) { 8.5 final SecurityManager sm = System.getSecurityManager(); 8.6 if (sm != null) { 8.7 - sm.checkPermission(new RuntimePermission("getNashornContext")); 8.8 + sm.checkPermission(new RuntimePermission("nashorn.getContext")); 8.9 } 8.10 return Global.getThisContext(); 8.11 }
9.1 --- a/src/jdk/nashorn/internal/objects/NativeJava.java Sat Mar 09 21:49:32 2013 +0530 9.2 +++ b/src/jdk/nashorn/internal/objects/NativeJava.java Tue Mar 12 18:12:42 2013 +0530 9.3 @@ -223,6 +223,23 @@ 9.4 } 9.5 9.6 /** 9.7 + * Returns name of a java type {@link StaticClass}. 9.8 + * @param self not used 9.9 + * @param type the type whose name is returned 9.10 + * @return name of the given type 9.11 + */ 9.12 + @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) 9.13 + public static Object typeName(final Object self, final Object type) { 9.14 + if (type instanceof StaticClass) { 9.15 + return ((StaticClass)type).getRepresentedClass().getName(); 9.16 + } else if (type instanceof Class) { 9.17 + return ((Class<?>)type).getName(); 9.18 + } else { 9.19 + return UNDEFINED; 9.20 + } 9.21 + } 9.22 + 9.23 + /** 9.24 * Given a JavaScript array and a Java type, returns a Java array with the same initial contents, and with the 9.25 * specified component type. Example: 9.26 * <pre>
10.1 --- a/src/jdk/nashorn/internal/runtime/Context.java Sat Mar 09 21:49:32 2013 +0530 10.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java Tue Mar 12 18:12:42 2013 +0530 10.3 @@ -39,10 +39,13 @@ 10.4 import java.lang.reflect.Constructor; 10.5 import java.net.MalformedURLException; 10.6 import java.net.URL; 10.7 +import java.security.AccessControlContext; 10.8 import java.security.AccessController; 10.9 import java.security.CodeSigner; 10.10 import java.security.CodeSource; 10.11 +import java.security.Permissions; 10.12 import java.security.PrivilegedAction; 10.13 +import java.security.ProtectionDomain; 10.14 import jdk.internal.org.objectweb.asm.ClassReader; 10.15 import jdk.internal.org.objectweb.asm.util.CheckClassAdapter; 10.16 import jdk.nashorn.internal.codegen.Compiler; 10.17 @@ -123,7 +126,7 @@ 10.18 if (callerLoader != myLoader && 10.19 !(callerLoader instanceof StructureLoader) && 10.20 !(JavaAdapterFactory.isAdapterClass(caller))) { 10.21 - sm.checkPermission(new RuntimePermission("getNashornGlobal")); 10.22 + sm.checkPermission(new RuntimePermission("nashorn.getGlobal")); 10.23 } 10.24 } 10.25 10.26 @@ -137,7 +140,7 @@ 10.27 public static void setGlobal(final ScriptObject global) { 10.28 final SecurityManager sm = System.getSecurityManager(); 10.29 if (sm != null) { 10.30 - sm.checkPermission(new RuntimePermission("setNashornGlobal")); 10.31 + sm.checkPermission(new RuntimePermission("nashorn.setGlobal")); 10.32 } 10.33 10.34 if (global != null && !(global instanceof GlobalObject)) { 10.35 @@ -154,7 +157,7 @@ 10.36 public static Context getContext() { 10.37 final SecurityManager sm = System.getSecurityManager(); 10.38 if (sm != null) { 10.39 - sm.checkPermission(new RuntimePermission("getNashornContext")); 10.40 + sm.checkPermission(new RuntimePermission("nashorn.getContext")); 10.41 } 10.42 return getContextTrusted(); 10.43 } 10.44 @@ -267,7 +270,7 @@ 10.45 public Context(final Options options, final ErrorManager errors, final PrintWriter out, final PrintWriter err, final ClassLoader appLoader) { 10.46 final SecurityManager sm = System.getSecurityManager(); 10.47 if (sm != null) { 10.48 - sm.checkPermission(new RuntimePermission("createNashornContext")); 10.49 + sm.checkPermission(new RuntimePermission("nashorn.createContext")); 10.50 } 10.51 10.52 this.env = new ScriptEnvironment(options, out, err); 10.53 @@ -533,7 +536,13 @@ 10.54 if (index != -1) { 10.55 final SecurityManager sm = System.getSecurityManager(); 10.56 if (sm != null) { 10.57 - sm.checkPackageAccess(fullName.substring(0, index)); 10.58 + AccessController.doPrivileged(new PrivilegedAction<Void>() { 10.59 + @Override 10.60 + public Void run() { 10.61 + sm.checkPackageAccess(fullName.substring(0, index)); 10.62 + return null; 10.63 + } 10.64 + }, createNoPermissionsContext()); 10.65 } 10.66 } 10.67 10.68 @@ -599,7 +608,7 @@ 10.69 public ScriptObject newGlobal() { 10.70 final SecurityManager sm = System.getSecurityManager(); 10.71 if (sm != null) { 10.72 - sm.checkPermission(new RuntimePermission("createNashornGlobal")); 10.73 + sm.checkPermission(new RuntimePermission("nashorn.newGlobal")); 10.74 } 10.75 10.76 return newGlobalTrusted(); 10.77 @@ -676,6 +685,10 @@ 10.78 return (context != null) ? context : Context.getContextTrusted(); 10.79 } 10.80 10.81 + private static AccessControlContext createNoPermissionsContext() { 10.82 + return new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, new Permissions()) }); 10.83 + } 10.84 + 10.85 private Object evaluateSource(final Source source, final ScriptObject scope, final ScriptObject thiz) { 10.86 ScriptFunction script = null; 10.87
11.1 --- a/src/jdk/nashorn/internal/runtime/NashornLoader.java Sat Mar 09 21:49:32 2013 +0530 11.2 +++ b/src/jdk/nashorn/internal/runtime/NashornLoader.java Tue Mar 12 18:12:42 2013 +0530 11.3 @@ -30,6 +30,10 @@ 11.4 import java.net.MalformedURLException; 11.5 import java.net.URL; 11.6 import java.net.URLClassLoader; 11.7 +import java.security.CodeSource; 11.8 +import java.security.Permission; 11.9 +import java.security.PermissionCollection; 11.10 +import java.security.Permissions; 11.11 import java.security.SecureClassLoader; 11.12 import jdk.nashorn.tools.Shell; 11.13 11.14 @@ -40,6 +44,28 @@ 11.15 * 11.16 */ 11.17 abstract class NashornLoader extends SecureClassLoader { 11.18 + private static final String OBJECTS_PKG = "jdk.nashorn.internal.objects"; 11.19 + private static final String RUNTIME_PKG = "jdk.nashorn.internal.runtime"; 11.20 + private static final String RUNTIME_LINKER_PKG = "jdk.nashorn.internal.runtime.linker"; 11.21 + private static final String SCRIPTS_PKG = "jdk.nashorn.internal.scripts"; 11.22 + 11.23 + private static final Permission[] SCRIPT_PERMISSIONS; 11.24 + static { 11.25 + SCRIPT_PERMISSIONS = new Permission[4]; 11.26 + 11.27 + /* 11.28 + * Generated classes get access to runtime, runtime.linker, objects, scripts packages. 11.29 + * Note that the actual scripts can not access these because Java.type, Packages 11.30 + * prevent these restricted packages. And Java reflection and JSR292 access is prevented 11.31 + * for scripts. In other words, nashorn generated portions of script classes can access 11.32 + * clases in these implementation packages. 11.33 + */ 11.34 + SCRIPT_PERMISSIONS[0] = new RuntimePermission("accessClassInPackage." + RUNTIME_PKG); 11.35 + SCRIPT_PERMISSIONS[1] = new RuntimePermission("accessClassInPackage." + RUNTIME_LINKER_PKG); 11.36 + SCRIPT_PERMISSIONS[2] = new RuntimePermission("accessClassInPackage." + OBJECTS_PKG); 11.37 + SCRIPT_PERMISSIONS[3] = new RuntimePermission("accessClassInPackage." + SCRIPTS_PKG); 11.38 + } 11.39 + 11.40 private final Context context; 11.41 11.42 final Context getContext() { 11.43 @@ -68,11 +94,30 @@ 11.44 if (i != -1) { 11.45 final SecurityManager sm = System.getSecurityManager(); 11.46 if (sm != null) { 11.47 - sm.checkPackageAccess(name.substring(0, i)); 11.48 + final String pkgName = name.substring(0, i); 11.49 + switch (pkgName) { 11.50 + case RUNTIME_PKG: 11.51 + case RUNTIME_LINKER_PKG: 11.52 + case OBJECTS_PKG: 11.53 + case SCRIPTS_PKG: 11.54 + // allow it. 11.55 + break; 11.56 + default: 11.57 + sm.checkPackageAccess(pkgName); 11.58 + } 11.59 } 11.60 } 11.61 } 11.62 11.63 + @Override 11.64 + protected PermissionCollection getPermissions(CodeSource codesource) { 11.65 + final Permissions permCollection = new Permissions(); 11.66 + for (final Permission perm : SCRIPT_PERMISSIONS) { 11.67 + permCollection.add(perm); 11.68 + } 11.69 + return permCollection; 11.70 + } 11.71 + 11.72 /** 11.73 * Create a secure URL class loader for the given classpath 11.74 * @param classPath classpath for the loader to search from
12.1 --- a/src/jdk/nashorn/internal/runtime/ScriptLoader.java Sat Mar 09 21:49:32 2013 +0530 12.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptLoader.java Tue Mar 12 18:12:42 2013 +0530 12.3 @@ -26,6 +26,7 @@ 12.4 package jdk.nashorn.internal.runtime; 12.5 12.6 import java.security.CodeSource; 12.7 +import java.security.ProtectionDomain; 12.8 12.9 /** 12.10 * Responsible for loading script generated classes. 12.11 @@ -57,6 +58,10 @@ 12.12 * @return Installed class. 12.13 */ 12.14 synchronized Class<?> installClass(final String name, final byte[] data, final CodeSource cs) { 12.15 - return defineClass(name, data, 0, data.length, cs); 12.16 + if (cs == null) { 12.17 + return defineClass(name, data, 0, data.length, new ProtectionDomain(null, getPermissions(null))); 12.18 + } else { 12.19 + return defineClass(name, data, 0, data.length, cs); 12.20 + } 12.21 } 12.22 }
13.1 --- a/src/jdk/nashorn/internal/runtime/StructureLoader.java Sat Mar 09 21:49:32 2013 +0530 13.2 +++ b/src/jdk/nashorn/internal/runtime/StructureLoader.java Tue Mar 12 18:12:42 2013 +0530 13.3 @@ -38,6 +38,7 @@ 13.4 import java.security.CodeSource; 13.5 import java.security.PrivilegedActionException; 13.6 import java.security.PrivilegedExceptionAction; 13.7 +import java.security.ProtectionDomain; 13.8 import jdk.nashorn.internal.codegen.ObjectClassGenerator; 13.9 13.10 /** 13.11 @@ -129,6 +130,6 @@ 13.12 } 13.13 13.14 final byte[] code = new ObjectClassGenerator(context).generate(descriptor); 13.15 - return defineClass(name, code, 0, code.length); 13.16 + return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null))); 13.17 } 13.18 }
14.1 --- a/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java Sat Mar 09 21:49:32 2013 +0530 14.2 +++ b/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java Tue Mar 12 18:12:42 2013 +0530 14.3 @@ -57,7 +57,7 @@ 14.4 static { 14.5 final DynamicLinkerFactory factory = new DynamicLinkerFactory(); 14.6 factory.setPrioritizedLinkers(new NashornLinker(), new NashornPrimitiveLinker(), new NashornStaticClassLinker(), 14.7 - new JSObjectLinker()); 14.8 + new JSObjectLinker(), new ReflectionCheckLinker()); 14.9 factory.setFallbackLinkers(new BeansLinker(), new NashornBottomLinker()); 14.10 factory.setSyncOnRelink(true); 14.11 final int relinkThreshold = Options.getIntProperty("nashorn.unstable.relink.threshold", -1);
15.1 --- a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java Sat Mar 09 21:49:32 2013 +0530 15.2 +++ b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java Tue Mar 12 18:12:42 2013 +0530 15.3 @@ -54,6 +54,7 @@ 15.4 import java.security.CodeSource; 15.5 import java.security.Permissions; 15.6 import java.security.PrivilegedAction; 15.7 +import java.security.PrivilegedExceptionAction; 15.8 import java.security.ProtectionDomain; 15.9 import java.security.SecureClassLoader; 15.10 import java.security.SecureRandom; 15.11 @@ -410,9 +411,13 @@ 15.12 */ 15.13 public static MethodHandle getConstructor(final Class<?> sourceType, final Class<?> targetType) throws Exception { 15.14 final StaticClass adapterClass = getAdapterClassFor(new Class<?>[] { targetType }); 15.15 - return MH.bindTo(Bootstrap.getLinkerServices().getGuardedInvocation(new LinkRequestImpl(NashornCallSiteDescriptor.get( 15.16 - "dyn:new", MethodType.methodType(targetType, StaticClass.class, sourceType), 0), false, 15.17 - adapterClass, null)).getInvocation(), adapterClass); 15.18 + return AccessController.doPrivileged(new PrivilegedExceptionAction<MethodHandle>() { 15.19 + public MethodHandle run() throws Exception { 15.20 + return MH.bindTo(Bootstrap.getLinkerServices().getGuardedInvocation(new LinkRequestImpl(NashornCallSiteDescriptor.get( 15.21 + "dyn:new", MethodType.methodType(targetType, StaticClass.class, sourceType), 0), false, 15.22 + adapterClass, null)).getInvocation(), adapterClass); 15.23 + } 15.24 + }); 15.25 } 15.26 15.27 /** 15.28 @@ -456,9 +461,26 @@ 15.29 private static ClassLoader createClassLoader(final ClassLoader parentLoader, final String className, 15.30 final byte[] classBytes, final String privilegedActionClassName) { 15.31 return new AdapterLoader(parentLoader) { 15.32 + private final ClassLoader myLoader = getClass().getClassLoader(); 15.33 private final ProtectionDomain myProtectionDomain = getClass().getProtectionDomain(); 15.34 15.35 @Override 15.36 + public Class<?> loadClass(final String name, final boolean resolve) throws ClassNotFoundException { 15.37 + try { 15.38 + return super.loadClass(name, resolve); 15.39 + } catch (final SecurityException se) { 15.40 + // we may be implementing an interface or extending a class that was 15.41 + // loaded by a loader that prevents package.access. If so, it'd throw 15.42 + // SecurityException for nashorn's classes!. For adapter's to work, we 15.43 + // should be able to refer to nashorn classes. 15.44 + if (name.startsWith("jdk.nashorn.internal.")) { 15.45 + return myLoader.loadClass(name); 15.46 + } 15.47 + throw se; 15.48 + } 15.49 + } 15.50 + 15.51 + @Override 15.52 protected Class<?> findClass(final String name) throws ClassNotFoundException { 15.53 if(name.equals(className)) { 15.54 final byte[] bytes = classBytes;
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java Tue Mar 12 18:12:42 2013 +0530 16.3 @@ -0,0 +1,60 @@ 16.4 +/* 16.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 16.7 + * 16.8 + * This code is free software; you can redistribute it and/or modify it 16.9 + * under the terms of the GNU General Public License version 2 only, as 16.10 + * published by the Free Software Foundation. Oracle designates this 16.11 + * particular file as subject to the "Classpath" exception as provided 16.12 + * by Oracle in the LICENSE file that accompanied this code. 16.13 + * 16.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 16.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16.17 + * version 2 for more details (a copy is included in the LICENSE file that 16.18 + * accompanied this code). 16.19 + * 16.20 + * You should have received a copy of the GNU General Public License version 16.21 + * 2 along with this work; if not, write to the Free Software Foundation, 16.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 16.23 + * 16.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 16.25 + * or visit www.oracle.com if you need additional information or have any 16.26 + * questions. 16.27 + */ 16.28 + 16.29 +package jdk.nashorn.internal.runtime.linker; 16.30 + 16.31 +import jdk.internal.dynalink.linker.GuardedInvocation; 16.32 +import jdk.internal.dynalink.linker.LinkRequest; 16.33 +import jdk.internal.dynalink.linker.LinkerServices; 16.34 +import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker; 16.35 + 16.36 +/** 16.37 + * Check java reflection permission for java reflective and java.lang.invoke access from scripts 16.38 + */ 16.39 +final class ReflectionCheckLinker implements TypeBasedGuardingDynamicLinker{ 16.40 + @Override 16.41 + public boolean canLinkType(final Class<?> type) { 16.42 + return canLinkTypeStatic(type); 16.43 + } 16.44 + 16.45 + private static boolean canLinkTypeStatic(final Class<?> type) { 16.46 + if (type == Class.class || ClassLoader.class.isAssignableFrom(type)) { 16.47 + return true; 16.48 + } 16.49 + final String name = type.getName(); 16.50 + return name.startsWith("java.lang.reflect.") || name.startsWith("java.lang.invoke."); 16.51 + } 16.52 + 16.53 + @Override 16.54 + public GuardedInvocation getGuardedInvocation(final LinkRequest origRequest, final LinkerServices linkerServices) 16.55 + throws Exception { 16.56 + final SecurityManager sm = System.getSecurityManager(); 16.57 + if (sm != null) { 16.58 + sm.checkPermission(new RuntimePermission("nashorn.JavaReflection")); 16.59 + } 16.60 + // let the next linker deal with actual linking 16.61 + return null; 16.62 + } 16.63 +}
17.1 --- a/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js Sat Mar 09 21:49:32 2013 +0530 17.2 +++ b/src/jdk/nashorn/internal/runtime/resources/mozilla_compat.js Tue Mar 12 18:12:42 2013 +0530 17.3 @@ -1,21 +1,21 @@ 17.4 /* 17.5 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 17.6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 17.7 - * 17.8 + * 17.9 * This code is free software; you can redistribute it and/or modify it 17.10 * under the terms of the GNU General Public License version 2 only, as 17.11 * published by the Free Software Foundation. 17.12 - * 17.13 + * 17.14 * This code is distributed in the hope that it will be useful, but WITHOUT 17.15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 17.16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17.17 * version 2 for more details (a copy is included in the LICENSE file that 17.18 * accompanied this code). 17.19 - * 17.20 + * 17.21 * You should have received a copy of the GNU General Public License version 17.22 * 2 along with this work; if not, write to the Free Software Foundation, 17.23 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17.24 - * 17.25 + * 17.26 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 17.27 * or visit www.oracle.com if you need additional information or have any 17.28 * questions. 17.29 @@ -34,7 +34,7 @@ 17.30 if (arguments.length < 2) { 17.31 throw new TypeError("JavaAdapter requires atleast two arguments"); 17.32 } 17.33 - 17.34 + 17.35 var types = Array.prototype.slice.call(arguments, 0, arguments.length - 1); 17.36 var NewType = Java.extend.apply(Java, types); 17.37 return new NewType(arguments[arguments.length - 1]); 17.38 @@ -56,10 +56,10 @@ 17.39 return type; 17.40 } catch (e) {} 17.41 } 17.42 - 17.43 + 17.44 return oldNoSuchProperty? oldNoSuchProperty(name) : undefined; 17.45 } 17.46 - 17.47 + 17.48 var prefix = "[JavaPackage "; 17.49 return function() { 17.50 for (var i in arguments) { 17.51 @@ -343,7 +343,9 @@ 17.52 configurable: true, enumerable: false, writable: true, 17.53 value: function(clazz) { 17.54 if (Java.isType(clazz)) { 17.55 - this[clazz.class.getSimpleName()] = clazz; 17.56 + var className = Java.typeName(clazz); 17.57 + var simpleName = className.substring(className.lastIndexOf('.') + 1); 17.58 + this[simpleName] = clazz; 17.59 } else { 17.60 throw new TypeError(clazz + " is not a Java class"); 17.61 }
18.1 --- a/src/jdk/nashorn/internal/runtime/resources/parser.js Sat Mar 09 21:49:32 2013 +0530 18.2 +++ b/src/jdk/nashorn/internal/runtime/resources/parser.js Tue Mar 12 18:12:42 2013 +0530 18.3 @@ -1,21 +1,21 @@ 18.4 /* 18.5 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 18.6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.7 - * 18.8 + * 18.9 * This code is free software; you can redistribute it and/or modify it 18.10 * under the terms of the GNU General Public License version 2 only, as 18.11 * published by the Free Software Foundation. 18.12 - * 18.13 + * 18.14 * This code is distributed in the hope that it will be useful, but WITHOUT 18.15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18.16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18.17 * version 2 for more details (a copy is included in the LICENSE file that 18.18 * accompanied this code). 18.19 - * 18.20 + * 18.21 * You should have received a copy of the GNU General Public License version 18.22 * 2 along with this work; if not, write to the Free Software Foundation, 18.23 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18.24 - * 18.25 + * 18.26 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 18.27 * or visit www.oracle.com if you need additional information or have any 18.28 * questions. 18.29 @@ -47,7 +47,7 @@ 18.30 code = arguments[0]; 18.31 } 18.32 18.33 - var jsonStr = Packages.jdk.nashorn.internal.runtime.ScriptRuntime.parse(code, name, location); 18.34 + var jsonStr = Packages.jdk.nashorn.api.scripting.ScriptUtils.parse(code, name, location); 18.35 return JSON.parse(jsonStr, 18.36 function (prop, value) { 18.37 if (typeof(value) == 'string' && prop == "value") {
19.1 --- a/test/script/basic/JDK-8008448.js Sat Mar 09 21:49:32 2013 +0530 19.2 +++ b/test/script/basic/JDK-8008448.js Tue Mar 12 18:12:42 2013 +0530 19.3 @@ -32,7 +32,7 @@ 19.4 19.5 var File = Java.type("java.io.File"); 19.6 var FilenameFilter = Java.type("java.io.FilenameFilter"); 19.7 -var Source = Java.type("jdk.nashorn.internal.runtime.Source") 19.8 +var SourceHelper = Java.type("jdk.nashorn.test.models.SourceHelper") 19.9 19.10 // Filter out non .js files 19.11 var files = new File(__DIR__).listFiles(new FilenameFilter() { 19.12 @@ -44,5 +44,5 @@ 19.13 19.14 // parse each file to make sure it does not result in exception 19.15 for each (var f in files) { 19.16 - parse(new Source(f.toString(), f).getString()); 19.17 + parse(SourceHelper.readFully(f)); 19.18 }
20.1 --- a/test/script/basic/NASHORN-401.js Sat Mar 09 21:49:32 2013 +0530 20.2 +++ b/test/script/basic/NASHORN-401.js Tue Mar 12 18:12:42 2013 +0530 20.3 @@ -28,7 +28,7 @@ 20.4 * @run 20.5 */ 20.6 20.7 -var t = new Packages.jdk.nashorn.internal.runtime.Nashorn401TestSubject(); 20.8 +var t = new Packages.jdk.nashorn.test.models.Nashorn401TestSubject(); 20.9 20.10 print(t.method2(10)); 20.11 print(t.method2(10.2));
21.1 --- a/test/script/basic/consstring.js Sat Mar 09 21:49:32 2013 +0530 21.2 +++ b/test/script/basic/consstring.js Tue Mar 12 18:12:42 2013 +0530 21.3 @@ -37,4 +37,4 @@ 21.4 list.add((str + "3").toString()); // toString() called on primitive string 21.5 list.add(new String(str + "4").toString()); // toString() called on String object 21.6 21.7 -Packages.jdk.nashorn.internal.test.models.StringArgs.checkString(list); 21.8 +Packages.jdk.nashorn.test.models.StringArgs.checkString(list);
22.1 --- a/test/script/basic/fileline.js Sat Mar 09 21:49:32 2013 +0530 22.2 +++ b/test/script/basic/fileline.js Tue Mar 12 18:12:42 2013 +0530 22.3 @@ -41,8 +41,8 @@ 22.4 load(__DIR__ + "loadedfile.js"); 22.5 22.6 // Add check for base part of a URL. We can't test __DIR__ inside 22.7 -// a script that is downloaded from a URL. check for Source.baseURL 22.8 +// a script that is downloaded from a URL. check for SourceHelper.baseURL 22.9 // which is exposed as __DIR__ for URL case. 22.10 22.11 var url = new java.net.URL("http://www.acme.com:8080/foo/bar.js"); 22.12 -print(Packages.jdk.nashorn.internal.runtime.Source.baseURL(url)); 22.13 +print(Packages.jdk.nashorn.test.models.SourceHelper.baseURL(url));
23.1 --- a/test/script/basic/javainnerclasses.js Sat Mar 09 21:49:32 2013 +0530 23.2 +++ b/test/script/basic/javainnerclasses.js Tue Mar 12 18:12:42 2013 +0530 23.3 @@ -29,25 +29,25 @@ 23.4 */ 23.5 23.6 // Do it with Java.type() 23.7 -var outer = new (Java.type("jdk.nashorn.internal.test.models.OuterClass"))("apple") 23.8 +var outer = new (Java.type("jdk.nashorn.test.models.OuterClass"))("apple") 23.9 print(outer) 23.10 -var innerStatic = new (Java.type("jdk.nashorn.internal.test.models.OuterClass$InnerStaticClass"))("orange") 23.11 +var innerStatic = new (Java.type("jdk.nashorn.test.models.OuterClass$InnerStaticClass"))("orange") 23.12 print(innerStatic) 23.13 -var innerNonStatic = new (Java.type("jdk.nashorn.internal.test.models.OuterClass$InnerNonStaticClass"))(outer, "pear") 23.14 +var innerNonStatic = new (Java.type("jdk.nashorn.test.models.OuterClass$InnerNonStaticClass"))(outer, "pear") 23.15 print(innerNonStatic) 23.16 23.17 // Now do it with Packages and explicit $ names 23.18 -var outer = new Packages.jdk.nashorn.internal.test.models.OuterClass("red") 23.19 +var outer = new Packages.jdk.nashorn.test.models.OuterClass("red") 23.20 print(outer) 23.21 -var innerStatic = new Packages.jdk.nashorn.internal.test.models.OuterClass$InnerStaticClass("green") 23.22 +var innerStatic = new Packages.jdk.nashorn.test.models.OuterClass$InnerStaticClass("green") 23.23 print(innerStatic) 23.24 -var innerNonStatic = new Packages.jdk.nashorn.internal.test.models.OuterClass$InnerNonStaticClass(outer, "blue") 23.25 +var innerNonStatic = new Packages.jdk.nashorn.test.models.OuterClass$InnerNonStaticClass(outer, "blue") 23.26 print(innerNonStatic) 23.27 23.28 // Now do it with Packages and nested properties 23.29 -var outer = new Packages.jdk.nashorn.internal.test.models.OuterClass("sweet") 23.30 +var outer = new Packages.jdk.nashorn.test.models.OuterClass("sweet") 23.31 print(outer) 23.32 -var innerStatic = new Packages.jdk.nashorn.internal.test.models.OuterClass.InnerStaticClass("sour") 23.33 +var innerStatic = new Packages.jdk.nashorn.test.models.OuterClass.InnerStaticClass("sour") 23.34 print(innerStatic) 23.35 -var innerNonStatic = new Packages.jdk.nashorn.internal.test.models.OuterClass.InnerNonStaticClass(outer, "bitter") 23.36 +var innerNonStatic = new Packages.jdk.nashorn.test.models.OuterClass.InnerNonStaticClass(outer, "bitter") 23.37 print(innerNonStatic)
24.1 --- a/test/script/basic/list.js Sat Mar 09 21:49:32 2013 +0530 24.2 +++ b/test/script/basic/list.js Tue Mar 12 18:12:42 2013 +0530 24.3 @@ -28,7 +28,7 @@ 24.4 * @run 24.5 */ 24.6 var l = new java.util.ArrayList(); 24.7 -print("l.class.name=" + l.class.name) // Has "class" property like any POJO 24.8 +print("l.class.name=" + Java.typeName(l.class)) // Has "class" property like any POJO 24.9 24.10 l.add("foo") 24.11 l.add("bar")
25.1 --- a/test/script/basic/map.js Sat Mar 09 21:49:32 2013 +0530 25.2 +++ b/test/script/basic/map.js Tue Mar 12 18:12:42 2013 +0530 25.3 @@ -28,7 +28,7 @@ 25.4 * @run 25.5 */ 25.6 var m = new (Java.type("java.util.LinkedHashMap")); 25.7 -print("m.class.name=" + m.class.name) // Has "class" property like any POJO 25.8 +print("m.class.name=" + Java.typeName(m.class)) // Has "class" property like any POJO 25.9 25.10 var empty_key = "empty" 25.11
26.1 --- a/test/script/basic/stdin.js Sat Mar 09 21:49:32 2013 +0530 26.2 +++ b/test/script/basic/stdin.js Tue Mar 12 18:12:42 2013 +0530 26.3 @@ -28,8 +28,8 @@ 26.4 * @run 26.5 */ 26.6 26.7 -print(java.lang.System.in.class.name); 26.8 +print(Java.typeName(java.lang.System.in.class)); 26.9 var prop = "in"; 26.10 -print(java.lang.System[prop].class.name); 26.11 -print(java.lang.System["in"].class.name); 26.12 +print(Java.typeName(java.lang.System[prop].class)); 26.13 +print(Java.typeName(java.lang.System["in"].class)); 26.14
27.1 --- a/test/script/sandbox/javaextend.js Sat Mar 09 21:49:32 2013 +0530 27.2 +++ b/test/script/sandbox/javaextend.js Tue Mar 12 18:12:42 2013 +0530 27.3 @@ -27,7 +27,7 @@ 27.4 */ 27.5 27.6 function model(n) { 27.7 - return Java.type("jdk.nashorn.internal.test.models." + n) 27.8 + return Java.type("jdk.nashorn.test.models." + n) 27.9 } 27.10 27.11 // Can't extend a final class
28.1 --- a/test/script/sandbox/javaextend.js.EXPECTED Sat Mar 09 21:49:32 2013 +0530 28.2 +++ b/test/script/sandbox/javaextend.js.EXPECTED Tue Mar 12 18:12:42 2013 +0530 28.3 @@ -1,6 +1,6 @@ 28.4 -TypeError: Can not extend final class jdk.nashorn.internal.test.models.FinalClass. 28.5 -TypeError: Can not extend class jdk.nashorn.internal.test.models.NoAccessibleConstructorClass as it has no public or protected constructors. 28.6 -TypeError: Can not extend/implement non-public class/interface jdk.nashorn.internal.test.models.NonPublicClass. 28.7 +TypeError: Can not extend final class jdk.nashorn.test.models.FinalClass. 28.8 +TypeError: Can not extend class jdk.nashorn.test.models.NoAccessibleConstructorClass as it has no public or protected constructors. 28.9 +TypeError: Can not extend/implement non-public class/interface jdk.nashorn.test.models.NonPublicClass. 28.10 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. 28.11 abcdabcd 28.12 run-object
29.1 --- a/test/script/sandbox/reflection.js Sat Mar 09 21:49:32 2013 +0530 29.2 +++ b/test/script/sandbox/reflection.js Tue Mar 12 18:12:42 2013 +0530 29.3 @@ -30,9 +30,7 @@ 29.4 */ 29.5 29.6 function check(e) { 29.7 - if (e instanceof java.lang.SecurityException) { 29.8 - print(e); 29.9 - } else { 29.10 + if (! (e instanceof java.lang.SecurityException)) { 29.11 fail("expected SecurityException, got " + e); 29.12 } 29.13 }
30.1 --- a/test/script/sandbox/reflection.js.EXPECTED Sat Mar 09 21:49:32 2013 +0530 30.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 30.3 @@ -1,1 +0,0 @@ 30.4 -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
31.1 --- a/test/script/sandbox/unsafe.js Sat Mar 09 21:49:32 2013 +0530 31.2 +++ b/test/script/sandbox/unsafe.js Tue Mar 12 18:12:42 2013 +0530 31.3 @@ -30,9 +30,7 @@ 31.4 */ 31.5 31.6 function check(e) { 31.7 - if (e instanceof java.lang.SecurityException) { 31.8 - print(e); 31.9 - } else { 31.10 + if (! (e instanceof java.lang.SecurityException)) { 31.11 fail("expected SecurityException, got " + e); 31.12 } 31.13 }
32.1 --- a/test/script/sandbox/unsafe.js.EXPECTED Sat Mar 09 21:49:32 2013 +0530 32.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 32.3 @@ -1,4 +0,0 @@ 32.4 -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.misc") 32.5 -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.misc") 32.6 -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun") 32.7 -java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")
33.1 --- a/test/script/trusted/urlreader.js Sat Mar 09 21:49:32 2013 +0530 33.2 +++ b/test/script/trusted/urlreader.js Tue Mar 12 18:12:42 2013 +0530 33.3 @@ -9,7 +9,7 @@ 33.4 var URL = Java.type("java.net.URL"); 33.5 var File = Java.type("java.io.File"); 33.6 var JString = Java.type("java.lang.String"); 33.7 -var Source = Java.type("jdk.nashorn.internal.runtime.Source"); 33.8 +var SourceHelper = Java.type("jdk.nashorn.test.models.SourceHelper"); 33.9 33.10 var url = new File(__FILE__).toURI().toURL(); 33.11 var reader = new URLReader(url); 33.12 @@ -19,9 +19,9 @@ 33.13 33.14 // check URL read 33.15 // read URL content by directly reading from URL 33.16 -var str = new Source(url.toString(), url).getString(); 33.17 +var str = SourceHelper.readFully(url); 33.18 // read URL content via URLReader 33.19 -var content = new JString(Source.readFully(reader)); 33.20 +var content = new JString(SourceHelper.readFully(reader)); 33.21 33.22 // assert that the content is same 33.23 Assert.assertEquals(str, content);
34.1 --- a/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java Sat Mar 09 21:49:32 2013 +0530 34.2 +++ b/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java Tue Mar 12 18:12:42 2013 +0530 34.3 @@ -47,7 +47,6 @@ 34.4 import javax.script.ScriptEngineManager; 34.5 import javax.script.ScriptException; 34.6 import javax.script.SimpleScriptContext; 34.7 -import jdk.nashorn.internal.runtime.Version; 34.8 import netscape.javascript.JSObject; 34.9 import org.testng.Assert; 34.10 import org.testng.annotations.Test; 34.11 @@ -129,7 +128,6 @@ 34.12 assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript"); 34.13 assertEquals(fac.getLanguageVersion(), "ECMA - 262 Edition 5.1"); 34.14 assertEquals(fac.getEngineName(), "Oracle Nashorn"); 34.15 - assertEquals(fac.getEngineVersion(), Version.version()); 34.16 assertEquals(fac.getOutputStatement("context"), "print(context)"); 34.17 assertEquals(fac.getProgram("print('hello')", "print('world')"), "print('hello');print('world');"); 34.18 assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript"); 34.19 @@ -313,27 +311,6 @@ 34.20 } 34.21 } 34.22 34.23 - public static void alert(final Object msg) { 34.24 - System.out.println(msg); 34.25 - } 34.26 - 34.27 - @Test 34.28 - public void exposeMethodTest() { 34.29 - final ScriptEngineManager m = new ScriptEngineManager(); 34.30 - final ScriptEngine e = m.getEngineByName("nashorn"); 34.31 - 34.32 - try { 34.33 - final Method alert = ScriptEngineTest.class.getMethod("alert", Object.class); 34.34 - // expose a Method object as global var. 34.35 - e.put("alert", alert); 34.36 - // call the global var. 34.37 - e.eval("alert.invoke(null, 'alert! alert!!')"); 34.38 - } catch (final NoSuchMethodException | SecurityException | ScriptException exp) { 34.39 - exp.printStackTrace(); 34.40 - fail(exp.getMessage()); 34.41 - } 34.42 - } 34.43 - 34.44 @Test 34.45 public void putGlobalFunctionTest() { 34.46 final ScriptEngineManager m = new ScriptEngineManager(); 34.47 @@ -593,13 +570,6 @@ 34.48 } 34.49 34.50 @Test 34.51 - public void versionTest() { 34.52 - final ScriptEngineManager m = new ScriptEngineManager(); 34.53 - final ScriptEngine e = m.getEngineByName("nashorn"); 34.54 - assertEquals(e.getFactory().getEngineVersion(), Version.version()); 34.55 - } 34.56 - 34.57 - @Test 34.58 public void noEnumerablePropertiesTest() { 34.59 final ScriptEngineManager m = new ScriptEngineManager(); 34.60 final ScriptEngine e = m.getEngineByName("nashorn"); 34.61 @@ -874,26 +844,4 @@ 34.62 fail(se.getMessage()); 34.63 } 34.64 } 34.65 - 34.66 - @Test 34.67 - public void factoryOptionsTest() { 34.68 - final ScriptEngineManager sm = new ScriptEngineManager(); 34.69 - for (ScriptEngineFactory fac : sm.getEngineFactories()) { 34.70 - if (fac instanceof NashornScriptEngineFactory) { 34.71 - final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac; 34.72 - // specify --no-syntax-extensions flag 34.73 - final String[] options = new String[] { "--no-syntax-extensions" }; 34.74 - final ScriptEngine e = nfac.getScriptEngine(options); 34.75 - try { 34.76 - // try nashorn specific extension 34.77 - e.eval("var f = funtion(x) 2*x;"); 34.78 - fail("should have thrown exception!"); 34.79 - } catch (final ScriptException se) { 34.80 - } 34.81 - return; 34.82 - } 34.83 - } 34.84 - 34.85 - fail("Cannot find nashorn factory!"); 34.86 - } 34.87 }
35.1 --- a/test/src/jdk/nashorn/internal/runtime/Nashorn401TestSubject.java Sat Mar 09 21:49:32 2013 +0530 35.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 35.3 @@ -1,57 +0,0 @@ 35.4 -/* 35.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 35.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 35.7 - * 35.8 - * This code is free software; you can redistribute it and/or modify it 35.9 - * under the terms of the GNU General Public License version 2 only, as 35.10 - * published by the Free Software Foundation. Oracle designates this 35.11 - * particular file as subject to the "Classpath" exception as provided 35.12 - * by Oracle in the LICENSE file that accompanied this code. 35.13 - * 35.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 35.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 35.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 35.17 - * version 2 for more details (a copy is included in the LICENSE file that 35.18 - * accompanied this code). 35.19 - * 35.20 - * You should have received a copy of the GNU General Public License version 35.21 - * 2 along with this work; if not, write to the Free Software Foundation, 35.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 35.23 - * 35.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 35.25 - * or visit www.oracle.com if you need additional information or have any 35.26 - * questions. 35.27 - */ 35.28 - 35.29 -package jdk.nashorn.internal.runtime; 35.30 - 35.31 -public class Nashorn401TestSubject { 35.32 - public String method2(int arg) { 35.33 - return "int method 2"; 35.34 - } 35.35 - 35.36 - public String method2(double arg) { 35.37 - return "double method 2"; 35.38 - } 35.39 - 35.40 - public String method2(String arg) { 35.41 - return "string method 2"; 35.42 - } 35.43 - 35.44 - public String method3(double arg) { 35.45 - return "double method 3: " + arg; 35.46 - } 35.47 - 35.48 - public String method3(int arg) { 35.49 - return "int method 3: " + arg; 35.50 - } 35.51 - 35.52 - public String method4(Double arg) { 35.53 - return "double method 4: " + arg; 35.54 - } 35.55 - 35.56 - public String method4(int arg) { 35.57 - return "int method 4: " + arg; 35.58 - } 35.59 - 35.60 -}
36.1 --- a/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java Sat Mar 09 21:49:32 2013 +0530 36.2 +++ b/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java Tue Mar 12 18:12:42 2013 +0530 36.3 @@ -25,7 +25,7 @@ 36.4 36.5 package jdk.nashorn.internal.runtime; 36.6 36.7 - 36.8 +import static org.testng.Assert.assertEquals; 36.9 import static org.testng.Assert.assertTrue; 36.10 import static org.testng.Assert.fail; 36.11 36.12 @@ -40,6 +40,13 @@ 36.13 * Tests for trusted client usage of nashorn script engine factory extension API 36.14 */ 36.15 public class TrustedScriptEngineTest { 36.16 + @Test 36.17 + public void versionTest() { 36.18 + final ScriptEngineManager m = new ScriptEngineManager(); 36.19 + final ScriptEngine e = m.getEngineByName("nashorn"); 36.20 + assertEquals(e.getFactory().getEngineVersion(), Version.version()); 36.21 + } 36.22 + 36.23 private static class MyClassLoader extends ClassLoader { 36.24 // to check if script engine uses the specified class loader 36.25 private final boolean[] reached = new boolean[1]; 36.26 @@ -116,4 +123,26 @@ 36.27 36.28 fail("Cannot find nashorn factory!"); 36.29 } 36.30 + 36.31 + @Test 36.32 + public void factoryOptionsTest() { 36.33 + final ScriptEngineManager sm = new ScriptEngineManager(); 36.34 + for (ScriptEngineFactory fac : sm.getEngineFactories()) { 36.35 + if (fac instanceof NashornScriptEngineFactory) { 36.36 + final NashornScriptEngineFactory nfac = (NashornScriptEngineFactory)fac; 36.37 + // specify --no-syntax-extensions flag 36.38 + final String[] options = new String[] { "--no-syntax-extensions" }; 36.39 + final ScriptEngine e = nfac.getScriptEngine(options); 36.40 + try { 36.41 + // try nashorn specific extension 36.42 + e.eval("var f = funtion(x) 2*x;"); 36.43 + fail("should have thrown exception!"); 36.44 + } catch (final ScriptException se) { 36.45 + } 36.46 + return; 36.47 + } 36.48 + } 36.49 + 36.50 + fail("Cannot find nashorn factory!"); 36.51 + } 36.52 }
37.1 --- a/test/src/jdk/nashorn/internal/test/models/ConstructorWithArgument.java Sat Mar 09 21:49:32 2013 +0530 37.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 37.3 @@ -1,40 +0,0 @@ 37.4 -/* 37.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 37.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 37.7 - * 37.8 - * This code is free software; you can redistribute it and/or modify it 37.9 - * under the terms of the GNU General Public License version 2 only, as 37.10 - * published by the Free Software Foundation. Oracle designates this 37.11 - * particular file as subject to the "Classpath" exception as provided 37.12 - * by Oracle in the LICENSE file that accompanied this code. 37.13 - * 37.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 37.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 37.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 37.17 - * version 2 for more details (a copy is included in the LICENSE file that 37.18 - * accompanied this code). 37.19 - * 37.20 - * You should have received a copy of the GNU General Public License version 37.21 - * 2 along with this work; if not, write to the Free Software Foundation, 37.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 37.23 - * 37.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 37.25 - * or visit www.oracle.com if you need additional information or have any 37.26 - * questions. 37.27 - */ 37.28 - 37.29 -package jdk.nashorn.internal.test.models; 37.30 - 37.31 -public abstract class ConstructorWithArgument { 37.32 - private final String token; 37.33 - 37.34 - protected ConstructorWithArgument(String token) { 37.35 - this.token = token; 37.36 - } 37.37 - 37.38 - public String getToken() { 37.39 - return token; 37.40 - } 37.41 - 37.42 - protected abstract void doSomething(); 37.43 -}
38.1 --- a/test/src/jdk/nashorn/internal/test/models/DessertTopping.java Sat Mar 09 21:49:32 2013 +0530 38.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 38.3 @@ -1,30 +0,0 @@ 38.4 -/* 38.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 38.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 38.7 - * 38.8 - * This code is free software; you can redistribute it and/or modify it 38.9 - * under the terms of the GNU General Public License version 2 only, as 38.10 - * published by the Free Software Foundation. Oracle designates this 38.11 - * particular file as subject to the "Classpath" exception as provided 38.12 - * by Oracle in the LICENSE file that accompanied this code. 38.13 - * 38.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 38.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 38.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 38.17 - * version 2 for more details (a copy is included in the LICENSE file that 38.18 - * accompanied this code). 38.19 - * 38.20 - * You should have received a copy of the GNU General Public License version 38.21 - * 2 along with this work; if not, write to the Free Software Foundation, 38.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 38.23 - * 38.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 38.25 - * or visit www.oracle.com if you need additional information or have any 38.26 - * questions. 38.27 - */ 38.28 - 38.29 -package jdk.nashorn.internal.test.models; 38.30 - 38.31 -public interface DessertTopping { 38.32 - public String pourOnDessert(); 38.33 -}
39.1 --- a/test/src/jdk/nashorn/internal/test/models/DessertToppingFloorWaxDriver.java Sat Mar 09 21:49:32 2013 +0530 39.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 39.3 @@ -1,36 +0,0 @@ 39.4 -/* 39.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 39.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 39.7 - * 39.8 - * This code is free software; you can redistribute it and/or modify it 39.9 - * under the terms of the GNU General Public License version 2 only, as 39.10 - * published by the Free Software Foundation. Oracle designates this 39.11 - * particular file as subject to the "Classpath" exception as provided 39.12 - * by Oracle in the LICENSE file that accompanied this code. 39.13 - * 39.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 39.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 39.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 39.17 - * version 2 for more details (a copy is included in the LICENSE file that 39.18 - * accompanied this code). 39.19 - * 39.20 - * You should have received a copy of the GNU General Public License version 39.21 - * 2 along with this work; if not, write to the Free Software Foundation, 39.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 39.23 - * 39.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 39.25 - * or visit www.oracle.com if you need additional information or have any 39.26 - * questions. 39.27 - */ 39.28 - 39.29 -package jdk.nashorn.internal.test.models; 39.30 - 39.31 -public class DessertToppingFloorWaxDriver { 39.32 - public void decorateDessert(DessertTopping dt) { 39.33 - dt.pourOnDessert(); 39.34 - } 39.35 - 39.36 - public void waxFloor(FloorWax fw) { 39.37 - fw.shineUpTheFloor(); 39.38 - } 39.39 -}
40.1 --- a/test/src/jdk/nashorn/internal/test/models/FinalClass.java Sat Mar 09 21:49:32 2013 +0530 40.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 40.3 @@ -1,30 +0,0 @@ 40.4 -/* 40.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 40.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 40.7 - * 40.8 - * This code is free software; you can redistribute it and/or modify it 40.9 - * under the terms of the GNU General Public License version 2 only, as 40.10 - * published by the Free Software Foundation. Oracle designates this 40.11 - * particular file as subject to the "Classpath" exception as provided 40.12 - * by Oracle in the LICENSE file that accompanied this code. 40.13 - * 40.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 40.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 40.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 40.17 - * version 2 for more details (a copy is included in the LICENSE file that 40.18 - * accompanied this code). 40.19 - * 40.20 - * You should have received a copy of the GNU General Public License version 40.21 - * 2 along with this work; if not, write to the Free Software Foundation, 40.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 40.23 - * 40.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 40.25 - * or visit www.oracle.com if you need additional information or have any 40.26 - * questions. 40.27 - */ 40.28 - 40.29 -package jdk.nashorn.internal.test.models; 40.30 - 40.31 -public final class FinalClass { 40.32 - //empty 40.33 -}
41.1 --- a/test/src/jdk/nashorn/internal/test/models/FloorWax.java Sat Mar 09 21:49:32 2013 +0530 41.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 41.3 @@ -1,30 +0,0 @@ 41.4 -/* 41.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 41.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 41.7 - * 41.8 - * This code is free software; you can redistribute it and/or modify it 41.9 - * under the terms of the GNU General Public License version 2 only, as 41.10 - * published by the Free Software Foundation. Oracle designates this 41.11 - * particular file as subject to the "Classpath" exception as provided 41.12 - * by Oracle in the LICENSE file that accompanied this code. 41.13 - * 41.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 41.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 41.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 41.17 - * version 2 for more details (a copy is included in the LICENSE file that 41.18 - * accompanied this code). 41.19 - * 41.20 - * You should have received a copy of the GNU General Public License version 41.21 - * 2 along with this work; if not, write to the Free Software Foundation, 41.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 41.23 - * 41.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 41.25 - * or visit www.oracle.com if you need additional information or have any 41.26 - * questions. 41.27 - */ 41.28 - 41.29 -package jdk.nashorn.internal.test.models; 41.30 - 41.31 -public interface FloorWax { 41.32 - public String shineUpTheFloor(); 41.33 -}
42.1 --- a/test/src/jdk/nashorn/internal/test/models/NoAccessibleConstructorClass.java Sat Mar 09 21:49:32 2013 +0530 42.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 42.3 @@ -1,30 +0,0 @@ 42.4 -/* 42.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 42.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 42.7 - * 42.8 - * This code is free software; you can redistribute it and/or modify it 42.9 - * under the terms of the GNU General Public License version 2 only, as 42.10 - * published by the Free Software Foundation. Oracle designates this 42.11 - * particular file as subject to the "Classpath" exception as provided 42.12 - * by Oracle in the LICENSE file that accompanied this code. 42.13 - * 42.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 42.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 42.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 42.17 - * version 2 for more details (a copy is included in the LICENSE file that 42.18 - * accompanied this code). 42.19 - * 42.20 - * You should have received a copy of the GNU General Public License version 42.21 - * 2 along with this work; if not, write to the Free Software Foundation, 42.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 42.23 - * 42.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 42.25 - * or visit www.oracle.com if you need additional information or have any 42.26 - * questions. 42.27 - */ 42.28 - 42.29 -package jdk.nashorn.internal.test.models; 42.30 - 42.31 -public class NoAccessibleConstructorClass { 42.32 - NoAccessibleConstructorClass() { } 42.33 -}
43.1 --- a/test/src/jdk/nashorn/internal/test/models/NonPublicClass.java Sat Mar 09 21:49:32 2013 +0530 43.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 43.3 @@ -1,30 +0,0 @@ 43.4 -/* 43.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 43.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 43.7 - * 43.8 - * This code is free software; you can redistribute it and/or modify it 43.9 - * under the terms of the GNU General Public License version 2 only, as 43.10 - * published by the Free Software Foundation. Oracle designates this 43.11 - * particular file as subject to the "Classpath" exception as provided 43.12 - * by Oracle in the LICENSE file that accompanied this code. 43.13 - * 43.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 43.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 43.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 43.17 - * version 2 for more details (a copy is included in the LICENSE file that 43.18 - * accompanied this code). 43.19 - * 43.20 - * You should have received a copy of the GNU General Public License version 43.21 - * 2 along with this work; if not, write to the Free Software Foundation, 43.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 43.23 - * 43.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 43.25 - * or visit www.oracle.com if you need additional information or have any 43.26 - * questions. 43.27 - */ 43.28 - 43.29 -package jdk.nashorn.internal.test.models; 43.30 - 43.31 -class NonPublicClass { 43.32 - public NonPublicClass() { } 43.33 -}
44.1 --- a/test/src/jdk/nashorn/internal/test/models/OuterClass.java Sat Mar 09 21:49:32 2013 +0530 44.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 44.3 @@ -1,65 +0,0 @@ 44.4 -/* 44.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 44.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 44.7 - * 44.8 - * This code is free software; you can redistribute it and/or modify it 44.9 - * under the terms of the GNU General Public License version 2 only, as 44.10 - * published by the Free Software Foundation. Oracle designates this 44.11 - * particular file as subject to the "Classpath" exception as provided 44.12 - * by Oracle in the LICENSE file that accompanied this code. 44.13 - * 44.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 44.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 44.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 44.17 - * version 2 for more details (a copy is included in the LICENSE file that 44.18 - * accompanied this code). 44.19 - * 44.20 - * You should have received a copy of the GNU General Public License version 44.21 - * 2 along with this work; if not, write to the Free Software Foundation, 44.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 44.23 - * 44.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 44.25 - * or visit www.oracle.com if you need additional information or have any 44.26 - * questions. 44.27 - */ 44.28 - 44.29 -package jdk.nashorn.internal.test.models; 44.30 - 44.31 -public class OuterClass { 44.32 - private final String value; 44.33 - 44.34 - public OuterClass(String value) { 44.35 - this.value = value; 44.36 - } 44.37 - 44.38 - public static class InnerStaticClass { 44.39 - private final String value; 44.40 - 44.41 - public InnerStaticClass(String value) { 44.42 - this.value = value; 44.43 - } 44.44 - 44.45 - @Override 44.46 - public String toString() { 44.47 - return "InnerStaticClass[value=" + value + "]"; 44.48 - } 44.49 - } 44.50 - 44.51 - public class InnerNonStaticClass { 44.52 - private final String value; 44.53 - 44.54 - public InnerNonStaticClass(String value) { 44.55 - this.value = value; 44.56 - } 44.57 - 44.58 - @Override 44.59 - public String toString() { 44.60 - return "InnerNonStaticClass[value=" + value + ", outer=" + OuterClass.this + "]"; 44.61 - } 44.62 - } 44.63 - 44.64 - @Override 44.65 - public String toString() { 44.66 - return "OuterClass[value=" + value + "]"; 44.67 - } 44.68 -}
45.1 --- a/test/src/jdk/nashorn/internal/test/models/OverloadedSam.java Sat Mar 09 21:49:32 2013 +0530 45.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 45.3 @@ -1,31 +0,0 @@ 45.4 -/* 45.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 45.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 45.7 - * 45.8 - * This code is free software; you can redistribute it and/or modify it 45.9 - * under the terms of the GNU General Public License version 2 only, as 45.10 - * published by the Free Software Foundation. Oracle designates this 45.11 - * particular file as subject to the "Classpath" exception as provided 45.12 - * by Oracle in the LICENSE file that accompanied this code. 45.13 - * 45.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 45.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 45.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 45.17 - * version 2 for more details (a copy is included in the LICENSE file that 45.18 - * accompanied this code). 45.19 - * 45.20 - * You should have received a copy of the GNU General Public License version 45.21 - * 2 along with this work; if not, write to the Free Software Foundation, 45.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 45.23 - * 45.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 45.25 - * or visit www.oracle.com if you need additional information or have any 45.26 - * questions. 45.27 - */ 45.28 - 45.29 -package jdk.nashorn.internal.test.models; 45.30 - 45.31 -public interface OverloadedSam { 45.32 - public void sam(String s); 45.33 - public void sam(String s1, String s2); 45.34 -}
46.1 --- a/test/src/jdk/nashorn/internal/test/models/OverrideObject.java Sat Mar 09 21:49:32 2013 +0530 46.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 46.3 @@ -1,44 +0,0 @@ 46.4 -/* 46.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 46.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 46.7 - * 46.8 - * This code is free software; you can redistribute it and/or modify it 46.9 - * under the terms of the GNU General Public License version 2 only, as 46.10 - * published by the Free Software Foundation. Oracle designates this 46.11 - * particular file as subject to the "Classpath" exception as provided 46.12 - * by Oracle in the LICENSE file that accompanied this code. 46.13 - * 46.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 46.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 46.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 46.17 - * version 2 for more details (a copy is included in the LICENSE file that 46.18 - * accompanied this code). 46.19 - * 46.20 - * You should have received a copy of the GNU General Public License version 46.21 - * 2 along with this work; if not, write to the Free Software Foundation, 46.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 46.23 - * 46.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 46.25 - * or visit www.oracle.com if you need additional information or have any 46.26 - * questions. 46.27 - */ 46.28 - 46.29 -package jdk.nashorn.internal.test.models; 46.30 - 46.31 -public class OverrideObject { 46.32 - @Override 46.33 - public int hashCode() { 46.34 - return 5; 46.35 - } 46.36 - 46.37 - @Override 46.38 - public String toString() { 46.39 - return "override-object"; 46.40 - } 46.41 - 46.42 - @Override 46.43 - public boolean equals(Object o) { 46.44 - // TODO: add a FindBugs annotation to ignore EQ_ALWAYS_FALSE here. This is just a test. 46.45 - return false; 46.46 - } 46.47 -}
47.1 --- a/test/src/jdk/nashorn/internal/test/models/StringArgs.java Sat Mar 09 21:49:32 2013 +0530 47.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 47.3 @@ -1,39 +0,0 @@ 47.4 -/* 47.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 47.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 47.7 - * 47.8 - * This code is free software; you can redistribute it and/or modify it 47.9 - * under the terms of the GNU General Public License version 2 only, as 47.10 - * published by the Free Software Foundation. Oracle designates this 47.11 - * particular file as subject to the "Classpath" exception as provided 47.12 - * by Oracle in the LICENSE file that accompanied this code. 47.13 - * 47.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 47.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 47.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 47.17 - * version 2 for more details (a copy is included in the LICENSE file that 47.18 - * accompanied this code). 47.19 - * 47.20 - * You should have received a copy of the GNU General Public License version 47.21 - * 2 along with this work; if not, write to the Free Software Foundation, 47.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 47.23 - * 47.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 47.25 - * or visit www.oracle.com if you need additional information or have any 47.26 - * questions. 47.27 - */ 47.28 - 47.29 -package jdk.nashorn.internal.test.models; 47.30 - 47.31 -import java.util.List; 47.32 - 47.33 -public class StringArgs { 47.34 - 47.35 - public static void checkString(List<?> list) { 47.36 - for (Object s : list) { 47.37 - if (!(s instanceof String)) { 47.38 - throw new AssertionError("Not a String: " + s); 47.39 - } 47.40 - } 47.41 - } 47.42 -}
48.1 --- a/test/src/jdk/nashorn/internal/test/models/Toothpaste.java Sat Mar 09 21:49:32 2013 +0530 48.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 48.3 @@ -1,34 +0,0 @@ 48.4 -/* 48.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 48.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 48.7 - * 48.8 - * This code is free software; you can redistribute it and/or modify it 48.9 - * under the terms of the GNU General Public License version 2 only, as 48.10 - * published by the Free Software Foundation. Oracle designates this 48.11 - * particular file as subject to the "Classpath" exception as provided 48.12 - * by Oracle in the LICENSE file that accompanied this code. 48.13 - * 48.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 48.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 48.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 48.17 - * version 2 for more details (a copy is included in the LICENSE file that 48.18 - * accompanied this code). 48.19 - * 48.20 - * You should have received a copy of the GNU General Public License version 48.21 - * 2 along with this work; if not, write to the Free Software Foundation, 48.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 48.23 - * 48.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 48.25 - * or visit www.oracle.com if you need additional information or have any 48.26 - * questions. 48.27 - */ 48.28 - 48.29 -package jdk.nashorn.internal.test.models; 48.30 - 48.31 -public abstract class Toothpaste { 48.32 - public void applyToBrush() { 48.33 - applyToBrushImpl(); 48.34 - } 48.35 - 48.36 - protected abstract void applyToBrushImpl(); 48.37 -}
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 49.2 +++ b/test/src/jdk/nashorn/test/models/ConstructorWithArgument.java Tue Mar 12 18:12:42 2013 +0530 49.3 @@ -0,0 +1,40 @@ 49.4 +/* 49.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 49.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 49.7 + * 49.8 + * This code is free software; you can redistribute it and/or modify it 49.9 + * under the terms of the GNU General Public License version 2 only, as 49.10 + * published by the Free Software Foundation. Oracle designates this 49.11 + * particular file as subject to the "Classpath" exception as provided 49.12 + * by Oracle in the LICENSE file that accompanied this code. 49.13 + * 49.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 49.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 49.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 49.17 + * version 2 for more details (a copy is included in the LICENSE file that 49.18 + * accompanied this code). 49.19 + * 49.20 + * You should have received a copy of the GNU General Public License version 49.21 + * 2 along with this work; if not, write to the Free Software Foundation, 49.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 49.23 + * 49.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 49.25 + * or visit www.oracle.com if you need additional information or have any 49.26 + * questions. 49.27 + */ 49.28 + 49.29 +package jdk.nashorn.test.models; 49.30 + 49.31 +public abstract class ConstructorWithArgument { 49.32 + private final String token; 49.33 + 49.34 + protected ConstructorWithArgument(String token) { 49.35 + this.token = token; 49.36 + } 49.37 + 49.38 + public String getToken() { 49.39 + return token; 49.40 + } 49.41 + 49.42 + protected abstract void doSomething(); 49.43 +}
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/test/src/jdk/nashorn/test/models/DessertTopping.java Tue Mar 12 18:12:42 2013 +0530 50.3 @@ -0,0 +1,30 @@ 50.4 +/* 50.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 50.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 50.7 + * 50.8 + * This code is free software; you can redistribute it and/or modify it 50.9 + * under the terms of the GNU General Public License version 2 only, as 50.10 + * published by the Free Software Foundation. Oracle designates this 50.11 + * particular file as subject to the "Classpath" exception as provided 50.12 + * by Oracle in the LICENSE file that accompanied this code. 50.13 + * 50.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 50.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 50.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 50.17 + * version 2 for more details (a copy is included in the LICENSE file that 50.18 + * accompanied this code). 50.19 + * 50.20 + * You should have received a copy of the GNU General Public License version 50.21 + * 2 along with this work; if not, write to the Free Software Foundation, 50.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 50.23 + * 50.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 50.25 + * or visit www.oracle.com if you need additional information or have any 50.26 + * questions. 50.27 + */ 50.28 + 50.29 +package jdk.nashorn.test.models; 50.30 + 50.31 +public interface DessertTopping { 50.32 + public String pourOnDessert(); 50.33 +}
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 51.2 +++ b/test/src/jdk/nashorn/test/models/DessertToppingFloorWaxDriver.java Tue Mar 12 18:12:42 2013 +0530 51.3 @@ -0,0 +1,36 @@ 51.4 +/* 51.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 51.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 51.7 + * 51.8 + * This code is free software; you can redistribute it and/or modify it 51.9 + * under the terms of the GNU General Public License version 2 only, as 51.10 + * published by the Free Software Foundation. Oracle designates this 51.11 + * particular file as subject to the "Classpath" exception as provided 51.12 + * by Oracle in the LICENSE file that accompanied this code. 51.13 + * 51.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 51.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 51.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 51.17 + * version 2 for more details (a copy is included in the LICENSE file that 51.18 + * accompanied this code). 51.19 + * 51.20 + * You should have received a copy of the GNU General Public License version 51.21 + * 2 along with this work; if not, write to the Free Software Foundation, 51.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 51.23 + * 51.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 51.25 + * or visit www.oracle.com if you need additional information or have any 51.26 + * questions. 51.27 + */ 51.28 + 51.29 +package jdk.nashorn.test.models; 51.30 + 51.31 +public class DessertToppingFloorWaxDriver { 51.32 + public void decorateDessert(DessertTopping dt) { 51.33 + dt.pourOnDessert(); 51.34 + } 51.35 + 51.36 + public void waxFloor(FloorWax fw) { 51.37 + fw.shineUpTheFloor(); 51.38 + } 51.39 +}
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 52.2 +++ b/test/src/jdk/nashorn/test/models/FinalClass.java Tue Mar 12 18:12:42 2013 +0530 52.3 @@ -0,0 +1,30 @@ 52.4 +/* 52.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 52.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 52.7 + * 52.8 + * This code is free software; you can redistribute it and/or modify it 52.9 + * under the terms of the GNU General Public License version 2 only, as 52.10 + * published by the Free Software Foundation. Oracle designates this 52.11 + * particular file as subject to the "Classpath" exception as provided 52.12 + * by Oracle in the LICENSE file that accompanied this code. 52.13 + * 52.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 52.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 52.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 52.17 + * version 2 for more details (a copy is included in the LICENSE file that 52.18 + * accompanied this code). 52.19 + * 52.20 + * You should have received a copy of the GNU General Public License version 52.21 + * 2 along with this work; if not, write to the Free Software Foundation, 52.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 52.23 + * 52.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 52.25 + * or visit www.oracle.com if you need additional information or have any 52.26 + * questions. 52.27 + */ 52.28 + 52.29 +package jdk.nashorn.test.models; 52.30 + 52.31 +public final class FinalClass { 52.32 + //empty 52.33 +}
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 53.2 +++ b/test/src/jdk/nashorn/test/models/FloorWax.java Tue Mar 12 18:12:42 2013 +0530 53.3 @@ -0,0 +1,30 @@ 53.4 +/* 53.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 53.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 53.7 + * 53.8 + * This code is free software; you can redistribute it and/or modify it 53.9 + * under the terms of the GNU General Public License version 2 only, as 53.10 + * published by the Free Software Foundation. Oracle designates this 53.11 + * particular file as subject to the "Classpath" exception as provided 53.12 + * by Oracle in the LICENSE file that accompanied this code. 53.13 + * 53.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 53.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 53.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 53.17 + * version 2 for more details (a copy is included in the LICENSE file that 53.18 + * accompanied this code). 53.19 + * 53.20 + * You should have received a copy of the GNU General Public License version 53.21 + * 2 along with this work; if not, write to the Free Software Foundation, 53.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 53.23 + * 53.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 53.25 + * or visit www.oracle.com if you need additional information or have any 53.26 + * questions. 53.27 + */ 53.28 + 53.29 +package jdk.nashorn.test.models; 53.30 + 53.31 +public interface FloorWax { 53.32 + public String shineUpTheFloor(); 53.33 +}
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 54.2 +++ b/test/src/jdk/nashorn/test/models/Nashorn401TestSubject.java Tue Mar 12 18:12:42 2013 +0530 54.3 @@ -0,0 +1,57 @@ 54.4 +/* 54.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 54.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 54.7 + * 54.8 + * This code is free software; you can redistribute it and/or modify it 54.9 + * under the terms of the GNU General Public License version 2 only, as 54.10 + * published by the Free Software Foundation. Oracle designates this 54.11 + * particular file as subject to the "Classpath" exception as provided 54.12 + * by Oracle in the LICENSE file that accompanied this code. 54.13 + * 54.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 54.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 54.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 54.17 + * version 2 for more details (a copy is included in the LICENSE file that 54.18 + * accompanied this code). 54.19 + * 54.20 + * You should have received a copy of the GNU General Public License version 54.21 + * 2 along with this work; if not, write to the Free Software Foundation, 54.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 54.23 + * 54.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 54.25 + * or visit www.oracle.com if you need additional information or have any 54.26 + * questions. 54.27 + */ 54.28 + 54.29 +package jdk.nashorn.test.models; 54.30 + 54.31 +public class Nashorn401TestSubject { 54.32 + public String method2(int arg) { 54.33 + return "int method 2"; 54.34 + } 54.35 + 54.36 + public String method2(double arg) { 54.37 + return "double method 2"; 54.38 + } 54.39 + 54.40 + public String method2(String arg) { 54.41 + return "string method 2"; 54.42 + } 54.43 + 54.44 + public String method3(double arg) { 54.45 + return "double method 3: " + arg; 54.46 + } 54.47 + 54.48 + public String method3(int arg) { 54.49 + return "int method 3: " + arg; 54.50 + } 54.51 + 54.52 + public String method4(Double arg) { 54.53 + return "double method 4: " + arg; 54.54 + } 54.55 + 54.56 + public String method4(int arg) { 54.57 + return "int method 4: " + arg; 54.58 + } 54.59 + 54.60 +}
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 55.2 +++ b/test/src/jdk/nashorn/test/models/NoAccessibleConstructorClass.java Tue Mar 12 18:12:42 2013 +0530 55.3 @@ -0,0 +1,30 @@ 55.4 +/* 55.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 55.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 55.7 + * 55.8 + * This code is free software; you can redistribute it and/or modify it 55.9 + * under the terms of the GNU General Public License version 2 only, as 55.10 + * published by the Free Software Foundation. Oracle designates this 55.11 + * particular file as subject to the "Classpath" exception as provided 55.12 + * by Oracle in the LICENSE file that accompanied this code. 55.13 + * 55.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 55.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 55.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 55.17 + * version 2 for more details (a copy is included in the LICENSE file that 55.18 + * accompanied this code). 55.19 + * 55.20 + * You should have received a copy of the GNU General Public License version 55.21 + * 2 along with this work; if not, write to the Free Software Foundation, 55.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 55.23 + * 55.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 55.25 + * or visit www.oracle.com if you need additional information or have any 55.26 + * questions. 55.27 + */ 55.28 + 55.29 +package jdk.nashorn.test.models; 55.30 + 55.31 +public class NoAccessibleConstructorClass { 55.32 + NoAccessibleConstructorClass() { } 55.33 +}
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 56.2 +++ b/test/src/jdk/nashorn/test/models/NonPublicClass.java Tue Mar 12 18:12:42 2013 +0530 56.3 @@ -0,0 +1,30 @@ 56.4 +/* 56.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 56.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 56.7 + * 56.8 + * This code is free software; you can redistribute it and/or modify it 56.9 + * under the terms of the GNU General Public License version 2 only, as 56.10 + * published by the Free Software Foundation. Oracle designates this 56.11 + * particular file as subject to the "Classpath" exception as provided 56.12 + * by Oracle in the LICENSE file that accompanied this code. 56.13 + * 56.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 56.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 56.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 56.17 + * version 2 for more details (a copy is included in the LICENSE file that 56.18 + * accompanied this code). 56.19 + * 56.20 + * You should have received a copy of the GNU General Public License version 56.21 + * 2 along with this work; if not, write to the Free Software Foundation, 56.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 56.23 + * 56.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 56.25 + * or visit www.oracle.com if you need additional information or have any 56.26 + * questions. 56.27 + */ 56.28 + 56.29 +package jdk.nashorn.test.models; 56.30 + 56.31 +class NonPublicClass { 56.32 + public NonPublicClass() { } 56.33 +}
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 57.2 +++ b/test/src/jdk/nashorn/test/models/OuterClass.java Tue Mar 12 18:12:42 2013 +0530 57.3 @@ -0,0 +1,65 @@ 57.4 +/* 57.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 57.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 57.7 + * 57.8 + * This code is free software; you can redistribute it and/or modify it 57.9 + * under the terms of the GNU General Public License version 2 only, as 57.10 + * published by the Free Software Foundation. Oracle designates this 57.11 + * particular file as subject to the "Classpath" exception as provided 57.12 + * by Oracle in the LICENSE file that accompanied this code. 57.13 + * 57.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 57.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 57.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 57.17 + * version 2 for more details (a copy is included in the LICENSE file that 57.18 + * accompanied this code). 57.19 + * 57.20 + * You should have received a copy of the GNU General Public License version 57.21 + * 2 along with this work; if not, write to the Free Software Foundation, 57.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 57.23 + * 57.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 57.25 + * or visit www.oracle.com if you need additional information or have any 57.26 + * questions. 57.27 + */ 57.28 + 57.29 +package jdk.nashorn.test.models; 57.30 + 57.31 +public class OuterClass { 57.32 + private final String value; 57.33 + 57.34 + public OuterClass(String value) { 57.35 + this.value = value; 57.36 + } 57.37 + 57.38 + public static class InnerStaticClass { 57.39 + private final String value; 57.40 + 57.41 + public InnerStaticClass(String value) { 57.42 + this.value = value; 57.43 + } 57.44 + 57.45 + @Override 57.46 + public String toString() { 57.47 + return "InnerStaticClass[value=" + value + "]"; 57.48 + } 57.49 + } 57.50 + 57.51 + public class InnerNonStaticClass { 57.52 + private final String value; 57.53 + 57.54 + public InnerNonStaticClass(String value) { 57.55 + this.value = value; 57.56 + } 57.57 + 57.58 + @Override 57.59 + public String toString() { 57.60 + return "InnerNonStaticClass[value=" + value + ", outer=" + OuterClass.this + "]"; 57.61 + } 57.62 + } 57.63 + 57.64 + @Override 57.65 + public String toString() { 57.66 + return "OuterClass[value=" + value + "]"; 57.67 + } 57.68 +}
58.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 58.2 +++ b/test/src/jdk/nashorn/test/models/OverloadedSam.java Tue Mar 12 18:12:42 2013 +0530 58.3 @@ -0,0 +1,31 @@ 58.4 +/* 58.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 58.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 58.7 + * 58.8 + * This code is free software; you can redistribute it and/or modify it 58.9 + * under the terms of the GNU General Public License version 2 only, as 58.10 + * published by the Free Software Foundation. Oracle designates this 58.11 + * particular file as subject to the "Classpath" exception as provided 58.12 + * by Oracle in the LICENSE file that accompanied this code. 58.13 + * 58.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 58.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 58.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 58.17 + * version 2 for more details (a copy is included in the LICENSE file that 58.18 + * accompanied this code). 58.19 + * 58.20 + * You should have received a copy of the GNU General Public License version 58.21 + * 2 along with this work; if not, write to the Free Software Foundation, 58.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 58.23 + * 58.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 58.25 + * or visit www.oracle.com if you need additional information or have any 58.26 + * questions. 58.27 + */ 58.28 + 58.29 +package jdk.nashorn.test.models; 58.30 + 58.31 +public interface OverloadedSam { 58.32 + public void sam(String s); 58.33 + public void sam(String s1, String s2); 58.34 +}
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 59.2 +++ b/test/src/jdk/nashorn/test/models/OverrideObject.java Tue Mar 12 18:12:42 2013 +0530 59.3 @@ -0,0 +1,44 @@ 59.4 +/* 59.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 59.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 59.7 + * 59.8 + * This code is free software; you can redistribute it and/or modify it 59.9 + * under the terms of the GNU General Public License version 2 only, as 59.10 + * published by the Free Software Foundation. Oracle designates this 59.11 + * particular file as subject to the "Classpath" exception as provided 59.12 + * by Oracle in the LICENSE file that accompanied this code. 59.13 + * 59.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 59.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 59.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 59.17 + * version 2 for more details (a copy is included in the LICENSE file that 59.18 + * accompanied this code). 59.19 + * 59.20 + * You should have received a copy of the GNU General Public License version 59.21 + * 2 along with this work; if not, write to the Free Software Foundation, 59.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 59.23 + * 59.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 59.25 + * or visit www.oracle.com if you need additional information or have any 59.26 + * questions. 59.27 + */ 59.28 + 59.29 +package jdk.nashorn.test.models; 59.30 + 59.31 +public class OverrideObject { 59.32 + @Override 59.33 + public int hashCode() { 59.34 + return 5; 59.35 + } 59.36 + 59.37 + @Override 59.38 + public String toString() { 59.39 + return "override-object"; 59.40 + } 59.41 + 59.42 + @Override 59.43 + public boolean equals(Object o) { 59.44 + // TODO: add a FindBugs annotation to ignore EQ_ALWAYS_FALSE here. This is just a test. 59.45 + return false; 59.46 + } 59.47 +}
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 60.2 +++ b/test/src/jdk/nashorn/test/models/SourceHelper.java Tue Mar 12 18:12:42 2013 +0530 60.3 @@ -0,0 +1,55 @@ 60.4 +/* 60.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 60.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 60.7 + * 60.8 + * This code is free software; you can redistribute it and/or modify it 60.9 + * under the terms of the GNU General Public License version 2 only, as 60.10 + * published by the Free Software Foundation. Oracle designates this 60.11 + * particular file as subject to the "Classpath" exception as provided 60.12 + * by Oracle in the LICENSE file that accompanied this code. 60.13 + * 60.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 60.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 60.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 60.17 + * version 2 for more details (a copy is included in the LICENSE file that 60.18 + * accompanied this code). 60.19 + * 60.20 + * You should have received a copy of the GNU General Public License version 60.21 + * 2 along with this work; if not, write to the Free Software Foundation, 60.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 60.23 + * 60.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 60.25 + * or visit www.oracle.com if you need additional information or have any 60.26 + * questions. 60.27 + */ 60.28 + 60.29 +package jdk.nashorn.test.models; 60.30 + 60.31 +import java.io.File; 60.32 +import java.io.IOException; 60.33 +import java.io.Reader; 60.34 +import java.net.URL; 60.35 +import jdk.nashorn.internal.runtime.Source; 60.36 + 60.37 +/** 60.38 + * Helper class to facilitate script access of nashorn Source class. 60.39 + */ 60.40 +public final class SourceHelper { 60.41 + private SourceHelper() {} 60.42 + 60.43 + public static String baseURL(final URL url) { 60.44 + return Source.baseURL(url); 60.45 + } 60.46 + 60.47 + public static String readFully(final File file) throws IOException { 60.48 + return new String(Source.readFully(file)); 60.49 + } 60.50 + 60.51 + public static String readFully(final URL url) throws IOException { 60.52 + return new Source(url.toString(), url).getString(); 60.53 + } 60.54 + 60.55 + public static String readFully(final Reader reader) throws IOException { 60.56 + return new String(Source.readFully(reader)); 60.57 + } 60.58 +}
61.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 61.2 +++ b/test/src/jdk/nashorn/test/models/StringArgs.java Tue Mar 12 18:12:42 2013 +0530 61.3 @@ -0,0 +1,39 @@ 61.4 +/* 61.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 61.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 61.7 + * 61.8 + * This code is free software; you can redistribute it and/or modify it 61.9 + * under the terms of the GNU General Public License version 2 only, as 61.10 + * published by the Free Software Foundation. Oracle designates this 61.11 + * particular file as subject to the "Classpath" exception as provided 61.12 + * by Oracle in the LICENSE file that accompanied this code. 61.13 + * 61.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 61.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 61.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 61.17 + * version 2 for more details (a copy is included in the LICENSE file that 61.18 + * accompanied this code). 61.19 + * 61.20 + * You should have received a copy of the GNU General Public License version 61.21 + * 2 along with this work; if not, write to the Free Software Foundation, 61.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 61.23 + * 61.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 61.25 + * or visit www.oracle.com if you need additional information or have any 61.26 + * questions. 61.27 + */ 61.28 + 61.29 +package jdk.nashorn.test.models; 61.30 + 61.31 +import java.util.List; 61.32 + 61.33 +public class StringArgs { 61.34 + 61.35 + public static void checkString(List<?> list) { 61.36 + for (Object s : list) { 61.37 + if (!(s instanceof String)) { 61.38 + throw new AssertionError("Not a String: " + s); 61.39 + } 61.40 + } 61.41 + } 61.42 +}
62.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 62.2 +++ b/test/src/jdk/nashorn/test/models/Toothpaste.java Tue Mar 12 18:12:42 2013 +0530 62.3 @@ -0,0 +1,34 @@ 62.4 +/* 62.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 62.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 62.7 + * 62.8 + * This code is free software; you can redistribute it and/or modify it 62.9 + * under the terms of the GNU General Public License version 2 only, as 62.10 + * published by the Free Software Foundation. Oracle designates this 62.11 + * particular file as subject to the "Classpath" exception as provided 62.12 + * by Oracle in the LICENSE file that accompanied this code. 62.13 + * 62.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 62.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 62.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 62.17 + * version 2 for more details (a copy is included in the LICENSE file that 62.18 + * accompanied this code). 62.19 + * 62.20 + * You should have received a copy of the GNU General Public License version 62.21 + * 2 along with this work; if not, write to the Free Software Foundation, 62.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 62.23 + * 62.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 62.25 + * or visit www.oracle.com if you need additional information or have any 62.26 + * questions. 62.27 + */ 62.28 + 62.29 +package jdk.nashorn.test.models; 62.30 + 62.31 +public abstract class Toothpaste { 62.32 + public void applyToBrush() { 62.33 + applyToBrushImpl(); 62.34 + } 62.35 + 62.36 + protected abstract void applyToBrushImpl(); 62.37 +}