8169880: Remove the sun.reflect.noCaches option
authorredestad
Thu, 17 Nov 2016 19:38:14 +0100
changeset 42162 b5b738635d55
parent 42161 5b0b84715c06
child 42163 57aecd16d061
8169880: Remove the sun.reflect.noCaches option Reviewed-by: shade, psandoz, mchung
jdk/src/java.base/share/classes/java/lang/Class.java
--- a/jdk/src/java.base/share/classes/java/lang/Class.java	Thu Nov 17 21:02:39 2016 +0800
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java	Thu Nov 17 19:38:14 2016 +0100
@@ -2704,9 +2704,6 @@
      * Reflection support.
      */
 
-    // Caches for certain reflective results
-    private static boolean useCaches = true;
-
     // reflection data that might get invalidated when JVM TI RedefineClasses() is called
     private static class ReflectionData<T> {
         volatile Field[] declaredFields;
@@ -2739,8 +2736,7 @@
         SoftReference<ReflectionData<T>> reflectionData = this.reflectionData;
         int classRedefinedCount = this.classRedefinedCount;
         ReflectionData<T> rd;
-        if (useCaches &&
-            reflectionData != null &&
+        if (reflectionData != null &&
             (rd = reflectionData.get()) != null &&
             rd.redefinedCount == classRedefinedCount) {
             return rd;
@@ -2752,8 +2748,6 @@
 
     private ReflectionData<T> newReflectionData(SoftReference<ReflectionData<T>> oldReflectionData,
                                                 int classRedefinedCount) {
-        if (!useCaches) return null;
-
         while (true) {
             ReflectionData<T> rd = new ReflectionData<>(classRedefinedCount);
             // try to CAS it...
@@ -2819,7 +2813,6 @@
     // be propagated to the outside world, but must instead be copied
     // via ReflectionFactory.copyField.
     private Field[] privateGetDeclaredFields(boolean publicOnly) {
-        checkInitted();
         Field[] res;
         ReflectionData<T> rd = reflectionData();
         if (rd != null) {
@@ -2842,7 +2835,6 @@
     // be propagated to the outside world, but must instead be copied
     // via ReflectionFactory.copyField.
     private Field[] privateGetPublicFields(Set<Class<?>> traversedInterfaces) {
-        checkInitted();
         Field[] res;
         ReflectionData<T> rd = reflectionData();
         if (rd != null) {
@@ -2902,7 +2894,6 @@
     // objects must NOT be propagated to the outside world, but must
     // instead be copied via ReflectionFactory.copyConstructor.
     private Constructor<T>[] privateGetDeclaredConstructors(boolean publicOnly) {
-        checkInitted();
         Constructor<T>[] res;
         ReflectionData<T> rd = reflectionData();
         if (rd != null) {
@@ -2937,7 +2928,6 @@
     // be propagated to the outside world, but must instead be copied
     // via ReflectionFactory.copyMethod.
     private Method[] privateGetDeclaredMethods(boolean publicOnly) {
-        checkInitted();
         Method[] res;
         ReflectionData<T> rd = reflectionData();
         if (rd != null) {
@@ -3134,7 +3124,6 @@
     // be propagated to the outside world, but must instead be copied
     // via ReflectionFactory.copyMethod.
     private Method[] privateGetPublicMethods() {
-        checkInitted();
         Method[] res;
         ReflectionData<T> rd = reflectionData();
         if (rd != null) {
@@ -3490,39 +3479,6 @@
     }
     private static ReflectionFactory reflectionFactory;
 
-    // To be able to query system properties as soon as they're available
-    private static boolean initted = false;
-    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
-                    // if System.out is non-null then the System class has been
-                    // 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;
-                    }
-
-                    // Doesn't use Boolean.getBoolean to avoid class init.
-                    String val =
-                        System.getProperty("sun.reflect.noCaches");
-                    if (val != null && val.equals("true")) {
-                        useCaches = false;
-                    }
-
-                    initted = true;
-                    return null;
-                }
-            });
-    }
-
     /**
      * Returns the elements of this enum class or null if this
      * Class object does not represent an enum type.