< prev index next >

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

Print this page
rev 49922 : 8202419: Avoid creating Permission constants early
Reviewed-by: alanb

@@ -33,10 +33,11 @@
 import jdk.internal.module.IllegalAccessLogger;
 import jdk.internal.reflect.CallerSensitive;
 import jdk.internal.reflect.Reflection;
 import jdk.internal.reflect.ReflectionFactory;
 import sun.security.action.GetPropertyAction;
+import sun.security.util.SecurityConstants;
 
 /**
  * The {@code AccessibleObject} class is the base class for {@code Field},
  * {@code Method}, and {@code Constructor} objects (known as <em>reflected
  * objects</em>). It provides the ability to flag a reflected object as

@@ -71,21 +72,18 @@
  * @revised 9
  * @spec JPMS
  */
 public class AccessibleObject implements AnnotatedElement {
 
-    /**
-     * The Permission object that is used to check whether a client
-     * has sufficient privilege to defeat Java language access
-     * control checks.
-     */
-    private static final java.security.Permission ACCESS_PERMISSION =
-        new ReflectPermission("suppressAccessChecks");
-
     static void checkPermission() {
         SecurityManager sm = System.getSecurityManager();
-        if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
+        if (sm != null) {
+            // SecurityConstants.ACCESS_PERMISSION is used to check
+            // whether a client has sufficient privilege to defeat Java
+            // language access control checks.
+            sm.checkPermission(SecurityConstants.ACCESS_PERMISSION);
+        }
     }
 
     /**
      * Convenience method to set the {@code accessible} flag for an
      * array of reflected objects with a single security check (for efficiency).
< prev index next >