Mercurial > hg > truffle
comparison src/share/vm/services/attachListener.cpp @ 14909:4ca6dc0799b6
Backout jdk9 merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 01 Apr 2014 13:57:07 +0200 |
parents | ad3f8397fe37 |
children | 52b4284cb496 |
comparison
equal
deleted
inserted
replaced
14908:8db6e76cb658 | 14909:4ca6dc0799b6 |
---|---|
280 if (n != 1) { | 280 if (n != 1) { |
281 out->print_cr("flag value must be an unsigned integer"); | 281 out->print_cr("flag value must be an unsigned integer"); |
282 return JNI_ERR; | 282 return JNI_ERR; |
283 } | 283 } |
284 } | 284 } |
285 | |
286 if (strncmp(name, "MaxHeapFreeRatio", 17) == 0) { | |
287 FormatBuffer<80> err_msg(""); | |
288 if (!Arguments::verify_MaxHeapFreeRatio(err_msg, value)) { | |
289 out->print_cr(err_msg.buffer()); | |
290 return JNI_ERR; | |
291 } | |
292 } else if (strncmp(name, "MinHeapFreeRatio", 17) == 0) { | |
293 FormatBuffer<80> err_msg(""); | |
294 if (!Arguments::verify_MinHeapFreeRatio(err_msg, value)) { | |
295 out->print_cr(err_msg.buffer()); | |
296 return JNI_ERR; | |
297 } | |
298 } | |
299 bool res = CommandLineFlags::uintxAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND); | 285 bool res = CommandLineFlags::uintxAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND); |
300 if (! res) { | 286 if (! res) { |
301 out->print_cr("setting flag %s failed", name); | 287 out->print_cr("setting flag %s failed", name); |
302 } | 288 } |
303 | 289 |
463 // operation complete - send result and output to client | 449 // operation complete - send result and output to client |
464 op->complete(res, &st); | 450 op->complete(res, &st); |
465 } | 451 } |
466 } | 452 } |
467 | 453 |
468 bool AttachListener::has_init_error(TRAPS) { | |
469 if (HAS_PENDING_EXCEPTION) { | |
470 tty->print_cr("Exception in VM (AttachListener::init) : "); | |
471 java_lang_Throwable::print(PENDING_EXCEPTION, tty); | |
472 tty->cr(); | |
473 | |
474 CLEAR_PENDING_EXCEPTION; | |
475 | |
476 return true; | |
477 } else { | |
478 return false; | |
479 } | |
480 } | |
481 | |
482 // Starts the Attach Listener thread | 454 // Starts the Attach Listener thread |
483 void AttachListener::init() { | 455 void AttachListener::init() { |
484 EXCEPTION_MARK; | 456 EXCEPTION_MARK; |
485 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, THREAD); | 457 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK); |
486 if (has_init_error(THREAD)) { | |
487 return; | |
488 } | |
489 | |
490 instanceKlassHandle klass (THREAD, k); | 458 instanceKlassHandle klass (THREAD, k); |
491 instanceHandle thread_oop = klass->allocate_instance_handle(THREAD); | 459 instanceHandle thread_oop = klass->allocate_instance_handle(CHECK); |
492 if (has_init_error(THREAD)) { | |
493 return; | |
494 } | |
495 | 460 |
496 const char thread_name[] = "Attach Listener"; | 461 const char thread_name[] = "Attach Listener"; |
497 Handle string = java_lang_String::create_from_str(thread_name, THREAD); | 462 Handle string = java_lang_String::create_from_str(thread_name, CHECK); |
498 if (has_init_error(THREAD)) { | |
499 return; | |
500 } | |
501 | 463 |
502 // Initialize thread_oop to put it into the system threadGroup | 464 // Initialize thread_oop to put it into the system threadGroup |
503 Handle thread_group (THREAD, Universe::system_thread_group()); | 465 Handle thread_group (THREAD, Universe::system_thread_group()); |
504 JavaValue result(T_VOID); | 466 JavaValue result(T_VOID); |
505 JavaCalls::call_special(&result, thread_oop, | 467 JavaCalls::call_special(&result, thread_oop, |
508 vmSymbols::threadgroup_string_void_signature(), | 470 vmSymbols::threadgroup_string_void_signature(), |
509 thread_group, | 471 thread_group, |
510 string, | 472 string, |
511 THREAD); | 473 THREAD); |
512 | 474 |
513 if (has_init_error(THREAD)) { | 475 if (HAS_PENDING_EXCEPTION) { |
476 tty->print_cr("Exception in VM (AttachListener::init) : "); | |
477 java_lang_Throwable::print(PENDING_EXCEPTION, tty); | |
478 tty->cr(); | |
479 | |
480 CLEAR_PENDING_EXCEPTION; | |
481 | |
514 return; | 482 return; |
515 } | 483 } |
516 | 484 |
517 KlassHandle group(THREAD, SystemDictionary::ThreadGroup_klass()); | 485 KlassHandle group(THREAD, SystemDictionary::ThreadGroup_klass()); |
518 JavaCalls::call_special(&result, | 486 JavaCalls::call_special(&result, |
520 group, | 488 group, |
521 vmSymbols::add_method_name(), | 489 vmSymbols::add_method_name(), |
522 vmSymbols::thread_void_signature(), | 490 vmSymbols::thread_void_signature(), |
523 thread_oop, // ARG 1 | 491 thread_oop, // ARG 1 |
524 THREAD); | 492 THREAD); |
525 if (has_init_error(THREAD)) { | 493 |
494 if (HAS_PENDING_EXCEPTION) { | |
495 tty->print_cr("Exception in VM (AttachListener::init) : "); | |
496 java_lang_Throwable::print(PENDING_EXCEPTION, tty); | |
497 tty->cr(); | |
498 | |
499 CLEAR_PENDING_EXCEPTION; | |
500 | |
526 return; | 501 return; |
527 } | 502 } |
528 | 503 |
529 { MutexLocker mu(Threads_lock); | 504 { MutexLocker mu(Threads_lock); |
530 JavaThread* listener_thread = new JavaThread(&attach_listener_thread_entry); | 505 JavaThread* listener_thread = new JavaThread(&attach_listener_thread_entry); |
531 | 506 |
532 // Check that thread and osthread were created | 507 // Check that thread and osthread were created |
533 if (listener_thread == NULL || listener_thread->osthread() == NULL) { | 508 if (listener_thread == NULL || listener_thread->osthread() == NULL) { |
534 vm_exit_during_initialization("java.lang.OutOfMemoryError", | 509 vm_exit_during_initialization("java.lang.OutOfMemoryError", |
535 os::native_thread_creation_failed_msg()); | 510 "unable to create new native thread"); |
536 } | 511 } |
537 | 512 |
538 java_lang_Thread::set_thread(thread_oop(), listener_thread); | 513 java_lang_Thread::set_thread(thread_oop(), listener_thread); |
539 java_lang_Thread::set_daemon(thread_oop()); | 514 java_lang_Thread::set_daemon(thread_oop()); |
540 | 515 |