Blame callerclass-04.patch

f9252f7
f9252f7
# HG changeset patch
f9252f7
# User alanb
f9252f7
# Date 1375374329 -3600
f9252f7
# Node ID a1ec65ac926d41ccca2545dbc3b62bb7c12282af
f9252f7
# Parent  6f1a1e26f52119ee7b8ce91bf425a726935e02c3
f9252f7
8021946: Disabling sun.reflect.Reflection.getCallerCaller(int) by default breaks several frameworks and libraries
f9252f7
Reviewed-by: chegar, dholmes, dfuchs
f9252f7
f9252f7
diff -r 6f1a1e26f521 -r a1ec65ac926d src/share/classes/sun/misc/VM.java
f9252f7
--- openjdk/jdk/src/share/classes/sun/misc/VM.java	Thu Aug 08 01:48:56 2013 +0100
f9252f7
+++ openjdk/jdk/src/share/classes/sun/misc/VM.java	Thu Aug 01 17:25:29 2013 +0100
f9252f7
@@ -216,12 +216,13 @@
f9252f7
         return allowArraySyntax;
f9252f7
     }
f9252f7
 
f9252f7
-    private static boolean allowGetCallerClass = false;
f9252f7
+    private static boolean allowGetCallerClass = true;
f9252f7
 
f9252f7
-    // Reflection.getCallerClass(int) is disabled by default.
f9252f7
-    // It can be enabled by setting the system property
f9252f7
-    // "jdk.reflect.allowGetCallerClass" and also used by
f9252f7
-    // logging stack walk of a resource bundle if it is turned on.
f9252f7
+    // Reflection.getCallerClass(int) is enabled by default.
f9252f7
+    // It can be disabled by setting the system property
f9252f7
+    // "jdk.reflect.allowGetCallerClass" to "false". It cannot be
f9252f7
+    // disabled if the logging stack walk (to find resource bundles)
f9252f7
+    // is enabled.
f9252f7
     public static boolean allowGetCallerClass() {
f9252f7
         return allowGetCallerClass;
f9252f7
     }
f9252f7
@@ -290,14 +291,13 @@
f9252f7
                                ? defaultAllowArraySyntax
f9252f7
                                : Boolean.parseBoolean(s));
f9252f7
 
f9252f7
-        // Reflection.getCallerClass(int) is disabled by default.
f9252f7
-        // It can be enabled by setting the system property
f9252f7
-        // "jdk.reflect.allowGetCallerClass" and also used by
f9252f7
-        // logging stack walk of a resource bundle if it is turned on.
f9252f7
+        // Reflection.getCallerClass(int) is enabled by default.
f9252f7
+        // It can be disabled by setting a system property (but only if
f9252f7
+        // the logging stack walk is not enabled)
f9252f7
         s = props.getProperty("jdk.reflect.allowGetCallerClass");
f9252f7
         allowGetCallerClass = (s != null
f9252f7
                                    ? (s.isEmpty() || Boolean.parseBoolean(s))
f9252f7
-                                   : false) ||
f9252f7
+                                   : true) ||
f9252f7
              Boolean.valueOf(props.getProperty("jdk.logging.allowStackWalkSearch"));
f9252f7
 
f9252f7
         // Remove other private system properties
f9252f7
diff -r 6f1a1e26f521 -r a1ec65ac926d src/share/classes/sun/reflect/Reflection.java
f9252f7
--- openjdk/jdk/src/share/classes/sun/reflect/Reflection.java	Thu Aug 08 01:48:56 2013 +0100
f9252f7
+++ openjdk/jdk/src/share/classes/sun/reflect/Reflection.java	Thu Aug 01 17:25:29 2013 +0100
f9252f7
@@ -59,8 +59,8 @@
f9252f7
     public static native Class getCallerClass();
f9252f7
 
f9252f7
     /**
f9252f7
-     * @deprecated No replacement.  This method will be removed in the next
f9252f7
-     * JDK 7 update release.
f9252f7
+     * @deprecated No replacement. This method will be removed in a future
f9252f7
+     *   release.
f9252f7
      */
f9252f7
     @Deprecated
f9252f7
     @CallerSensitive
f9252f7
@@ -68,12 +68,8 @@
f9252f7
         if (sun.misc.VM.allowGetCallerClass()) {
f9252f7
             return getCallerClass0(depth+1);
f9252f7
         }
f9252f7
-        throw new UnsupportedOperationException("This method is in the sun.* " +
f9252f7
-             "namespace so it is not a supported, public interface. " +
f9252f7
-             "The 7u40 release notes describe a temporary mechanism " +
f9252f7
-             "to reenable the historical functionality of this method. " +
f9252f7
-             "Update code to function properly and this method will be " +
f9252f7
-             "removed without further warning in a subsequent 7 update release.");
f9252f7
+        throw new UnsupportedOperationException("This method has been disabled by a " +
f9252f7
+            "system property");
f9252f7
     }
f9252f7
 
f9252f7
     // If the VM enforces getting caller class with @CallerSensitive,
f9252f7
diff -r 6f1a1e26f521 -r a1ec65ac926d test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java
f9252f7
--- openjdk/jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java	Thu Aug 08 01:48:56 2013 +0100
f9252f7
+++ openjdk/jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java	Thu Aug 01 17:25:29 2013 +0100
f9252f7
@@ -29,6 +29,7 @@
f9252f7
  * @build  ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp1 LoadItUp2 TwiceIndirectlyLoadABundle LoadItUp2Invoker
f9252f7
  * @run main/othervm ResourceBundleSearchTest
f9252f7
  * @run main/othervm -Djdk.logging.allowStackWalkSearch=true ResourceBundleSearchTest
f9252f7
+ * @run main/othervm -Djdk.reflect.allowGetCallerClass=false -Djdk.logging.allowStackWalkSearch=true ResourceBundleSearchTest
f9252f7
  */
f9252f7
 import java.net.URL;
f9252f7
 import java.net.URLClassLoader;
f9252f7
diff -r 6f1a1e26f521 -r a1ec65ac926d test/sun/reflect/GetCallerClass.java
f9252f7
--- openjdk/jdk/test/sun/reflect/GetCallerClass.java	Thu Aug 08 01:48:56 2013 +0100
f9252f7
+++ openjdk/jdk/test/sun/reflect/GetCallerClass.java	Thu Aug 01 17:25:29 2013 +0100
f9252f7
@@ -23,7 +23,7 @@
f9252f7
 
f9252f7
 /*
f9252f7
  * @test
f9252f7
- * @bug 8016814 8014925
f9252f7
+ * @bug 8016814 8014925 8021946
f9252f7
  * @summary Test sun.reflect.Reflection.getCallerClass(int) disabled by default
f9252f7
  * @compile -XDignore.symbol.file GetCallerClass.java
f9252f7
  * @run main/othervm GetCallerClass
f9252f7
@@ -36,10 +36,10 @@
f9252f7
     public static void main(String[] args) throws Exception {
f9252f7
         String s = System.getProperty("jdk.reflect.allowGetCallerClass");
f9252f7
         boolean allowed;
f9252f7
-        if (s == null || s.equals("false")) {
f9252f7
+        if (s == null || s.equals("") || s.equals("true")) {
f9252f7
+            allowed = true;
f9252f7
+        } else if (s.equals("false")) {
f9252f7
             allowed = false;
f9252f7
-        } else if (s.equals("") || s.equals("true")) {
f9252f7
-            allowed = true;
f9252f7
         } else {
f9252f7
             throw new RuntimeException("Unsupported test setting");
f9252f7
         }
f9252f7