9191
9292public abstract class Launcher {
9393 private static final boolean STATIC_VERBOSE = Boolean .getBoolean ("org.graalvm.launcher.verbose" );
94- private static final boolean SHELL_SCRIPT_LAUNCHER = Boolean .getBoolean ("org.graalvm.launcher.shell" );
9594
9695 /**
9796 * Default option description indentation.
@@ -480,15 +479,15 @@ protected final void setOptionIndent(int indent) {
480479 protected abstract OptionDescriptor findOptionDescriptor (String group , String key );
481480
482481 /**
483- * Determines if the tool supports polyglot. Returns true, if {@code --polyglot} option is valid
484- * for this tool and polyglot launcher works for it. The default implementation returns false
485- * only when {@link #isStandalone()} is true.
482+ * Deprecated, always returns true.
486483 *
487- * @return {@code true}, if polyglot is relevant in this launcher.
484+ * @deprecated always returns true.
485+ * @return {@code true}
488486 * @since 20.0
489487 */
488+ @ Deprecated (since = "26.0" )
490489 protected boolean canPolyglot () {
491- return ! isStandalone () ;
490+ return true ;
492491 }
493492
494493 /**
@@ -517,7 +516,7 @@ private String[] executableNames(String basename) {
517516
518517 /**
519518 * Returns the name of the main class for this launcher.
520- *
519+ * <p>
521520 * Typically:
522521 *
523522 * <pre>
@@ -629,22 +628,13 @@ protected boolean runLauncherAction() {
629628 * @since 20.0
630629 */
631630 protected void printDefaultHelp (OptionCategory printCategory ) {
632- final VMType defaultVMType = SHELL_SCRIPT_LAUNCHER ? VMType .JVM : this .getDefaultVMType ();
633-
634631 printHelp (printCategory );
635632 out .println ();
636633 out .println ("Runtime options:" );
637634
638635 setOptionIndent (45 );
639- if (canPolyglot ()) {
640- launcherOption ("--polyglot" , "Run with all other guest languages accessible." );
641- }
642- if (!SHELL_SCRIPT_LAUNCHER ) {
643- launcherOption ("--native" , "Run using the native launcher with limited access to Java libraries" + (defaultVMType == VMType .Native ? " (default)" : "" ) + "." );
644- }
645- if (!isStandalone ()) {
646- launcherOption ("--jvm" , "Run on the Java Virtual Machine with access to Java libraries" + (defaultVMType == VMType .JVM ? " (default)" : "" ) + "." );
647- }
636+ launcherOption ("--native" , "Ensure to run in Native mode." );
637+ launcherOption ("--jvm" , "Ensure to run in JVM mode." );
648638 // @formatter:off
649639 launcherOption ("--vm.[option]" , "Pass options to the host VM. To see available options, use '--help:vm'." );
650640 launcherOption ("--log.file=<String>" , "Redirect guest languages logging into a given file." );
@@ -693,7 +683,7 @@ static String optionsTitle(String kind, OptionCategory optionCategory) {
693683 * the generic launcher / VM ones.
694684 *
695685 * @param defaultOptionPrefix (language) prefix for the options
696- * @param polyglotOptions options being built for the polyglot launcher
686+ * @param polyglotOptions options being built for the polyglot context
697687 * @param unrecognizedArgs arguments (options) to evaluate
698688 * @since 20.0
699689 */
@@ -723,8 +713,8 @@ protected final void parseUnrecognizedOptions(String defaultOptionPrefix, Map<St
723713 /**
724714 * Parses an option, returning success. The method is called to parse `arg` option from the
725715 * commandline, not recognized by the application. The method may contribute to the
726- * `polyglotOptions` (in/out parameter, modifiable) to alter polyglot behaviour . If the option
727- * is recognized, the method must return {@code true}.
716+ * `polyglotOptions` (in/out parameter, modifiable) to alter polyglot options . If the option is
717+ * recognized, the method must return {@code true}.
728718 *
729719 * @param defaultOptionPrefix default prefix for the option names, derived from the launching
730720 * application.
@@ -792,12 +782,12 @@ private void parseHelpArg(String arg) {
792782 void parsePolyglotOption (String defaultOptionPrefix , Map <String , String > polyglotOptions , boolean experimentalOptions , String arg ) {
793783 if (arg .equals ("--jvm" )) {
794784 if (isAOT ()) {
795- throw abort ("should not reach here: jvm option failed to switch to JVM " );
785+ throw abort ("-- jvm is not supported in a Native standalone " );
796786 }
797787 return ;
798788 } else if (arg .equals ("--native" )) {
799789 if (!isAOT ()) {
800- throw abort ("native options are not supported on the JVM" );
790+ throw abort ("-- native is not supported in a JVM standalone " );
801791 }
802792 return ;
803793 } else if (arg .startsWith ("--vm." ) && arg .length () > "--vm." .length ()) {
@@ -883,9 +873,6 @@ void parsePolyglotOption(String defaultOptionPrefix, Map<String, String> polyglo
883873 private Set <String > collectAllArguments () {
884874 Set <String > options = new LinkedHashSet <>();
885875 collectArguments (options );
886- if (canPolyglot ()) {
887- options .add ("--polyglot" );
888- }
889876 if (!isStandalone ()) {
890877 options .add ("--jvm" );
891878 }
@@ -1223,10 +1210,10 @@ protected final void maybeNativeExec(List<String> args, boolean isPolyglotLaunch
12231210 * {@link #isAOT()} is true. If the result is to run native, then it applies VM options on the
12241211 * current process.
12251212 * <p>
1226- * The method parses the {@code unrecognizedArgs} for --jvm/--native/--polyglot flags and --vm.*
1227- * options. If JVM mode is requested, it execs a Java process configured with supported JVM
1228- * parameters and system properties over this process - in this case, the method does not return
1229- * (except errors).
1213+ * The method parses the {@code unrecognizedArgs} for --jvm/--native flags and --vm.* options.
1214+ * If JVM mode is requested, it execs a Java process configured with supported JVM parameters
1215+ * and system properties over this process - in this case, the method does not return (except
1216+ * errors).
12301217 *
12311218 * @param originalArgs the original arguments from main(), unmodified.
12321219 * @param unrecognizedArgs a subset of {@code originalArgs} that was not recognized by
@@ -1245,7 +1232,6 @@ protected final void maybeNativeExec(List<String> originalArgs, List<String> unr
12451232 void maybeExec (List <String > originalArgs , List <String > unrecognizedArgs , VMType defaultVmType , boolean thinLauncher ) {
12461233 assert isAOT ();
12471234 VMType vmType = null ;
1248- boolean polyglot = false ;
12491235 List <String > jvmArgs = new ArrayList <>();
12501236 List <String > applicationArgs = new ArrayList <>(originalArgs );
12511237
@@ -1284,24 +1270,17 @@ void maybeExec(List<String> originalArgs, List<String> unrecognizedArgs, VMType
12841270 vmOptions .add (vmArg );
12851271 }
12861272 iterator .remove ();
1287- } else if (arg .equals ("--polyglot" )) {
1288- polyglot = true ;
12891273 }
12901274 }
1291- boolean isDefaultVMType = false ;
12921275 if (vmType == null ) {
12931276 vmType = defaultVmType ;
1294- isDefaultVMType = true ;
12951277 }
12961278
12971279 if (vmType == VMType .JVM ) {
12981280 for (String vmOption : vmOptions ) {
12991281 jvmArgs .add ('-' + vmOption );
13001282 }
13011283
1302- if (polyglot ) {
1303- applicationArgs .add (0 , "--polyglot" );
1304- }
13051284 assert !isStandalone ();
13061285 if (thinLauncher ) {
13071286 Map <String , String > env = new HashMap <>();
@@ -1328,14 +1307,6 @@ void maybeExec(List<String> originalArgs, List<String> unrecognizedArgs, VMType
13281307 * option values.
13291308 */
13301309 VMRuntime .initialize ();
1331-
1332- if (polyglot ) {
1333- assert jvmArgs .isEmpty ();
1334- if (isStandalone ()) {
1335- throw abort ("--polyglot option is only supported when this launcher is part of a GraalVM." );
1336- }
1337- executePolyglot (applicationArgs , Collections .emptyMap (), !isDefaultVMType );
1338- }
13391310 }
13401311 }
13411312
@@ -1357,24 +1328,8 @@ protected void executeJVM(String classpath, List<String> jvmArgs, List<String> r
13571328 nativeAccess .execJVM (classpath , jvmArgs , remainingArgs );
13581329 }
13591330
1360- @ SuppressWarnings ("unused" )
1361- @ Deprecated (since = "20.3" )
1362- protected void executePolyglot (List <String > mainArgs , Map <String , String > polyglotOptions , boolean forceNative ) {
1363- executePolyglot (mainArgs , forceNative );
1364- }
1365-
1366- /**
1367- * Called to execute the bin/polyglot launcher with the supplied options. Subclasses may
1368- * eventually override and implement in a different way.
1369- *
1370- * @param mainArgs program arguments
1371- */
1372- protected void executePolyglot (List <String > mainArgs , boolean forceNative ) {
1373- nativeAccess .executePolyglot (mainArgs , forceNative );
1374- }
1375-
13761331 class Native {
1377- // execve() to JVM/polyglot from native if needed.
1332+ // execve() to JVM from native if needed.
13781333 // Only parses --jvm/--native to find the VMType and --vm.* to pass/set the VM options.
13791334
13801335 private void setNativeOption (String arg ) {
@@ -1528,18 +1483,6 @@ private void printNativeHelp() {
15281483 printBasicNativeHelp ();
15291484 }
15301485
1531- private void executePolyglot (List <String > args , boolean forceNative ) {
1532- List <String > command = new ArrayList <>(args .size () + 3 );
1533- Path executable = getGraalVMBinaryPath ("polyglot" );
1534- if (forceNative ) {
1535- command .add ("--native" );
1536- }
1537- command .add ("--use-launcher" );
1538- command .add (getMainClass ());
1539- command .addAll (args );
1540- exec (executable , command );
1541- }
1542-
15431486 private void execJVM (String classpath , List <String > jvmArgs , List <String > args ) {
15441487 // TODO use String[] for command to avoid a copy later
15451488 List <String > command = new ArrayList <>(jvmArgs .size () + args .size () + 4 );
0 commit comments