Mercurial > hg > truffle
comparison src/share/vm/prims/jvm.cpp @ 6152:958bb4b7be49
Merge
author | asaha |
---|---|
date | Tue, 10 Apr 2012 10:42:34 -0700 |
parents | f7c4174b33ba |
children | 3f1ab0c19c30 8150fa46d2ed |
comparison
equal
deleted
inserted
replaced
6151:e778c29768e6 | 6152:958bb4b7be49 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
1299 | 1299 |
1300 | 1300 |
1301 // Inner class reflection /////////////////////////////////////////////////////////////////////////////// | 1301 // Inner class reflection /////////////////////////////////////////////////////////////////////////////// |
1302 | 1302 |
1303 JVM_ENTRY(jobjectArray, JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)) | 1303 JVM_ENTRY(jobjectArray, JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass)) |
1304 const int inner_class_info_index = 0; | |
1305 const int outer_class_info_index = 1; | |
1306 | |
1307 JvmtiVMObjectAllocEventCollector oam; | 1304 JvmtiVMObjectAllocEventCollector oam; |
1308 // ofClass is a reference to a java_lang_Class object. The mirror object | 1305 // ofClass is a reference to a java_lang_Class object. The mirror object |
1309 // of an instanceKlass | 1306 // of an instanceKlass |
1310 | 1307 |
1311 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || | 1308 if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(ofClass)) || |
1313 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); | 1310 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
1314 return (jobjectArray)JNIHandles::make_local(env, result); | 1311 return (jobjectArray)JNIHandles::make_local(env, result); |
1315 } | 1312 } |
1316 | 1313 |
1317 instanceKlassHandle k(thread, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(ofClass))); | 1314 instanceKlassHandle k(thread, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(ofClass))); |
1318 | 1315 InnerClassesIterator iter(k); |
1319 if (k->inner_classes()->length() == 0) { | 1316 |
1317 if (iter.length() == 0) { | |
1320 // Neither an inner nor outer class | 1318 // Neither an inner nor outer class |
1321 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); | 1319 oop result = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_NULL); |
1322 return (jobjectArray)JNIHandles::make_local(env, result); | 1320 return (jobjectArray)JNIHandles::make_local(env, result); |
1323 } | 1321 } |
1324 | 1322 |
1325 // find inner class info | 1323 // find inner class info |
1326 typeArrayHandle icls(thread, k->inner_classes()); | |
1327 constantPoolHandle cp(thread, k->constants()); | 1324 constantPoolHandle cp(thread, k->constants()); |
1328 int length = icls->length(); | 1325 int length = iter.length(); |
1329 | 1326 |
1330 // Allocate temp. result array | 1327 // Allocate temp. result array |
1331 objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), length/4, CHECK_NULL); | 1328 objArrayOop r = oopFactory::new_objArray(SystemDictionary::Class_klass(), length/4, CHECK_NULL); |
1332 objArrayHandle result (THREAD, r); | 1329 objArrayHandle result (THREAD, r); |
1333 int members = 0; | 1330 int members = 0; |
1334 | 1331 |
1335 for(int i = 0; i < length; i += 4) { | 1332 for (; !iter.done(); iter.next()) { |
1336 int ioff = icls->ushort_at(i + inner_class_info_index); | 1333 int ioff = iter.inner_class_info_index(); |
1337 int ooff = icls->ushort_at(i + outer_class_info_index); | 1334 int ooff = iter.outer_class_info_index(); |
1338 | 1335 |
1339 if (ioff != 0 && ooff != 0) { | 1336 if (ioff != 0 && ooff != 0) { |
1340 // Check to see if the name matches the class we're looking for | 1337 // Check to see if the name matches the class we're looking for |
1341 // before attempting to find the class. | 1338 // before attempting to find the class. |
1342 if (cp->klass_name_at_matches(k, ooff)) { | 1339 if (cp->klass_name_at_matches(k, ooff)) { |
1390 // should be in instanceKlass.cpp, but is here for historical reasons | 1387 // should be in instanceKlass.cpp, but is here for historical reasons |
1391 klassOop instanceKlass::compute_enclosing_class_impl(instanceKlassHandle k, | 1388 klassOop instanceKlass::compute_enclosing_class_impl(instanceKlassHandle k, |
1392 bool* inner_is_member, | 1389 bool* inner_is_member, |
1393 TRAPS) { | 1390 TRAPS) { |
1394 Thread* thread = THREAD; | 1391 Thread* thread = THREAD; |
1395 const int inner_class_info_index = inner_class_inner_class_info_offset; | 1392 InnerClassesIterator iter(k); |
1396 const int outer_class_info_index = inner_class_outer_class_info_offset; | 1393 if (iter.length() == 0) { |
1397 | |
1398 if (k->inner_classes()->length() == 0) { | |
1399 // No inner class info => no declaring class | 1394 // No inner class info => no declaring class |
1400 return NULL; | 1395 return NULL; |
1401 } | 1396 } |
1402 | 1397 |
1403 typeArrayHandle i_icls(thread, k->inner_classes()); | |
1404 constantPoolHandle i_cp(thread, k->constants()); | 1398 constantPoolHandle i_cp(thread, k->constants()); |
1405 int i_length = i_icls->length(); | |
1406 | 1399 |
1407 bool found = false; | 1400 bool found = false; |
1408 klassOop ok; | 1401 klassOop ok; |
1409 instanceKlassHandle outer_klass; | 1402 instanceKlassHandle outer_klass; |
1410 *inner_is_member = false; | 1403 *inner_is_member = false; |
1411 | 1404 |
1412 // Find inner_klass attribute | 1405 // Find inner_klass attribute |
1413 for (int i = 0; i < i_length && !found; i += inner_class_next_offset) { | 1406 for (; !iter.done() && !found; iter.next()) { |
1414 int ioff = i_icls->ushort_at(i + inner_class_info_index); | 1407 int ioff = iter.inner_class_info_index(); |
1415 int ooff = i_icls->ushort_at(i + outer_class_info_index); | 1408 int ooff = iter.outer_class_info_index(); |
1416 int noff = i_icls->ushort_at(i + inner_class_inner_name_offset); | 1409 int noff = iter.inner_name_index(); |
1417 if (ioff != 0) { | 1410 if (ioff != 0) { |
1418 // Check to see if the name matches the class we're looking for | 1411 // Check to see if the name matches the class we're looking for |
1419 // before attempting to find the class. | 1412 // before attempting to find the class. |
1420 if (i_cp->klass_name_at_matches(k, ioff)) { | 1413 if (i_cp->klass_name_at_matches(k, ioff)) { |
1421 klassOop inner_klass = i_cp->klass_at(ioff, CHECK_NULL); | 1414 klassOop inner_klass = i_cp->klass_at(ioff, CHECK_NULL); |
2714 if (java_throwable == NULL) { | 2707 if (java_throwable == NULL) { |
2715 THROW(vmSymbols::java_lang_NullPointerException()); | 2708 THROW(vmSymbols::java_lang_NullPointerException()); |
2716 } | 2709 } |
2717 oop java_thread = JNIHandles::resolve_non_null(jthread); | 2710 oop java_thread = JNIHandles::resolve_non_null(jthread); |
2718 JavaThread* receiver = java_lang_Thread::thread(java_thread); | 2711 JavaThread* receiver = java_lang_Thread::thread(java_thread); |
2719 Events::log("JVM_StopThread thread JavaThread " INTPTR_FORMAT " as oop " INTPTR_FORMAT " [exception " INTPTR_FORMAT "]", receiver, (address)java_thread, throwable); | 2712 Events::log_exception(JavaThread::current(), |
2713 "JVM_StopThread thread JavaThread " INTPTR_FORMAT " as oop " INTPTR_FORMAT " [exception " INTPTR_FORMAT "]", | |
2714 receiver, (address)java_thread, throwable); | |
2720 // First check if thread is alive | 2715 // First check if thread is alive |
2721 if (receiver != NULL) { | 2716 if (receiver != NULL) { |
2722 // Check if exception is getting thrown at self (use oop equality, since the | 2717 // Check if exception is getting thrown at self (use oop equality, since the |
2723 // target object might exit) | 2718 // target object might exit) |
2724 if (java_thread == thread->threadObj()) { | 2719 if (java_thread == thread->threadObj()) { |