diff --git a/src/java.base/share/native/libjli/java.c b/src/java.base/share/native/libjli/java.c index 0bb1daed28a..4f9a6426dff 100644 --- a/src/java.base/share/native/libjli/java.c +++ b/src/java.base/share/native/libjli/java.c @@ -1198,9 +1198,6 @@ ParseArguments(int *pargc, char ***pargv, JLI_StrCmp(arg, "-cp") == 0) { REPORT_ERROR (has_arg_any_len, ARG_ERROR1, arg); SetClassPath(value); - if (mode != LM_SOURCE) { - mode = LM_CLASS; - } } else if (JLI_StrCmp(arg, "--list-modules") == 0) { listModules = JNI_TRUE; } else if (JLI_StrCmp(arg, "--show-resolved-modules") == 0) { @@ -1355,11 +1352,12 @@ ParseArguments(int *pargc, char ***pargv, *pret = 1; } } else if (mode == LM_UNKNOWN) { - /* default to LM_CLASS if -m, -jar and -cp options are - * not specified */ if (!_have_classpath) { SetClassPath("."); } + /* If neither of -m, -jar, --source option is set, then the + * launcher mode is LM_UNKNOWN. In such cases, we determine the + * mode as LM_CLASS or LM_SOURCE per the input file. */ mode = IsSourceFile(arg) ? LM_SOURCE : LM_CLASS; } else if (mode == LM_CLASS && IsSourceFile(arg)) { /* override LM_CLASS mode if given a source file */