mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
Merge
This commit is contained in:
commit
55f6f35697
37 changed files with 190 additions and 1105 deletions
|
@ -3241,24 +3241,10 @@ JVM_ENTRY(jobject, JVM_CurrentClassLoader(JNIEnv *env))
|
|||
JVM_END
|
||||
|
||||
|
||||
// Utility object for collecting method holders walking down the stack
|
||||
class KlassLink: public ResourceObj {
|
||||
public:
|
||||
KlassHandle klass;
|
||||
KlassLink* next;
|
||||
|
||||
KlassLink(KlassHandle k) { klass = k; next = NULL; }
|
||||
};
|
||||
|
||||
|
||||
JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env))
|
||||
JVMWrapper("JVM_GetClassContext");
|
||||
ResourceMark rm(THREAD);
|
||||
JvmtiVMObjectAllocEventCollector oam;
|
||||
// Collect linked list of (handles to) method holders
|
||||
KlassLink* first = NULL;
|
||||
KlassLink* last = NULL;
|
||||
int depth = 0;
|
||||
vframeStream vfst(thread);
|
||||
|
||||
if (SystemDictionary::reflect_CallerSensitive_klass() != NULL) {
|
||||
|
@ -3272,32 +3258,23 @@ JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env))
|
|||
}
|
||||
|
||||
// Collect method holders
|
||||
GrowableArray<KlassHandle>* klass_array = new GrowableArray<KlassHandle>();
|
||||
for (; !vfst.at_end(); vfst.security_next()) {
|
||||
Method* m = vfst.method();
|
||||
// Native frames are not returned
|
||||
if (!m->is_ignored_by_security_stack_walk() && !m->is_native()) {
|
||||
Klass* holder = m->method_holder();
|
||||
assert(holder->is_klass(), "just checking");
|
||||
depth++;
|
||||
KlassLink* l = new KlassLink(KlassHandle(thread, holder));
|
||||
if (first == NULL) {
|
||||
first = last = l;
|
||||
} else {
|
||||
last->next = l;
|
||||
last = l;
|
||||
}
|
||||
klass_array->append(holder);
|
||||
}
|
||||
}
|
||||
|
||||
// Create result array of type [Ljava/lang/Class;
|
||||
objArrayOop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), depth, CHECK_NULL);
|
||||
objArrayOop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), klass_array->length(), CHECK_NULL);
|
||||
// Fill in mirrors corresponding to method holders
|
||||
int index = 0;
|
||||
while (first != NULL) {
|
||||
result->obj_at_put(index++, first->klass()->java_mirror());
|
||||
first = first->next;
|
||||
for (int i = 0; i < klass_array->length(); i++) {
|
||||
result->obj_at_put(i, klass_array->at(i)->java_mirror());
|
||||
}
|
||||
assert(index == depth, "just checking");
|
||||
|
||||
return (jobjectArray) JNIHandles::make_local(env, result);
|
||||
JVM_END
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue