< prev index next >

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

Print this page

        

*** 167,177 **** * * <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> * * <p> If there is a security manager, its * {@code checkPermission} method is first called with a * {@code ReflectPermission("suppressAccessChecks")} permission. * --- 167,178 ---- * * <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 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,298 **** --- 290,303 ---- 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 >