changeset 453:4b06441b7624

8020820: Limit access to static members of reflective classes Reviewed-by: jlaskey, sundar
author attila
date Thu, 18 Jul 2013 16:47:45 +0200
parents 624f8be5c3fe
children 0cfa27ed82fe
files make/build.xml src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java test/script/basic/JDK-8010946-2.js test/script/basic/JDK-8010946-2.js.EXPECTED test/script/basic/NASHORN-473.js test/script/basic/classloader.js test/script/basic/classloader.js.EXPECTED test/script/basic/javaarray.js test/script/sandbox/classloader.js.EXPECTED test/script/sandbox/reflection.js test/src/jdk/nashorn/api/javaaccess/BooleanAccessTest.java test/src/jdk/nashorn/api/javaaccess/NumberAccessTest.java test/src/jdk/nashorn/api/javaaccess/ObjectAccessTest.java test/src/jdk/nashorn/api/javaaccess/StringAccessTest.java
diffstat 14 files changed, 98 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/make/build.xml	Thu Jul 18 16:22:25 2013 +0200
+++ b/make/build.xml	Thu Jul 18 16:47:45 2013 +0200
@@ -267,6 +267,11 @@
 grant codeBase "file:/${basedir}/test/script/basic/JDK-8010946-privileged.js" {
     permission java.util.PropertyPermission "java.security.policy", "read";
 };
+
+grant codeBase "file:/${basedir}/test/script/basic/classloader.js" {
+    permission java.lang.RuntimePermission "nashorn.JavaReflection";
+};
+
     </echo>
 
     <replace file="${build.dir}/nashorn.policy"><replacetoken>\</replacetoken><replacevalue>/</replacevalue></replace>    <!--hack for Windows - to make URLs with normal path separators -->
--- a/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java	Thu Jul 18 16:22:25 2013 +0200
+++ b/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java	Thu Jul 18 16:47:45 2013 +0200
@@ -63,10 +63,11 @@
         if (self.getClass() != StaticClass.class) {
             return null;
         }
