1 /*
   2  * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc_implementation/shared/vmGCOperations.hpp"
  27 #include "runtime/javaCalls.hpp"
  28 #include "services/diagnosticArgument.hpp"
  29 #include "services/diagnosticCommand.hpp"
  30 #include "services/diagnosticFramework.hpp"
  31 #include "services/heapDumper.hpp"
  32 #include "services/management.hpp"
  33 
  34 void DCmdRegistrant::register_dcmds(){
  35   // Registration of the diagnostic commands
  36   // First boolean argument specifies if the command is enabled
  37   // Second boolean argument specifies if the command is hidden
  38   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HelpDCmd>(true, false));
  39   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VersionDCmd>(true, false));
  40   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<CommandLineDCmd>(true, false));
  41   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintSystemPropertiesDCmd>(true, false));
  42   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<PrintVMFlagsDCmd>(true, false));
  43   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<VMUptimeDCmd>(true, false));
  44   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<SystemGCDCmd>(true, false));
  45   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RunFinalizationDCmd>(true, false));
  46 #if INCLUDE_SERVICES // Heap dumping/inspection supported
  47   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<HeapDumpDCmd>(true, false));
  48   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(true, false));
  49   if (UnlockDiagnosticVMOptions) {
  50     DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassStatsDCmd>(true, false));
  51   }
  52 #endif // INCLUDE_SERVICES
  53   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(true, false));
  54   //Enhanced JMX Agent Support
  55   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(true,false));
  56   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(true,false));
  57   DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(true,false));
  58 
  59 }
  60 
  61 #ifndef HAVE_EXTRA_DCMD
  62 void DCmdRegistrant::register_dcmds_ext(){
  63    // Do nothing here
  64 }
  65 #endif
  66 
  67 
  68 HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),
  69   _all("-all", "Show help for all commands", "BOOLEAN", false, "false"),
  70   _cmd("command name", "The name of the command for which we want help",
  71         "STRING", false) {
  72   _dcmdparser.add_dcmd_option(&_all);
  73   _dcmdparser.add_dcmd_argument(&_cmd);
  74 };
  75 
  76 void HelpDCmd::execute(TRAPS) {
  77   if (_all.value()) {
  78     GrowableArray<const char*>* cmd_list = DCmdFactory::DCmd_list();
  79     for (int i = 0; i < cmd_list->length(); i++) {
  80       DCmdFactory* factory = DCmdFactory::factory(cmd_list->at(i),
  81                                                   strlen(cmd_list->at(i)));
  82       if (!factory->is_hidden()) {
  83         output()->print_cr("%s%s", factory->name(),
  84                            factory->is_enabled() ? "" : " [disabled]");
  85         output()->print_cr("\t%s", factory->description());
  86         output()->cr();
  87       }
  88       factory = factory->next();
  89     }
  90   } else if (_cmd.has_value()) {
  91     DCmd* cmd = NULL;
  92     DCmdFactory* factory = DCmdFactory::factory(_cmd.value(),
  93                                                 strlen(_cmd.value()));
  94     if (factory != NULL) {
  95       output()->print_cr("%s%s", factory->name(),
  96                          factory->is_enabled() ? "" : " [disabled]");
  97       output()->print_cr(factory->description());
  98       output()->print_cr("\nImpact: %s", factory->impact());
  99       output()->cr();
 100       cmd = factory->create_resource_instance(output());
 101       if (cmd != NULL) {
 102         DCmdMark mark(cmd);
 103         cmd->print_help(factory->name());
 104       }
 105     } else {
 106       output()->print_cr("Help unavailable : '%s' : No such command", _cmd.value());
 107     }
 108   } else {
 109     output()->print_cr("The following commands are available:");
 110     GrowableArray<const char *>* cmd_list = DCmdFactory::DCmd_list();
 111     for (int i = 0; i < cmd_list->length(); i++) {
 112       DCmdFactory* factory = DCmdFactory::factory(cmd_list->at(i),
 113                                                   strlen(cmd_list->at(i)));
 114       if (!factory->is_hidden()) {
 115         output()->print_cr("%s%s", factory->name(),
 116                            factory->is_enabled() ? "" : " [disabled]");
 117       }
 118       factory = factory->_next;
 119     }
 120     output()->print_cr("\nFor more information about a specific command use 'help <command>'.");
 121   }
 122 }
 123 
 124 int HelpDCmd::num_arguments() {
 125   ResourceMark rm;
 126   HelpDCmd* dcmd = new HelpDCmd(NULL, false);
 127   if (dcmd != NULL) {
 128     DCmdMark mark(dcmd);
 129     return dcmd->_dcmdparser.num_arguments();
 130   } else {
 131     return 0;
 132   }
 133 }
 134 
 135 void VersionDCmd::execute(TRAPS) {
 136   output()->print_cr("%s version %s", Abstract_VM_Version::vm_name(),
 137           Abstract_VM_Version::vm_release());
 138   JDK_Version jdk_version = JDK_Version::current();
 139   if (jdk_version.update_version() > 0) {
 140     output()->print_cr("JDK %d.%d_%02d", jdk_version.major_version(),
 141             jdk_version.minor_version(), jdk_version.update_version());
 142   } else {
 143     output()->print_cr("JDK %d.%d", jdk_version.major_version(),
 144             jdk_version.minor_version());
 145   }
 146 }
 147 
 148 PrintVMFlagsDCmd::PrintVMFlagsDCmd(outputStream* output, bool heap) :
 149                                    DCmdWithParser(output, heap),
 150   _all("-all", "Print all flags supported by the VM", "BOOLEAN", false, "false") {
 151   _dcmdparser.add_dcmd_option(&_all);
 152 }
 153 
 154 void PrintVMFlagsDCmd::execute(TRAPS) {
 155   if (_all.value()) {
 156     CommandLineFlags::printFlags(output(), true);
 157   } else {
 158     CommandLineFlags::printSetFlags(output());
 159   }
 160 }
 161 
 162 int PrintVMFlagsDCmd::num_arguments() {
 163     ResourceMark rm;
 164     PrintVMFlagsDCmd* dcmd = new PrintVMFlagsDCmd(NULL, false);
 165     if (dcmd != NULL) {
 166       DCmdMark mark(dcmd);
 167       return dcmd->_dcmdparser.num_arguments();
 168     } else {
 169       return 0;
 170     }
 171 }
 172 
 173 void PrintSystemPropertiesDCmd::execute(TRAPS) {
 174   // load sun.misc.VMSupport
 175   Symbol* klass = vmSymbols::sun_misc_VMSupport();
 176   Klass* k = SystemDictionary::resolve_or_fail(klass, true, CHECK);
 177   instanceKlassHandle ik (THREAD, k);
 178   if (ik->should_be_initialized()) {
 179     ik->initialize(THREAD);
 180   }
 181   if (HAS_PENDING_EXCEPTION) {
 182     java_lang_Throwable::print(PENDING_EXCEPTION, output());
 183     output()->cr();
 184     CLEAR_PENDING_EXCEPTION;
 185     return;
 186   }
 187 
 188   // invoke the serializePropertiesToByteArray method
 189   JavaValue result(T_OBJECT);
 190   JavaCallArguments args;
 191 
 192   Symbol* signature = vmSymbols::serializePropertiesToByteArray_signature();
 193   JavaCalls::call_static(&result,
 194                          ik,
 195                          vmSymbols::serializePropertiesToByteArray_name(),
 196                          signature,
 197                          &args,
 198                          THREAD);
 199   if (HAS_PENDING_EXCEPTION) {
 200     java_lang_Throwable::print(PENDING_EXCEPTION, output());
 201     output()->cr();
 202     CLEAR_PENDING_EXCEPTION;
 203     return;
 204   }
 205 
 206   // The result should be a [B
 207   oop res = (oop)result.get_jobject();
 208   assert(res->is_typeArray(), "just checking");
 209   assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking");
 210 
 211   // copy the bytes to the output stream
 212   typeArrayOop ba = typeArrayOop(res);
 213   jbyte* addr = typeArrayOop(res)->byte_at_addr(0);
 214   output()->print_raw((const char*)addr, ba->length());
 215 }
 216 
 217 VMUptimeDCmd::VMUptimeDCmd(outputStream* output, bool heap) :
 218                            DCmdWithParser(output, heap),
 219   _date("-date", "Add a prefix with current date", "BOOLEAN", false, "false") {
 220   _dcmdparser.add_dcmd_option(&_date);
 221 }
 222 
 223 void VMUptimeDCmd::execute(TRAPS) {
 224   if (_date.value()) {
 225     output()->date_stamp(true, "", ": ");
 226   }
 227   output()->time_stamp().update_to(tty->time_stamp().ticks());
 228   output()->stamp();
 229   output()->print_cr(" s");
 230 }
 231 
 232 int VMUptimeDCmd::num_arguments() {
 233   ResourceMark rm;
 234   VMUptimeDCmd* dcmd = new VMUptimeDCmd(NULL, false);
 235   if (dcmd != NULL) {
 236     DCmdMark mark(dcmd);
 237     return dcmd->_dcmdparser.num_arguments();
 238   } else {
 239     return 0;
 240   }
 241 }
 242 
 243 void SystemGCDCmd::execute(TRAPS) {
 244   Universe::heap()->collect(GCCause::_java_lang_system_gc);
 245 }
 246 
 247 void RunFinalizationDCmd::execute(TRAPS) {
 248   Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(),
 249                                                  true, CHECK);
 250   instanceKlassHandle klass(THREAD, k);
 251   JavaValue result(T_VOID);
 252   JavaCalls::call_static(&result, klass,
 253                          vmSymbols::run_finalization_name(),
 254                          vmSymbols::void_method_signature(), CHECK);
 255 }
 256 
 257 #if INCLUDE_SERVICES // Heap dumping/inspection supported
 258 HeapDumpDCmd::HeapDumpDCmd(outputStream* output, bool heap) :
 259                            DCmdWithParser(output, heap),
 260   _filename("filename","Name of the dump file", "STRING",true),
 261   _all("-all", "Dump all objects, including unreachable objects",
 262        "BOOLEAN", false, "false") {
 263   _dcmdparser.add_dcmd_option(&_all);
 264   _dcmdparser.add_dcmd_argument(&_filename);
 265 }
 266 
 267 void HeapDumpDCmd::execute(TRAPS) {
 268   // Request a full GC before heap dump if _all is false
 269   // This helps reduces the amount of unreachable objects in the dump
 270   // and makes it easier to browse.
 271   HeapDumper dumper(!_all.value() /* request GC if _all is false*/);
 272   int res = dumper.dump(_filename.value());
 273   if (res == 0) {
 274     output()->print_cr("Heap dump file created");
 275   } else {
 276     // heap dump failed
 277     ResourceMark rm;
 278     char* error = dumper.error_as_C_string();
 279     if (error == NULL) {
 280       output()->print_cr("Dump failed - reason unknown");
 281     } else {
 282       output()->print_cr("%s", error);
 283     }
 284   }
 285 }
 286 
 287 int HeapDumpDCmd::num_arguments() {
 288   ResourceMark rm;
 289   HeapDumpDCmd* dcmd = new HeapDumpDCmd(NULL, false);
 290   if (dcmd != NULL) {
 291     DCmdMark mark(dcmd);
 292     return dcmd->_dcmdparser.num_arguments();
 293   } else {
 294     return 0;
 295   }
 296 }
 297 
 298 ClassHistogramDCmd::ClassHistogramDCmd(outputStream* output, bool heap) :
 299                                        DCmdWithParser(output, heap),
 300   _all("-all", "Inspect all objects, including unreachable objects",
 301        "BOOLEAN", false, "false") {
 302   _dcmdparser.add_dcmd_option(&_all);
 303 }
 304 
 305 void ClassHistogramDCmd::execute(TRAPS) {
 306   VM_GC_HeapInspection heapop(output(),
 307                               !_all.value() /* request full gc if false */,
 308                               true /* need_prologue */);
 309   VMThread::execute(&heapop);
 310 }
 311 
 312 int ClassHistogramDCmd::num_arguments() {
 313   ResourceMark rm;
 314   ClassHistogramDCmd* dcmd = new ClassHistogramDCmd(NULL, false);
 315   if (dcmd != NULL) {
 316     DCmdMark mark(dcmd);
 317     return dcmd->_dcmdparser.num_arguments();
 318   } else {
 319     return 0;
 320   }
 321 }
 322 
 323 #define DEFAULT_COLUMNS "InstBytes,KlassBytes,CpAll,annotations,MethodCount,Bytecodes,MethodAll,ROAll,RWAll,Total"
 324 ClassStatsDCmd::ClassStatsDCmd(outputStream* output, bool heap) :
 325                                        DCmdWithParser(output, heap),
 326   _csv("-csv", "Print in CSV (comma-separated values) format for spreadsheets",
 327        "BOOLEAN", false, "false"),
 328   _all("-all", "Show all columns",
 329        "BOOLEAN", false, "false"),
 330   _help("-help", "Show meaning of all the columns",
 331        "BOOLEAN", false, "false"),
 332   _columns("columns", "Comma-separated list of all the columns to show. "
 333            "If not specified, the following columns are shown: " DEFAULT_COLUMNS,
 334            "STRING", false) {
 335   _dcmdparser.add_dcmd_option(&_all);
 336   _dcmdparser.add_dcmd_option(&_csv);
 337   _dcmdparser.add_dcmd_option(&_help);
 338   _dcmdparser.add_dcmd_argument(&_columns);
 339 }
 340 
 341 void ClassStatsDCmd::execute(TRAPS) {
 342   VM_GC_HeapInspection heapop(output(),
 343                               true, /* request_full_gc */
 344                               true /* need_prologue */);
 345   heapop.set_csv_format(_csv.value());
 346   heapop.set_print_help(_help.value());
 347   heapop.set_print_class_stats(true);
 348   if (_all.value()) {
 349     if (_columns.has_value()) {
 350       output()->print_cr("Cannot specify -all and individual columns at the same time");
 351       return;
 352     } else {
 353       heapop.set_columns(NULL);
 354     }
 355   } else {
 356     if (_columns.has_value()) {
 357       heapop.set_columns(_columns.value());
 358     } else {
 359       heapop.set_columns(DEFAULT_COLUMNS);
 360     }
 361   }
 362   VMThread::execute(&heapop);
 363 }
 364 
 365 int ClassStatsDCmd::num_arguments() {
 366   ResourceMark rm;
 367   ClassStatsDCmd* dcmd = new ClassStatsDCmd(NULL, false);
 368   if (dcmd != NULL) {
 369     DCmdMark mark(dcmd);
 370     return dcmd->_dcmdparser.num_arguments();
 371   } else {
 372     return 0;
 373   }
 374 }
 375 #endif // INCLUDE_SERVICES
 376 
 377 ThreadDumpDCmd::ThreadDumpDCmd(outputStream* output, bool heap) :
 378                                DCmdWithParser(output, heap),
 379   _locks("-l", "print java.util.concurrent locks", "BOOLEAN", false, "false") {
 380   _dcmdparser.add_dcmd_option(&_locks);
 381 }
 382 
 383 void ThreadDumpDCmd::execute(TRAPS) {
 384   // thread stacks
 385   VM_PrintThreads op1(output(), _locks.value());
 386   VMThread::execute(&op1);
 387 
 388   // JNI global handles
 389   VM_PrintJNI op2(output());
 390   VMThread::execute(&op2);
 391 
 392   // Deadlock detection
 393   VM_FindDeadlocks op3(output());
 394   VMThread::execute(&op3);
 395 }
 396 
 397 int ThreadDumpDCmd::num_arguments() {
 398   ResourceMark rm;
 399   ThreadDumpDCmd* dcmd = new ThreadDumpDCmd(NULL, false);
 400   if (dcmd != NULL) {
 401     DCmdMark mark(dcmd);
 402     return dcmd->_dcmdparser.num_arguments();
 403   } else {
 404     return 0;
 405   }
 406 }
 407 
 408 // Enhanced JMX Agent support
 409 
 410 JMXStartRemoteDCmd::JMXStartRemoteDCmd(outputStream *output, bool heap_allocated) :
 411 
 412   DCmdWithParser(output, heap_allocated),
 413 
 414   _config_file
 415   ("config.file",
 416    "set com.sun.management.config.file", "STRING", false),
 417 
 418   _jmxremote_port
 419   ("jmxremote.port",
 420    "set com.sun.management.jmxremote.port", "STRING", false),
 421 
 422   _jmxremote_rmi_port
 423   ("jmxremote.rmi.port",
 424    "set com.sun.management.jmxremote.rmi.port", "STRING", false),
 425 
 426   _jmxremote_ssl
 427   ("jmxremote.ssl",
 428    "set com.sun.management.jmxremote.ssl", "STRING", false),
 429 
 430   _jmxremote_registry_ssl
 431   ("jmxremote.registry.ssl",
 432    "set com.sun.management.jmxremote.registry.ssl", "STRING", false),
 433 
 434   _jmxremote_authenticate
 435   ("jmxremote.authenticate",
 436    "set com.sun.management.jmxremote.authenticate", "STRING", false),
 437 
 438   _jmxremote_password_file
 439   ("jmxremote.password.file",
 440    "set com.sun.management.jmxremote.password.file", "STRING", false),
 441 
 442   _jmxremote_access_file
 443   ("jmxremote.access.file",
 444    "set com.sun.management.jmxremote.access.file", "STRING", false),
 445 
 446   _jmxremote_login_config
 447   ("jmxremote.login.config",
 448    "set com.sun.management.jmxremote.login.config", "STRING", false),
 449 
 450   _jmxremote_ssl_enabled_cipher_suites
 451   ("jmxremote.ssl.enabled.cipher.suites",
 452    "set com.sun.management.jmxremote.ssl.enabled.cipher.suite", "STRING", false),
 453 
 454   _jmxremote_ssl_enabled_protocols
 455   ("jmxremote.ssl.enabled.protocols",
 456    "set com.sun.management.jmxremote.ssl.enabled.protocols", "STRING", false),
 457 
 458   _jmxremote_ssl_need_client_auth
 459   ("jmxremote.ssl.need.client.auth",
 460    "set com.sun.management.jmxremote.need.client.auth", "STRING", false),
 461 
 462   _jmxremote_ssl_config_file
 463   ("jmxremote.ssl.config.file",
 464    "set com.sun.management.jmxremote.ssl_config_file", "STRING", false)
 465 
 466   {
 467     _dcmdparser.add_dcmd_option(&_config_file);
 468     _dcmdparser.add_dcmd_option(&_jmxremote_port);
 469     _dcmdparser.add_dcmd_option(&_jmxremote_rmi_port);
 470     _dcmdparser.add_dcmd_option(&_jmxremote_ssl);
 471     _dcmdparser.add_dcmd_option(&_jmxremote_registry_ssl);
 472     _dcmdparser.add_dcmd_option(&_jmxremote_authenticate);
 473     _dcmdparser.add_dcmd_option(&_jmxremote_password_file);
 474     _dcmdparser.add_dcmd_option(&_jmxremote_access_file);
 475     _dcmdparser.add_dcmd_option(&_jmxremote_login_config);
 476     _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_cipher_suites);
 477     _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_protocols);
 478     _dcmdparser.add_dcmd_option(&_jmxremote_ssl_need_client_auth);
 479     _dcmdparser.add_dcmd_option(&_jmxremote_ssl_config_file);
 480 }
 481 
 482 
 483 int JMXStartRemoteDCmd::num_arguments() {
 484   ResourceMark rm;
 485   JMXStartRemoteDCmd* dcmd = new JMXStartRemoteDCmd(NULL, false);
 486   if (dcmd != NULL) {
 487     DCmdMark mark(dcmd);
 488     return dcmd->_dcmdparser.num_arguments();
 489   } else {
 490     return 0;
 491   }
 492 }
 493 
 494 
 495 void JMXStartRemoteDCmd::execute(TRAPS) {
 496     ResourceMark rm(THREAD);
 497     HandleMark hm(THREAD);
 498 
 499     // Load and initialize the sun.management.Agent class
 500     // invoke startRemoteManagementAgent(string) method to start
 501     // the remote management server.
 502     // throw java.lang.NoSuchMethodError if the method doesn't exist
 503 
 504     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
 505     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
 506     instanceKlassHandle ik (THREAD, k);
 507 
 508     JavaValue result(T_VOID);
 509 
 510     // Pass all command line arguments to java as key=value,...
 511     // All checks are done on java side
 512 
 513     int len = 0;
 514     stringStream options;
 515     char comma[2] = {0,0};
 516 
 517     // Leave default values on Agent.class side and pass only
 518     // agruments explicitly set by user. All arguments passed
 519     // to jcmd override properties with the same name set by
 520     // command line with -D or by managmenent.properties
 521     // file.
 522 #define PUT_OPTION(a) \
 523     if ( (a).is_set() ){ \
 524         options.print("%scom.sun.management.%s=%s", comma, (a).name(), (a).value()); \
 525         comma[0] = ','; \
 526     }
 527 
 528     PUT_OPTION(_config_file);
 529     PUT_OPTION(_jmxremote_port);
 530     PUT_OPTION(_jmxremote_rmi_port);
 531     PUT_OPTION(_jmxremote_ssl);
 532     PUT_OPTION(_jmxremote_registry_ssl);
 533     PUT_OPTION(_jmxremote_authenticate);
 534     PUT_OPTION(_jmxremote_password_file);
 535     PUT_OPTION(_jmxremote_access_file);
 536     PUT_OPTION(_jmxremote_login_config);
 537     PUT_OPTION(_jmxremote_ssl_enabled_cipher_suites);
 538     PUT_OPTION(_jmxremote_ssl_enabled_protocols);
 539     PUT_OPTION(_jmxremote_ssl_need_client_auth);
 540     PUT_OPTION(_jmxremote_ssl_config_file);
 541 
 542 #undef PUT_OPTION
 543 
 544     Handle str = java_lang_String::create_from_str(options.as_string(), CHECK);
 545     JavaCalls::call_static(&result, ik, vmSymbols::startRemoteAgent_name(), vmSymbols::string_void_signature(), str, CHECK);
 546 }
 547 
 548 JMXStartLocalDCmd::JMXStartLocalDCmd(outputStream *output, bool heap_allocated) :
 549   DCmd(output, heap_allocated)
 550 {
 551   // do nothing
 552 }
 553 
 554 void JMXStartLocalDCmd::execute(TRAPS) {
 555     ResourceMark rm(THREAD);
 556     HandleMark hm(THREAD);
 557 
 558     // Load and initialize the sun.management.Agent class
 559     // invoke startLocalManagementAgent(void) method to start
 560     // the local management server
 561     // throw java.lang.NoSuchMethodError if method doesn't exist
 562 
 563     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
 564     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
 565     instanceKlassHandle ik (THREAD, k);
 566 
 567     JavaValue result(T_VOID);
 568     JavaCalls::call_static(&result, ik, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK);
 569 }
 570 
 571 
 572 void JMXStopRemoteDCmd::execute(TRAPS) {
 573     ResourceMark rm(THREAD);
 574     HandleMark hm(THREAD);
 575 
 576     // Load and initialize the sun.management.Agent class
 577     // invoke stopRemoteManagementAgent method to stop the
 578     // management server
 579     // throw java.lang.NoSuchMethodError if method doesn't exist
 580 
 581     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
 582     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
 583     instanceKlassHandle ik (THREAD, k);
 584 
 585     JavaValue result(T_VOID);
 586     JavaCalls::call_static(&result, ik, vmSymbols::stopRemoteAgent_name(), vmSymbols::void_method_signature(), CHECK);
 587 }
 588