172 * with no caller class on the stack to enable access to a {@link Member member}
173 * of {@link Member#getDeclaringClass() declaring class} {@code D} if and only if:
174 * <ul>
175 * <li> The member is {@code public} and {@code D} is {@code public} in
176 * a package that the module containing {@code D} {@link
177 * Module#isExported(String,Module) exports} unconditionally. </li>
178 * </ul>
179 *
180 * <p> This method cannot be used to enable access to private members,
181 * members with default (package) access, protected instance members, or
182 * protected constructors when the declaring class is in a different module
183 * to the caller and the package containing the declaring class is not open
184 * to the caller's module. </p>
185 *
186 * <p> This method cannot be used to enable {@linkplain Field#set <em>write</em>}
187 * access to a <em>non-modifiable</em> final field. The following fields
188 * are non-modifiable:
189 * <ul>
190 * <li>static final fields declared in any class or interface</li>
191 * <li>final fields declared in a {@linkplain Class#isHidden() hidden class}</li>
192 * <li>final fields declared in a {@linkplain Class#isRecord() record}</li>
193 * </ul>
194 * <p> The {@code accessible} flag when {@code true} suppresses Java language access
195 * control checks to only enable {@linkplain Field#get <em>read</em>} access to
196 * these non-modifiable final fields.
197 *
198 * <p> If there is a security manager, its
199 * {@code checkPermission} method is first called with a
200 * {@code ReflectPermission("suppressAccessChecks")} permission.
201 *
202 * @param flag the new value for the {@code accessible} flag
203 * @throws InaccessibleObjectException if access cannot be enabled
204 * @throws SecurityException if the request is denied by the security manager
205 * @see #trySetAccessible
206 * @see java.lang.invoke.MethodHandles#privateLookupIn
207 * @revised 9
208 */
209 @CallerSensitive // overrides in Method/Field/Constructor are @CS
210 public void setAccessible(boolean flag) {
211 AccessibleObject.checkPermission();
|
172 * with no caller class on the stack to enable access to a {@link Member member}
173 * of {@link Member#getDeclaringClass() declaring class} {@code D} if and only if:
174 * <ul>
175 * <li> The member is {@code public} and {@code D} is {@code public} in
176 * a package that the module containing {@code D} {@link
177 * Module#isExported(String,Module) exports} unconditionally. </li>
178 * </ul>
179 *
180 * <p> This method cannot be used to enable access to private members,
181 * members with default (package) access, protected instance members, or
182 * protected constructors when the declaring class is in a different module
183 * to the caller and the package containing the declaring class is not open
184 * to the caller's module. </p>
185 *
186 * <p> This method cannot be used to enable {@linkplain Field#set <em>write</em>}
187 * access to a <em>non-modifiable</em> final field. The following fields
188 * are non-modifiable:
189 * <ul>
190 * <li>static final fields declared in any class or interface</li>
191 * <li>final fields declared in a {@linkplain Class#isHidden() hidden class}</li>
192 * <li>fields declared in a {@linkplain Class#isValue() value class}</li>
193 * <li>final fields declared in a {@linkplain Class#isRecord() record}</li>
194 * </ul>
195 * <p> The {@code accessible} flag when {@code true} suppresses Java language access
196 * control checks to only enable {@linkplain Field#get <em>read</em>} access to
197 * these non-modifiable final fields.
198 *
199 * <p> If there is a security manager, its
200 * {@code checkPermission} method is first called with a
201 * {@code ReflectPermission("suppressAccessChecks")} permission.
202 *
203 * @param flag the new value for the {@code accessible} flag
204 * @throws InaccessibleObjectException if access cannot be enabled
205 * @throws SecurityException if the request is denied by the security manager
206 * @see #trySetAccessible
207 * @see java.lang.invoke.MethodHandles#privateLookupIn
208 * @revised 9
209 */
210 @CallerSensitive // overrides in Method/Field/Constructor are @CS
211 public void setAccessible(boolean flag) {
212 AccessibleObject.checkPermission();
|