8217802: Invalid Option warning message. JDK-8200758-branch
authorherrick
Fri, 15 Feb 2019 17:41:06 -0500
branchJDK-8200758-branch
changeset 57192 3d6a21f41c10
parent 57184 f801bf6ff225
child 57193 fab566567af9
8217802: Invalid Option warning message. Reviewed-by: almatvee
src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/ValidOptions.java
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties
src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties
test/jdk/tools/launcher/HelpFlagsTest.java
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java	Wed Feb 13 18:31:09 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java	Fri Feb 15 17:41:06 2019 -0500
@@ -167,8 +167,10 @@
 
         INSTALLER_TYPE("installer-type", OptionCategories.PROPERTY, () -> {
             String type = popArg();
-            context().deployParams.setTargetFormat(type);
-            context().hasTargetFormat = true;
+            if (BundlerType.INSTALLER.equals(context().bundleType)) {
+                context().deployParams.setTargetFormat(type);
+                context().hasTargetFormat = true;
+            }
             setOptionValue("installer-type", type);
         }),
 
@@ -657,8 +659,12 @@
         CLIOptions mode = allOptions.get(0);
         for (CLIOptions option : allOptions) {
             if(!ValidOptions.checkIfSupported(mode, option)) {
-                Log.info(MessageFormat.format(I18N.getString(
-                        "warning.unsupported.option"), option.getId(), mode));
+                String key = "warning.unsupported.option";
+                if (ValidOptions.checkIfOtherSupported(mode, option)) {
+                    key = "warning.unsupported.mode.option";
+                }
+                Log.info(MessageFormat.format(I18N.getString(key),
+                        option.getId(), mode));
             }
         }
     }
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ValidOptions.java	Wed Feb 13 18:31:09 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/ValidOptions.java	Fri Feb 15 17:41:06 2019 -0500
@@ -41,6 +41,9 @@
  *
  * checkIfSupported(CLIOptions mode, CLIOptions arg)
  *      Determine if the given arg is valid in the given mode.
+ *
+ * checkIfOtherSupported(CLIOptions mode, CLIOptions arg)
+ *      Determine if the given arg is valid in the a different mode.
  */
 class ValidOptions {
 
@@ -166,4 +169,15 @@
         }
         return false;
     }
+
+    static boolean checkIfOtherSupported(CLIOptions mode, CLIOptions arg) {
+        for (CLIOptions other : options.keySet()) {
+            if (!other.equals(mode)) {
+                if (checkIfSupported(other, arg)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
 }
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties	Wed Feb 13 18:31:09 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties	Fri Feb 15 17:41:06 2019 -0500
@@ -149,9 +149,10 @@
 error.main-jar-does-not-exist=The configured main jar does not exist {0}
 error.main-jar-does-not-exist.advice=The main jar must be specified relative to the app resources (not an absolute path), and must exist within those resources.
 
-warning.module.does.not.exist=Module {0} does not exist.
+warning.module.does.not.exist=Module [{0}] does not exist.
 warning.no.jdk.modules.found=Warning: No JDK Modules found.
-warning.unsupported.option=Warning: Option [{0}] is not supported in {1} mode on this platform.
+warning.unsupported.option=Warning: Option [{0}] is not supported on this platform.
+warning.unsupported.mode.option=Warning: Option [{0}] is not supported in {1} mode.
 warning.missing.arg.file=Warning: Missing argument file: {0}
 
 MSG_BundlerFailed=Error: Bundler "{1}" ({0}) failed to produce a bundle.
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties	Wed Feb 13 18:31:09 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties	Fri Feb 15 17:41:06 2019 -0500
@@ -151,7 +151,8 @@
 
 warning.module.does.not.exist=Module {0} does not exist.
 warning.no.jdk.modules.found=Warning: No JDK Modules found.
-warning.unsupported.option=Warning: Option [{0}] is not supported in {1} mode on this platform.
+warning.unsupported.option=Warning: Option [{0}] is not supported on this platform.
+warning.unsupported.mode.option=Warning: Option [{0}] is not supported in {1} mode.
 warning.missing.arg.file=Warning: Missing argument file: {0}
 
 MSG_BundlerFailed=Error: Bundler "{1}" ({0}) failed to produce a bundle.
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties	Wed Feb 13 18:31:09 2019 -0500
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties	Fri Feb 15 17:41:06 2019 -0500
@@ -151,7 +151,8 @@
 
 warning.module.does.not.exist=Module {0} does not exist.
 warning.no.jdk.modules.found=Warning: No JDK Modules found.
-warning.unsupported.option=Warning: Option [{0}] is not supported in {1} mode on this platform.
+warning.unsupported.option=Warning: Option [{0}] is not supported on this platform.
+warning.unsupported.mode.option=Warning: Option [{0}] is not supported in {1} mode.
 warning.missing.arg.file=Warning: Missing argument file: {0}
 
 MSG_BundlerFailed=Error: Bundler "{1}" ({0}) failed to produce a bundle.
--- a/test/jdk/tools/launcher/HelpFlagsTest.java	Wed Feb 13 18:31:09 2019 -0500
+++ b/test/jdk/tools/launcher/HelpFlagsTest.java	Fri Feb 15 17:41:06 2019 -0500
@@ -161,7 +161,7 @@
         new ToolHelpSpec("rmiregistry", 0,   0,   0,   0,         0,    0,     1),     // none, prints help message anyways.
         new ToolHelpSpec("serialver",   0,   0,   0,   0,         0,    0,     1),     // none, prints help message anyways.
         new ToolHelpSpec("unpack200",   1,   1,   1,   0,         1,    0,     2),     // -?, -h, --help, -help accepted but not documented.
-        new ToolHelpSpec("jpackage",    0,   1,   1,   0,         0,    0,   255),     //     -h, --help,
+        new ToolHelpSpec("jpackage",    0,   1,   1,   0,         0,    1,   255),     //     -h, --help,
     };
 
     // Returns true if the file is not a tool.