src/share/vm/services/attachListener.cpp

changeset 9313
fd0ca2c1433b
parent 8658
f8a5d01c0929
child 9448
73d689add964
equal deleted inserted replaced
9312:9d85c3e90648 9313:fd0ca2c1433b
464 // operation complete - send result and output to client 464 // operation complete - send result and output to client
465 op->complete(res, &st); 465 op->complete(res, &st);
466 } 466 }
467 } 467 }
468 468
469 bool AttachListener::has_init_error(TRAPS) {
470 if (HAS_PENDING_EXCEPTION) {
471 tty->print_cr("Exception in VM (AttachListener::init) : ");
472 java_lang_Throwable::print(PENDING_EXCEPTION, tty);
473 tty->cr();
474
475 CLEAR_PENDING_EXCEPTION;
476
477 return true;
478 } else {
479 return false;
480 }
481 }
482
469 // Starts the Attach Listener thread 483 // Starts the Attach Listener thread
470 void AttachListener::init() { 484 void AttachListener::init() {
471 EXCEPTION_MARK; 485 EXCEPTION_MARK;
472 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK); 486 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, THREAD);
487 if (has_init_error(THREAD)) {
488 return;
489 }
490
473 instanceKlassHandle klass (THREAD, k); 491 instanceKlassHandle klass (THREAD, k);
474 instanceHandle thread_oop = klass->allocate_instance_handle(CHECK); 492 instanceHandle thread_oop = klass->allocate_instance_handle(THREAD);
493 if (has_init_error(THREAD)) {
494 return;
495 }
475 496
476 const char thread_name[] = "Attach Listener"; 497 const char thread_name[] = "Attach Listener";
477 Handle string = java_lang_String::create_from_str(thread_name, CHECK); 498 Handle string = java_lang_String::create_from_str(thread_name, THREAD);
499 if (has_init_error(THREAD)) {
500 return;
501 }
478 502
479 // Initialize thread_oop to put it into the system threadGroup 503 // Initialize thread_oop to put it into the system threadGroup
480 Handle thread_group (THREAD, Universe::system_thread_group()); 504 Handle thread_group (THREAD, Universe::system_thread_group());
481 JavaValue result(T_VOID); 505 JavaValue result(T_VOID);
482 JavaCalls::call_special(&result, thread_oop, 506 JavaCalls::call_special(&result, thread_oop,
485 vmSymbols::threadgroup_string_void_signature(), 509 vmSymbols::threadgroup_string_void_signature(),
486 thread_group, 510 thread_group,
487 string, 511 string,
488 THREAD); 512 THREAD);
489 513
490 if (HAS_PENDING_EXCEPTION) { 514 if (has_init_error(THREAD)) {
491 tty->print_cr("Exception in VM (AttachListener::init) : ");
492 java_lang_Throwable::print(PENDING_EXCEPTION, tty);
493 tty->cr();
494
495 CLEAR_PENDING_EXCEPTION;
496
497 return; 515 return;
498 } 516 }
499 517
500 KlassHandle group(THREAD, SystemDictionary::ThreadGroup_klass()); 518 KlassHandle group(THREAD, SystemDictionary::ThreadGroup_klass());
501 JavaCalls::call_special(&result, 519 JavaCalls::call_special(&result,
503 group, 521 group,
504 vmSymbols::add_method_name(), 522 vmSymbols::add_method_name(),
505 vmSymbols::thread_void_signature(), 523 vmSymbols::thread_void_signature(),
506 thread_oop, // ARG 1 524 thread_oop, // ARG 1
507 THREAD); 525 THREAD);
508 526 if (has_init_error(THREAD)) {
509 if (HAS_PENDING_EXCEPTION) {
510 tty->print_cr("Exception in VM (AttachListener::init) : ");
511 java_lang_Throwable::print(PENDING_EXCEPTION, tty);
512 tty->cr();
513
514 CLEAR_PENDING_EXCEPTION;
515
516 return; 527 return;
517 } 528 }
518 529
519 { MutexLocker mu(Threads_lock); 530 { MutexLocker mu(Threads_lock);
520 JavaThread* listener_thread = new JavaThread(&attach_listener_thread_entry); 531 JavaThread* listener_thread = new JavaThread(&attach_listener_thread_entry);

mercurial