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

Print this page
rev 10452 : imported patch lang-Typos


  61      * has sufficient privilege to defeat Java language access
  62      * control checks.
  63      */
  64     static final private java.security.Permission ACCESS_PERMISSION =
  65         new ReflectPermission("suppressAccessChecks");
  66 
  67     /**
  68      * Convenience method to set the {@code accessible} flag for an
  69      * array of objects with a single security check (for efficiency).
  70      *
  71      * <p>First, if there is a security manager, its
  72      * {@code checkPermission} method is called with a
  73      * {@code ReflectPermission("suppressAccessChecks")} permission.
  74      *
  75      * <p>A {@code SecurityException} is raised if {@code flag} is
  76      * {@code true} but accessibility of any of the elements of the input
  77      * {@code array} may not be changed (for example, if the element
  78      * object is a {@link Constructor} object for the class {@link
  79      * java.lang.Class}).  In the event of such a SecurityException, the
  80      * accessibility of objects is set to {@code flag} for array elements
  81      * upto (and excluding) the element for which the exception occurred; the
  82      * accessibility of elements beyond (and including) the element for which
  83      * the exception occurred is unchanged.
  84      *
  85      * @param array the array of AccessibleObjects
  86      * @param flag  the new value for the {@code accessible} flag
  87      *              in each object
  88      * @throws SecurityException if the request is denied.
  89      * @see SecurityManager#checkPermission
  90      * @see java.lang.RuntimePermission
  91      */
  92     public static void setAccessible(AccessibleObject[] array, boolean flag)
  93         throws SecurityException {
  94         SecurityManager sm = System.getSecurityManager();
  95         if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
  96         for (AccessibleObject ao : array) {
  97             setAccessible0(ao, flag);
  98         }
  99     }
 100 
 101     /**




  61      * has sufficient privilege to defeat Java language access
  62      * control checks.
  63      */
  64     static final private java.security.Permission ACCESS_PERMISSION =
  65         new ReflectPermission("suppressAccessChecks");
  66 
  67     /**
  68      * Convenience method to set the {@code accessible} flag for an
  69      * array of objects with a single security check (for efficiency).
  70      *
  71      * <p>First, if there is a security manager, its
  72      * {@code checkPermission} method is called with a
  73      * {@code ReflectPermission("suppressAccessChecks")} permission.
  74      *
  75      * <p>A {@code SecurityException} is raised if {@code flag} is
  76      * {@code true} but accessibility of any of the elements of the input
  77      * {@code array} may not be changed (for example, if the element
  78      * object is a {@link Constructor} object for the class {@link
  79      * java.lang.Class}).  In the event of such a SecurityException, the
  80      * accessibility of objects is set to {@code flag} for array elements
  81      * up to (and excluding) the element for which the exception occurred; the
  82      * accessibility of elements beyond (and including) the element for which
  83      * the exception occurred is unchanged.
  84      *
  85      * @param array the array of AccessibleObjects
  86      * @param flag  the new value for the {@code accessible} flag
  87      *              in each object
  88      * @throws SecurityException if the request is denied.
  89      * @see SecurityManager#checkPermission
  90      * @see java.lang.RuntimePermission
  91      */
  92     public static void setAccessible(AccessibleObject[] array, boolean flag)
  93         throws SecurityException {
  94         SecurityManager sm = System.getSecurityManager();
  95         if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
  96         for (AccessibleObject ao : array) {
  97             setAccessible0(ao, flag);
  98         }
  99     }
 100 
 101     /**