/** @com.intel.drl.spec_ref */ public void setAccessible(boolean flag) throws SecurityException { SecurityManager sc = System.getSecurityManager(); if (sc != null) { sc.checkPermission(ReflectPermissionCollection.SUPPRESS_ACCESS_CHECKS_PERMISSION); } setAccessible0(flag); }
/** * Convenience method to set the {@code accessible} flag for an array of objects with a single * security check (for efficiency). * * <p>First, if there is a security manager, its {@code checkPermission} method is called with a * {@code ReflectPermission("suppressAccessChecks")} permission. * * <p>A {@code SecurityException} is raised if {@code flag} is {@code true} but accessibility of * any of the elements of the input {@code array} may not be changed (for example, if the element * object is a {@link Constructor} object for the class {@link java.lang.Class}). In the event of * such a SecurityException, the accessibility of objects is set to {@code flag} for array * elements upto (and excluding) the element for which the exception occurred; the accessibility * of elements beyond (and including) the element for which the exception occurred is unchanged. * * @param array the array of AccessibleObjects * @param flag the new value for the {@code accessible} flag in each object * @throws SecurityException if the request is denied. * @see SecurityManager#checkPermission * @see java.lang.RuntimePermission */ public static void setAccessible(AccessibleObject[] array, boolean flag) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(ACCESS_PERMISSION); for (int i = 0; i < array.length; i++) { setAccessible0(array[i], flag); } }
/** * Set the {@code accessible} flag for this object to the indicated boolean value. A value of * {@code true} indicates that the reflected object should suppress Java language access checking * when it is used. A value of {@code false} indicates that the reflected object should enforce * Java language access checks. * * <p>First, if there is a security manager, its {@code checkPermission} method is called with a * {@code ReflectPermission("suppressAccessChecks")} permission. * * <p>A {@code SecurityException} is raised if {@code flag} is {@code true} but accessibility of * this object may not be changed (for example, if this element object is a {@link Constructor} * object for the class {@link java.lang.Class}). * * <p>A {@code SecurityException} is raised if this object is a {@link * java.lang.reflect.Constructor} object for the class {@code java.lang.Class}, and {@code flag} * is true. * * @param flag the new value for the {@code accessible} flag * @throws SecurityException if the request is denied. * @see SecurityManager#checkPermission * @see java.lang.RuntimePermission */ public void setAccessible(boolean flag) throws SecurityException { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(ACCESS_PERMISSION); setAccessible0(this, flag); }