Thu, 30 Jan 2014 19:04:00 +0530
8032954: Nashorn: extend Java.extend
Reviewed-by: attila, jlaskey, ahgross
1.1 --- a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java Thu Jan 30 18:34:37 2014 +0530 1.2 +++ b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java Thu Jan 30 19:04:00 2014 +0530 1.3 @@ -110,6 +110,8 @@ 1.4 for (Class<?> type : types) { 1.5 // check for restricted package access 1.6 Context.checkPackageAccess(type); 1.7 + // check for classes, interfaces in reflection 1.8 + ReflectionCheckLinker.checkReflectionAccess(type); 1.9 } 1.10 } 1.11 return getAdapterInfo(types).getAdapterClassFor(classOverrides);
2.1 --- a/test/script/sandbox/classbind.js Thu Jan 30 18:34:37 2014 +0530 2.2 +++ b/test/script/sandbox/classbind.js Thu Jan 30 19:04:00 2014 +0530 2.3 @@ -25,7 +25,7 @@ 2.4 * Try to bind properties of StaticClass representing Class. 2.5 * 2.6 * @test 2.7 - * @security 2.8 + * @bug JDK-8032943: Improve reflection in Nashorn 2.9 */ 2.10 2.11
3.1 --- a/test/script/sandbox/classloader.js Thu Jan 30 18:34:37 2014 +0530 3.2 +++ b/test/script/sandbox/classloader.js Thu Jan 30 19:04:00 2014 +0530 3.3 @@ -26,6 +26,7 @@ 3.4 * 3.5 * @test 3.6 * @security 3.7 + * @bug JDK-8032954: Nashorn: extend Java.extend 3.8 */ 3.9 3.10 try { 3.11 @@ -39,3 +40,24 @@ 3.12 } 3.13 } 3.14 3.15 +try { 3.16 + Java.extend(Java.type('java.lang.ClassLoader')); 3.17 + fail("should have thrown SecurityException"); 3.18 +} catch (e) { 3.19 + if (e instanceof java.lang.SecurityException) { 3.20 + print(e); 3.21 + } else { 3.22 + fail("expected SecurityException, got " + e); 3.23 + } 3.24 +} 3.25 + 3.26 +try { 3.27 + Java.extend(Java.type("javax.management.loading.MLet")); 3.28 + fail("should have thrown SecurityException"); 3.29 +} catch (e) { 3.30 + if (e instanceof java.lang.SecurityException) { 3.31 + print(e); 3.32 + } else { 3.33 + fail("expected SecurityException, got " + e); 3.34 + } 3.35 +}
4.1 --- a/test/script/sandbox/classloader.js.EXPECTED Thu Jan 30 18:34:37 2014 +0530 4.2 +++ b/test/script/sandbox/classloader.js.EXPECTED Thu Jan 30 19:04:00 2014 +0530 4.3 @@ -1,1 +1,3 @@ 4.4 java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection") 4.5 +java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection") 4.6 +java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection")