< prev index next >

src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java

Print this page
rev 14210 : 8154231: Simplify access to System properties from JDK code
Reviewed-by: rriggs

@@ -28,14 +28,15 @@
 import java.lang.reflect.Field;
 import java.lang.reflect.Executable;
 import java.lang.reflect.Method;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Modifier;
-import java.security.AccessController;
 import java.security.Permission;
 import java.security.PrivilegedAction;
+import java.util.Properties;
 import sun.reflect.misc.ReflectUtil;
+import sun.security.action.GetPropertyAction;
 
 /** <P> The master factory for all reflective objects, both those in
     java.lang.reflect (Fields, Methods, Constructors) as well as their
     delegates (FieldAccessors, MethodAccessors, ConstructorAccessors).
     </P>

@@ -380,13 +381,11 @@
         static initializer (more properly, that for
         java.lang.reflect.AccessibleObject) causes this class's to be
         run, before the system properties are set up. */
     private static void checkInitted() {
         if (initted) return;
-        AccessController.doPrivileged(
-            new PrivilegedAction<>() {
-                public Void run() {
+
                     // Tests to ensure the system properties table is fully
                     // initialized. This is needed because reflection code is
                     // called very early in the initialization process (before
                     // command-line arguments have been parsed and therefore
                     // these user-settable properties installed.) We assume that

@@ -394,31 +393,29 @@
                     // fully initialized and that the bulk of the startup code
                     // has been run.
 
                     if (System.out == null) {
                         // java.lang.System not yet fully initialized
-                        return null;
+            return;
                     }
 
-                    String val = System.getProperty("sun.reflect.noInflation");
+        Properties props = GetPropertyAction.getProperties();
+        String val = props.getProperty("sun.reflect.noInflation");
                     if (val != null && val.equals("true")) {
                         noInflation = true;
                     }
 
-                    val = System.getProperty("sun.reflect.inflationThreshold");
+        val = props.getProperty("sun.reflect.inflationThreshold");
                     if (val != null) {
                         try {
                             inflationThreshold = Integer.parseInt(val);
                         } catch (NumberFormatException e) {
                             throw new RuntimeException("Unable to parse property sun.reflect.inflationThreshold", e);
                         }
                     }
 
                     initted = true;
-                    return null;
-                }
-            });
     }
 
     private static LangReflectAccess langReflectAccess() {
         if (langReflectAccess == null) {
             // Call a static method to get class java.lang.reflect.Modifier
< prev index next >