917 } |
917 } |
918 |
918 |
919 thread_objs = NEW_RESOURCE_ARRAY(Handle, nthreads); |
919 thread_objs = NEW_RESOURCE_ARRAY(Handle, nthreads); |
920 NULL_CHECK(thread_objs, JVMTI_ERROR_OUT_OF_MEMORY); |
920 NULL_CHECK(thread_objs, JVMTI_ERROR_OUT_OF_MEMORY); |
921 |
921 |
922 for (int i=0; i < nthreads; i++) { |
922 for (int i = 0; i < nthreads; i++) { |
923 thread_objs[i] = Handle(tle.get_threadObj(i)); |
923 thread_objs[i] = Handle(tle.get_threadObj(i)); |
924 } |
924 } |
925 |
925 |
926 jthread *jthreads = new_jthreadArray(nthreads, thread_objs); |
926 jthread *jthreads = new_jthreadArray(nthreads, thread_objs); |
927 NULL_CHECK(jthreads, JVMTI_ERROR_OUT_OF_MEMORY); |
927 NULL_CHECK(jthreads, JVMTI_ERROR_OUT_OF_MEMORY); |
1142 ThreadPriority priority; |
1142 ThreadPriority priority; |
1143 Handle thread_group; |
1143 Handle thread_group; |
1144 Handle context_class_loader; |
1144 Handle context_class_loader; |
1145 bool is_daemon; |
1145 bool is_daemon; |
1146 |
1146 |
1147 { MutexLocker mu(Threads_lock); |
1147 name = Handle(current_thread, java_lang_Thread::name(thread_obj())); |
1148 |
1148 priority = java_lang_Thread::priority(thread_obj()); |
1149 name = Handle(current_thread, java_lang_Thread::name(thread_obj())); |
1149 thread_group = Handle(current_thread, java_lang_Thread::threadGroup(thread_obj())); |
1150 priority = java_lang_Thread::priority(thread_obj()); |
1150 is_daemon = java_lang_Thread::is_daemon(thread_obj()); |
1151 thread_group = Handle(current_thread, java_lang_Thread::threadGroup(thread_obj())); |
1151 |
1152 is_daemon = java_lang_Thread::is_daemon(thread_obj()); |
1152 oop loader = java_lang_Thread::context_class_loader(thread_obj()); |
1153 |
1153 context_class_loader = Handle(current_thread, loader); |
1154 oop loader = java_lang_Thread::context_class_loader(thread_obj()); |
1154 |
1155 context_class_loader = Handle(current_thread, loader); |
|
1156 } |
|
1157 { const char *n; |
1155 { const char *n; |
1158 |
1156 |
1159 if (name() != NULL) { |
1157 if (name() != NULL) { |
1160 n = java_lang_String::as_utf8_string(name()); |
1158 n = java_lang_String::as_utf8_string(name()); |
1161 } else { |
1159 } else { |
1400 const char* name; |
1398 const char* name; |
1401 Handle parent_group; |
1399 Handle parent_group; |
1402 bool is_daemon; |
1400 bool is_daemon; |
1403 ThreadPriority max_priority; |
1401 ThreadPriority max_priority; |
1404 |
1402 |
1405 { MutexLocker mu(Threads_lock); |
1403 name = java_lang_ThreadGroup::name(group_obj()); |
1406 |
1404 parent_group = Handle(current_thread, java_lang_ThreadGroup::parent(group_obj())); |
1407 name = java_lang_ThreadGroup::name(group_obj()); |
1405 is_daemon = java_lang_ThreadGroup::is_daemon(group_obj()); |
1408 parent_group = Handle(current_thread, java_lang_ThreadGroup::parent(group_obj())); |
1406 max_priority = java_lang_ThreadGroup::maxPriority(group_obj()); |
1409 is_daemon = java_lang_ThreadGroup::is_daemon(group_obj()); |
|
1410 max_priority = java_lang_ThreadGroup::maxPriority(group_obj()); |
|
1411 } |
|
1412 |
1407 |
1413 info_ptr->is_daemon = is_daemon; |
1408 info_ptr->is_daemon = is_daemon; |
1414 info_ptr->max_priority = max_priority; |
1409 info_ptr->max_priority = max_priority; |
1415 info_ptr->parent = jni_reference(parent_group); |
1410 info_ptr->parent = jni_reference(parent_group); |
1416 |
1411 |
1446 HandleMark hm(current_thread); |
1441 HandleMark hm(current_thread); |
1447 |
1442 |
1448 Handle group_hdl(current_thread, group_obj); |
1443 Handle group_hdl(current_thread, group_obj); |
1449 |
1444 |
1450 { // Cannot allow thread or group counts to change. |
1445 { // Cannot allow thread or group counts to change. |
1451 MutexLocker mu(Threads_lock); |
1446 ObjectLocker ol(group_hdl, current_thread); |
1452 |
1447 |
1453 nthreads = java_lang_ThreadGroup::nthreads(group_hdl()); |
1448 nthreads = java_lang_ThreadGroup::nthreads(group_hdl()); |
1454 ngroups = java_lang_ThreadGroup::ngroups(group_hdl()); |
1449 ngroups = java_lang_ThreadGroup::ngroups(group_hdl()); |
1455 |
1450 |
1456 if (nthreads > 0) { |
1451 if (nthreads > 0) { |
1457 ThreadsListHandle tlh(current_thread); |
1452 ThreadsListHandle tlh(current_thread); |
1458 objArrayOop threads = java_lang_ThreadGroup::threads(group_hdl()); |
1453 objArrayOop threads = java_lang_ThreadGroup::threads(group_hdl()); |
1459 assert(nthreads <= threads->length(), "too many threads"); |
1454 assert(nthreads <= threads->length(), "too many threads"); |
1460 thread_objs = NEW_RESOURCE_ARRAY(Handle,nthreads); |
1455 thread_objs = NEW_RESOURCE_ARRAY(Handle,nthreads); |
1461 for (int i=0, j=0; i<nthreads; i++) { |
1456 for (int i = 0, j = 0; i < nthreads; i++) { |
1462 oop thread_obj = threads->obj_at(i); |
1457 oop thread_obj = threads->obj_at(i); |
1463 assert(thread_obj != NULL, "thread_obj is NULL"); |
1458 assert(thread_obj != NULL, "thread_obj is NULL"); |
1464 JavaThread *java_thread = NULL; |
1459 JavaThread *java_thread = NULL; |
1465 jvmtiError err = JvmtiExport::cv_oop_to_JavaThread(tlh.list(), thread_obj, &java_thread); |
1460 jvmtiError err = JvmtiExport::cv_oop_to_JavaThread(tlh.list(), thread_obj, &java_thread); |
1466 if (err == JVMTI_ERROR_NONE) { |
1461 if (err == JVMTI_ERROR_NONE) { |
1488 |
1483 |
1489 if (ngroups > 0) { |
1484 if (ngroups > 0) { |
1490 objArrayOop groups = java_lang_ThreadGroup::groups(group_hdl()); |
1485 objArrayOop groups = java_lang_ThreadGroup::groups(group_hdl()); |
1491 assert(ngroups <= groups->length(), "too many groups"); |
1486 assert(ngroups <= groups->length(), "too many groups"); |
1492 group_objs = NEW_RESOURCE_ARRAY(Handle,ngroups); |
1487 group_objs = NEW_RESOURCE_ARRAY(Handle,ngroups); |
1493 for (int i=0; i<ngroups; i++) { |
1488 for (int i = 0; i < ngroups; i++) { |
1494 oop group_obj = groups->obj_at(i); |
1489 oop group_obj = groups->obj_at(i); |
1495 assert(group_obj != NULL, "group_obj != NULL"); |
1490 assert(group_obj != NULL, "group_obj != NULL"); |
1496 group_objs[i] = Handle(current_thread, group_obj); |
1491 group_objs[i] = Handle(current_thread, group_obj); |
1497 } |
1492 } |
1498 } |
1493 } |
1499 } |
1494 } // ThreadGroup unlocked here |
1500 |
1495 |
1501 // have to make global handles outside of Threads_lock |
|
1502 *group_count_ptr = ngroups; |
1496 *group_count_ptr = ngroups; |
1503 *thread_count_ptr = nthreads; |
1497 *thread_count_ptr = nthreads; |
1504 *threads_ptr = new_jthreadArray(nthreads, thread_objs); |
1498 *threads_ptr = new_jthreadArray(nthreads, thread_objs); |
1505 *groups_ptr = new_jthreadGroupArray(ngroups, group_objs); |
1499 *groups_ptr = new_jthreadGroupArray(ngroups, group_objs); |
1506 if ((nthreads > 0) && (*threads_ptr == NULL)) { |
1500 if ((nthreads > 0) && (*threads_ptr == NULL)) { |
3244 // "delete monitor" call below can work without an assertion |
3238 // "delete monitor" call below can work without an assertion |
3245 // failure on systems that don't like destroying synchronization |
3239 // failure on systems that don't like destroying synchronization |
3246 // objects that are locked. |
3240 // objects that are locked. |
3247 int r; |
3241 int r; |
3248 intptr_t recursion = rmonitor->recursions(); |
3242 intptr_t recursion = rmonitor->recursions(); |
3249 for (intptr_t i=0; i <= recursion; i++) { |
3243 for (intptr_t i = 0; i <= recursion; i++) { |
3250 r = rmonitor->raw_exit(thread); |
3244 r = rmonitor->raw_exit(thread); |
3251 assert(r == ObjectMonitor::OM_OK, "raw_exit should have worked"); |
3245 assert(r == ObjectMonitor::OM_OK, "raw_exit should have worked"); |
3252 if (r != ObjectMonitor::OM_OK) { // robustness |
3246 if (r != ObjectMonitor::OM_OK) { // robustness |
3253 return JVMTI_ERROR_INTERNAL; |
3247 return JVMTI_ERROR_INTERNAL; |
3254 } |
3248 } |
3674 err = allocate((strlen(key)+1) * sizeof(char), (unsigned char**)tmp_value); |
3668 err = allocate((strlen(key)+1) * sizeof(char), (unsigned char**)tmp_value); |
3675 if (err == JVMTI_ERROR_NONE) { |
3669 if (err == JVMTI_ERROR_NONE) { |
3676 strcpy(*tmp_value, key); |
3670 strcpy(*tmp_value, key); |
3677 } else { |
3671 } else { |
3678 // clean up previously allocated memory. |
3672 // clean up previously allocated memory. |
3679 for (int j=0; j<readable_count; j++) { |
3673 for (int j = 0; j < readable_count; j++) { |
3680 Deallocate((unsigned char*)*property_ptr+j); |
3674 Deallocate((unsigned char*)*property_ptr+j); |
3681 } |
3675 } |
3682 Deallocate((unsigned char*)property_ptr); |
3676 Deallocate((unsigned char*)property_ptr); |
3683 break; |
3677 break; |
3684 } |
3678 } |