comparison src/share/vm/prims/jvm.cpp @ 11022:9f3e3245b50f

Merge
author amurillo
date Tue, 25 Jun 2013 12:46:21 -0700
parents 3a0774193f71 ac91879aa56f
children ba9dacff9c9d
comparison
equal deleted inserted replaced
11021:38e483cb1bcd 11022:9f3e3245b50f
3308 } 3308 }
3309 return NULL; 3309 return NULL;
3310 JVM_END 3310 JVM_END
3311 3311
3312 3312
3313 // Utility object for collecting method holders walking down the stack
3314 class KlassLink: public ResourceObj {
3315 public:
3316 KlassHandle klass;
3317 KlassLink* next;
3318
3319 KlassLink(KlassHandle k) { klass = k; next = NULL; }
3320 };
3321
3322
3323 JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env)) 3313 JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env))
3324 JVMWrapper("JVM_GetClassContext"); 3314 JVMWrapper("JVM_GetClassContext");
3325 ResourceMark rm(THREAD); 3315 ResourceMark rm(THREAD);
3326 JvmtiVMObjectAllocEventCollector oam; 3316 JvmtiVMObjectAllocEventCollector oam;
3327 // Collect linked list of (handles to) method holders
3328 KlassLink* first = NULL;
3329 KlassLink* last = NULL;
3330 int depth = 0;
3331 vframeStream vfst(thread); 3317 vframeStream vfst(thread);
3332 3318
3333 if (SystemDictionary::reflect_CallerSensitive_klass() != NULL) { 3319 if (SystemDictionary::reflect_CallerSensitive_klass() != NULL) {
3334 // This must only be called from SecurityManager.getClassContext 3320 // This must only be called from SecurityManager.getClassContext
3335 Method* m = vfst.method(); 3321 Method* m = vfst.method();
3339 THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVM_GetClassContext must only be called from SecurityManager.getClassContext"); 3325 THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVM_GetClassContext must only be called from SecurityManager.getClassContext");
3340 } 3326 }
3341 } 3327 }
3342 3328
3343 // Collect method holders 3329 // Collect method holders
3330 GrowableArray<KlassHandle>* klass_array = new GrowableArray<KlassHandle>();
3344 for (; !vfst.at_end(); vfst.security_next()) { 3331 for (; !vfst.at_end(); vfst.security_next()) {
3345 Method* m = vfst.method(); 3332 Method* m = vfst.method();
3346 // Native frames are not returned 3333 // Native frames are not returned
3347 if (!m->is_ignored_by_security_stack_walk() && !m->is_native()) { 3334 if (!m->is_ignored_by_security_stack_walk() && !m->is_native()) {
3348 Klass* holder = m->method_holder(); 3335 Klass* holder = m->method_holder();
3349 assert(holder->is_klass(), "just checking"); 3336 assert(holder->is_klass(), "just checking");
3350 depth++; 3337 klass_array->append(holder);
3351 KlassLink* l = new KlassLink(KlassHandle(thread, holder));
3352 if (first == NULL) {
3353 first = last = l;
3354 } else {
3355 last->next = l;
3356 last = l;
3357 }
3358 } 3338 }
3359 } 3339 }
3360 3340
3361 // Create result array of type [Ljava/lang/Class; 3341 // Create result array of type [Ljava/lang/Class;
3362 objArrayOop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), depth, CHECK_NULL); 3342 objArrayOop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), klass_array->length(), CHECK_NULL);
3363 // Fill in mirrors corresponding to method holders 3343 // Fill in mirrors corresponding to method holders
3364 int index = 0; 3344 for (int i = 0; i < klass_array->length(); i++) {
3365 while (first != NULL) { 3345 result->obj_at_put(i, klass_array->at(i)->java_mirror());
3366 result->obj_at_put(index++, first->klass()->java_mirror()); 3346 }
3367 first = first->next;
3368 }
3369 assert(index == depth, "just checking");
3370 3347
3371 return (jobjectArray) JNIHandles::make_local(env, result); 3348 return (jobjectArray) JNIHandles::make_local(env, result);
3372 JVM_END 3349 JVM_END
3373 3350
3374 3351