< prev index next >

src/java.base/share/native/libjli/java.c

Print this page

        

@@ -571,10 +571,21 @@
            JLI_StrCmp(name, "--add-opens") == 0 ||
            JLI_StrCmp(name, "--add-reads") == 0 ||
            JLI_StrCmp(name, "--patch-module") == 0;
 }
 
+static jboolean
+IsLongFormModuleOption(const char* name) {
+    return JLI_StrCCmp(name, "--module-path=") == 0 ||
+           JLI_StrCCmp(name, "--upgrade-module-path=") == 0 ||
+           JLI_StrCCmp(name, "--add-modules=") == 0 ||
+           JLI_StrCCmp(name, "--limit-modules=") == 0 ||
+           JLI_StrCCmp(name, "--add-exports=") == 0 ||
+           JLI_StrCCmp(name, "--add-reads=") == 0 ||
+           JLI_StrCCmp(name, "--patch-module=") == 0;
+}
+
 /*
  * Test if the given name has a white space option.
  */
 jboolean
 IsWhiteSpaceOption(const char* name) {

@@ -1234,11 +1245,11 @@
 
     while ((arg = *argv) != 0 && *arg == '-') {
         char *option = NULL;
         char *value = NULL;
         int kind = GetOpt(&argc, &argv, &option, &value);
-        jboolean has_arg = value != NULL;
+        jboolean has_arg = value != NULL && JLI_StrLen(value) > 0;
 
 /*
  * Option to set main entry point
  */
         if (JLI_StrCmp(arg, "-jar") == 0) {

@@ -1283,23 +1294,17 @@
                 AddLongFormOption(option, value);
             }
 /*
  * Error missing argument
  */
-        } else if (!has_arg && IsWhiteSpaceOption(arg)) {
-            if (JLI_StrCmp(arg, "--module-path") == 0 ||
+        } else if (!has_arg && (JLI_StrCmp(arg, "--module-path") == 0 ||
                 JLI_StrCmp(arg, "-p") == 0 ||
-                JLI_StrCmp(arg, "--upgrade-module-path") == 0) {
+                                JLI_StrCmp(arg, "--upgrade-module-path") == 0)) {
                 REPORT_ERROR (has_arg, ARG_ERROR4, arg);
-            } else if (JLI_StrCmp(arg, "--add-modules") == 0 ||
-                       JLI_StrCmp(arg, "--limit-modules") == 0 ||
-                       JLI_StrCmp(arg, "--add-exports") == 0 ||
-                       JLI_StrCmp(arg, "--add-opens") == 0 ||
-                       JLI_StrCmp(arg, "--add-reads") == 0 ||
-                       JLI_StrCmp(arg, "--patch-module") == 0) {
+
+        } else if (!has_arg && (IsModuleOption(arg) || IsLongFormModuleOption(arg))) {
                 REPORT_ERROR (has_arg, ARG_ERROR6, arg);
-            }
 /*
  * The following cases will cause the argument parsing to stop
  */
         } else if (JLI_StrCmp(arg, "-help") == 0 ||
                    JLI_StrCmp(arg, "-h") == 0 ||
< prev index next >