+        final Class<?> receiverClass = ((StaticClass) self).getRepresentedClass();
+        Bootstrap.checkReflectionAccess(receiverClass);
         final CallSiteDescriptor desc = request.getCallSiteDescriptor();
         // We intercept "new" on StaticClass instances to provide additional capabilities
         if ("new".equals(desc.getNameToken(CallSiteDescriptor.OPERATOR))) {
-            final Class<?> receiverClass = ((StaticClass) self).getRepresentedClass();
             // Is the class abstract? (This includes interfaces.)
             if (NashornLinker.isAbstractClass(receiverClass)) {
                 // Change this link request into a link request on the adapter class.
--- a/test/script/basic/JDK-8010946-2.js	Thu Jul 18 16:22:25 2013 +0200
+++ b/test/script/basic/JDK-8010946-2.js	Thu Jul 18 16:47:45 2013 +0200
@@ -30,9 +30,8 @@
  * @run
  */
 
-// Ensure these are CallerSensitiveDynamicMethods
+// Ensure this is CallerSensitiveDynamicMethod
 print(java.security.AccessController["doPrivileged(PrivilegedAction)"])
-print(java.lang.Class["forName(String)"])
 
 // Ensure this is not
 print(java.lang.String["valueOf(char)"])
--- a/test/script/basic/JDK-8010946-2.js.EXPECTED	Thu Jul 18 16:22:25 2013 +0200
+++ b/test/script/basic/JDK-8010946-2.js.EXPECTED	Thu Jul 18 16:47:45 2013 +0200
@@ -1,3 +1,2 @@
 [jdk.internal.dynalink.beans.CallerSensitiveDynamicMethod Object java.security.AccessController.doPrivileged(PrivilegedAction)]
-[jdk.internal.dynalink.beans.CallerSensitiveDynamicMethod Class java.lang.Class.forName(String)]
 [jdk.internal.dynalink.beans.SimpleDynamicMethod String java.lang.String.valueOf(char)]
--- a/test/script/basic/NASHORN-473.js	Thu Jul 18 16:22:25 2013 +0200
+++ b/test/script/basic/NASHORN-473.js	Thu Jul 18 16:47:45 2013 +0200
@@ -28,7 +28,7 @@
  * @run
  */
 
-var boolArr = java.lang.reflect.Array.newInstance(java.lang.Boolean.TYPE, 2);
+var boolArr = new (Java.type("boolean[]"))(2);
 boolArr[0] = true;
 boolArr[1] = false;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/classloader.js	Thu Jul 18 16:47:45 2013 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Try to extend ClassLoader.
+ *
+ * @test
+ * @security
+ */
+
+try {
+    var l = new (Java.extend(java.lang.ClassLoader))({});
+    fail("should have thrown SecurityException");
+} catch (e) {
+    if (e instanceof java.lang.SecurityException) {
+        print(e);
+    } else {
+        fail("expected SecurityException, got " + e);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/classloader.js.EXPECTED	Thu Jul 18 16:47:45 2013 +0200
@@ -0,0 +1,1 @@
+java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "createClassLoader")
--- a/test/script/basic/javaarray.js	Thu Jul 18 16:22:25 2013 +0200
+++ b/test/script/basic/javaarray.js	Thu Jul 18 16:47:45 2013 +0200
@@ -30,7 +30,7 @@
 
 (function() {
     var nargs = arguments.length;
-    var args = java.lang.reflect.Array.newInstance(java.lang.Object.class, nargs);
+    var args = new (Java.type("java.lang.Object[]"))(nargs);
     print(args.length);
     for (var i = 0; i < nargs; i++) {
         var arg = arguments[i];
@@ -41,7 +41,7 @@
 
 var z; // undefined
 
-var intArray = java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE, 1);
+var intArray = new (Java.type("int[]"))(1);
 intArray[0] = 10;
 print(intArray[0]);
 print(intArray.length);
@@ -50,19 +50,19 @@
 intArray[0] = 10.1;
 print(intArray[0]);
 
-var boolArray = java.lang.reflect.Array.newInstance(java.lang.Boolean.TYPE, 2);
+var boolArray = new (Java.type("boolean[]"))(2);
 boolArray[0] = true;
 print(boolArray[0]);
 print(boolArray[1]);
 print(boolArray.length);
 
-var charArray = java.lang.reflect.Array.newInstance(java.lang.Character.TYPE, 1);
+var charArray = new (Java.type("char[]"))(1);
 charArray[0] = 'j';
 print(charArray[0]);
 print(charArray.length);
 
 
-var doubleArray = java.lang.reflect.Array.newInstance(java.lang.Double.TYPE, 1)
+var doubleArray = new (Java.type("double[]"))(1)
 doubleArray[0]=z
 print(doubleArray[0])
 doubleArray[0]=1
--- a/test/script/sandbox/classloader.js.EXPECTED	Thu Jul 18 16:22:25 2013 +0200
+++ b/test/script/sandbox/classloader.js.EXPECTED	Thu Jul 18 16:47:45 2013 +0200
@@ -1,1 +1,1 @@
-java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "createClassLoader")
+java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection")
--- a/test/script/sandbox/reflection.js	Thu Jul 18 16:22:25 2013 +0200
+++ b/test/script/sandbox/reflection.js	Thu Jul 18 16:47:45 2013 +0200
@@ -35,9 +35,8 @@
     }
 }
 
-var cl = java.lang.Class.class;
 try {
-    cl.getDeclaredMethods();
+    var cl = java.lang.Class.class;
 } catch(e) {
     check(e); 
 }
--- a/test/src/jdk/nashorn/api/javaaccess/BooleanAccessTest.java	Thu Jul 18 16:22:25 2013 +0200
+++ b/test/src/jdk/nashorn/api/javaaccess/BooleanAccessTest.java	Thu Jul 18 16:47:45 2013 +0200
@@ -72,7 +72,7 @@
         e.eval("var p_boolean_array = o.publicBooleanArray;");
         assertEquals(o.publicBooleanArray[0], e.eval("o.publicBooleanArray[0]"));
         assertTrue(Arrays.equals(o.publicBooleanArray, (boolean[])e.get("p_boolean_array")));
-        e.eval("var t_boolean_arr = java.lang.reflect.Array.newInstance(java.lang.Boolean.TYPE, 3);" +
+        e.eval("var t_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
                 "t_boolean_arr[0] = true;" +
                 "t_boolean_arr[1] = false;" +
                 "t_boolean_arr[2] = false;" +
@@ -96,7 +96,7 @@
         e.eval("var ps_boolean_array = SharedObject.publicStaticBooleanArray;");
         assertEquals(SharedObject.publicStaticBooleanArray[0], e.eval("SharedObject.publicStaticBooleanArray[0]"));
         assertTrue(Arrays.equals(SharedObject.publicStaticBooleanArray, (boolean[])e.get("ps_boolean_array")));
-        e.eval("var ts_boolean_arr = java.lang.reflect.Array.newInstance(java.lang.Boolean.TYPE, 3);" +
+        e.eval("var ts_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
                 "ts_boolean_arr[0] = true;" +
                 "ts_boolean_arr[1] = false;" +
                 "ts_boolean_arr[2] = true;" +
@@ -120,7 +120,7 @@
         e.eval("var pf_boolean_array = o.publicFinalBooleanArray;");
         assertEquals(o.publicFinalBooleanArray[0], e.eval("o.publicFinalBooleanArray[0]"));
         assertTrue(Arrays.equals(o.publicFinalBooleanArray, (boolean[])e.get("pf_boolean_array")));
-        e.eval("var tf_boolean_arr = java.lang.reflect.Array.newInstance(java.lang.Boolean.TYPE, 3);" +
+        e.eval("var tf_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
                 "tf_boolean_arr[0] = false;" +
                 "tf_boolean_arr[1] = false;" +
                 "tf_boolean_arr[2] = true;" +
@@ -144,7 +144,7 @@
         e.eval("var psf_boolean_array = SharedObject.publicStaticFinalBooleanArray;");
         assertEquals(SharedObject.publicStaticFinalBooleanArray[0], e.eval("SharedObject.publicStaticFinalBooleanArray[0]"));
         assertTrue(Arrays.equals(SharedObject.publicStaticFinalBooleanArray, (boolean[])e.get("psf_boolean_array")));
-        e.eval("var tsf_boolean_arr = java.lang.reflect.Array.newInstance(java.lang.Boolean.TYPE, 3);" +
+        e.eval("var tsf_boolean_arr = new (Java.type(\"boolean[]\"))(3);" +
                 "tsf_boolean_arr[0] = false;" +
                 "tsf_boolean_arr[1] = true;" +
                 "tsf_boolean_arr[2] = false;" +
--- a/test/src/jdk/nashorn/api/javaaccess/NumberAccessTest.java	Thu Jul 18 16:22:25 2013 +0200
+++ b/test/src/jdk/nashorn/api/javaaccess/NumberAccessTest.java	Thu Jul 18 16:47:45 2013 +0200
@@ -73,7 +73,7 @@
         e.eval("var p_long_array = o.publicLongArray;");
         assertEquals(o.publicLongArray[0], e.eval("o.publicLongArray[0];"));
         assertArrayEquals(o.publicLongArray, (long[])e.get("p_long_array"));
-        e.eval("var t_long_arr = java.lang.reflect.Array.newInstance(java.lang.Long.TYPE, 3);" +
+        e.eval("var t_long_arr = new (Java.type(\"long[]\"))(3);" +
                 "t_long_arr[0] = -189009;" +
                 "t_long_arr[1] = 456;" +
                 "t_long_arr[2] = 600000001;" +
@@ -97,7 +97,7 @@
         e.eval("var ps_long_array = SharedObject.publicStaticLongArray;");
         assertEquals(SharedObject.publicStaticLongArray[0], e.eval("SharedObject.publicStaticLongArray[0];"));
         assertArrayEquals(SharedObject.publicStaticLongArray, (long[])e.get("ps_long_array"));
-        e.eval("var ts_long_arr = java.lang.reflect.Array.newInstance(java.lang.Long.TYPE, 3);" +
+        e.eval("var ts_long_arr = new (Java.type(\"long[]\"))(3);" +
                 "ts_long_arr[0] = -189009;" +
                 "ts_long_arr[1] = 456;" +
                 "ts_long_arr[2] = 600000001;" +
@@ -121,7 +121,7 @@
         e.eval("var pf_long_array = o.publicFinalLongArray;");
         assertEquals(o.publicFinalLongArray[0], e.eval("o.publicFinalLongArray[0];"));
         assertArrayEquals(o.publicFinalLongArray, (long[])e.get("pf_long_array"));
-        e.eval("var tf_long_arr = java.lang.reflect.Array.newInstance(java.lang.Long.TYPE, 3);" +
+        e.eval("var tf_long_arr = new (Java.type(\"long[]\"))(3);" +
                 "tf_long_arr[0] = -189009;" +
                 "tf_long_arr[1] = 456;" +
                 "tf_long_arr[2] = 600000001;" +
@@ -145,7 +145,7 @@
         e.eval("var psf_long_array = SharedObject.publicStaticFinalLongArray;");
         assertEquals(SharedObject.publicStaticFinalLongArray[0], e.eval("SharedObject.publicStaticFinalLongArray[0];"));
         assertArrayEquals(SharedObject.publicStaticFinalLongArray, (long[])e.get("psf_long_array"));
-        e.eval("var tsf_long_arr = java.lang.reflect.Array.newInstance(java.lang.Long.TYPE, 3);" +
+        e.eval("var tsf_long_arr = new (Java.type(\"long[]\"))(3);" +
                 "tsf_long_arr[0] = -189009;" +
                 "tsf_long_arr[1] = 456;" +
                 "tsf_long_arr[2] = 600000001;" +
@@ -171,7 +171,7 @@
         e.eval("var p_int_array = o.publicIntArray;");
         assertEquals(o.publicIntArray[0], e.eval("o.publicIntArray[0];"));
         assertArrayEquals(o.publicIntArray, (int[])e.get("p_int_array"));
-        e.eval("var t_int_arr = java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE, 3);" +
+        e.eval("var t_int_arr = new (Java.type(\"int[]\"))(3);" +
                 "t_int_arr[0] = 4;" +
                 "t_int_arr[1] = 5;" +
                 "t_int_arr[2] = 6;" +
@@ -194,7 +194,7 @@
         e.eval("var ps_int_array = SharedObject.publicStaticIntArray;");
         assertEquals(SharedObject.publicStaticIntArray[0], e.eval("SharedObject.publicStaticIntArray[0];"));
         assertArrayEquals(SharedObject.publicStaticIntArray, (int[])e.get("ps_int_array"));
-        e.eval("var ts_int_arr = java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE, 3);" +
+        e.eval("var ts_int_arr = new (Java.type(\"int[]\"))(3);" +
                 "ts_int_arr[0] = 4;" +
                 "ts_int_arr[1] = 5;" +
                 "ts_int_arr[2] = 6;" +
@@ -218,7 +218,7 @@
         e.eval("var pf_int_array = o.publicFinalIntArray;");
         assertEquals(o.publicFinalIntArray[0], e.eval("o.publicFinalIntArray[0];"));
         assertArrayEquals(o.publicFinalIntArray, (int[])e.get("pf_int_array"));
-        e.eval("var tf_int_arr = java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE, 3);" +
+        e.eval("var tf_int_arr = new (Java.type(\"int[]\"))(3);" +
                 "tf_int_arr[0] = 4;" +
                 "tf_int_arr[1] = 5;" +
                 "tf_int_arr[2] = 6;" +
@@ -241,7 +241,7 @@
         e.eval("var psf_int_array = SharedObject.publicStaticFinalIntArray;");
         assertEquals(SharedObject.publicStaticFinalIntArray[0], e.eval("SharedObject.publicStaticFinalIntArray[0];"));
         assertArrayEquals(SharedObject.publicStaticFinalIntArray, (int[])e.get("psf_int_array"));
-        e.eval("var tsf_int_arr = java.lang.reflect.Array.newInstance(java.lang.Integer.TYPE, 3);" +
+        e.eval("var tsf_int_arr = new (Java.type(\"int[]\"))(3);" +
                 "tsf_int_arr[0] = 4;" +
                 "tsf_int_arr[1] = 5;" +
                 "tsf_int_arr[2] = 6;" +
@@ -266,7 +266,7 @@
         e.eval("var p_byte_array = o.publicByteArray;");
         assertEquals(o.publicByteArray[0], e.eval("o.publicByteArray[0];"));
         assertArrayEquals(o.publicByteArray, (byte[])e.get("p_byte_array"));
-        e.eval("var t_byte_arr = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 3);" +
+        e.eval("var t_byte_arr = new (Java.type(\"byte[]\"))(3);" +
                 "t_byte_arr[0] = -18;" +
                 "t_byte_arr[1] = 56;" +
                 "t_byte_arr[2] = 60;" +
@@ -289,7 +289,7 @@
         e.eval("var ps_byte_array = SharedObject.publicStaticByteArray;");
         assertEquals(SharedObject.publicStaticByteArray[0], e.eval("SharedObject.publicStaticByteArray[0];"));
         assertArrayEquals(SharedObject.publicStaticByteArray, (byte[])e.get("ps_byte_array"));
-        e.eval("var ts_byte_arr = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 3);" +
+        e.eval("var ts_byte_arr = new (Java.type(\"byte[]\"))(3);" +
                 "ts_byte_arr[0] = -18;" +
                 "ts_byte_arr[1] = 56;" +
                 "ts_byte_arr[2] = 60;" +
@@ -312,7 +312,7 @@
         e.eval("var pf_byte_array = o.publicFinalByteArray;");
         assertEquals(o.publicFinalByteArray[0], e.eval("o.publicFinalByteArray[0];"));
         assertArrayEquals(o.publicFinalByteArray, (byte[])e.get("pf_byte_array"));
-        e.eval("var tf_byte_arr = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 3);" +
+        e.eval("var tf_byte_arr = new (Java.type(\"byte[]\"))(3);" +
                 "tf_byte_arr[0] = -18;" +
                 "tf_byte_arr[1] = 56;" +
                 "tf_byte_arr[2] = 60;" +
@@ -335,7 +335,7 @@
         e.eval("var psf_byte_array = SharedObject.publicStaticFinalByteArray;");
         assertEquals(SharedObject.publicStaticFinalByteArray[0], e.eval("SharedObject.publicStaticFinalByteArray[0];"));
         assertArrayEquals(SharedObject.publicStaticFinalByteArray, (byte[])e.get("psf_byte_array"));
-        e.eval("var tsf_byte_arr = java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 3);" +
+        e.eval("var tsf_byte_arr = new (Java.type(\"byte[]\"))(3);" +
                 "tsf_byte_arr[0] = -18;" +
                 "tsf_byte_arr[1] = 56;" +
                 "tsf_byte_arr[2] = 60;" +
@@ -360,7 +360,7 @@
         e.eval("var p_short_array = o.publicShortArray;");
         assertEquals(o.publicShortArray[0], e.eval("o.publicShortArray[0];"));
         assertArrayEquals(o.publicShortArray, (short[])e.get("p_short_array"));
-        e.eval("var t_short_arr = java.lang.reflect.Array.newInstance(java.lang.Short.TYPE, 3);" +
+        e.eval("var t_short_arr = new (Java.type(\"short[]\"))(3);" +
                 "t_short_arr[0] = 90;" +
                 "t_short_arr[1] = 5;" +
                 "t_short_arr[2] = -6000;" +
@@ -383,7 +383,7 @@
         e.eval("var ps_short_array = SharedObject.publicStaticShortArray;");
         assertEquals(SharedObject.publicStaticShortArray[0], e.eval("SharedObject.publicStaticShortArray[0];"));
         assertArrayEquals(SharedObject.publicStaticShortArray, (short[])e.get("ps_short_array"));
-        e.eval("var ts_short_arr = java.lang.reflect.Array.newInstance(java.lang.Short.TYPE, 3);" +
+        e.eval("var ts_short_arr = new (Java.type(\"short[]\"))(3);" +
                 "ts_short_arr[0] = 90;" +
                 "ts_short_arr[1] = 5;" +
                 "ts_short_arr[2] = -6000;" +
@@ -406,7 +406,7 @@
         e.eval("var pf_short_array = o.publicFinalShortArray;");
         assertEquals(o.publicFinalShortArray[0], e.eval("o.publicFinalShortArray[0];"));
         assertArrayEquals(o.publicFinalShortArray, (short[])e.get("pf_short_array"));
-        e.eval("var tf_short_arr = java.lang.reflect.Array.newInstance(java.lang.Short.TYPE, 3);" +
+        e.eval("var tf_short_arr = new (Java.type(\"short[]\"))(3);" +
                 "tf_short_arr[0] = 90;" +
                 "tf_short_arr[1] = 5;" +
                 "tf_short_arr[2] = -6000;" +
@@ -429,7 +429,7 @@
         e.eval("var psf_short_array = SharedObject.publicStaticFinalShortArray;");
         assertEquals(SharedObject.publicStaticFinalShortArray[0], e.eval("SharedObject.publicStaticFinalShortArray[0];"));
         assertArrayEquals(SharedObject.publicStaticFinalShortArray, (short[])e.get("psf_short_array"));
-        e.eval("var tsf_short_arr = java.lang.reflect.Array.newInstance(java.lang.Short.TYPE, 3);" +
+        e.eval("var tsf_short_arr = new (Java.type(\"short[]\"))(3);" +
                 "tsf_short_arr[0] = 90;" +
                 "tsf_short_arr[1] = 5;" +
                 "tsf_short_arr[2] = -6000;" +
@@ -463,7 +463,7 @@
         e.eval("var p_char_array = o.publicCharArray;");
         assertEquals(o.publicCharArray[0], e.eval("o.publicCharArray[0];"));
         assertArrayEquals(o.publicCharArray, (char[])e.get("p_char_array"));
-        e.eval("var t_char_arr = java.lang.reflect.Array.newInstance(java.lang.Character.TYPE, 3);" +
+        e.eval("var t_char_arr = new (Java.type(\"char[]\"))(3);" +
                 "t_char_arr[0] = 'F';" +
                 "t_char_arr[1] = 'o';" +
                 "t_char_arr[2] = 'o';" +
@@ -486,7 +486,7 @@
         e.eval("var ps_char_array = SharedObject.publicStaticCharArray;");
         assertEquals(SharedObject.publicStaticCharArray[0], e.eval("SharedObject.publicStaticCharArray[0];"));
         assertArrayEquals(SharedObject.publicStaticCharArray, (char[])e.get("ps_char_array"));
-        e.eval("var ts_char_arr = java.lang.reflect.Array.newInstance(java.lang.Character.TYPE, 3);" +
+        e.eval("var ts_char_arr = new (Java.type(\"char[]\"))(3);" +
                 "ts_char_arr[0] = 'G';" +
                 "ts_char_arr[1] = 'o';" +
                 "ts_char_arr[2] = 'o';" +
@@ -509,7 +509,7 @@
         e.eval("var pf_char_array = o.publicFinalCharArray;");
         assertEquals(o.publicFinalCharArray[0], e.eval("o.publicFinalCharArray[0];"));
         assertArrayEquals(o.publicFinalCharArray, (char[])e.get("pf_char_array"));
-        e.eval("var tf_char_arr = java.lang.reflect.Array.newInstance(java.lang.Character.TYPE, 3);" +
+        e.eval("var tf_char_arr = new (Java.type(\"char[]\"))(3);" +
                 "tf_char_arr[0] = 'F';" +
                 "tf_char_arr[1] = 'o';" +
                 "tf_char_arr[2] = 'o';" +
@@ -532,7 +532,7 @@
         e.eval("var psf_char_array = SharedObject.publicStaticFinalCharArray;");
         assertEquals(SharedObject.publicStaticFinalCharArray[0], e.eval("SharedObject.publicStaticFinalCharArray[0];"));
         assertArrayEquals(SharedObject.publicStaticFinalCharArray, (char[])e.get("psf_char_array"));
-        e.eval("var tsf_char_arr = java.lang.reflect.Array.newInstance(java.lang.Character.TYPE, 3);" +
+        e.eval("var tsf_char_arr = new (Java.type(\"char[]\"))(3);" +
                 "tsf_char_arr[0] = 'Z';" +
                 "tsf_char_arr[1] = 'o';" +
                 "tsf_char_arr[2] = 'o';" +
@@ -569,7 +569,7 @@
         e.eval("var p_float_array = o.publicFloatArray;");
         assertEquals(o.publicFloatArray[0], e.eval("o.publicFloatArray[0];"));
         assertArrayEquals(o.publicFloatArray, (float[])e.get("p_float_array"), 1e-10f);
-        e.eval("var t_float_arr = java.lang.reflect.Array.newInstance(java.lang.Float.TYPE, 3);" +
+        e.eval("var t_float_arr = new (Java.type(\"float[]\"))(3);" +
                 "t_float_arr[0] = 9.0;" +
                 "t_float_arr[1] = 5.12345;" +
                 "t_float_arr[2] = -60.03;" +
@@ -604,7 +604,7 @@
         e.eval("var ps_float_array = SharedObject.publicStaticFloatArray;");
         assertEquals(SharedObject.publicStaticFloatArray[0], e.eval("SharedObject.publicStaticFloatArray[0];"));
         assertArrayEquals(SharedObject.publicStaticFloatArray, (float[])e.get("ps_float_array"), 1e-10f);
-        e.eval("var ts_float_arr = java.lang.reflect.Array.newInstance(java.lang.Float.TYPE, 3);" +
+        e.eval("var ts_float_arr = new (Java.type(\"float[]\"))(3);" +
                 "ts_float_arr[0] = 9.0;" +
                 "ts_float_arr[1] = 5.12345;" +
                 "ts_float_arr[2] = -60.03;" +
@@ -627,7 +627,7 @@
         e.eval("var pf_float_array = o.publicFinalFloatArray;");
         assertEquals(o.publicFinalFloatArray[0], e.eval("o.publicFinalFloatArray[0];"));
         assertArrayEquals(o.publicFinalFloatArray, (float[])e.get("pf_float_array"), 1e-10f);
-        e.eval("var tf_float_arr = java.lang.reflect.Array.newInstance(java.lang.Float.TYPE, 3);" +
+        e.eval("var tf_float_arr = new (Java.type(\"float[]\"))(3);" +
                 "tf_float_arr[0] = 9.0;" +
                 "tf_float_arr[1] = 5.12345;" +
                 "tf_float_arr[2] = -60.03;" +
@@ -650,7 +650,7 @@
         e.eval("var psf_float_array = SharedObject.publicStaticFinalFloatArray;");
         assertEquals(SharedObject.publicStaticFinalFloatArray[0], e.eval("SharedObject.publicStaticFinalFloatArray[0];"));
         assertArrayEquals(SharedObject.publicStaticFinalFloatArray, (float[])e.get("psf_float_array"), 1e-10f);
-        e.eval("var tsf_float_arr = java.lang.reflect.Array.newInstance(java.lang.Float.TYPE, 3);" +
+        e.eval("var tsf_float_arr = new (Java.type(\"float[]\"))(3);" +
                 "tsf_float_arr[0] = 9.0;" +
                 "tsf_float_arr[1] = 5.12345;" +
                 "tsf_float_arr[2] = -60.03;" +
@@ -687,7 +687,7 @@
         e.eval("var p_double_array = o.publicDoubleArray;");
         assertEquals(o.publicDoubleArray[0], e.eval("o.publicDoubleArray[0];"));
         assertArrayEquals(o.publicDoubleArray, (double[])e.get("p_double_array"), 1e-10);
-        e.eval("var t_double_arr = java.lang.reflect.Array.newInstance(java.lang.Double.TYPE, 3);" +
+        e.eval("var t_double_arr = new (Java.type(\"double[]\"))(3);" +
                 "t_double_arr[0] = 9e10;" +
                 "t_double_arr[1] = 0.677777;" +
                 "t_double_arr[2] = -0.0000001;" +
@@ -722,7 +722,7 @@
         e.eval("var ps_double_array = SharedObject.publicStaticDoubleArray;");
         assertEquals(SharedObject.publicStaticDoubleArray[0], e.eval("SharedObject.publicStaticDoubleArray[0];"));
         assertArrayEquals(SharedObject.publicStaticDoubleArray, (double[])e.get("ps_double_array"), 1e-10);
-        e.eval("var ts_double_arr = java.lang.reflect.Array.newInstance(java.lang.Double.TYPE, 3);" +
+        e.eval("var ts_double_arr = new (Java.type(\"double[]\"))(3);" +
                 "ts_double_arr[0] = 9e10;" +
                 "ts_double_arr[1] = 0.677777;" +
                 "ts_double_arr[2] = -0.0000001;" +
@@ -745,7 +745,7 @@
         e.eval("var pf_double_array = o.publicFinalDoubleArray;");
         assertEquals(o.publicFinalDoubleArray[0], e.eval("o.publicFinalDoubleArray[0];"));
         assertArrayEquals(o.publicFinalDoubleArray, (double[])e.get("pf_double_array"), 1e-10);
-        e.eval("var tf_double_arr = java.lang.reflect.Array.newInstance(java.lang.Double.TYPE, 3);" +
+        e.eval("var tf_double_arr = new (Java.type(\"double[]\"))(3);" +
                 "tf_double_arr[0] = 9e10;" +
                 "tf_double_arr[1] = 0.677777;" +
                 "tf_double_arr[2] = -0.0000001;" +
@@ -768,7 +768,7 @@
         e.eval("var psf_double_array = SharedObject.publicStaticFinalDoubleArray;");
         assertEquals(SharedObject.publicStaticFinalDoubleArray[0], e.eval("SharedObject.publicStaticFinalDoubleArray[0];"));
         assertArrayEquals(SharedObject.publicStaticFinalDoubleArray, (double[])e.get("psf_double_array"), 1e-10);
-        e.eval("var tsf_double_arr = java.lang.reflect.Array.newInstance(java.lang.Double.TYPE, 3);" +
+        e.eval("var tsf_double_arr = new (Java.type(\"double[]\"))(3);" +
                 "tsf_double_arr[0] = 9e10;" +
                 "tsf_double_arr[1] = 0.677777;" +
                 "tsf_double_arr[2] = -0.0000001;" +
--- a/test/src/jdk/nashorn/api/javaaccess/ObjectAccessTest.java	Thu Jul 18 16:22:25 2013 +0200
+++ b/test/src/jdk/nashorn/api/javaaccess/ObjectAccessTest.java	Thu Jul 18 16:47:45 2013 +0200
@@ -72,7 +72,7 @@
         e.eval("var p_object_array = o.publicObjectArray;");
         assertEquals(o.publicObjectArray[0], e.eval("o.publicObjectArray[0]"));
         assertArrayEquals(o.publicObjectArray, (Object[])e.get("p_object_array"));
-        e.eval("var t_object_arr = java.lang.reflect.Array.newInstance(Person.class, 3);" +
+        e.eval("var t_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" +
                 "t_object_arr[0] = new Person(100);" +
                 "t_object_arr[1] = new Person(120);" +
                 "t_object_arr[2] = new Person(140);" +
@@ -96,7 +96,7 @@
         e.eval("var ps_object_array = SharedObject.publicStaticObjectArray;");
         assertEquals(SharedObject.publicStaticObjectArray[0], e.eval("SharedObject.publicStaticObjectArray[0]"));
         assertArrayEquals(SharedObject.publicStaticObjectArray, (Object[])e.get("ps_object_array"));
-        e.eval("var ts_object_arr = java.lang.reflect.Array.newInstance(Person.class, 3);" +
+        e.eval("var ts_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" +
                 "ts_object_arr[0] = new Person(100);" +
                 "ts_object_arr[1] = new Person(120);" +
                 "ts_object_arr[2] = new Person(140);" +
@@ -120,7 +120,7 @@
         e.eval("var pf_object_array = o.publicFinalObjectArray;");
         assertEquals(o.publicFinalObjectArray[0], e.eval("o.publicFinalObjectArray[0]"));
         assertArrayEquals(o.publicFinalObjectArray, (Object[])e.get("pf_object_array"));
-        e.eval("var tf_object_arr = java.lang.reflect.Array.newInstance(Person.class, 3);" +
+        e.eval("var tf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" +
                 "tf_object_arr[0] = new Person(100);" +
                 "tf_object_arr[1] = new Person(120);" +
                 "tf_object_arr[2] = new Person(140);" +
@@ -144,7 +144,7 @@
         e.eval("var psf_object_array = SharedObject.publicStaticFinalObjectArray;");
         assertEquals(SharedObject.publicStaticFinalObjectArray[0], e.eval("SharedObject.publicStaticFinalObjectArray[0]"));
         assertArrayEquals(SharedObject.publicStaticFinalObjectArray, (Object[])e.get("psf_object_array"));
-        e.eval("var tsf_object_arr = java.lang.reflect.Array.newInstance(Person.class, 3);" +
+        e.eval("var tsf_object_arr = new (Java.type(\"jdk.nashorn.api.javaaccess.Person[]\"))(3);" +
                 "tsf_object_arr[0] = new Person(100);" +
                 "tsf_object_arr[1] = new Person(120);" +
                 "tsf_object_arr[2] = new Person(140);" +
--- a/test/src/jdk/nashorn/api/javaaccess/StringAccessTest.java	Thu Jul 18 16:22:25 2013 +0200
+++ b/test/src/jdk/nashorn/api/javaaccess/StringAccessTest.java	Thu Jul 18 16:47:45 2013 +0200
@@ -71,7 +71,7 @@
         e.eval("var p_string_array = o.publicStringArray;");
         assertEquals(o.publicStringArray[0], e.eval("o.publicStringArray[0]"));
         assertArrayEquals(o.publicStringArray, (String[])e.get("p_string_array"));
-        e.eval("var t_string_arr = java.lang.reflect.Array.newInstance(java.lang.String.class, 3);" +
+        e.eval("var t_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
                 "t_string_arr[0] = 'abc';" +
                 "t_string_arr[1] = '123';" +
                 "t_string_arr[2] = 'xyzzzz';" +
@@ -95,7 +95,7 @@
         e.eval("var ps_string_array = SharedObject.publicStaticStringArray;");
         assertEquals(SharedObject.publicStaticStringArray[0], e.eval("SharedObject.publicStaticStringArray[0]"));
         assertArrayEquals(SharedObject.publicStaticStringArray, (String[])e.get("ps_string_array"));
-        e.eval("var ts_string_arr = java.lang.reflect.Array.newInstance(java.lang.String.class, 3);" +
+        e.eval("var ts_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
                 "ts_string_arr[0] = 'abc';" +
                 "ts_string_arr[1] = '123';" +
                 "ts_string_arr[2] = 'xyzzzz';" +
@@ -119,7 +119,7 @@
         e.eval("var pf_string_array = o.publicFinalStringArray;");
         assertEquals(o.publicFinalStringArray[0], e.eval("o.publicFinalStringArray[0]"));
         assertArrayEquals(o.publicFinalStringArray, (String[])e.get("pf_string_array"));
-        e.eval("var tf_string_arr = java.lang.reflect.Array.newInstance(java.lang.String.class, 3);" +
+        e.eval("var tf_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
                 "tf_string_arr[0] = 'abc';" +
                 "tf_string_arr[1] = '123';" +
                 "tf_string_arr[2] = 'xyzzzz';" +
@@ -143,7 +143,7 @@
         e.eval("var psf_string_array = SharedObject.publicStaticFinalStringArray;");
         assertEquals(SharedObject.publicStaticFinalStringArray[0], e.eval("SharedObject.publicStaticFinalStringArray[0]"));
         assertArrayEquals(SharedObject.publicStaticFinalStringArray, (String[])e.get("psf_string_array"));
-        e.eval("var tsf_string_arr = java.lang.reflect.Array.newInstance(java.lang.String.class, 3);" +
+        e.eval("var tsf_string_arr = new (Java.type(\"java.lang.String[]\"))(3);" +
                 "tsf_string_arr[0] = 'abc';" +
                 "tsf_string_arr[1] = '123';" +
                 "tsf_string_arr[2] = 'xyzzzz';" +