< prev index next >

src/java.base/share/classes/java/lang/reflect/AccessibleObject.java

Print this page

        

@@ -167,11 +167,12 @@
      *
      * <p> This method cannot be used to enable access to private members,
      * members with default (package) access, protected instance members, or
      * protected constructors when the declaring class is in a different module
      * to the caller and the package containing the declaring class is not open
-     * to the caller's module. </p>
+     * to the caller's module or it is a {@linkplain Class#isHiddenClass()
+     * hidden class}.</p>
      *
      * <p> If there is a security manager, its
      * {@code checkPermission} method is first called with a
      * {@code ReflectPermission("suppressAccessChecks")} permission.
      *

@@ -289,10 +290,14 @@
                                           boolean throwExceptionIfDenied) {
         if (caller == MethodHandle.class) {
             throw new IllegalCallerException();   // should not happen
         }
 
+        if (declaringClass.isHiddenClass()) {
+            return false;
+        }
+
         Module callerModule = caller.getModule();
         Module declaringModule = declaringClass.getModule();
 
         if (callerModule == declaringModule) return true;
         if (callerModule == Object.class.getModule()) return true;
< prev index next >