< prev index next >

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

Print this page
rev 58565 : 8238358: Implementation of JEP 371: Hidden Classes
Reviewed-by: duke
Contributed-by: mandy.chung@oracle.com, lois.foltan@oracle.com, david.holmes@oracle.com, harold.seigel@oracle.com, serguei.spitsyn@oracle.com, alex.buckley@oracle.com, jamsheed.c.m@oracle.com
rev 58567 : [mq]: rename-isHidden


 159      *
 160      *     <li> The member is {@code protected} {@code static}, {@code D} is
 161      *     {@code public} in a package that the module containing {@code D}
 162      *     exports to at least the module containing {@code C}, and {@code C}
 163      *     is a subclass of {@code D}. </li>
 164      *
 165      *     <li> {@code D} is in a package that the module containing {@code D}
 166      *     {@link Module#isOpen(String,Module) opens} to at least the module
 167      *     containing {@code C}.
 168      *     All packages in unnamed and open modules are open to all modules and
 169      *     so this method always succeeds when {@code D} is in an unnamed or
 170      *     open module. </li>
 171      * </ul>
 172      *
 173      * <p> This method cannot be used to enable access to private members,
 174      * members with default (package) access, protected instance members, or
 175      * protected constructors when the declaring class is in a different module
 176      * to the caller and the package containing the declaring class is not open
 177      * to the caller's module. </p>
 178      *






 179      * <p> If there is a security manager, its
 180      * {@code checkPermission} method is first called with a
 181      * {@code ReflectPermission("suppressAccessChecks")} permission.
 182      *
 183      * @param flag the new value for the {@code accessible} flag
 184      * @throws InaccessibleObjectException if access cannot be enabled
 185      * @throws SecurityException if the request is denied by the security manager
 186      * @see #trySetAccessible
 187      * @see java.lang.invoke.MethodHandles#privateLookupIn
 188      * @revised 9
 189      * @spec JPMS
 190      */
 191     @CallerSensitive   // overrides in Method/Field/Constructor are @CS
 192     public void setAccessible(boolean flag) {
 193         AccessibleObject.checkPermission();
 194         setAccessible0(flag);
 195     }
 196 
 197     /**
 198      * Sets the accessible flag and returns the new value




 159      *
 160      *     <li> The member is {@code protected} {@code static}, {@code D} is
 161      *     {@code public} in a package that the module containing {@code D}
 162      *     exports to at least the module containing {@code C}, and {@code C}
 163      *     is a subclass of {@code D}. </li>
 164      *
 165      *     <li> {@code D} is in a package that the module containing {@code D}
 166      *     {@link Module#isOpen(String,Module) opens} to at least the module
 167      *     containing {@code C}.
 168      *     All packages in unnamed and open modules are open to all modules and
 169      *     so this method always succeeds when {@code D} is in an unnamed or
 170      *     open module. </li>
 171      * </ul>
 172      *
 173      * <p> This method cannot be used to enable access to private members,
 174      * members with default (package) access, protected instance members, or
 175      * protected constructors when the declaring class is in a different module
 176      * to the caller and the package containing the declaring class is not open
 177      * to the caller's module. </p>
 178      *
 179      * <p> This method cannot be used to enable {@linkplain Field#set <em>write</em>}
 180      * access to a final field declared in a {@linkplain Class#isHidden() hidden class},
 181      * since such fields are not modifiable.  The {@code accessible} flag when
 182      * {@code true} suppresses Java language access control checks to only
 183      * enable {@linkplain Field#get <em>read</em>} access to such fields.
 184      *
 185      * <p> If there is a security manager, its
 186      * {@code checkPermission} method is first called with a
 187      * {@code ReflectPermission("suppressAccessChecks")} permission.
 188      *
 189      * @param flag the new value for the {@code accessible} flag
 190      * @throws InaccessibleObjectException if access cannot be enabled
 191      * @throws SecurityException if the request is denied by the security manager
 192      * @see #trySetAccessible
 193      * @see java.lang.invoke.MethodHandles#privateLookupIn
 194      * @revised 9
 195      * @spec JPMS
 196      */
 197     @CallerSensitive   // overrides in Method/Field/Constructor are @CS
 198     public void setAccessible(boolean flag) {
 199         AccessibleObject.checkPermission();
 200         setAccessible0(flag);
 201     }
 202 
 203     /**
 204      * Sets the accessible flag and returns the new value


< prev index next >