--- old/make/mapfiles/libjava/mapfile-vers 2017-12-20 22:38:22.303682573 +0000 +++ new/make/mapfiles/libjava/mapfile-vers 2017-12-20 22:38:21.763694319 +0000 @@ -257,7 +257,6 @@ Java_jdk_internal_reflect_NativeConstructorAccessorImpl_newInstance0; Java_jdk_internal_reflect_NativeMethodAccessorImpl_invoke0; Java_jdk_internal_reflect_Reflection_getCallerClass__; - Java_jdk_internal_reflect_Reflection_getCallerClass__I; Java_jdk_internal_reflect_Reflection_getClassAccessFlags; Java_jdk_internal_misc_VM_latestUserDefinedLoader0; Java_jdk_internal_misc_VM_getuid; --- old/make/mapfiles/libjava/reorder-sparc 2017-12-20 22:38:22.871670217 +0000 +++ new/make/mapfiles/libjava/reorder-sparc 2017-12-20 22:38:22.615675786 +0000 @@ -27,7 +27,6 @@ text: .text%Java_java_io_FileOutputStream_initIDs; text: .text%Java_java_lang_System_setIn0; text: .text%Java_sun_reflect_Reflection_getCallerClass__; -text: .text%Java_sun_reflect_Reflection_getCallerClass__I; text: .text%Java_java_lang_Class_forName0; text: .text%Java_java_lang_Object_getClass; text: .text%Java_sun_reflect_Reflection_getClassAccessFlags; --- old/make/mapfiles/libjava/reorder-sparcv9 2017-12-20 22:38:23.375659255 +0000 +++ new/make/mapfiles/libjava/reorder-sparcv9 2017-12-20 22:38:23.155664040 +0000 @@ -26,7 +26,6 @@ text: .text%Java_java_io_FileOutputStream_initIDs; text: .text%Java_java_lang_System_setIn0; text: .text%Java_sun_reflect_Reflection_getCallerClass__; -text: .text%Java_sun_reflect_Reflection_getCallerClass__I; text: .text%Java_java_lang_Class_forName0; text: .text%Java_java_lang_String_intern; text: .text%Java_java_lang_StringUTF16_isBigEndian; --- old/make/mapfiles/libjava/reorder-x86 2017-12-20 22:38:23.851648901 +0000 +++ new/make/mapfiles/libjava/reorder-x86 2017-12-20 22:38:23.655653164 +0000 @@ -27,7 +27,6 @@ text: .text%Java_java_io_FileOutputStream_initIDs; text: .text%Java_java_lang_System_setIn0; text: .text%Java_sun_reflect_Reflection_getCallerClass__; -text: .text%Java_sun_reflect_Reflection_getCallerClass__I; text: .text%Java_java_lang_Class_forName0; text: .text%Java_java_lang_String_intern; text: .text%Java_java_lang_StringUTF16_isBigEndian; --- old/src/hotspot/share/include/jvm.h 2017-12-20 22:38:24.331638460 +0000 +++ new/src/hotspot/share/include/jvm.h 2017-12-20 22:38:24.135642723 +0000 @@ -317,23 +317,18 @@ JNIEXPORT jobject JNICALL JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim); -/* - * java.lang.Class and java.lang.ClassLoader - */ - -#define JVM_CALLER_DEPTH -1 /* * Returns the immediate caller class of the native method invoking * JVM_GetCallerClass. The Method.invoke and other frames due to * reflection machinery are skipped. * - * The depth parameter must be -1 (JVM_DEPTH). The caller is expected - * to be marked with sun.reflect.CallerSensitive. The JVM will throw - * an error if it is not marked propertly. + * The caller is expected to be marked with + * jdk.internal.reflect.CallerSensitive. The JVM will throw an + * error if it is not marked propertly. */ JNIEXPORT jclass JNICALL -JVM_GetCallerClass(JNIEnv *env, int depth); +JVM_GetCallerClass(JNIEnv *env); /* --- old/src/hotspot/share/prims/jvm.cpp 2017-12-20 22:38:24.823627758 +0000 +++ new/src/hotspot/share/prims/jvm.cpp 2017-12-20 22:38:24.631631934 +0000 @@ -678,17 +678,9 @@ // Misc. class handling /////////////////////////////////////////////////////////// -JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env, int depth)) +JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env)) JVMWrapper("JVM_GetCallerClass"); - // Pre-JDK 8 and early builds of JDK 8 don't have a CallerSensitive annotation; or - // sun.reflect.Reflection.getCallerClass with a depth parameter is provided - // temporarily for existing code to use until a replacement API is defined. - if (SystemDictionary::reflect_CallerSensitive_klass() == NULL || depth != JVM_CALLER_DEPTH) { - Klass* k = thread->security_get_caller_class(depth); - return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, k->java_mirror()); - } - // Getting the class of the caller frame. // // The call stack at this point looks something like this: --- old/src/java.base/share/classes/jdk/internal/reflect/Reflection.java 2017-12-20 22:38:25.363616012 +0000 +++ new/src/java.base/share/classes/jdk/internal/reflect/Reflection.java 2017-12-20 22:38:25.163620362 +0000 @@ -64,14 +64,6 @@ @HotSpotIntrinsicCandidate public static native Class getCallerClass(); - /** - * @deprecated This method will be removed. - * This method is a private JDK API and retained temporarily to - * simplify the implementation of sun.misc.Reflection.getCallerClass. - */ - @Deprecated(forRemoval=true) - public static native Class getCallerClass(int depth); - /** Retrieves the access flags written to the class file. For inner classes these flags may differ from those returned by Class.getModifiers(), which searches the InnerClasses --- old/src/java.base/share/native/libjava/Reflection.c 2017-12-20 22:38:25.859605223 +0000 +++ new/src/java.base/share/native/libjava/Reflection.c 2017-12-20 22:38:25.663609486 +0000 @@ -30,13 +30,7 @@ JNIEXPORT jclass JNICALL Java_jdk_internal_reflect_Reflection_getCallerClass__(JNIEnv *env, jclass unused) { - return JVM_GetCallerClass(env, JVM_CALLER_DEPTH); -} - -JNIEXPORT jclass JNICALL -Java_jdk_internal_reflect_Reflection_getCallerClass__I(JNIEnv *env, jclass unused, jint depth) -{ - return JVM_GetCallerClass(env, depth); + return JVM_GetCallerClass(env); } JNIEXPORT jint JNICALL --- old/src/jdk.unsupported/share/classes/sun/reflect/Reflection.java 2017-12-20 22:38:26.347594608 +0000 +++ /dev/null 2017-10-29 15:33:32.190964158 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2001, 2017, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * 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. - */ - -package sun.reflect; - -public class Reflection { - - private Reflection() { } - - /** - * @deprecated This method is an internal API and will be removed. - * Use {@link StackWalker} to walk the stack and obtain the caller class - * with {@link StackWalker.StackFrame#getDeclaringClass} instead. - */ - @Deprecated(forRemoval=true) - @SuppressWarnings("removal") // Reflection.getCallerClass - public static Class getCallerClass(int depth) { - if (depth < 0) - throw new InternalError("depth must be positive"); - - // increase depth to account for delegation to the internal impl - return jdk.internal.reflect.Reflection.getCallerClass(depth + 1); - } -} --- old/test/jdk/jdk/internal/reflect/Reflection/GetCallerClassWithDepth.java 2017-12-20 22:38:26.699586951 +0000 +++ /dev/null 2017-10-29 15:33:32.190964158 +0000 @@ -1,95 +0,0 @@ -/* - * 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 8025799 - * @summary Reflection.getCallerClass(int) - * @modules java.base/jdk.internal.reflect - * @run main GetCallerClassWithDepth - */ - -import jdk.internal.reflect.Reflection; - -public class GetCallerClassWithDepth { - public static void main(String[] args) throws Exception { - Class c = Test.test(); - assertEquals(c, GetCallerClassWithDepth.class); - Class caller = Test.caller(); - assertEquals(caller, GetCallerClassWithDepth.class); - Test.selfTest(); - - try { - Reflection.getCallerClass(-1); - throw new RuntimeException("getCallerClass(-1) should fail"); - } catch (Error e) { - System.out.println("Expected: " + e.getMessage()); - } - } - - public Class getCallerClass() { - // 0: Reflection 1: getCallerClass 2: Test.test 3: main - return Reflection.getCallerClass(3); - } - - static void assertEquals(Class c, Class expected) { - if (c != expected) { - throw new RuntimeException("Incorrect caller: " + c); - } - } - - static class Test { - // Returns the caller of this method - public static Class test() { - return new GetCallerClassWithDepth().getCallerClass(); - } - - // Returns the caller of this method - public static Class caller() { - // 0: Reflection 1: Test.caller 2: main - return Reflection.getCallerClass(2); - } - public static void selfTest() { - // 0: Reflection 1: Test.selfTest - Class c = Reflection.getCallerClass(1); - assertEquals(c, Test.class); - 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 = Reflection.getCallerClass(4); - assertEquals(c, Test.class); - } - } - } - } -} --- old/test/jdk/sun/reflect/Reflection/GetCallerClassWithDepth.java 2017-12-20 22:38:27.059579120 +0000 +++ /dev/null 2017-10-29 15:33:32.190964158 +0000 @@ -1,94 +0,0 @@ -/* - * 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 8137058 - * @summary Basic test for the unsupported Reflection.getCallerClass(int) - * @modules jdk.unsupported - */ - -import sun.reflect.Reflection; - -public class GetCallerClassWithDepth { - public static void main(String[] args) throws Exception { - Class c = Test.test(); - assertEquals(c, GetCallerClassWithDepth.class); - Class caller = Test.caller(); - assertEquals(caller, GetCallerClassWithDepth.class); - Test.selfTest(); - - try { - Reflection.getCallerClass(-1); - throw new RuntimeException("getCallerClass(-1) should fail"); - } catch (Error e) { - System.out.println("Expected: " + e.getMessage()); - } - } - - public Class getCallerClass() { - // 0: Reflection 1: getCallerClass 2: Test.test 3: main - return Reflection.getCallerClass(3); - } - - static void assertEquals(Class c, Class expected) { - if (c != expected) { - throw new RuntimeException("Incorrect caller: " + c); - } - } - - static class Test { - // Returns the caller of this method - public static Class test() { - return new GetCallerClassWithDepth().getCallerClass(); - } - - // Returns the caller of this method - public static Class caller() { - // 0: Reflection 1: Test.caller 2: main - return Reflection.getCallerClass(2); - } - public static void selfTest() { - // 0: Reflection 1: Test.selfTest - Class c = Reflection.getCallerClass(1); - assertEquals(c, Test.class); - 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 = Reflection.getCallerClass(4); - assertEquals(c, Test.class); - } - } - } - } -}