changeset 48544:7067fe4e054e

8189102: All tools should support -?, -h and --help Reviewed-by: kvn, jjg, weijun, alanb, rfield, ksrini
author goetz
date Tue, 16 Jan 2018 08:48:34 +0100
parents 19effb7970bc
children 050352ed64d5 36a1966132aa
files src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java src/java.base/share/classes/com/sun/java/util/jar/pack/DriverResource.java src/java.base/share/classes/sun/security/tools/keytool/Main.java src/java.base/share/classes/sun/security/tools/keytool/Resources.java src/java.rmi/share/classes/sun/rmi/server/resources/rmid.properties src/java.scripting/share/classes/com/sun/tools/script/shell/Main.java src/java.scripting/share/classes/com/sun/tools/script/shell/messages.properties src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/KinitOptions.java src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Ktab.java src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Options.java src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties src/jdk.javadoc/share/classes/com/sun/tools/javadoc/resources/javadoc.properties src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java src/jdk.jcmd/share/classes/sun/tools/jcmd/Arguments.java src/jdk.jcmd/share/classes/sun/tools/jcmd/JCmd.java src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java src/jdk.jcmd/share/classes/sun/tools/jps/Arguments.java src/jdk.jcmd/share/classes/sun/tools/jstack/JStack.java src/jdk.jcmd/share/classes/sun/tools/jstat/Arguments.java src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties src/jdk.jstatd/share/classes/sun/tools/jstatd/Jstatd.java src/jdk.pack/share/native/unpack200/main.cpp src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Options.properties test/jdk/sun/tools/jcmd/TestJcmdDefaults.java test/jdk/sun/tools/jcmd/usage.out test/jdk/sun/tools/jps/TestJpsSanity.java test/jdk/sun/tools/jps/usage.out test/jdk/sun/tools/jstat/jstatHelp.sh test/jdk/sun/tools/jstat/usage.out test/jdk/sun/tools/jstatd/TestJstatdUsage.java test/jdk/tools/launcher/HelpFlagsTest.java test/langtools/jdk/javadoc/doclet/testHelpOption/TestHelpOption.java test/langtools/jdk/javadoc/tool/CheckResourceKeys.java test/langtools/jdk/javadoc/tool/ToolProviderTest.java test/langtools/jdk/jshell/StartOptionTest.java test/langtools/tools/javap/InvalidOptions.java test/langtools/tools/jdeps/MultiReleaseJar.java
diffstat 59 files changed, 680 insertions(+), 152 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -162,11 +162,12 @@
                         engProps.put((String) me.getKey(), (String) me.getValue());
                     }
                 } else if ("--version".equals(state)) {
-                        System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.VERSION), Driver.class.getName(), "1.31, 07/05/05"));
+                        System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.VERSION),
+                                                                Driver.class.getName(), "1.31, 07/05/05"));
                     return;
                 } else if ("--help".equals(state)) {
                     printUsage(doPack, true, System.out);
-                    System.exit(1);
+                    System.exit(0);
                     return;
                 } else {
                     break;
--- a/src/java.base/share/classes/com/sun/java/util/jar/pack/DriverResource.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/DriverResource.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -89,7 +89,7 @@
                 "  -q, --quiet                     set verbosity to lowest level",
                 "  -l{F}, --log-file={F}           output to the given log file, ",
                 "                                  or '-' for System.out",
-                "  -?, -h, --help                  print this message",
+                "  -?, -h, --help                  print this help message",
                 "  -V, --version                   print program version",
                 "  -J{X}                           pass option X to underlying Java VM",
                 "",
@@ -118,7 +118,7 @@
                 "  -q, --quiet                   set verbosity to lowest level",
                 "  -l{F}, --log-file={F}         output to the given log file, or",
                 "                                '-' for System.out",
-                "  -?, -h, --help                print this message",
+                "  -?, -h, --help                print this help message",
                 "  -V, --version                 print program version",
                 "  -J{X}                         pass option X to underlying Java VM"
             }
--- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -523,9 +523,11 @@
 
             if (c != null) {
                 command = c;
-            } else if (collator.compare(flags, "-help") == 0 ||
-                    collator.compare(flags, "-h") == 0 ||
-                    collator.compare(flags, "-?") == 0) {
+            } else if (collator.compare(flags, "--help") == 0 ||
+                       collator.compare(flags, "-h") == 0 ||
+                       collator.compare(flags, "-?") == 0 ||
+                       // -help: legacy.
+                       collator.compare(flags, "-help") == 0) {
                 help = true;
             } else if (collator.compare(flags, "-conf") == 0) {
                 i++;
@@ -4610,6 +4612,8 @@
             }
             System.err.println();
             System.err.println(rb.getString(
+                    "Use.keytool.help.for.all.available.commands"));
+            System.err.println(rb.getString(
                     "Use.keytool.command.name.help.for.usage.of.command.name"));
         }
     }
--- a/src/java.base/share/classes/sun/security/tools/keytool/Resources.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Resources.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,12 +45,12 @@
         {"option.1.set.twice", "The %s option is specified multiple times. All except the last one will be ignored."},
         {"multiple.commands.1.2", "Only one command is allowed: both %1$s and %2$s were specified."},
         {"Use.keytool.help.for.all.available.commands",
-                 "Use \"keytool -help\" for all available commands"},
+                 "Use \"keytool -?, -h, or --help\" for this help message"},
         {"Key.and.Certificate.Management.Tool",
                  "Key and Certificate Management Tool"},
         {"Commands.", "Commands:"},
         {"Use.keytool.command.name.help.for.usage.of.command.name",
-                "Use \"keytool -command_name -help\" for usage of command_name.\n" +
+                "Use \"keytool -command_name --help\" for usage of command_name.\n" +
                 "Use the -conf <url> option to specify a pre-configured options file."},
         // keytool: help: commands
         {"Generates.a.certificate.request",
--- a/src/java.rmi/share/classes/sun/rmi/server/resources/rmid.properties	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/java.rmi/share/classes/sun/rmi/server/resources/rmid.properties	Tue Jan 16 08:48:34 2018 +0100
@@ -1,6 +1,6 @@
 #
 #
-# Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,7 @@
 
 # {0} = the (string) illegal argument in question
 rmid.syntax.illegal.option=\
-	illegal option: {0}
+	invalid option: {0}
 
 # {0} = the (string) reason text that came with a thrown exception
 # "Activation.main" should not be translated, because it's a codepoint
--- a/src/java.scripting/share/classes/com/sun/tools/script/shell/Main.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/java.scripting/share/classes/com/sun/tools/script/shell/Main.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -122,7 +122,11 @@
                     }
                 }
                 continue;
-            } else if (arg.equals("-?") || arg.equals("-help")) {
+            } else if (arg.equals("-?") ||
+                       arg.equals("-h") ||
+                       arg.equals("--help") ||
+                       // -help: legacy.
+                       arg.equals("-help")) {
                 usage(EXIT_SUCCESS);
             } else if (arg.equals("-e")) {
                 seenScript = true;
--- a/src/java.scripting/share/classes/com/sun/tools/script/shell/messages.properties	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/java.scripting/share/classes/com/sun/tools/script/shell/messages.properties	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -55,8 +55,7 @@
 \  \-f <script file>     Evaluate given script file \n\
 \  \-f -                 Interactive mode, read script from standard input \n\
 \  \                     If this is used, this should be the last -f option \n\
-\  \-help                Print this usage message and exit \n\
-\  \-?                   Print this usage message and exit \n\
+\  \-? -h --help -help   Print this help message and exit \n\
 \  \-q                   List all scripting engines available and exit \n\
 \  \n\
 If [arguments..] are present and if no -e or -f option is used, then first\n\
--- a/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/KinitOptions.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/KinitOptions.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -137,7 +137,11 @@
                 lifetime = getTime(Config.duration(args[++i]));
             } else if (args[i].equals("-r")) {
                 renewable_lifetime = getTime(Config.duration(args[++i]));
-            } else if (args[i].equalsIgnoreCase("-help")) {
+            } else if (args[i].equalsIgnoreCase("-?") ||
+                       args[i].equalsIgnoreCase("-h") ||
+                       args[i].equalsIgnoreCase("--help") ||
+                       // -help: legacy.
+                       args[i].equalsIgnoreCase("-help")) {
                 printHelp();
                 System.exit(0);
             } else if (p == null) { // Haven't yet processed a "principal"
--- a/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -133,6 +133,12 @@
     void processArgs(String[] args) {
         Character arg;
         for (int i = 0; i < args.length; i++) {
+            if (args[i].equals("-?") ||
+                args[i].equals("-h") ||
+                args[i].equals("--help")) {
+                printHelp();
+                System.exit(0);
+            }
             if ((args[i].length() >= 2) && (args[i].startsWith("-"))) {
                 arg = Character.valueOf(args[i].charAt(1));
                 switch (arg.charValue()) {
@@ -350,7 +356,5 @@
         System.out.println("\t-t \t shows keytab entry timestamps");
         System.out.println("\t-K \t shows keytab entry key value");
         System.out.println("\t-e \t shows keytab entry key type");
-        System.out.println("\nUsage: java sun.security.krb5.tools.Klist " +
-                           "-help for help.");
     }
 }
--- a/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Ktab.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Ktab.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,8 +72,14 @@
      */
     public static void main(String[] args) {
         Ktab ktab = new Ktab();
-        if ((args.length == 1) && (args[0].equalsIgnoreCase("-help"))) {
+        if ((args.length == 1) &&
+            ((args[0].equalsIgnoreCase("-?")) ||
+             (args[0].equalsIgnoreCase("-h")) ||
+             (args[0].equalsIgnoreCase("--help")) ||
+             // -help: legacy.
+             (args[0].equalsIgnoreCase("-help")))) {
             ktab.printHelp();
+            System.exit(0);
             return;
         } else if ((args == null) || (args.length == 0)) {
             ktab.action = 'l';
--- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Options.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Options.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -227,7 +227,7 @@
             task.options.verbose = true;
             task.options.debug = true;
         }
-    }, new Option("  --help                     Print this usage message", false, "--help") {
+    }, new Option("  -? -h --help               Print this help message", false, "--help", "-h", "-?") {
         @Override
         void process(Main task, String opt, String arg) {
             task.options.help = true;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Option.java	Tue Jan 16 08:48:34 2018 +0100
@@ -362,7 +362,7 @@
     },
 
     // Note: -h is already taken for "native header output directory".
-    HELP("--help -help", "opt.help", STANDARD, INFO) {
+    HELP("--help -help -?", "opt.help", STANDARD, INFO) {
         @Override
         public void process(OptionHelper helper, String option) throws InvalidValueException {
             Log log = helper.getLog();
--- a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -457,9 +457,11 @@
                 showcerts = true;
             } else if (collator.compare(flags, "-strict") ==0) {
                 strict = true;
-            } else if (collator.compare(flags, "-h") == 0 ||
-                        collator.compare(flags, "-?") == 0 ||
-                        collator.compare(flags, "-help") == 0) {
+            } else if (collator.compare(flags, "-?") == 0 ||
+                       collator.compare(flags, "-h") == 0 ||
+                       collator.compare(flags, "--help") == 0 ||
+                       // -help: legacy.
+                       collator.compare(flags, "-help") == 0) {
                 fullusage();
             } else {
                 System.err.println(
@@ -648,6 +650,9 @@
         System.out.println(rb.getString
                 (".conf.url.specify.a.pre.configured.options.file"));
         System.out.println();
+        System.out.println(rb.getString
+                (".print.this.help.message"));
+        System.out.println();
 
         System.exit(0);
     }
--- a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -118,8 +118,10 @@
                 "[-strict]                   treat warnings as errors"},
         {".conf.url.specify.a.pre.configured.options.file",
                 "[-conf <url>]               specify a pre-configured options file"},
+        {".print.this.help.message",
+                "[-? -h --help]              Print this help message"},
         {"Option.lacks.argument", "Option lacks argument"},
-        {"Please.type.jarsigner.help.for.usage", "Please type jarsigner -help for usage"},
+        {"Please.type.jarsigner.help.for.usage", "Please type jarsigner --help for usage"},
         {"Please.specify.jarfile.name", "Please specify jarfile name"},
         {"Please.specify.alias.name", "Please specify alias name"},
         {"Only.one.alias.can.be.specified", "Only one alias can be specified"},
--- a/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jartool/share/classes/sun/tools/jar/GNUStyleOptions.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -200,7 +200,7 @@
             },
 
             // Other options
-            new Option(true, true, OptionType.OTHER, "--help", "-h") {
+            new Option(true, true, OptionType.OTHER, "--help", "-h", "-?") {
                 void process(Main jartool, String opt, String arg) throws BadArgs {
                     if (jartool.info == null) {
                         if (arg == null) {
--- a/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -286,7 +286,7 @@
 main.help.opt.other=\
 \ Other options:\n
 main.help.opt.other.help=\
-\  -h, --help[:compat]        Give this, or optionally the compatibility, help
+\  -?, -h, --help[:compat]    Give this, or optionally the compatibility, help
 main.help.opt.other.help-extra=\
 \      --help-extra           Give help on extra options
 main.help.opt.other.version=\
--- a/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
 \  -protected                       Show protected/public classes and members (default)\n\
 \  -package                         Show package/protected/public classes and members\n\
 \  -private                         Show all classes and members\n\
-\  -help                            Display command line options and exit\n\
+\  --help                           Display command line options and exit\n\
 \  -doclet <class>                  Generate output via alternate doclet\n\
 \  -docletpath <path>               Specify where to find doclet class files\n\
 \  --module-source-path <path>      Specify where to find input source files for multiple modules\n\
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOption.java	Tue Jan 16 08:48:34 2018 +0100
@@ -346,7 +346,7 @@
 
     // ----- help options -----
 
-    HELP("--help -help", STANDARD) {
+    HELP("--help -help -? -h", STANDARD) {
         @Override
         public void process(Helper helper) throws OptionException {
             throw new OptionException(OK, helper::usage);
--- a/src/jdk.jcmd/share/classes/sun/tools/jcmd/Arguments.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jcmd/share/classes/sun/tools/jcmd/Arguments.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,11 @@
             return;
         }
 
-        if (args[0].equals("-h") || args[0].equals("-help") ) {
+        if (args[0].equals("-?") ||
+            args[0].equals("-h") ||
+            args[0].equals("--help") ||
+            // -help: legacy.
+            args[0].equals("-help")) {
             showUsage = true;
             return;
         }
@@ -116,6 +120,6 @@
         System.out.println("  PerfCounter.print display the counters exposed by this process  ");
         System.out.println("  -f  read and execute commands from the file                     ");
         System.out.println("  -l  list JVM processes on the local machine                     ");
-        System.out.println("  -h  this help                                                   ");
+        System.out.println("  -? -h --help print this help message                            ");
     }
 }
--- a/src/jdk.jcmd/share/classes/sun/tools/jcmd/JCmd.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jcmd/share/classes/sun/tools/jcmd/JCmd.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,7 +62,7 @@
 
         if (arg.isShowUsage()) {
             Arguments.usage();
-            System.exit(1);
+            System.exit(0);
         }
 
         ProcessArgumentMatcher ap = null;
--- a/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,7 +63,11 @@
 
             optionCount++;
 
-            if (arg.equals("-help") || arg.equals("-h")) {
+            if (arg.equals("-?") ||
+                arg.equals("-h") ||
+                arg.equals("--help") ||
+                // -help: legacy.
+                arg.equals("-help")) {
                 usage(0);
             }
 
@@ -255,7 +259,7 @@
         System.err.println("    -flags               to print VM flags");
         System.err.println("    -sysprops            to print Java system properties");
         System.err.println("    <no option>          to print both VM flags and system properties");
-        System.err.println("    -h | -help           to print this help message");
+        System.err.println("    -? | -h | --help | -help to print this help message");
         System.exit(exit);
     }
 }
--- a/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,7 +64,11 @@
             if (!arg.startsWith("-")) {
                 break;
             }
-            if (arg.equals("-help") || arg.equals("-h")) {
+            if (arg.equals("-?") ||
+                arg.equals("-h") ||
+                arg.equals("--help") ||
+                // -help: legacy. Undocumented.
+                arg.equals("-help")) {
                 usage(0);
             } else {
                 if (option != null) {
@@ -247,6 +251,8 @@
         System.err.println("        if the \"live\" suboption is specified, only count live objects");
         System.err.println("    jmap -dump:<dump-options> <pid>");
         System.err.println("        to connect to running process and dump java heap");
+        System.err.println("    jmap -? -h --help");
+        System.err.println("        to print this help message");
         System.err.println("");
         System.err.println("    dump-options:");
         System.err.println("      live         dump only live objects; if not specified,");
--- a/src/jdk.jcmd/share/classes/sun/tools/jps/Arguments.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jcmd/share/classes/sun/tools/jps/Arguments.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,11 +52,12 @@
     private HostIdentifier hostId;
 
     public static void printUsage(PrintStream ps) {
-      ps.println("usage: jps [-help]");
+      ps.println("usage: jps [--help]");
       ps.println("       jps [-q] [-mlvV] [<hostid>]");
       ps.println();
       ps.println("Definitions:");
       ps.println("    <hostid>:      <hostname>[:<port>]");
+      ps.println("    -? -h --help -help: Print this help message and exit.");
     }
 
     public Arguments(String[] args) throws IllegalArgumentException {
@@ -64,7 +65,10 @@
 
         if (args.length == 1) {
             if ((args[0].compareTo("-?") == 0)
-                    || (args[0].compareTo("-help")== 0)) {
+                || (args[0].compareTo("-h")== 0)
+                || (args[0].compareTo("--help")== 0)
+                // -help: legacy.
+                || (args[0].compareTo("-help")== 0)) {
               help = true;
               return;
             }
--- a/src/jdk.jcmd/share/classes/sun/tools/jstack/JStack.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jcmd/share/classes/sun/tools/jstack/JStack.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,11 @@
             if (!arg.startsWith("-")) {
                 break;
             }
-            if (arg.equals("-help") || arg.equals("-h")) {
+            if (arg.equals("-?")     ||
+                arg.equals("-h")     ||
+                arg.equals("--help") ||
+                // -help: legacy.
+                arg.equals("-help")) {
                 usage(0);
             }
             else {
@@ -171,7 +175,7 @@
         System.err.println("");
         System.err.println("Options:");
         System.err.println("    -l  long listing. Prints additional information about locks");
-        System.err.println("    -h or -help to print this help message");
+        System.err.println("    -? -h --help -help to print this help message");
         System.exit(exit);
     }
 }
--- a/src/jdk.jcmd/share/classes/sun/tools/jstat/Arguments.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jcmd/share/classes/sun/tools/jstat/Arguments.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -73,7 +73,7 @@
     private VmIdentifier vmId;
 
     public static void printUsage(PrintStream ps) {
-        ps.println("Usage: jstat -help|-options");
+        ps.println("Usage: jstat --help|-options");
         ps.println("       jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]");
         ps.println();
         ps.println("Definitions:");
@@ -93,6 +93,8 @@
         ps.println("                milliseconds(\"ms\") or seconds(\"s\"). The default units are \"ms\".");
         ps.println("  <count>       Number of samples to take before terminating.");
         ps.println("  -J<flag>      Pass <flag> directly to the runtime system.");
+        ps.println("  -? -h --help  Prints this help message.");
+        ps.println("  -help         Prints this help message.");
 
         // undocumented options:
         //   -list [<vmid>]  - list counter names
@@ -103,6 +105,7 @@
         //   -v              - verbose output  (-snap)
         //   -constants      - output constants with -name output
         //   -strings        - output strings with -name output
+        //   -help           - same as -? ...
     }
 
     private static int toMillis(String s) throws IllegalArgumentException {
@@ -147,6 +150,9 @@
         }
 
         if ((args[0].compareTo("-?") == 0)
+                || (args[0].compareTo("-h") == 0)
+                || (args[0].compareTo("--help") == 0)
+                // -help: legacy.
                 || (args[0].compareTo("-help") == 0)) {
             help = true;
             return;
--- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -123,7 +123,7 @@
 
     static final Option[] recognizedOptions = {
 
-        new Option(false, "-help", "--help", "-?") {
+        new Option(false, "-help", "--help", "-?", "-h") {
             @Override
             void process(JavapTask task, String opt, String arg) {
                 task.options.help = true;
--- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/javap.properties	Tue Jan 16 08:48:34 2018 +0100
@@ -24,7 +24,7 @@
 
 main.usage.summary=\
 Usage: {0} <options> <classes>\n\
-use -help for a list of possible options
+use --help for a list of possible options
 
 warn.prefix=Warning:
 warn.unexpected.class=File {0} does not contain class {1}
@@ -33,7 +33,7 @@
 
 main.usage.summary=\
 Usage: {0} <options> <classes>\n\
-use -help for a list of possible options
+use --help for a list of possible options
 
 main.usage=\
 Usage: {0} <options> <classes>\n\
@@ -41,7 +41,7 @@
 
 
 main.opt.help=\
-\  -help  --help  -?                Print this usage message
+\  -? -h --help -help               Print this help message
 
 main.opt.version=\
 \  -version                         Version information
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -506,10 +506,11 @@
                             return false;
                         case "--help":
                         case "-h":
+                        case "-?":
                             out.println(Messages.get("main.usage"));
                             out.println();
                             out.println(Messages.get("main.help"));
-                            return false;
+                            return true;
                         case "-l":
                         case "--list":
                             require(scanMode == ScanMode.ARGS);
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties	Tue Jan 16 08:48:34 2018 +0100
@@ -2,14 +2,14 @@
 Usage: jdeprscan [options] '{dir|jar|class}' ...\n\
 \n\
 options:\n\
-\       --class-path PATH\n\
-\       --for-removal\n\
-\       --full-version\n\
-\  -h   --help\n\
-\  -l   --list\n\
-\       --release 6|7|8|9|10\n\
-\  -v   --verbose\n\
-\       --version
+\        --class-path PATH\n\
+\        --for-removal\n\
+\        --full-version\n\
+\  -? -h --help\n\
+\  -l    --list\n\
+\        --release 6|7|8|9|10\n\
+\  -v    --verbose\n\
+\        --version
 
 main.help=\
 Scans each argument for usages of deprecated APIs. An argument\n\
@@ -28,7 +28,7 @@
 \n\
 The --full-version option prints out the full version string of the tool.\n\
 \n\
-The --help option prints out a full help message.\n\
+The --help (-? -h) option prints out a full help message.\n\
 \n\
 The --list (-l) option prints out the set of deprecated APIs. No scanning is done,\n\
 so no directory, jar, or class arguments should be provided.\n\
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1144,7 +1144,7 @@
         for (Option o : recognizedOptions) {
             String name = o.aliases[0].substring(1); // there must always be at least one name
             name = name.charAt(0) == '-' ? name.substring(1) : name;
-            if (o.isHidden() || name.equals("h") || name.startsWith("filter:")) {
+            if (o.isHidden() || name.startsWith("filter:")) {
                 continue;
             }
             log.println(getMessage("main.opt." + name));
--- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/jdeps.properties	Tue Jan 16 08:48:34 2018 +0100
@@ -1,6 +1,6 @@
 main.usage.summary=\
 Usage: {0} <options> <path ...>]\n\
-use -h, -?, -help, or --help for a list of possible options
+use --help for a list of possible options
 
 main.usage=\
 Usage: {0} <options> <path ...>]\n\
@@ -12,8 +12,7 @@
 warn.prefix=Warning:
 
 main.opt.h=\
-\  -h -? -help\n\
-\  --help                        Print this usage message
+\  -h -? --help                  Print this help message
 
 main.opt.version=\
 \  -version --version            Version information
--- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -791,7 +791,7 @@
     private static void usage() {
         MessageOutput.println("zz usage text", new Object [] {progname,
                                                      File.pathSeparator});
-        System.exit(1);
+        System.exit(0);
     }
 
     static void usageError(String messageKey) {
@@ -1007,7 +1007,11 @@
                     return;
                 }
                 connectSpec = argv[++i];
-            } else if (token.equals("-help")) {
+            } else if (token.equals("-?") ||
+                       token.equals("-h") ||
+                       token.equals("--help") ||
+                       // -help: legacy.
+                       token.equals("-help")) {
                 usage();
             } else if (token.equals("-version")) {
                 Commands evaluator = new Commands();
--- a/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -426,7 +426,7 @@
              "Usage: {0} <options> <class> <arguments>\n" +
              "\n" +
              "where options include:\n" +
-             "    -help             print out this message and exit\n" +
+             "    -? -h --help -help print this help message and exit\n" +
              "    -sourcepath <directories separated by \"{1}\">\n" +
              "                      directories in which to look for source files\n" +
              "    -attach <address>\n" +
--- a/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jlink/share/classes/jdk/tools/jimage/JImageTask.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,7 +70,7 @@
 
         new Option<JImageTask>(false, (task, option, arg) -> {
             task.options.help = true;
-        }, "--help", "-h"),
+        }, "--help", "-h", "-?"),
 
         new Option<JImageTask>(false, (task, option, arg) -> {
             task.options.verbose = true;
--- a/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -60,23 +60,23 @@
 warn.prefix=Warning:
 
 main.opt.dir=\
-\       --dir                        Target directory for extract directive
+\          --dir                        Target directory for extract directive
 
 main.opt.include=\
-\       --include <pattern-list>     Pattern list for filtering entries.
+\          --include <pattern-list>     Pattern list for filtering entries.
 
 main.opt.full-version=\
-\       --full-version               Print full version information
+\          --full-version               Print full version information
 
 main.opt.help=\
-\  -h,  --help                       Print usage message
+\  -?, -h, --help                       Print this help message
 
 main.opt.verbose=\
-\       --verbose                    Listing prints entry size and offset\n\
-\                                    attributes
+\          --verbose                    Listing prints entry size and offset\n\
+\                                       attributes
 
 main.opt.version=\
-\       --version                    Print version information
+\          --version                    Print version information
 
 main.command.files=\
 \       @<filename>                  Read options from file
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -88,7 +88,7 @@
     private static final Option<?>[] recognizedOptions = {
         new Option<JlinkTask>(false, (task, opt, arg) -> {
             task.options.help = true;
-        }, "--help", "-h"),
+        }, "--help", "-h", "-?"),
         new Option<JlinkTask>(true, (task, opt, arg) -> {
             // if used multiple times, the last one wins!
             // So, clear previous values, if any.
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -101,6 +101,7 @@
         final boolean hidden;
         final String name;
         final String shortname;
+        final String shortname2;
         final boolean terminalOption;
 
         public Option(boolean hasArg,
@@ -108,6 +109,7 @@
                       boolean hidden,
                       String name,
                       String shortname,
+                      String shortname2,
                       boolean isTerminal)
         {
             if (!name.startsWith("--")) {
@@ -122,19 +124,33 @@
             this.hidden = hidden;
             this.name = name;
             this.shortname = shortname;
+            this.shortname2 = shortname2;
             this.terminalOption = isTerminal;
         }
+        public Option(boolean hasArg,
+                      Processing<T> processing,
+                      boolean hidden,
+                      String name,
+                      String shortname,
+                      boolean isTerminal)
+        {
+            this(hasArg, processing, false, name, shortname, "", isTerminal);
+        }
 
         public Option(boolean hasArg, Processing<T> processing, String name, String shortname, boolean isTerminal) {
-            this(hasArg, processing, false, name, shortname, isTerminal);
+            this(hasArg, processing, false, name, shortname, "", isTerminal);
+        }
+
+        public Option(boolean hasArg, Processing<T> processing, String name, String shortname, String shortname2) {
+            this(hasArg, processing, false, name, shortname, shortname2, false);
         }
 
         public Option(boolean hasArg, Processing<T> processing, String name, String shortname) {
-            this(hasArg, processing, false, name, shortname, false);
+            this(hasArg, processing, false, name, shortname, "", false);
         }
 
         public Option(boolean hasArg, Processing<T> processing, boolean hidden, String name) {
-            this(hasArg, processing, hidden, name, "", false);
+            this(hasArg, processing, hidden, name, "", "", false);
         }
 
         public Option(boolean hasArg, Processing<T> processing, String name) {
@@ -152,6 +168,7 @@
         public boolean matches(String opt) {
             return opt.equals(name) ||
                    opt.equals(shortname) ||
+                   opt.equals(shortname2) ||
                    hasArg && opt.startsWith("--") && opt.startsWith(name + "=");
          }
 
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
 \Possible options include:
 
 main.opt.help=\
-\  -h, --help                            Print this help message
+\  -h, --help, -?                        Print this help message
 
 main.opt.version=\
 \      --version                         Version information
--- a/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1309,7 +1309,7 @@
                         .withValuesConvertedBy(new PatternConverter());
 
         OptionSpec<Void> help
-                = parser.acceptsAll(Set.of("h", "help"), getMessage("main.opt.help"))
+                = parser.acceptsAll(Set.of("h", "help", "?"), getMessage("main.opt.help"))
                         .forHelp();
 
         OptionSpec<Void> helpExtra
--- a/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
 main.opt.mode.hash=\
 \hash      - Records hashes of tied modules.
 
-main.opt.help=Print this usage message
+main.opt.help=Print this help message
 main.opt.help-extra=Print help on extra options
 main.opt.version=Version information
 main.opt.class-path=Application jar files|dir containing classes
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -515,7 +515,7 @@
         private final OptionSpecBuilder argV = parser.accepts("v");
         private final OptionSpec<String> argR = parser.accepts("R").withRequiredArg();
         private final OptionSpec<String> argC = parser.accepts("C").withRequiredArg();
-        private final OptionSpecBuilder argHelp = parser.acceptsAll(asList("h", "help"));
+        private final OptionSpecBuilder argHelp = parser.acceptsAll(asList("?", "h", "help"));
         private final OptionSpecBuilder argVersion = parser.accepts("version");
         private final OptionSpecBuilder argFullVersion = parser.accepts("full-version");
         private final OptionSpecBuilder argShowVersion = parser.accepts("show-version");
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -216,7 +216,7 @@
 \                            Use one -C for each compiler flag or flag argument\n\
 \    --version             Print version information and exit\n\
 \    --show-version        Print version information and continue\n\
-\    --help                Print this synopsis of standard options and exit\n\
+\    --help, -?, -h        Print this synopsis of standard options and exit\n\
 \    --help-extra, -X      Print help on non-standard options and exit\n\
 \n\
 A file argument may be a file name, or one of the predefined file names: DEFAULT,\n\
--- a/src/jdk.jstatd/share/classes/sun/tools/jstatd/Jstatd.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.jstatd/share/classes/sun/tools/jstatd/Jstatd.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,8 @@
     private static boolean startRegistry = true;
 
     private static void printUsage() {
-        System.err.println("usage: jstatd [-nr] [-p port] [-n rminame]");
+        System.err.println("usage: jstatd [-nr] [-p port] [-n rminame]\n" +
+                           "       jstatd -?|-h|--help");
     }
 
     static void bind(String name, RemoteHostImpl remoteHost)
@@ -78,7 +79,12 @@
         for ( ; (argc < args.length) && (args[argc].startsWith("-")); argc++) {
             String arg = args[argc];
 
-            if (arg.compareTo("-nr") == 0) {
+            if (arg.compareTo("-?") == 0 ||
+                arg.compareTo("-h") == 0 ||
+                arg.compareTo("--help") == 0) {
+                printUsage();
+                System.exit(0);
+            } else if (arg.compareTo("-nr") == 0) {
                 startRegistry = false;
             } else if (arg.startsWith("-p")) {
                 if (arg.compareTo("-p") != 0) {
--- a/src/jdk.pack/share/native/unpack200/main.cpp	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.pack/share/native/unpack200/main.cpp	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -153,7 +153,7 @@
     "  -q, --quiet                   set verbosity to lowest level\n" \
     "  -l{F}, --log-file={F}         output to the given log file,\n" \
     "                                or '-' for standard output (default)\n" \
-    "  -?, -h, --help                print this message\n" \
+    "  -?, -h, --help                print this help message\n" \
     "  -V, --version                 print program version\n" \
     "\n" \
     "Exit Status:\n" \
@@ -313,7 +313,7 @@
     case 'h':
     case '?':
       usage(&u, argv[0], true);
-      exit(1);
+      exit(0);
 
     default:
       const char* inenv = isenvarg? " in ${UNPACK200_FLAGS}": "";
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Options.properties	Thu Jan 11 20:19:50 2018 -0800
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Options.properties	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -66,9 +66,9 @@
 ## At least short_name or name needs to be in place for an argument descriptor to be valid.
 
 nashorn.option.help = {                       \
-    name="-help",                             \
+    name="--help",                            \
     short_name="-h",                          \
-    desc="Print help for command line flags." \
+    desc="Print this help message."           \
 }
 
 nashorn.option.xhelp = {                               \
--- a/test/jdk/sun/tools/jcmd/TestJcmdDefaults.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/test/jdk/sun/tools/jcmd/TestJcmdDefaults.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,20 +52,22 @@
     private static final String JCMD_LIST_REGEX = "(?s)^\\d+\\s*.*";
 
     public static void main(String[] args) throws Exception {
+        testJcmdUsage("-?");
         testJcmdUsage("-h");
-        testJcmdUsage("-help");
+        testJcmdUsage("--help");
         testJcmdDefaults();
         testJcmdDefaults("-l");
     }
 
     /**
+     * jcmd -J-XX:+UsePerfData -?
      * jcmd -J-XX:+UsePerfData -h
-     * jcmd -J-XX:+UsePerfData -help
+     * jcmd -J-XX:+UsePerfData --help
      */
     private static void testJcmdUsage(String... jcmdArgs) throws Exception {
         OutputAnalyzer output = JcmdBase.jcmdNoPid(VM_ARGS, jcmdArgs);
 
-        assertNotEquals(output.getExitValue(), 0);
+        assertEquals(output.getExitValue(), 0);
         verifyOutputAgainstFile(output);
     }
 
--- a/test/jdk/sun/tools/jcmd/usage.out	Thu Jan 11 20:19:50 2018 -0800
+++ b/test/jdk/sun/tools/jcmd/usage.out	Tue Jan 16 08:48:34 2018 +0100
@@ -12,4 +12,4 @@
   PerfCounter.print display the counters exposed by this process  
   -f  read and execute commands from the file                     
   -l  list JVM processes on the local machine                     
-  -h  this help                                                   
+  -? -h --help print this help message                            
--- a/test/jdk/sun/tools/jps/TestJpsSanity.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/test/jdk/sun/tools/jps/TestJpsSanity.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -84,7 +84,10 @@
         OutputAnalyzer output = JpsHelper.jps("-?");
         JpsHelper.verifyOutputAgainstFile(output);
 
-        output = JpsHelper.jps("-help");
+        output = JpsHelper.jps("-h");
+        JpsHelper.verifyOutputAgainstFile(output);
+
+        output = JpsHelper.jps("--help");
         JpsHelper.verifyOutputAgainstFile(output);
     }
 
--- a/test/jdk/sun/tools/jps/usage.out	Thu Jan 11 20:19:50 2018 -0800
+++ b/test/jdk/sun/tools/jps/usage.out	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,6 @@
-usage: jps [-help]
+usage: jps [--help]
        jps [-q] [-mlvV] [<hostid>]
 
 Definitions:
     <hostid>:      <hostname>[:<port>]
+    -? -h --help -help: Print this help message and exit.
--- a/test/jdk/sun/tools/jstat/jstatHelp.sh	Thu Jan 11 20:19:50 2018 -0800
+++ b/test/jdk/sun/tools/jstat/jstatHelp.sh	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 # @test
 # @bug 4990825 6364329
 # @run shell jstatHelp.sh
-# @summary Test that output of 'jstat -?', 'jstat -help' and 'jstat' matches the usage.out file
+# @summary Test that output of 'jstat -?', 'jstat -h', 'jstat --help' and 'jstat' matches the usage.out file
 
 . ${TESTSRC-.}/../../jvmstat/testlibrary/utils.sh
 
@@ -43,12 +43,22 @@
 fi
 
 rm -f jstat.out 2>/dev/null
-${JSTAT} -J-XX:+UsePerfData -help > jstat.out 2>&1
+${JSTAT} -J-XX:+UsePerfData --help > jstat.out 2>&1
 
 diff -w jstat.out ${TESTSRC}/usage.out
 if [ $? != 0 ]
 then
-  echo "Output of jstat -help differs from expected output. Failed."
+  echo "Output of jstat -h differs from expected output. Failed."
+  exit 1
+fi
+
+rm -f jstat.out 2>/dev/null
+${JSTAT} -J-XX:+UsePerfData --help > jstat.out 2>&1
+
+diff -w jstat.out ${TESTSRC}/usage.out
+if [ $? != 0 ]
+then
+  echo "Output of jstat --help differs from expected output. Failed."
   exit 1
 fi
 
--- a/test/jdk/sun/tools/jstat/usage.out	Thu Jan 11 20:19:50 2018 -0800
+++ b/test/jdk/sun/tools/jstat/usage.out	Tue Jan 16 08:48:34 2018 +0100
@@ -1,4 +1,4 @@
-Usage: jstat -help|-options
+Usage: jstat --help|-options
        jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]
 
 Definitions:
@@ -18,3 +18,5 @@
                 milliseconds("ms") or seconds("s"). The default units are "ms".
   <count>       Number of samples to take before terminating.
   -J<flag>      Pass <flag> directly to the runtime system.
+  -? -h --help  Prints this help message.
+  -help         Prints this help message.
--- a/test/jdk/sun/tools/jstatd/TestJstatdUsage.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/test/jdk/sun/tools/jstatd/TestJstatdUsage.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,8 +36,9 @@
 public class TestJstatdUsage {
 
     public static void main(String[] args) throws Exception {
-        testUsage("-help");
         testUsage("-?");
+        testUsage("-h");
+        testUsage("--help");
     }
 
     private static void testUsage(String option) throws Exception {
@@ -47,7 +48,7 @@
         OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
 
         output.shouldContain("usage: jstatd [-nr] [-p port] [-n rminame]");
-        output.shouldHaveExitValue(1);
+        output.shouldHaveExitValue(0);
     }
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/launcher/HelpFlagsTest.java	Tue Jan 16 08:48:34 2018 +0100
@@ -0,0 +1,425 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018 SAP SE. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary Validate and test -?, -h and --help flags. All tools in the jdk
+ *          should take the same flags to display the help message. These
+ *          flags should be documented in the printed help message. The
+ *          tool should quit without error code after displaying the
+ *          help message (if there  is no other problem with the command
+ *          line).
+ *          Also check that tools that used to accept -help still do
+ *          so. Test that tools that never accepted -help don't do so
+ *          in future. I.e., check that the tool returns with the same
+ *          return code as called with an invalid flag, and does not
+ *          print anything containing '-help' in that case.
+ * @compile HelpFlagsTest.java
+ * @run main HelpFlagsTest
+ */
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
+
+
+public class HelpFlagsTest extends TestHelper {
+
+    // Tools that should not be tested because a usage message is pointless.
+    static final String[] TOOLS_NOT_TO_TEST = {
+        "appletviewer",     // deprecated, don't test
+        "jaccessinspector", // gui, don't test, win only
+        "jaccesswalker",    // gui, don't test, win only
+        "jconsole",         // gui, don't test
+        "servertool",       // none. Shell, don't test.
+        "javaw",            // don't test, win only
+        // The flags of these tools need to be fixed in Java EE.
+        // The tools are deprecated for removal in Java SE. Don't test.
+        "idlj",
+        "orbd",
+        "schemagen",
+        "tnameserv",
+        "wsgen",
+        "wsimport",
+        "xjc",
+        // These shall have a help message that resembles that of
+        // MIT's tools. Thus -?, -h and --help are supported, but not
+        // mentioned in the help text.
+        "kinit",
+        "klist",
+        "ktab"
+    };
+
+    // Lists which tools support which flags.
+    private static class ToolHelpSpec {
+        String toolname;
+
+        // How the flags supposed to be supported are handled.
+        //
+        // These flags are supported, i.e.,
+        // * the tool accepts the flag
+        // * the tool prints a help message if the flag is specified
+        // * this help message lists the flag
+        // * the tool exits with exit code '0'.
+        boolean supportsQuestionMark;
+        boolean supportsH;
+        boolean supportsHelp;
+
+        // One tool returns with exit code != '0'.
+        int exitcodeOfHelp;
+
+        // How legacy -help is handled.
+        //
+        // Tools that so far support -help should still do so, but
+        // not print documentation about it. Tools that do not
+        // support -help should not do so in future.
+        //
+        // The tools accepts legacy -help. -help should not be
+        // documented in the usage message.
+        boolean supportsLegacyHelp;
+
+        // Java itself documents -help. -help prints to stderr,
+        // while --help prints to stdout. Leave as is.
+        boolean documentsLegacyHelp;
+
+        // The exit code of the tool if an invalid argument is passed to it.
+        // An exit code != 0 would be expected, but not all tools handle it
+        // that way.
+        int exitcodeOfWrongFlag;
+
+        // Some tools accept the invalid argument and thus hang the test.
+        // Don't execute these with the wrong flags.
+        // This actually should be considered a bug in the corresponding tool.
+        boolean dontExecuteWithWrongFlags;
+
+        ToolHelpSpec(String n, int q, int h, int hp, int ex1, int l, int dl, int ex2, int hangs) {
+            toolname = n;
+            supportsQuestionMark = ( q  == 1 ? true : false );
+            supportsH            = ( h  == 1 ? true : false );
+            supportsHelp         = ( hp == 1 ? true : false );
+            exitcodeOfHelp       = ex1;
+
+            supportsLegacyHelp   = (  l == 1 ? true : false );
+            documentsLegacyHelp  = ( dl == 1 ? true : false );
+            exitcodeOfWrongFlag  = ex2;
+
+            dontExecuteWithWrongFlags = ( hangs == 1 ? true : false );
+        }
+    }
+
+    static ToolHelpSpec[] jdkTools = {
+        //               name          -?   -h --help exitcode   -help -help  exitcode  Don't
+        //                                            of help          docu   of wrong  test
+        //                                                             mented flag      inv flag
+        new ToolHelpSpec("jabswitch",   0,   0,   0,   0,         0,    0,     0,       0),   // /?, prints help message anyways, win only
+        new ToolHelpSpec("jaotc",       1,   1,   1,   0,         0,    0,     2,       0),   // -?, -h, --help
+        new ToolHelpSpec("jar",         1,   1,   1,   0,         0,    0,     1,       0),   // -?, -h, --help
+        new ToolHelpSpec("jarsigner",   1,   1,   1,   0,         1,    0,     1,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("java",        1,   1,   1,   0,         1,    1,     1,       0),   // -?, -h, --help -help, Documents -help
+        new ToolHelpSpec("javac",       1,   0,   1,   0,         1,    1,     2,       0),   // -?,     --help -help, Documents -help, -h is already taken for "native header output directory".
+        new ToolHelpSpec("javadoc",     1,   1,   1,   0,         1,    1,     1,       0),   // -?, -h, --help -help, Documents -help
+        new ToolHelpSpec("javap",       1,   1,   1,   0,         1,    1,     2,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("javaw",       1,   1,   1,   0,         1,    1,     1,       0),   // -?, -h, --help -help, win only
+        new ToolHelpSpec("jcmd",        1,   1,   1,   0,         1,    0,     1,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("jdb",         1,   1,   1,   0,         1,    1,     0,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("jdeprscan",   1,   1,   1,   0,         0,    0,     1,       0),   // -?, -h, --help
+        new ToolHelpSpec("jdeps",       1,   1,   1,   0,         1,    0,     2,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("jhsdb",       0,   0,   0,   0,         0,    0,     0,       0),   // none, prints help message anyways.
+        new ToolHelpSpec("jimage",      1,   1,   1,   0,         0,    0,     2,       0),   // -?, -h, --help
+        new ToolHelpSpec("jinfo",       1,   1,   1,   0,         1,    1,     1,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("jjs",         0,   1,   1, 100,         0,    0,   100,       0),   //     -h, --help, return code 100
+        new ToolHelpSpec("jlink",       1,   1,   1,   0,         0,    0,     2,       0),   // -?, -h, --help
+        new ToolHelpSpec("jmap",        1,   1,   1,   0,         1,    0,     1,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("jmod",        1,   1,   1,   0,         1,    0,     2,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("jps",         1,   1,   1,   0,         1,    1,     1,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("jrunscript",  1,   1,   1,   0,         1,    1,     7,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("jshell",      1,   1,   1,   0,         1,    0,     1,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("jstack",      1,   1,   1,   0,         1,    1,     1,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("jstat",       1,   1,   1,   0,         1,    1,     1,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("jstatd",      1,   1,   1,   0,         0,    0,     1,       0),   // -?, -h, --help
+        new ToolHelpSpec("keytool",     1,   1,   1,   0,         1,    0,     1,       0),   // none, prints help message anyways.
+        new ToolHelpSpec("pack200",     1,   1,   1,   0,         1,    0,     2,       0),   // -?, -h, --help, -help accepted but not documented.
+        new ToolHelpSpec("rmic",        0,   0,   0,   0,         0,    0,     1,       0),   // none, pirnts help message anyways.
+        new ToolHelpSpec("rmid",        0,   0,   0,   0,         0,    0,     1,       0),   // none, prints help message anyways.
+        new ToolHelpSpec("rmiregistry", 0,   0,   0,   0,         0,    0,     1,       0),   // none, prints help message anyways.
+        new ToolHelpSpec("serialver",   0,   0,   0,   0,         0,    0,     1,       0),   // none, prints help message anyways.
+        new ToolHelpSpec("unpack200",   1,   1,   1,   0,         1,    0,     2,       0),   // -?, -h, --help, -help accepted but not documented.
+    };
+
+    // Returns true if the file is not a tool.
+    static boolean notATool(String file) {
+        if (isWindows && !file.endsWith(EXE_FILE_EXT))
+            return true;
+        return false;
+    }
+
+    // Returns true if tool is listed in TOOLS_NOT_TO_TEST.
+    static boolean dontTestTool(String tool) {
+        tool = tool.toLowerCase();
+        for (String x : TOOLS_NOT_TO_TEST) {
+            if (tool.toLowerCase().startsWith(x))
+                return true;
+        }
+        return false;
+    }
+
+    // Returns corresponding object from jdkTools array.
+    static ToolHelpSpec getToolHelpSpec(String tool) {
+        for (ToolHelpSpec x : jdkTools) {
+            if (tool.toLowerCase().equals(x.toolname) ||
+                tool.toLowerCase().equals(x.toolname + ".exe"))
+                return x;
+        }
+        return null;
+    }
+
+    // Check whether 'flag' appears in 'line' as a word of itself. It must not
+    // be a substring of a word, as then similar flags might be matched.
+    // E.g.: --help matches in the documentation of --help-extra.
+    // This works only with english locale, as some tools have translated
+    // usage messages.
+    static boolean findFlagInLine(String line, String flag) {
+        if (line.contains(flag) &&
+            !line.contains("nknown") &&                       // Some tools say 'Unknown option "<flag>"',
+            !line.contains("invalid flag") &&                 // 'invalid flag: <flag>'
+            !line.contains("invalid option") &&               // or 'invalid option: <flag>'. Skip that.
+            !line.contains("FileNotFoundException: -help") && // Special case for idlj.
+            !line.contains("-h requires an argument") &&      // Special case for javac.
+            !line.contains("port argument,")) {               // Special case for rmiregistry.
+            // There might be several appearances of 'flag' in
+            // 'line'. (-h as substring of --help).
+            int flagLen = flag.length();
+            int lineLen = line.length();
+            for (int i = line.indexOf(flag); i >= 0; i = line.indexOf(flag, i+1)) {
+                // There should be a space before 'flag' in 'line', or it's right at the beginning.
+                if (i > 0 &&
+                    line.charAt(i-1) != ' ' &&
+                    line.charAt(i-1) != '[' &&  // jarsigner
+                    line.charAt(i-1) != '|' &&  // jstatd
+                    line.charAt(i-1) != '\t') { // jjs
+                    continue;
+                }
+                // There should be a space or comma after 'flag' in 'line', or it's just at the end.
+                int posAfter = i + flagLen;
+                if (posAfter < lineLen &&
+                    line.charAt(posAfter) != ' ' &&
+                    line.charAt(posAfter) != ',' &&
+                    line.charAt(posAfter) != '[' && // jar
+                    line.charAt(posAfter) != ']' && // jarsigner
+                    line.charAt(posAfter) != '|' && // jstatd
+                    line.charAt(posAfter) != ':' && // jps
+                    line.charAt(posAfter) != '"') { // keytool
+                    continue;
+                }
+                return true;
+            }
+        }
+        return false;
+    }
+
+    static TestResult runToolWithFlag(File f, String flag) {
+        String x = f.getAbsolutePath();
+        TestResult tr = doExec(x, flag);
+        System.out.println("Testing " + f.getName());
+        System.out.println("#> " + x + " " + flag);
+        tr.testOutput.forEach(System.out::println);
+        System.out.println("#> echo $?");
+        System.out.println(tr.exitValue);
+
+        return tr;
+    }
+
+    // Checks whether tool supports flag 'flag' and documents it
+    // in the help message.
+    static String testTool(File f, String flag, int exitcode) {
+        String result = "";
+        TestResult tr = runToolWithFlag(f, flag);
+
+        // Check that the tool accepted the flag.
+        if (exitcode == 0 && !tr.isOK()) {
+            System.out.println("failed");
+            result = "failed: " + f.getName() + " " + flag + " has exit code " + tr.exitValue + ".\n";
+        }
+
+        // Check there is a help message listing the flag.
+        boolean foundFlag = false;
+        for (String y : tr.testOutput) {
+            if (!foundFlag && findFlagInLine(y, flag)) { // javac
+                foundFlag = true;
+                System.out.println("Found documentation of '" + flag + "': '" + y.trim() +"'");
+            }
+        }
+        if (!foundFlag) {
+            result += "failed: " + f.getName() + " does not document " +
+                flag + " in help message.\n";
+        }
+
+        if (!result.isEmpty())
+            System.out.println(result);
+
+        return result;
+    }
+
+    // Test the tool supports legacy option -help, but does
+    // not document it.
+    static String testLegacyFlag(File f, int exitcode) {
+        String result = "";
+        TestResult tr = runToolWithFlag(f, "-help");
+
+        // Check that the tool accepted the flag.
+        if (exitcode == 0 && !tr.isOK()) {
+            System.out.println("failed");
+            result = "failed: " + f.getName() + " -help has exit code " + tr.exitValue + ".\n";
+        }
+
+        // Check there is _no_ documentation of -help.
+        boolean foundFlag = false;
+        for (String y : tr.testOutput) {
+            if (!foundFlag && findFlagInLine(y, "-help")) {  // javac
+                foundFlag = true;
+                System.out.println("Found documentation of '-help': '" + y.trim() +"'");
+            }
+        }
+        if (foundFlag) {
+            result += "failed: " + f.getName() + " does document -help " +
+                "in help message. This legacy flag should not be documented.\n";
+        }
+
+        if (!result.isEmpty())
+            System.out.println(result);
+
+        return result;
+    }
+
+    // Test that the tool exits with the exit code expected for
+    // invalid flags. In general, one would expect this to be != 0,
+    // but currently a row of tools exit with 0 in this case.
+    // The output should not ask to get help with flag '-help'.
+    static String testInvalidFlag(File f, String flag, int exitcode, boolean documentsLegacyHelp) {
+        String result = "";
+        TestResult tr = runToolWithFlag(f, flag);
+
+        // Check that the tool did exit with the expected return code.
+        if (!((exitcode == tr.exitValue) ||
+              // Windows reports -1 where unix reports 255.
+              (tr.exitValue < 0 && exitcode == tr.exitValue + 256))) {
+            System.out.println("failed");
+            result = "failed: " + f.getName() + " " + flag + " should not be " +
+                     "accepted. But it has exit code " + tr.exitValue + ".\n";
+        }
+
+        if (!documentsLegacyHelp) {
+            // Check there is _no_ documentation of -help.
+            boolean foundFlag = false;
+            for (String y : tr.testOutput) {
+                if (!foundFlag && findFlagInLine(y, "-help")) {  // javac
+                    foundFlag = true;
+                    System.out.println("Found documentation of '-help': '" + y.trim() +"'");
+                }
+            }
+            if (foundFlag) {
+                result += "failed: " + f.getName() + " does document -help " +
+                    "in error message. This legacy flag should not be documented.\n";
+            }
+        }
+
+        if (!result.isEmpty())
+            System.out.println(result);
+
+        return result;
+    }
+
+    public static void main(String[] args) {
+        String errorMessage = "";
+
+        // The test analyses the help messages printed. It assumes englisch
+        // help messages. Thus it only works with english locale.
+        if (!isEnglishLocale()) { return; }
+
+        for (File f : new File(JAVA_BIN).listFiles()) {
+            String toolName = f.getName();
+
+            if (notATool(toolName)) {
+                continue;
+            }
+            if (dontTestTool(toolName)) {
+                System.out.println("Skipping test of tool " + toolName +
+                                   ". Tool has no help message.");
+                continue;
+            }
+
+            ToolHelpSpec tool = getToolHelpSpec(toolName);
+            if (tool == null) {
+                errorMessage += "Tool " + toolName + " not covered by this test. " +
+                    "Add specification to jdkTools array!\n";
+                continue;
+            }
+
+            // Test for help flags to be supported.
+            if (tool.supportsQuestionMark == true) {
+                errorMessage += testTool(f, "-?", tool.exitcodeOfHelp);
+            } else {
+                System.out.println("Skip " + tool.toolname + ". It does not support -?.");
+            }
+            if (tool.supportsH == true) {
+                errorMessage += testTool(f, "-h", tool.exitcodeOfHelp);
+            } else {
+                System.out.println("Skip " + tool.toolname + ". It does not support -h.");
+            }
+            if (tool.supportsHelp == true) {
+                errorMessage += testTool(f, "--help", tool.exitcodeOfHelp);
+            } else {
+                System.out.println("Skip " + tool.toolname + ". It does not support --help.");
+            }
+
+            // Check that the return code listing in jdkTools[] is
+            // correct for an invalid flag.
+            if (!tool.dontExecuteWithWrongFlags) {
+                errorMessage += testInvalidFlag(f, "-asdfxgr", tool.exitcodeOfWrongFlag, tool.documentsLegacyHelp);
+            }
+
+            // Test for legacy -help flag.
+            if (!tool.documentsLegacyHelp) {
+                if (tool.supportsLegacyHelp == true) {
+                    errorMessage += testLegacyFlag(f, tool.exitcodeOfHelp);
+                } else {
+                    if (!tool.dontExecuteWithWrongFlags) {
+                        errorMessage += testInvalidFlag(f, "-help", tool.exitcodeOfWrongFlag, false);
+                    }
+                }
+            }
+        }
+
+        if (errorMessage.isEmpty()) {
+            System.out.println("All help string tests: PASS");
+        } else {
+            throw new AssertionError("HelpFlagsTest failed:\n" + errorMessage);
+        }
+    }
+}
--- a/test/langtools/jdk/javadoc/doclet/testHelpOption/TestHelpOption.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/test/langtools/jdk/javadoc/doclet/testHelpOption/TestHelpOption.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 /*
  * @test
  * @bug      4934778 4777599 6553182 8146427 8146475 8175055 8185371
- * @summary  Make sure that -help, -helpfile and -nohelp options work correctly.
+ * @summary  Make sure that --help, -helpfile and -nohelp options work correctly.
  * @author   jamieh
  * @library ../lib
  * @modules jdk.javadoc/jdk.javadoc.internal.tool
@@ -66,7 +66,7 @@
     void testWithOption() {
         javadoc("-d", "out1",
                 "-sourcepath", testSrc,
-                "-help",
+                "--help",
                 testSrc("Sample.java"));
         checkExit(Exit.OK);
 
--- a/test/langtools/jdk/javadoc/tool/CheckResourceKeys.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/test/langtools/jdk/javadoc/tool/CheckResourceKeys.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -117,7 +117,7 @@
     }
 
     void usageTests(boolean xflag) {
-        String[] argarray = { xflag ? "-X" : "-help" };
+        String[] argarray = { xflag ? "-X" : "--help" };
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
         if (jdk.javadoc.internal.tool.Main.execute(argarray, pw) == 0) {
--- a/test/langtools/jdk/javadoc/tool/ToolProviderTest.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/test/langtools/jdk/javadoc/tool/ToolProviderTest.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,7 +69,7 @@
     public void testOneStream() throws Exception {
         StringWriter sw = new StringWriter();
         try (PrintWriter pw = new PrintWriter(sw)) {
-            int rc = javadoc.run(pw, pw, "-help");
+            int rc = javadoc.run(pw, pw, "--help");
             if (rc != 0) {
                 error("unexpected exit code: " + rc);
             }
@@ -86,7 +86,7 @@
         StringWriter swErr = new StringWriter();
         try (PrintWriter pwOut = new PrintWriter(swOut);
                 PrintWriter pwErr = new PrintWriter(swErr)) {
-            int rc = javadoc.run(pwOut, pwErr, "-help");
+            int rc = javadoc.run(pwOut, pwErr, "--help");
             if (rc != 0) {
                 error("unexpected exit code: " + rc);
             }
--- a/test/langtools/jdk/jshell/StartOptionTest.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/test/langtools/jdk/jshell/StartOptionTest.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -214,7 +214,7 @@
 
     // Test that the usage message is printed
     public void testUsage() {
-        for (String opt : new String[]{"-h", "--help"}) {
+        for (String opt : new String[]{"-?", "-h", "--help"}) {
             startCo(s -> {
                 assertTrue(s.split("\n").length >= 7, "Not enough usage lines: " + s);
                 assertTrue(s.startsWith("Usage:   jshell <option>..."), "Unexpect usage start: " + s);
--- a/test/langtools/tools/javap/InvalidOptions.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/test/langtools/tools/javap/InvalidOptions.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
     void run() throws Exception {
         test(2, "-b", "Error: unknown option: -b",
                       "Usage: javap <options> <classes>",
-                      "use -help for a list of possible options");
+                      "use --help for a list of possible options");
         if (errorCount > 0)
             throw new Exception(errorCount + " errors received");
     }
--- a/test/langtools/tools/jdeps/MultiReleaseJar.java	Thu Jan 11 20:19:50 2018 -0800
+++ b/test/langtools/tools/jdeps/MultiReleaseJar.java	Tue Jan 16 08:48:34 2018 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -118,7 +118,7 @@
         checkResult(r, false,
                 "Error: unknown option: -multi-release",
                 "Usage: jdeps <options> <path",
-                "use -h, -?, -help, or --help"
+                "use --help"
         );
 
         r = run("jdeps -v -R -cp Version.jar --multi-release 9 test/Main.class");