mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8201274: Launch Single-File Source-Code Programs
Reviewed-by: mcimadamore, jlahoda, ksrini, mchung, ihse, alanb
This commit is contained in:
parent
628aec8c75
commit
fe24730ed9
17 changed files with 1737 additions and 59 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2017, 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
|
||||
|
@ -502,12 +502,13 @@ public final class LauncherHelper {
|
|||
}
|
||||
|
||||
// From src/share/bin/java.c:
|
||||
// enum LaunchMode { LM_UNKNOWN = 0, LM_CLASS, LM_JAR, LM_MODULE }
|
||||
// enum LaunchMode { LM_UNKNOWN = 0, LM_CLASS, LM_JAR, LM_MODULE, LM_SOURCE }
|
||||
|
||||
private static final int LM_UNKNOWN = 0;
|
||||
private static final int LM_CLASS = 1;
|
||||
private static final int LM_JAR = 2;
|
||||
private static final int LM_MODULE = 3;
|
||||
private static final int LM_SOURCE = 4;
|
||||
|
||||
static void abort(Throwable t, String msgKey, Object... args) {
|
||||
if (msgKey != null) {
|
||||
|
@ -538,13 +539,21 @@ public final class LauncherHelper {
|
|||
*
|
||||
* @return the application's main class
|
||||
*/
|
||||
@SuppressWarnings("fallthrough")
|
||||
public static Class<?> checkAndLoadMain(boolean printToStderr,
|
||||
int mode,
|
||||
String what) {
|
||||
initOutput(printToStderr);
|
||||
|
||||
Class<?> mainClass = (mode == LM_MODULE) ? loadModuleMainClass(what)
|
||||
: loadMainClass(mode, what);
|
||||
Class<?> mainClass = null;
|
||||
switch (mode) {
|
||||
case LM_MODULE: case LM_SOURCE:
|
||||
mainClass = loadModuleMainClass(what);
|
||||
break;
|
||||
default:
|
||||
mainClass = loadMainClass(mode, what);
|
||||
break;
|
||||
}
|
||||
|
||||
// record the real main class for UI purposes
|
||||
// neither method above can return null, they will abort()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2007, 2017, 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
|
||||
|
@ -25,13 +25,17 @@
|
|||
|
||||
# Translators please note do not translate the options themselves
|
||||
java.launcher.opt.header = Usage: {0} [options] <mainclass> [args...]\n\
|
||||
\ (to execute a class)\n or {0} [options] -jar <jarfile> [args...]\n\
|
||||
\ (to execute a class)\n\
|
||||
\ or {0} [options] -jar <jarfile> [args...]\n\
|
||||
\ (to execute a jar file)\n\
|
||||
\ or {0} [options] -m <module>[/<mainclass>] [args...]\n\
|
||||
\ {0} [options] --module <module>[/<mainclass>] [args...]\n\
|
||||
\ (to execute the main class in a module)\n\n\
|
||||
\ Arguments following the main class, -jar <jarfile>, -m or --module\n\
|
||||
\ <module>/<mainclass> are passed as the arguments to main class.\n\n\
|
||||
\ (to execute the main class in a module)\n\
|
||||
\ or {0} [options] <sourcefile> [args]\n\
|
||||
\ (to execute a single source-file program)\n\n\
|
||||
\ Arguments following the main class, source file, -jar <jarfile>,\n\
|
||||
\ -m or --module <module>/<mainclass> are passed as the arguments to\n\
|
||||
\ main class.\n\n\
|
||||
\ where options include:\n\n
|
||||
|
||||
java.launcher.opt.vmselect =\ {0}\t to select the "{1}" VM\n
|
||||
|
@ -114,7 +118,7 @@ java.launcher.opt.footer = \
|
|||
\ -disable-@files\n\
|
||||
\ prevent further argument file expansion\n\
|
||||
\ --enable-preview\n\
|
||||
\ allow classes to depend on preview features of this release
|
||||
\ allow classes to depend on preview features of this release\n\
|
||||
\To specify an argument for a long option, you can use --<name>=<value> or\n\
|
||||
\--<name> <value>.\n
|
||||
|
||||
|
@ -176,7 +180,9 @@ java.launcher.X.usage=\n\
|
|||
\ --patch-module <module>=<file>({0}<file>)*\n\
|
||||
\ override or augment a module with classes and resources\n\
|
||||
\ in JAR files or directories.\n\
|
||||
\ --disable-@files disable further argument file expansion\n\n\
|
||||
\ --disable-@files disable further argument file expansion\n\
|
||||
\ --source <version>\n\
|
||||
\ set the version of the source in source-file mode.\n\n\
|
||||
These extra options are subject to change without notice.\n
|
||||
|
||||
# Translators please note do not translate the options themselves
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue