420 _dcmdparser.print_help(output(), name); 421 } 422 423 void DCmdWithParser::reset(TRAPS) { 424 _dcmdparser.reset(CHECK); 425 } 426 427 void DCmdWithParser::cleanup() { 428 _dcmdparser.cleanup(); 429 } 430 431 GrowableArray<const char*>* DCmdWithParser::argument_name_array() const { 432 return _dcmdparser.argument_name_array(); 433 } 434 435 GrowableArray<DCmdArgumentInfo*>* DCmdWithParser::argument_info_array() const { 436 return _dcmdparser.argument_info_array(); 437 } 438 439 void DCmdFactory::push_jmx_notification_request() { 440 MutexLocker ml(Service_lock, Mutex::_no_safepoint_check_flag); 441 _has_pending_jmx_notification = true; 442 Service_lock->notify_all(); 443 } 444 445 void DCmdFactory::send_notification(TRAPS) { 446 DCmdFactory::send_notification_internal(THREAD); 447 // Clearing pending exception to avoid premature termination of 448 // the service thread 449 if (HAS_PENDING_EXCEPTION) { 450 CLEAR_PENDING_EXCEPTION; 451 } 452 } 453 void DCmdFactory::send_notification_internal(TRAPS) { 454 ResourceMark rm(THREAD); 455 HandleMark hm(THREAD); 456 bool notif = false; 457 { 458 MutexLocker ml(Service_lock, Mutex::_no_safepoint_check_flag); 459 notif = _has_pending_jmx_notification; 460 _has_pending_jmx_notification = false; 461 } 462 if (notif) { 463 464 Klass* k = Management::com_sun_management_internal_DiagnosticCommandImpl_klass(CHECK); 465 InstanceKlass* dcmd_mbean_klass = InstanceKlass::cast(k); 466 467 JavaValue result(T_OBJECT); 468 JavaCalls::call_static(&result, 469 dcmd_mbean_klass, 470 vmSymbols::getDiagnosticCommandMBean_name(), 471 vmSymbols::getDiagnosticCommandMBean_signature(), 472 CHECK); 473 474 instanceOop m = (instanceOop) result.get_jobject(); 475 instanceHandle dcmd_mbean_h(THREAD, m); 476 477 if (!dcmd_mbean_h->is_a(k)) { 478 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), | 420 _dcmdparser.print_help(output(), name); 421 } 422 423 void DCmdWithParser::reset(TRAPS) { 424 _dcmdparser.reset(CHECK); 425 } 426 427 void DCmdWithParser::cleanup() { 428 _dcmdparser.cleanup(); 429 } 430 431 GrowableArray<const char*>* DCmdWithParser::argument_name_array() const { 432 return _dcmdparser.argument_name_array(); 433 } 434 435 GrowableArray<DCmdArgumentInfo*>* DCmdWithParser::argument_info_array() const { 436 return _dcmdparser.argument_info_array(); 437 } 438 439 void DCmdFactory::push_jmx_notification_request() { 440 MutexLocker ml(Notification_lock, Mutex::_no_safepoint_check_flag); 441 _has_pending_jmx_notification = true; 442 Notification_lock->notify_all(); 443 } 444 445 void DCmdFactory::send_notification(TRAPS) { 446 DCmdFactory::send_notification_internal(THREAD); 447 // Clearing pending exception to avoid premature termination of 448 // the service thread 449 if (HAS_PENDING_EXCEPTION) { 450 CLEAR_PENDING_EXCEPTION; 451 } 452 } 453 void DCmdFactory::send_notification_internal(TRAPS) { 454 ResourceMark rm(THREAD); 455 HandleMark hm(THREAD); 456 bool notif = false; 457 { 458 MutexLocker ml(Notification_lock, Mutex::_no_safepoint_check_flag); 459 notif = _has_pending_jmx_notification; 460 _has_pending_jmx_notification = false; 461 } 462 if (notif) { 463 464 Klass* k = Management::com_sun_management_internal_DiagnosticCommandImpl_klass(CHECK); 465 InstanceKlass* dcmd_mbean_klass = InstanceKlass::cast(k); 466 467 JavaValue result(T_OBJECT); 468 JavaCalls::call_static(&result, 469 dcmd_mbean_klass, 470 vmSymbols::getDiagnosticCommandMBean_name(), 471 vmSymbols::getDiagnosticCommandMBean_signature(), 472 CHECK); 473 474 instanceOop m = (instanceOop) result.get_jobject(); 475 instanceHandle dcmd_mbean_h(THREAD, m); 476 477 if (!dcmd_mbean_h->is_a(k)) { 478 THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), |