aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsundar <none@none>2014-01-30 19:04:00 +0530
committersundar <none@none>2014-01-30 19:04:00 +0530
commit070d7c55d4e2b53ed533bd5f5af37076c7599032 (patch)
tree554faff297e0de17db98a0daefb39db2f042652b
parentc45cf962b22600d2acaaa5a63dbaa21854fd76f3 (diff)
downloadnashorn-070d7c55d4e2b53ed533bd5f5af37076c7599032.tar.gz
8032954: Nashorn: extend Java.extend
Reviewed-by: attila, jlaskey, ahgross
-rw-r--r--src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java2
-rw-r--r--test/script/sandbox/classbind.js2
-rw-r--r--test/script/sandbox/classloader.js22
-rw-r--r--test/script/sandbox/classloader.js.EXPECTED2
4 files changed, 27 insertions, 1 deletions
diff --git a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java
index b221d000..878c0058 100644
--- a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java
+++ b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java
@@ -110,6 +110,8 @@ public final class JavaAdapterFactory {
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);
diff --git a/test/script/sandbox/classbind.js b/test/script/sandbox/classbind.js
index 379ec11e..2dabb3e2 100644
--- a/test/script/sandbox/classbind.js
+++ b/test/script/sandbox/classbind.js
@@ -25,7 +25,7 @@
* Try to bind properties of StaticClass representing Class.
*
* @test
- * @security
+ * @bug JDK-8032943: Improve reflection in Nashorn
*/
diff --git a/test/script/sandbox/classloader.js b/test/script/sandbox/classloader.js
index 76764960..9de1a5c3 100644
--- a/test/script/sandbox/classloader.js
+++ b/test/script/sandbox/classloader.js
@@ -26,6 +26,7 @@
*
* @test
* @security
+ * @bug JDK-8032954: Nashorn: extend Java.extend
*/
try {
@@ -39,3 +40,24 @@ try {
}
}
+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);
+ }
+}
diff --git a/test/script/sandbox/classloader.js.EXPECTED b/test/script/sandbox/classloader.js.EXPECTED
index 356053d4..8c241912 100644
--- a/test/script/sandbox/classloader.js.EXPECTED
+++ b/test/script/sandbox/classloader.js.EXPECTED
@@ -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")