diff options
Diffstat (limited to 'src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java')
-rw-r--r-- | src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java b/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java index 66720c23..10ab4349 100644 --- a/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java +++ b/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java @@ -25,6 +25,8 @@ package jdk.nashorn.internal.runtime.linker; +import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; + import java.lang.reflect.Modifier; import java.lang.reflect.Proxy; import jdk.internal.dynalink.CallSiteDescriptor; @@ -33,7 +35,9 @@ import jdk.internal.dynalink.linker.LinkRequest; import jdk.internal.dynalink.linker.LinkerServices; import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker; import jdk.internal.dynalink.support.CallSiteDescriptorFactory; +import jdk.nashorn.api.scripting.ClassFilter; import jdk.nashorn.internal.runtime.Context; +import jdk.nashorn.internal.objects.Global; /** * Check java reflection permission for java reflective and java.lang.invoke access from scripts @@ -100,6 +104,12 @@ final class ReflectionCheckLinker implements TypeBasedGuardingDynamicLinker{ } static void checkReflectionAccess(final Class<?> clazz, final boolean isStatic) { + final Global global = Context.getGlobal(); + final ClassFilter cf = global.getClassFilter(); + if (cf != null && isReflectiveCheckNeeded(clazz, isStatic)) { + throw typeError("no.reflection.with.classfilter"); + } + final SecurityManager sm = System.getSecurityManager(); if (sm != null && isReflectiveCheckNeeded(clazz, isStatic)) { checkReflectionPermission(sm); @@ -107,6 +117,12 @@ final class ReflectionCheckLinker implements TypeBasedGuardingDynamicLinker{ } private static void checkLinkRequest(final LinkRequest origRequest) { + final Global global = Context.getGlobal(); + final ClassFilter cf = global.getClassFilter(); + if (cf != null) { + throw typeError("no.reflection.with.classfilter"); + } + final SecurityManager sm = System.getSecurityManager(); if (sm != null) { final LinkRequest requestWithoutContext = origRequest.withoutRuntimeContext(); // Nashorn has no runtime context |