src/jdk.jcmd/share/classes/sun/tools/jstat/Arguments.java
changeset 48543 7067fe4e054e
parent 47216 71c04702a3d5
equal deleted inserted replaced
48542:19effb7970bc 48543:7067fe4e054e
     1 /*
     1 /*
     2  * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    71     private String vmIdString;
    71     private String vmIdString;
    72 
    72 
    73     private VmIdentifier vmId;
    73     private VmIdentifier vmId;
    74 
    74 
    75     public static void printUsage(PrintStream ps) {
    75     public static void printUsage(PrintStream ps) {
    76         ps.println("Usage: jstat -help|-options");
    76         ps.println("Usage: jstat --help|-options");
    77         ps.println("       jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]");
    77         ps.println("       jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]");
    78         ps.println();
    78         ps.println();
    79         ps.println("Definitions:");
    79         ps.println("Definitions:");
    80         ps.println("  <option>      An option reported by the -options option");
    80         ps.println("  <option>      An option reported by the -options option");
    81         ps.println("  <vmid>        Virtual Machine Identifier. A vmid takes the following form:");
    81         ps.println("  <vmid>        Virtual Machine Identifier. A vmid takes the following form:");
    91         ps.println("                    <n>[\"ms\"|\"s\"]");
    91         ps.println("                    <n>[\"ms\"|\"s\"]");
    92         ps.println("                Where <n> is an integer and the suffix specifies the units as ");
    92         ps.println("                Where <n> is an integer and the suffix specifies the units as ");
    93         ps.println("                milliseconds(\"ms\") or seconds(\"s\"). The default units are \"ms\".");
    93         ps.println("                milliseconds(\"ms\") or seconds(\"s\"). The default units are \"ms\".");
    94         ps.println("  <count>       Number of samples to take before terminating.");
    94         ps.println("  <count>       Number of samples to take before terminating.");
    95         ps.println("  -J<flag>      Pass <flag> directly to the runtime system.");
    95         ps.println("  -J<flag>      Pass <flag> directly to the runtime system.");
       
    96         ps.println("  -? -h --help  Prints this help message.");
       
    97         ps.println("  -help         Prints this help message.");
    96 
    98 
    97         // undocumented options:
    99         // undocumented options:
    98         //   -list [<vmid>]  - list counter names
   100         //   -list [<vmid>]  - list counter names
    99         //   -snap <vmid>    - snapshot counter values as name=value pairs
   101         //   -snap <vmid>    - snapshot counter values as name=value pairs
   100         //   -name <pattern> - output counters matching given pattern
   102         //   -name <pattern> - output counters matching given pattern
   101         //   -a              - sort in ascending order (default)
   103         //   -a              - sort in ascending order (default)
   102         //   -d              - sort in descending order
   104         //   -d              - sort in descending order
   103         //   -v              - verbose output  (-snap)
   105         //   -v              - verbose output  (-snap)
   104         //   -constants      - output constants with -name output
   106         //   -constants      - output constants with -name output
   105         //   -strings        - output strings with -name output
   107         //   -strings        - output strings with -name output
       
   108         //   -help           - same as -? ...
   106     }
   109     }
   107 
   110 
   108     private static int toMillis(String s) throws IllegalArgumentException {
   111     private static int toMillis(String s) throws IllegalArgumentException {
   109 
   112 
   110         String[] unitStrings = { "ms", "s" }; // ordered from most specific to
   113         String[] unitStrings = { "ms", "s" }; // ordered from most specific to
   145             help = true;
   148             help = true;
   146             return;
   149             return;
   147         }
   150         }
   148 
   151 
   149         if ((args[0].compareTo("-?") == 0)
   152         if ((args[0].compareTo("-?") == 0)
       
   153                 || (args[0].compareTo("-h") == 0)
       
   154                 || (args[0].compareTo("--help") == 0)
       
   155                 // -help: legacy.
   150                 || (args[0].compareTo("-help") == 0)) {
   156                 || (args[0].compareTo("-help") == 0)) {
   151             help = true;
   157             help = true;
   152             return;
   158             return;
   153         } else if (args[0].compareTo("-options") == 0) {
   159         } else if (args[0].compareTo("-options") == 0) {
   154             options = true;
   160             options = true;