# HG changeset patch # User kevinw # Date 1381225074 -7200 # Node ID ced68a57cdbd17fae96925701226900fbb76b1d2 # Parent 615d83933195c1e3b987b63fc5481c349e035465# Parent c90e76575b031b793cb4e7f19042d316517f1e8a Merge diff -r c90e76575b03 -r ced68a57cdbd src/share/vm/prims/jvm.cpp --- a/src/share/vm/prims/jvm.cpp Tue Oct 08 09:33:51 2013 +0100 +++ b/src/share/vm/prims/jvm.cpp Tue Oct 08 11:37:54 2013 +0200 @@ -668,13 +668,12 @@ JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env, int depth)) JVMWrapper("JVM_GetCallerClass"); - // Pre-JDK 8 and early builds of JDK 8 don't have a CallerSensitive annotation. - if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) { + // 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()); - } else { - // Basic handshaking with Java_sun_reflect_Reflection_getCallerClass - assert(depth == -1, "wrong handshake depth"); } // Getting the class of the caller frame. diff -r c90e76575b03 -r ced68a57cdbd src/share/vm/prims/jvm.h --- a/src/share/vm/prims/jvm.h Tue Oct 08 09:33:51 2013 +0100 +++ b/src/share/vm/prims/jvm.h Tue Oct 08 11:37:54 2013 +0200 @@ -374,6 +374,9 @@ /* * java.lang.Class and java.lang.ClassLoader */ + +#define JVM_CALLER_DEPTH -1 + /* * Returns the class in which the code invoking the native method * belongs.