< prev index next >

src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java

Print this page
rev 47329 : 8189102: All tools should support -?, -h and --help


  46         if (args.length == 0) {
  47             usage(1); // no arguments
  48         }
  49         checkForUnsupportedOptions(args);
  50 
  51         boolean doFlag = false;
  52         boolean doFlags = false;
  53         boolean doSysprops = false;
  54         int flag = -1;
  55 
  56         // Parse the options (arguments starting with "-" )
  57         int optionCount = 0;
  58         while (optionCount < args.length) {
  59             String arg = args[optionCount];
  60             if (!arg.startsWith("-")) {
  61                 break;
  62             }
  63 
  64             optionCount++;
  65 
  66             if (arg.equals("-help") || arg.equals("-h")) {

  67                 usage(0);
  68             }
  69 
  70             if (arg.equals("-flag")) {
  71                 doFlag = true;
  72                 // Consume the flag
  73                 if (optionCount < args.length) {
  74                     flag = optionCount++;
  75                     break;
  76                 }
  77                 usage(1);
  78             }
  79 
  80             if (arg.equals("-flags")) {
  81                 doFlags = true;
  82                 break;
  83             }
  84 
  85             if (arg.equals("-sysprops")) {
  86                 doSysprops = true;


 238 
 239     private static void SAOptionError(String msg) {
 240         System.err.println("Error: " + msg);
 241         System.err.println("Cannot connect to core dump or remote debug server. Use jhsdb jinfo instead");
 242         System.exit(1);
 243     }
 244 
 245      // print usage message
 246     private static void usage(int exit) {
 247         System.err.println("Usage:");
 248         System.err.println("    jinfo <option> <pid>");
 249         System.err.println("       (to connect to a running process)");
 250         System.err.println("");
 251         System.err.println("where <option> is one of:");
 252         System.err.println("    -flag <name>         to print the value of the named VM flag");
 253         System.err.println("    -flag [+|-]<name>    to enable or disable the named VM flag");
 254         System.err.println("    -flag <name>=<value> to set the named VM flag to the given value");
 255         System.err.println("    -flags               to print VM flags");
 256         System.err.println("    -sysprops            to print Java system properties");
 257         System.err.println("    <no option>          to print both VM flags and system properties");
 258         System.err.println("    -h | -help           to print this help message");
 259         System.exit(exit);
 260     }
 261 }


  46         if (args.length == 0) {
  47             usage(1); // no arguments
  48         }
  49         checkForUnsupportedOptions(args);
  50 
  51         boolean doFlag = false;
  52         boolean doFlags = false;
  53         boolean doSysprops = false;
  54         int flag = -1;
  55 
  56         // Parse the options (arguments starting with "-" )
  57         int optionCount = 0;
  58         while (optionCount < args.length) {
  59             String arg = args[optionCount];
  60             if (!arg.startsWith("-")) {
  61                 break;
  62             }
  63 
  64             optionCount++;
  65 
  66             // -help: legacy. Undocumented.
  67             if (arg.equals("-?") || arg.equals("-h") || arg.equals("--help") || arg.equals("-help")) {
  68                 usage(0);
  69             }
  70 
  71             if (arg.equals("-flag")) {
  72                 doFlag = true;
  73                 // Consume the flag
  74                 if (optionCount < args.length) {
  75                     flag = optionCount++;
  76                     break;
  77                 }
  78                 usage(1);
  79             }
  80 
  81             if (arg.equals("-flags")) {
  82                 doFlags = true;
  83                 break;
  84             }
  85 
  86             if (arg.equals("-sysprops")) {
  87                 doSysprops = true;


 239 
 240     private static void SAOptionError(String msg) {
 241         System.err.println("Error: " + msg);
 242         System.err.println("Cannot connect to core dump or remote debug server. Use jhsdb jinfo instead");
 243         System.exit(1);
 244     }
 245 
 246      // print usage message
 247     private static void usage(int exit) {
 248         System.err.println("Usage:");
 249         System.err.println("    jinfo <option> <pid>");
 250         System.err.println("       (to connect to a running process)");
 251         System.err.println("");
 252         System.err.println("where <option> is one of:");
 253         System.err.println("    -flag <name>         to print the value of the named VM flag");
 254         System.err.println("    -flag [+|-]<name>    to enable or disable the named VM flag");
 255         System.err.println("    -flag <name>=<value> to set the named VM flag to the given value");
 256         System.err.println("    -flags               to print VM flags");
 257         System.err.println("    -sysprops            to print Java system properties");
 258         System.err.println("    <no option>          to print both VM flags and system properties");
 259         System.err.println("    -? | -h | --help     to print this help message");
 260         System.exit(exit);
 261     }
 262 }
< prev index next >