From f9252f79a3409249a183137057604cbdeda22007 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Aug 20 2013 16:52:30 +0000 Subject: Backport getCallerClass-related patches from upstream --- diff --git a/aarch64.patch b/aarch64.patch index 91a99bf..ccb84a6 100644 --- a/aarch64.patch +++ b/aarch64.patch @@ -114,8 +114,8 @@ index 7e0b8de..d27129f 100644 # ZERO_ENDIANNESS is the endianness of the processor case "${ZERO_LIBARCH}" in -- i386|amd64|ia64) -+ i386|amd64|ia64|aarch64) +- i386|amd64|ia64|arm) ++ i386|amd64|ia64|arm|aarch64) ZERO_ENDIANNESS=little ;; ppc*|s390*|sparc*|alpha) diff --git a/callerclass-01.patch b/callerclass-01.patch new file mode 100644 index 0000000..b799159 --- /dev/null +++ b/callerclass-01.patch @@ -0,0 +1,76 @@ +# HG changeset patch +# User mchung +# Date 1372201967 25200 +# Node ID 6ae667b931d5389914a96c94117362eb87f92431 +# Parent 8c388c89a45c4220d05fb71d6291d9d1914f1c32 +8016814: sun.reflect.Reflection.getCallerClass returns the frame off by 1 +Reviewed-by: jrose, alanb, chegar, twisti + +diff -r 8c388c89a45c -r 6ae667b931d5 src/share/classes/sun/reflect/Reflection.java +--- openjdk/jdk/src/share/classes/sun/reflect/Reflection.java Thu Jul 25 20:48:39 2013 +0100 ++++ openjdk/jdk/src/share/classes/sun/reflect/Reflection.java Tue Jun 25 16:12:47 2013 -0700 +@@ -65,7 +65,7 @@ + @Deprecated + @CallerSensitive + public static Class getCallerClass(int depth) { +- return getCallerClass0(depth); ++ return getCallerClass0(depth+1); + } + + // If the VM enforces getting caller class with @CallerSensitive, +diff -r 8c388c89a45c -r 6ae667b931d5 test/sun/reflect/GetCallerClass.java +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ openjdk/jdk/test/sun/reflect/GetCallerClass.java Tue Jun 25 16:12:47 2013 -0700 +@@ -0,0 +1,51 @@ ++/* ++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ */ ++ ++/* ++ * @test ++ * @bug 8016814 ++ * @summary Test sun.reflect.Reflection.getCallerClass(int) ++ * @compile -XDignore.symbol.file GetCallerClass.java ++ * @run main GetCallerClass ++ */ ++ ++public class GetCallerClass { ++ public static void main(String[] args) throws Exception { ++ Class c = Temp.test(); ++ if (c != GetCallerClass.class) { ++ throw new RuntimeException("Incorrect caller: " + c); ++ } ++ } ++ ++ @sun.reflect.CallerSensitive ++ public Class getCallerClass() { ++ // 0: Reflection 1: getCallerClass 2: Temp.test 3: main ++ return sun.reflect.Reflection.getCallerClass(3); ++ } ++ ++ static class Temp { ++ public static Class test() { ++ return new GetCallerClass().getCallerClass(); ++ } ++ } ++} + diff --git a/callerclass-02.patch b/callerclass-02.patch new file mode 100644 index 0000000..fd28f41 --- /dev/null +++ b/callerclass-02.patch @@ -0,0 +1,161 @@ +# HG changeset patch +# User mchung +# Date 1372796615 25200 +# Node ID 64c0a3fb78cdf25cd5f8515446b058aac9b5cb7b +# Parent 6ae667b931d5389914a96c94117362eb87f92431 +8014925: Disable sun.reflect.Reflection.getCallerClass(int) with a temporary switch to re-enable it +Reviewed-by: jrose, alanb, chegar, twisti + +diff -r 6ae667b931d5 -r 64c0a3fb78cd src/share/classes/sun/misc/VM.java +--- openjdk/jdk/src/share/classes/sun/misc/VM.java Tue Jun 25 16:12:47 2013 -0700 ++++ openjdk/jdk/src/share/classes/sun/misc/VM.java Tue Jul 02 13:23:35 2013 -0700 +@@ -216,6 +216,16 @@ + return allowArraySyntax; + } + ++ private static boolean allowGetCallerClass = false; ++ ++ // Reflection.getCallerClass(int) is disabled by default. ++ // It can be enabled by setting the system property ++ // "jdk.reflect.allowGetCallerClass" and also used by ++ // logging stack walk of a resource bundle if it is turned on. ++ public static boolean allowGetCallerClass() { ++ return allowGetCallerClass; ++ } ++ + /** + * Returns the system property of the specified key saved at + * system initialization time. This method should only be used +@@ -280,6 +290,16 @@ + ? defaultAllowArraySyntax + : Boolean.parseBoolean(s)); + ++ // Reflection.getCallerClass(int) is disabled by default. ++ // It can be enabled by setting the system property ++ // "jdk.reflect.allowGetCallerClass" and also used by ++ // logging stack walk of a resource bundle if it is turned on. ++ s = props.getProperty("jdk.reflect.allowGetCallerClass"); ++ allowGetCallerClass = (s != null ++ ? (s.isEmpty() || Boolean.parseBoolean(s)) ++ : false) || ++ Boolean.valueOf(props.getProperty("jdk.logging.allowStackWalkSearch")); ++ + // Remove other private system properties + // used by java.lang.Integer.IntegerCache + props.remove("java.lang.Integer.IntegerCache.high"); +diff -r 6ae667b931d5 -r 64c0a3fb78cd src/share/classes/sun/reflect/Reflection.java +--- openjdk/jdk/src/share/classes/sun/reflect/Reflection.java Tue Jun 25 16:12:47 2013 -0700 ++++ openjdk/jdk/src/share/classes/sun/reflect/Reflection.java Tue Jul 02 13:23:35 2013 -0700 +@@ -65,7 +65,15 @@ + @Deprecated + @CallerSensitive + public static Class getCallerClass(int depth) { +- return getCallerClass0(depth+1); ++ if (sun.misc.VM.allowGetCallerClass()) { ++ return getCallerClass0(depth+1); ++ } ++ throw new UnsupportedOperationException("This method is in the sun.* " + ++ "namespace so it is not a supported, public interface. " + ++ "The 7u40 release notes describe a temporary mechanism " + ++ "to reenable the historical functionality of this method. " + ++ "Update code to function properly and this method will be " + ++ "removed without further warning in a subsequent 7 update release."); + } + + // If the VM enforces getting caller class with @CallerSensitive, +diff -r 6ae667b931d5 -r 64c0a3fb78cd test/sun/reflect/GetCallerClass.java +--- openjdk/jdk/test/sun/reflect/GetCallerClass.java Tue Jun 25 16:12:47 2013 -0700 ++++ openjdk/jdk/test/sun/reflect/GetCallerClass.java Tue Jul 02 13:23:35 2013 -0700 +@@ -23,29 +23,83 @@ + + /* + * @test +- * @bug 8016814 +- * @summary Test sun.reflect.Reflection.getCallerClass(int) ++ * @bug 8016814 8014925 ++ * @summary Test sun.reflect.Reflection.getCallerClass(int) disabled by default + * @compile -XDignore.symbol.file GetCallerClass.java +- * @run main GetCallerClass ++ * @run main/othervm GetCallerClass ++ * @run main/othervm -Djdk.reflect.allowGetCallerClass GetCallerClass ++ * @run main/othervm -Djdk.reflect.allowGetCallerClass=true GetCallerClass ++ * @run main/othervm -Djdk.reflect.allowGetCallerClass=false GetCallerClass + */ + + public class GetCallerClass { + public static void main(String[] args) throws Exception { +- Class c = Temp.test(); +- if (c != GetCallerClass.class) { +- throw new RuntimeException("Incorrect caller: " + c); ++ String s = System.getProperty("jdk.reflect.allowGetCallerClass"); ++ boolean allowed; ++ if (s == null || s.equals("false")) { ++ allowed = false; ++ } else if (s.equals("") || s.equals("true")) { ++ allowed = true; ++ } else { ++ throw new RuntimeException("Unsupported test setting"); ++ } ++ ++ try { ++ Class c = Test.test(); ++ if (!allowed) { ++ throw new RuntimeException("Reflection.getCallerClass should not be allowed"); ++ } ++ Class caller = Test.caller(); ++ if (c != GetCallerClass.class || caller != c) { ++ throw new RuntimeException("Incorrect caller: " + c); ++ } ++ Test.selfTest(); ++ } catch (UnsupportedOperationException e) { ++ if (allowed) throw e; + } + } + + @sun.reflect.CallerSensitive + public Class getCallerClass() { +- // 0: Reflection 1: getCallerClass 2: Temp.test 3: main ++ // 0: Reflection 1: getCallerClass 2: Test.test 3: main + return sun.reflect.Reflection.getCallerClass(3); + } + +- static class Temp { ++ static class Test { ++ // Returns the caller of this method + public static Class test() { + return new GetCallerClass().getCallerClass(); + } ++ @sun.reflect.CallerSensitive ++ public static Class caller() { ++ return sun.reflect.Reflection.getCallerClass(); ++ } ++ @sun.reflect.CallerSensitive ++ public static void selfTest() { ++ // 0: Reflection 1: Test.selfTest ++ Class c = sun.reflect.Reflection.getCallerClass(1); ++ if (c != Test.class || caller() != c) { ++ throw new RuntimeException("Incorrect caller: " + c); ++ } ++ Inner1.deep(); ++ } ++ ++ static class Inner1 { ++ static void deep() { ++ deeper(); ++ } ++ static void deeper() { ++ Inner2.deepest(); ++ } ++ static class Inner2 { ++ static void deepest() { ++ // 0: Reflection 1: deepest 2: deeper 3: deep 4: Test.selfTest ++ Class c = sun.reflect.Reflection.getCallerClass(4); ++ if (c != Test.class) { ++ throw new RuntimeException("Incorrect caller: " + c); ++ } ++ } ++ } ++ } + } + } + diff --git a/callerclass-03.patch b/callerclass-03.patch new file mode 100644 index 0000000..7122697 --- /dev/null +++ b/callerclass-03.patch @@ -0,0 +1,40 @@ +# HG changeset patch +# User andrew +# Date 1375922936 -3600 +# Node ID 6f1a1e26f52119ee7b8ce91bf425a726935e02c3 +# Parent 64c0a3fb78cdf25cd5f8515446b058aac9b5cb7b +Fix merge issues caused by faulty AOT 8010118 patch. + +diff -r 64c0a3fb78cd -r 6f1a1e26f521 src/share/classes/sun/reflect/misc/ReflectUtil.java +--- openjdk/jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java Tue Jul 02 13:23:35 2013 -0700 ++++ openjdk/jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java Thu Aug 08 01:48:56 2013 +0100 +@@ -47,14 +47,6 @@ + return cls.newInstance(); + } + +- public static void ensureClassAccess(Class clazz) +- throws IllegalAccessException +- { +- int mod = clazz.getModifiers(); +- if ( ! Modifier.isPublic(mod) ){ +- throw new IllegalAccessException("Class is not public and can't be instantiated"); +- } +- } + /* + * Reflection.ensureMemberAccess is overly-restrictive + * due to a bug. We awkwardly work around it for now. +diff -r 64c0a3fb78cd -r 6f1a1e26f521 src/share/native/sun/reflect/Reflection.c +--- openjdk/jdk/src/share/native/sun/reflect/Reflection.c Tue Jul 02 13:23:35 2013 -0700 ++++ openjdk/jdk/src/share/native/sun/reflect/Reflection.c Thu Aug 08 01:48:56 2013 +0100 +@@ -37,9 +37,7 @@ + JNIEXPORT jclass JNICALL Java_sun_reflect_Reflection_getCallerClass0 + (JNIEnv *env, jclass unused, jint depth) + { +- // Until there is hotspot @CallerSensitive support, +- // depth must always be 2 to get the immediate caller +- return JVM_GetCallerClass(env, 2); ++ return JVM_GetCallerClass(env, depth); + } + + JNIEXPORT jint JNICALL Java_sun_reflect_Reflection_getClassAccessFlags + diff --git a/callerclass-04.patch b/callerclass-04.patch new file mode 100644 index 0000000..25185eb --- /dev/null +++ b/callerclass-04.patch @@ -0,0 +1,117 @@ + +# HG changeset patch +# User alanb +# Date 1375374329 -3600 +# Node ID a1ec65ac926d41ccca2545dbc3b62bb7c12282af +# Parent 6f1a1e26f52119ee7b8ce91bf425a726935e02c3 +8021946: Disabling sun.reflect.Reflection.getCallerCaller(int) by default breaks several frameworks and libraries +Reviewed-by: chegar, dholmes, dfuchs + +diff -r 6f1a1e26f521 -r a1ec65ac926d src/share/classes/sun/misc/VM.java +--- openjdk/jdk/src/share/classes/sun/misc/VM.java Thu Aug 08 01:48:56 2013 +0100 ++++ openjdk/jdk/src/share/classes/sun/misc/VM.java Thu Aug 01 17:25:29 2013 +0100 +@@ -216,12 +216,13 @@ + return allowArraySyntax; + } + +- private static boolean allowGetCallerClass = false; ++ private static boolean allowGetCallerClass = true; + +- // Reflection.getCallerClass(int) is disabled by default. +- // It can be enabled by setting the system property +- // "jdk.reflect.allowGetCallerClass" and also used by +- // logging stack walk of a resource bundle if it is turned on. ++ // Reflection.getCallerClass(int) is enabled by default. ++ // It can be disabled by setting the system property ++ // "jdk.reflect.allowGetCallerClass" to "false". It cannot be ++ // disabled if the logging stack walk (to find resource bundles) ++ // is enabled. + public static boolean allowGetCallerClass() { + return allowGetCallerClass; + } +@@ -290,14 +291,13 @@ + ? defaultAllowArraySyntax + : Boolean.parseBoolean(s)); + +- // Reflection.getCallerClass(int) is disabled by default. +- // It can be enabled by setting the system property +- // "jdk.reflect.allowGetCallerClass" and also used by +- // logging stack walk of a resource bundle if it is turned on. ++ // Reflection.getCallerClass(int) is enabled by default. ++ // It can be disabled by setting a system property (but only if ++ // the logging stack walk is not enabled) + s = props.getProperty("jdk.reflect.allowGetCallerClass"); + allowGetCallerClass = (s != null + ? (s.isEmpty() || Boolean.parseBoolean(s)) +- : false) || ++ : true) || + Boolean.valueOf(props.getProperty("jdk.logging.allowStackWalkSearch")); + + // Remove other private system properties +diff -r 6f1a1e26f521 -r a1ec65ac926d src/share/classes/sun/reflect/Reflection.java +--- openjdk/jdk/src/share/classes/sun/reflect/Reflection.java Thu Aug 08 01:48:56 2013 +0100 ++++ openjdk/jdk/src/share/classes/sun/reflect/Reflection.java Thu Aug 01 17:25:29 2013 +0100 +@@ -59,8 +59,8 @@ + public static native Class getCallerClass(); + + /** +- * @deprecated No replacement. This method will be removed in the next +- * JDK 7 update release. ++ * @deprecated No replacement. This method will be removed in a future ++ * release. + */ + @Deprecated + @CallerSensitive +@@ -68,12 +68,8 @@ + if (sun.misc.VM.allowGetCallerClass()) { + return getCallerClass0(depth+1); + } +- throw new UnsupportedOperationException("This method is in the sun.* " + +- "namespace so it is not a supported, public interface. " + +- "The 7u40 release notes describe a temporary mechanism " + +- "to reenable the historical functionality of this method. " + +- "Update code to function properly and this method will be " + +- "removed without further warning in a subsequent 7 update release."); ++ throw new UnsupportedOperationException("This method has been disabled by a " + ++ "system property"); + } + + // If the VM enforces getting caller class with @CallerSensitive, +diff -r 6f1a1e26f521 -r a1ec65ac926d test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java +--- openjdk/jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Thu Aug 08 01:48:56 2013 +0100 ++++ openjdk/jdk/test/java/util/logging/bundlesearch/ResourceBundleSearchTest.java Thu Aug 01 17:25:29 2013 +0100 +@@ -29,6 +29,7 @@ + * @build ResourceBundleSearchTest IndirectlyLoadABundle LoadItUp1 LoadItUp2 TwiceIndirectlyLoadABundle LoadItUp2Invoker + * @run main/othervm ResourceBundleSearchTest + * @run main/othervm -Djdk.logging.allowStackWalkSearch=true ResourceBundleSearchTest ++ * @run main/othervm -Djdk.reflect.allowGetCallerClass=false -Djdk.logging.allowStackWalkSearch=true ResourceBundleSearchTest + */ + import java.net.URL; + import java.net.URLClassLoader; +diff -r 6f1a1e26f521 -r a1ec65ac926d test/sun/reflect/GetCallerClass.java +--- openjdk/jdk/test/sun/reflect/GetCallerClass.java Thu Aug 08 01:48:56 2013 +0100 ++++ openjdk/jdk/test/sun/reflect/GetCallerClass.java Thu Aug 01 17:25:29 2013 +0100 +@@ -23,7 +23,7 @@ + + /* + * @test +- * @bug 8016814 8014925 ++ * @bug 8016814 8014925 8021946 + * @summary Test sun.reflect.Reflection.getCallerClass(int) disabled by default + * @compile -XDignore.symbol.file GetCallerClass.java + * @run main/othervm GetCallerClass +@@ -36,10 +36,10 @@ + public static void main(String[] args) throws Exception { + String s = System.getProperty("jdk.reflect.allowGetCallerClass"); + boolean allowed; +- if (s == null || s.equals("false")) { ++ if (s == null || s.equals("") || s.equals("true")) { ++ allowed = true; ++ } else if (s.equals("false")) { + allowed = false; +- } else if (s.equals("") || s.equals("true")) { +- allowed = true; + } else { + throw new RuntimeException("Unsupported test setting"); + } + diff --git a/java-1.7.0-openjdk.spec b/java-1.7.0-openjdk.spec index 94ebc86..9891219 100644 --- a/java-1.7.0-openjdk.spec +++ b/java-1.7.0-openjdk.spec @@ -141,7 +141,7 @@ Name: java-%{javaver}-%{origin} Version: %{javaver}.%{buildver} -Release: %{icedtea_version}.3%{?dist} +Release: %{icedtea_version}.4%{?dist} # java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons, # and this change was brought into RHEL-4. java-1.5.0-ibm packages # also included the epoch in their virtual provides. This created a @@ -260,6 +260,12 @@ Patch403: PStack-808293.patch Patch404: aarch64.patch # End of tmp patches +# Temporary backport of patches already upstream but not in a icedtea7-2.3.X release yet +Patch501: callerclass-01.patch +Patch502: callerclass-02.patch +Patch503: callerclass-03.patch +Patch504: callerclass-04.patch + BuildRequires: autoconf BuildRequires: automake BuildRequires: gcc-c++ @@ -518,6 +524,11 @@ tar xzf %{SOURCE7} %patch404 -p1 %endif +%patch501 +%patch502 +%patch503 +%patch504 + %build # How many cpu's do we have? %ifarch aarch64 @@ -1286,6 +1297,9 @@ exit 0 %{_jvmdir}/%{jredir}/lib/accessibility.properties %changelog +* Tue Aug 20 2013 Omair Majid -1.7.0.25-2.3.12.4c20 +- Backport getCallerClass-related patches from upstream that are not in a release yet + * Sat Jul 27 2013 Jiri Vanek - 1.7.0.25-2.3.12.3.f20 - setting of alternatives moved into conditional block controlled by graceful_links - added graceful_links, set to enabled (1)