Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8203043

jcmd should output command list if no command is given

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 11
    • hotspot
    • None
    • svc
    • behavioral
    • minimal
    • None since using jcmd with VM id but without command was undefined behaviour before.
    • add/remove/modify command line option
    • JDK

      Summary

      jcmd should output command list if no command is given.

      Problem

      When jcmd is invoked with valid target VM id(s) but without command, the generic help text is output:

      ./images/jdk/bin/jcmd org.eclipse.equinox.launcher Error parsing arguments: No command specified

      Usage: jcmd or: jcmd -l
      or: jcmd -h

      In order to get the list of commands, one has to retype the command, preceeding the command name with "help":

      ./images/jdk/bin/jcmd help org.eclipse.equinox.launcher

      which involves moving the cursor back and loosing valuable seconds of your life.

      Solution

      When one or more VM ids are given, jcmd should connect to the VM(s) instead and print a list of available commands:

      ./images/jdk/bin/jcmd org.eclipse.equinox.launcher 8638: The following commands are available: VM.log VM.native_memory ManagementAgent.status ManagementAgent.stop ... VM.version help

      Where multiple VMs are affected, I'd like all of them to print out command lists.

      Specification

      src/jdk.jcmd/share/classes/sun/tools/jcmd/Arguments.java:

      @@ -86,11 +86,13 @@ sb.append(args[i]).append(" "); } }

           if (listCounters != true && sb.length() == 0) {

      - throw new IllegalArgumentException("No command specified"); + // Omitting the command shall cause the target VM to print out a list + // of available commands. + sb.append("help"); }

           command = sb.toString().trim();
       }

            stuefe Thomas Stuefe
            stuefe Thomas Stuefe
            Serguei Spitsyn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: