mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8026025: JVM_GetCallerClass allows Reflection.getCallerClass(int depth) to use
Reviewed-by: alanb, dholmes, twisti
This commit is contained in:
parent
088ded71f9
commit
f9f9dd164a
2 changed files with 7 additions and 5 deletions
|
@ -668,13 +668,12 @@ JVM_END
|
||||||
JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env, int depth))
|
JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env, int depth))
|
||||||
JVMWrapper("JVM_GetCallerClass");
|
JVMWrapper("JVM_GetCallerClass");
|
||||||
|
|
||||||
// Pre-JDK 8 and early builds of JDK 8 don't have a CallerSensitive annotation.
|
// Pre-JDK 8 and early builds of JDK 8 don't have a CallerSensitive annotation; or
|
||||||
if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) {
|
// 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);
|
Klass* k = thread->security_get_caller_class(depth);
|
||||||
return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, k->java_mirror());
|
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.
|
// Getting the class of the caller frame.
|
||||||
|
|
|
@ -374,6 +374,9 @@ JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
|
||||||
/*
|
/*
|
||||||
* java.lang.Class and java.lang.ClassLoader
|
* java.lang.Class and java.lang.ClassLoader
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define JVM_CALLER_DEPTH -1
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the class in which the code invoking the native method
|
* Returns the class in which the code invoking the native method
|
||||||
* belongs.
|
* belongs.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue