changeset 740:47f029b11643

8032954: Nashorn: extend Java.extend Reviewed-by: jlaskey, attila, ahgross
author sundar
date Thu, 30 Jan 2014 18:49:47 +0530
parents 560be4b9f5c4
children 6895d234836c
files src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java test/script/sandbox/classloader.js test/script/sandbox/classloader.js.EXPECTED
diffstat 3 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java	Thu Jan 30 18:26:15 2014 +0530
+++ b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java	Thu Jan 30 18:49:47 2014 +0530
@@ -110,6 +110,8 @@
             for (Class<?> type : types) {
                 // check for restricted package access
                 Context.checkPackageAccess(type);
+                // check for classes, interfaces in reflection
+                ReflectionCheckLinker.checkReflectionAccess(type);
             }
         }
         return getAdapterInfo(types).getAdapterClassFor(classOverrides);
--- a/test/script/sandbox/classloader.js	Thu Jan 30 18:26:15 2014 +0530
+++ b/test/script/sandbox/classloader.js	Thu Jan 30 18:49:47 2014 +0530
@@ -26,6 +26,7 @@
  *
  * @test
  * @security
+ * @bug JDK-8032954: Nashorn: extend Java.extend
  */
 
 try {
@@ -39,3 +40,24 @@
     }
 }
 
+try {
+    Java.extend(Java.type('java.lang.ClassLoader'));
+    fail("should have thrown SecurityException");
+} catch (e) {
+    if (e instanceof java.lang.SecurityException) {
+        print(e);
+    } else {
+        fail("expected SecurityException, got " + e);
+    }
+}
+
+try {
+    Java.extend(Java.type("javax.management.loading.MLet"));
+    fail("should have thrown SecurityException");
+} catch (e) {
+    if (e instanceof java.lang.SecurityException) {
+        print(e);
+    } else {
+        fail("expected SecurityException, got " + e);
+    }
+}
--- a/test/script/sandbox/classloader.js.EXPECTED	Thu Jan 30 18:26:15 2014 +0530
+++ b/test/script/sandbox/classloader.js.EXPECTED	Thu Jan 30 18:49:47 2014 +0530
@@ -1,1 +1,3 @@
 java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection")
+java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection")
+java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection")