< prev index next >

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

Print this page




 539 
 540 /*
 541  * Test if the given name is a launcher option taking the main entry point.
 542  */
 543 static jboolean
 544 IsLauncherMainOption(const char* name) {
 545     return JLI_StrCmp(name, "--module") == 0 ||
 546            JLI_StrCmp(name, "-m") == 0;
 547 }
 548 
 549 /*
 550  * Test if the given name is a white-space launcher option.
 551  */
 552 static jboolean
 553 IsLauncherOption(const char* name) {
 554     return IsClassPathOption(name) ||
 555            IsLauncherMainOption(name) ||
 556            JLI_StrCmp(name, "--list-modules") == 0;
 557 }
 558 
 559 #ifndef OLD_MODULE_OPTIONS
 560 /*
 561  * Old module options for transition
 562  */
 563 static jboolean
 564 IsOldModuleOption(const char* name) {
 565     return JLI_StrCmp(name, "-modulepath") == 0 ||
 566     JLI_StrCmp(name, "-mp") == 0 ||
 567     JLI_StrCmp(name, "-upgrademodulepath") == 0 ||
 568     JLI_StrCmp(name, "-addmods") == 0 ||
 569     JLI_StrCmp(name, "-limitmods") == 0;
 570 }
 571 #endif
 572 
 573 /*
 574  * Test if the given name is a module-system white-space option that
 575  * will be passed to the VM with its corresponding long-form option
 576  * name and "=" delimiter.
 577  */
 578 static jboolean
 579 IsModuleOption(const char* name) {
 580     return JLI_StrCmp(name, "--module-path") == 0 ||
 581            JLI_StrCmp(name, "-p") == 0 ||
 582            JLI_StrCmp(name, "--upgrade-module-path") == 0 ||
 583            JLI_StrCmp(name, "--add-modules") == 0 ||
 584            JLI_StrCmp(name, "--limit-modules") == 0 ||
 585            JLI_StrCmp(name, "--add-exports") == 0 ||
 586            JLI_StrCmp(name, "--add-reads") == 0 ||
 587            JLI_StrCmp(name, "--patch-module") == 0 ||
 588            IsOldModuleOption(name);
 589 }
 590 
 591 /*
 592  * Test if the given name has a white space option.
 593  */
 594 jboolean
 595 IsWhiteSpaceOption(const char* name) {
 596     return IsModuleOption(name) ||
 597            IsLauncherOption(name);
 598 }
 599 
 600 /*
 601  * Checks the command line options to find which JVM type was
 602  * specified.  If no command line option was given for the JVM type,
 603  * the default type is used.  The environment variable
 604  * JDK_ALTERNATE_VM and the command line option -XXaltjvm= are also
 605  * checked as ways of specifying which JVM type to invoke.
 606  */
 607 char *
 608 CheckJvmType(int *pargc, char ***argv, jboolean speculative) {


1207         }
1208 
1209         /*
1210          * Support short form alias
1211          */
1212         if (JLI_StrCmp(arg, "-p") == 0) {
1213             option = "--module-path";
1214         }
1215 
1216     } else if (JLI_StrCCmp(arg, "--") == 0 && (equals = JLI_StrChr(arg, '=')) != NULL) {
1217         value = equals+1;
1218         if (JLI_StrCCmp(arg, "--list-modules=") == 0 ||
1219             JLI_StrCCmp(arg, "--module=") == 0 ||
1220             JLI_StrCCmp(arg, "--class-path=") == 0) {
1221             kind = LAUNCHER_OPTION_WITH_ARGUMENT;
1222         } else {
1223             kind = VM_LONG_OPTION;
1224         }
1225     }
1226 
1227 #ifndef OLD_MODULE_OPTIONS
1228     // for transition to support both old and new syntax
1229     if (JLI_StrCmp(arg, "-modulepath") == 0 ||
1230         JLI_StrCmp(arg, "-mp") == 0) {
1231         option = "--module-path";
1232     } else if (JLI_StrCmp(arg, "-upgrademodulepath") == 0) {
1233         option = "--upgrade-module-path";
1234     } else if (JLI_StrCmp(arg, "-addmods") == 0) {
1235         option = "--add-modules";
1236     } else if (JLI_StrCmp(arg, "-limitmods") == 0) {
1237         option = "--limit-modules";
1238     } else if (JLI_StrCCmp(arg, "-XaddExports:") == 0) {
1239         option = "--add-exports";
1240         value = arg + 13;
1241         kind = VM_LONG_OPTION_WITH_ARGUMENT;
1242     } else if (JLI_StrCCmp(arg, "-XaddReads:") == 0) {
1243         option = "--add-reads";
1244         value = arg + 11;
1245         kind = VM_LONG_OPTION_WITH_ARGUMENT;
1246     } else if (JLI_StrCCmp(arg, "-Xpatch:") == 0) {
1247         option = "--patch-module";
1248         value = arg + 8;
1249         kind = VM_LONG_OPTION_WITH_ARGUMENT;
1250     }
1251 #endif
1252 
1253     *pargc = argc;
1254     *pargv = argv;
1255     *poption = option;
1256     *pvalue = value;
1257     return kind;
1258 }
1259 
1260 /*
1261  * Parses command line arguments.  Returns JNI_FALSE if launcher
1262  * should exit without starting vm, returns JNI_TRUE if vm needs
1263  * to be started to process given options.  *pret (the launcher
1264  * process return value) is set to 0 for a normal exit.
1265  */
1266 static jboolean
1267 ParseArguments(int *pargc, char ***pargv,
1268                int *pmode, char **pwhat,
1269                int *pret, const char *jrepath)
1270 {
1271     int argc = *pargc;
1272     char **argv = *pargv;


1323             if (kind == VM_LONG_OPTION) {
1324                 AddOption(option, NULL);
1325             } else if (kind == VM_LONG_OPTION_WITH_ARGUMENT) {
1326                 AddLongFormOption(option, value);
1327             }
1328 /*
1329  * Error missing argument
1330  */
1331         } else if (!has_arg && IsWhiteSpaceOption(arg)) {
1332             if (JLI_StrCmp(arg, "--module-path") == 0 ||
1333                 JLI_StrCmp(arg, "-p") == 0 ||
1334                 JLI_StrCmp(arg, "--upgrade-module-path") == 0) {
1335                 REPORT_ERROR (has_arg, ARG_ERROR4, arg);
1336             } else if (JLI_StrCmp(arg, "--add-modules") == 0 ||
1337                        JLI_StrCmp(arg, "--limit-modules") == 0 ||
1338                        JLI_StrCmp(arg, "--add-exports") == 0 ||
1339                        JLI_StrCmp(arg, "--add-reads") == 0 ||
1340                        JLI_StrCmp(arg, "--patch-module") == 0) {
1341                 REPORT_ERROR (has_arg, ARG_ERROR6, arg);
1342             }
1343 #ifndef OLD_MODULE_OPTIONS
1344             else if (JLI_StrCmp(arg, "-modulepath") == 0 ||
1345                      JLI_StrCmp(arg, "-mp") == 0 ||
1346                      JLI_StrCmp(arg, "-upgrademodulepath") == 0) {
1347                 REPORT_ERROR (has_arg, ARG_ERROR4, arg);
1348             } else if (JLI_StrCmp(arg, "-addmods") == 0 ||
1349                        JLI_StrCmp(arg, "-limitmods") == 0) {
1350                 REPORT_ERROR (has_arg, ARG_ERROR6, arg);
1351             }
1352 #endif
1353 /*
1354  * The following cases will cause the argument parsing to stop
1355  */
1356         } else if (JLI_StrCmp(arg, "--help") == 0 ||
1357                    JLI_StrCmp(arg, "-help") == 0 ||
1358                    JLI_StrCmp(arg, "-h") == 0 ||
1359                    JLI_StrCmp(arg, "-?") == 0) {
1360             printUsage = JNI_TRUE;
1361             return JNI_TRUE;
1362         } else if (JLI_StrCmp(arg, "-version") == 0) {
1363             printVersion = JNI_TRUE;
1364             return JNI_TRUE;
1365         } else if (JLI_StrCmp(arg, "-showversion") == 0) {
1366             showVersion = JNI_TRUE;
1367         } else if (JLI_StrCmp(arg, "--dry-run") == 0) {
1368             dryRun = JNI_TRUE;
1369         } else if (JLI_StrCmp(arg, "-X") == 0) {
1370             printXUsage = JNI_TRUE;
1371             return JNI_TRUE;
1372 /*




 539 
 540 /*
 541  * Test if the given name is a launcher option taking the main entry point.
 542  */
 543 static jboolean
 544 IsLauncherMainOption(const char* name) {
 545     return JLI_StrCmp(name, "--module") == 0 ||
 546            JLI_StrCmp(name, "-m") == 0;
 547 }
 548 
 549 /*
 550  * Test if the given name is a white-space launcher option.
 551  */
 552 static jboolean
 553 IsLauncherOption(const char* name) {
 554     return IsClassPathOption(name) ||
 555            IsLauncherMainOption(name) ||
 556            JLI_StrCmp(name, "--list-modules") == 0;
 557 }
 558 














 559 /*
 560  * Test if the given name is a module-system white-space option that
 561  * will be passed to the VM with its corresponding long-form option
 562  * name and "=" delimiter.
 563  */
 564 static jboolean
 565 IsModuleOption(const char* name) {
 566     return JLI_StrCmp(name, "--module-path") == 0 ||
 567            JLI_StrCmp(name, "-p") == 0 ||
 568            JLI_StrCmp(name, "--upgrade-module-path") == 0 ||
 569            JLI_StrCmp(name, "--add-modules") == 0 ||
 570            JLI_StrCmp(name, "--limit-modules") == 0 ||
 571            JLI_StrCmp(name, "--add-exports") == 0 ||
 572            JLI_StrCmp(name, "--add-reads") == 0 ||
 573            JLI_StrCmp(name, "--patch-module") == 0;

 574 }
 575 
 576 /*
 577  * Test if the given name has a white space option.
 578  */
 579 jboolean
 580 IsWhiteSpaceOption(const char* name) {
 581     return IsModuleOption(name) ||
 582            IsLauncherOption(name);
 583 }
 584 
 585 /*
 586  * Checks the command line options to find which JVM type was
 587  * specified.  If no command line option was given for the JVM type,
 588  * the default type is used.  The environment variable
 589  * JDK_ALTERNATE_VM and the command line option -XXaltjvm= are also
 590  * checked as ways of specifying which JVM type to invoke.
 591  */
 592 char *
 593 CheckJvmType(int *pargc, char ***argv, jboolean speculative) {


1192         }
1193 
1194         /*
1195          * Support short form alias
1196          */
1197         if (JLI_StrCmp(arg, "-p") == 0) {
1198             option = "--module-path";
1199         }
1200 
1201     } else if (JLI_StrCCmp(arg, "--") == 0 && (equals = JLI_StrChr(arg, '=')) != NULL) {
1202         value = equals+1;
1203         if (JLI_StrCCmp(arg, "--list-modules=") == 0 ||
1204             JLI_StrCCmp(arg, "--module=") == 0 ||
1205             JLI_StrCCmp(arg, "--class-path=") == 0) {
1206             kind = LAUNCHER_OPTION_WITH_ARGUMENT;
1207         } else {
1208             kind = VM_LONG_OPTION;
1209         }
1210     }
1211 


























1212     *pargc = argc;
1213     *pargv = argv;
1214     *poption = option;
1215     *pvalue = value;
1216     return kind;
1217 }
1218 
1219 /*
1220  * Parses command line arguments.  Returns JNI_FALSE if launcher
1221  * should exit without starting vm, returns JNI_TRUE if vm needs
1222  * to be started to process given options.  *pret (the launcher
1223  * process return value) is set to 0 for a normal exit.
1224  */
1225 static jboolean
1226 ParseArguments(int *pargc, char ***pargv,
1227                int *pmode, char **pwhat,
1228                int *pret, const char *jrepath)
1229 {
1230     int argc = *pargc;
1231     char **argv = *pargv;


1282             if (kind == VM_LONG_OPTION) {
1283                 AddOption(option, NULL);
1284             } else if (kind == VM_LONG_OPTION_WITH_ARGUMENT) {
1285                 AddLongFormOption(option, value);
1286             }
1287 /*
1288  * Error missing argument
1289  */
1290         } else if (!has_arg && IsWhiteSpaceOption(arg)) {
1291             if (JLI_StrCmp(arg, "--module-path") == 0 ||
1292                 JLI_StrCmp(arg, "-p") == 0 ||
1293                 JLI_StrCmp(arg, "--upgrade-module-path") == 0) {
1294                 REPORT_ERROR (has_arg, ARG_ERROR4, arg);
1295             } else if (JLI_StrCmp(arg, "--add-modules") == 0 ||
1296                        JLI_StrCmp(arg, "--limit-modules") == 0 ||
1297                        JLI_StrCmp(arg, "--add-exports") == 0 ||
1298                        JLI_StrCmp(arg, "--add-reads") == 0 ||
1299                        JLI_StrCmp(arg, "--patch-module") == 0) {
1300                 REPORT_ERROR (has_arg, ARG_ERROR6, arg);
1301             }










1302 /*
1303  * The following cases will cause the argument parsing to stop
1304  */
1305         } else if (JLI_StrCmp(arg, "--help") == 0 ||
1306                    JLI_StrCmp(arg, "-help") == 0 ||
1307                    JLI_StrCmp(arg, "-h") == 0 ||
1308                    JLI_StrCmp(arg, "-?") == 0) {
1309             printUsage = JNI_TRUE;
1310             return JNI_TRUE;
1311         } else if (JLI_StrCmp(arg, "-version") == 0) {
1312             printVersion = JNI_TRUE;
1313             return JNI_TRUE;
1314         } else if (JLI_StrCmp(arg, "-showversion") == 0) {
1315             showVersion = JNI_TRUE;
1316         } else if (JLI_StrCmp(arg, "--dry-run") == 0) {
1317             dryRun = JNI_TRUE;
1318         } else if (JLI_StrCmp(arg, "-X") == 0) {
1319             printXUsage = JNI_TRUE;
1320             return JNI_TRUE;
1321 /*


< prev index next >