91
91
92
92
public abstract class Launcher {
93
93
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" );
95
94
96
95
/**
97
96
* Default option description indentation.
@@ -480,15 +479,15 @@ protected final void setOptionIndent(int indent) {
480
479
protected abstract OptionDescriptor findOptionDescriptor (String group , String key );
481
480
482
481
/**
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.
486
483
*
487
- * @return {@code true}, if polyglot is relevant in this launcher.
484
+ * @deprecated always returns true.
485
+ * @return {@code true}
488
486
* @since 20.0
489
487
*/
488
+ @ Deprecated (since = "26.0" )
490
489
protected boolean canPolyglot () {
491
- return ! isStandalone () ;
490
+ return true ;
492
491
}
493
492
494
493
/**
@@ -517,7 +516,7 @@ private String[] executableNames(String basename) {
517
516
518
517
/**
519
518
* Returns the name of the main class for this launcher.
520
- *
519
+ * <p>
521
520
* Typically:
522
521
*
523
522
* <pre>
@@ -629,22 +628,13 @@ protected boolean runLauncherAction() {
629
628
* @since 20.0
630
629
*/
631
630
protected void printDefaultHelp (OptionCategory printCategory ) {
632
- final VMType defaultVMType = SHELL_SCRIPT_LAUNCHER ? VMType .JVM : this .getDefaultVMType ();
633
-
634
631
printHelp (printCategory );
635
632
out .println ();
636
633
out .println ("Runtime options:" );
637
634
638
635
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." );
648
638
// @formatter:off
649
639
launcherOption ("--vm.[option]" , "Pass options to the host VM. To see available options, use '--help:vm'." );
650
640
launcherOption ("--log.file=<String>" , "Redirect guest languages logging into a given file." );
@@ -693,7 +683,7 @@ static String optionsTitle(String kind, OptionCategory optionCategory) {
693
683
* the generic launcher / VM ones.
694
684
*
695
685
* @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
697
687
* @param unrecognizedArgs arguments (options) to evaluate
698
688
* @since 20.0
699
689
*/
@@ -723,8 +713,8 @@ protected final void parseUnrecognizedOptions(String defaultOptionPrefix, Map<St
723
713
/**
724
714
* Parses an option, returning success. The method is called to parse `arg` option from the
725
715
* 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}.
728
718
*
729
719
* @param defaultOptionPrefix default prefix for the option names, derived from the launching
730
720
* application.
@@ -792,12 +782,12 @@ private void parseHelpArg(String arg) {
792
782
void parsePolyglotOption (String defaultOptionPrefix , Map <String , String > polyglotOptions , boolean experimentalOptions , String arg ) {
793
783
if (arg .equals ("--jvm" )) {
794
784
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 " );
796
786
}
797
787
return ;
798
788
} else if (arg .equals ("--native" )) {
799
789
if (!isAOT ()) {
800
- throw abort ("native options are not supported on the JVM" );
790
+ throw abort ("-- native is not supported in a JVM standalone " );
801
791
}
802
792
return ;
803
793
} else if (arg .startsWith ("--vm." ) && arg .length () > "--vm." .length ()) {
@@ -883,9 +873,6 @@ void parsePolyglotOption(String defaultOptionPrefix, Map<String, String> polyglo
883
873
private Set <String > collectAllArguments () {
884
874
Set <String > options = new LinkedHashSet <>();
885
875
collectArguments (options );
886
- if (canPolyglot ()) {
887
- options .add ("--polyglot" );
888
- }
889
876
if (!isStandalone ()) {
890
877
options .add ("--jvm" );
891
878
}
@@ -1223,10 +1210,10 @@ protected final void maybeNativeExec(List<String> args, boolean isPolyglotLaunch
1223
1210
* {@link #isAOT()} is true. If the result is to run native, then it applies VM options on the
1224
1211
* current process.
1225
1212
* <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).
1230
1217
*
1231
1218
* @param originalArgs the original arguments from main(), unmodified.
1232
1219
* @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
1245
1232
void maybeExec (List <String > originalArgs , List <String > unrecognizedArgs , VMType defaultVmType , boolean thinLauncher ) {
1246
1233
assert isAOT ();
1247
1234
VMType vmType = null ;
1248
- boolean polyglot = false ;
1249
1235
List <String > jvmArgs = new ArrayList <>();
1250
1236
List <String > applicationArgs = new ArrayList <>(originalArgs );
1251
1237
@@ -1284,24 +1270,17 @@ void maybeExec(List<String> originalArgs, List<String> unrecognizedArgs, VMType
1284
1270
vmOptions .add (vmArg );
1285
1271
}
1286
1272
iterator .remove ();
1287
- } else if (arg .equals ("--polyglot" )) {
1288
- polyglot = true ;
1289
1273
}
1290
1274
}
1291
- boolean isDefaultVMType = false ;
1292
1275
if (vmType == null ) {
1293
1276
vmType = defaultVmType ;
1294
- isDefaultVMType = true ;
1295
1277
}
1296
1278
1297
1279
if (vmType == VMType .JVM ) {
1298
1280
for (String vmOption : vmOptions ) {
1299
1281
jvmArgs .add ('-' + vmOption );
1300
1282
}
1301
1283
1302
- if (polyglot ) {
1303
- applicationArgs .add (0 , "--polyglot" );
1304
- }
1305
1284
assert !isStandalone ();
1306
1285
if (thinLauncher ) {
1307
1286
Map <String , String > env = new HashMap <>();
@@ -1328,14 +1307,6 @@ void maybeExec(List<String> originalArgs, List<String> unrecognizedArgs, VMType
1328
1307
* option values.
1329
1308
*/
1330
1309
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
- }
1339
1310
}
1340
1311
}
1341
1312
@@ -1357,24 +1328,8 @@ protected void executeJVM(String classpath, List<String> jvmArgs, List<String> r
1357
1328
nativeAccess .execJVM (classpath , jvmArgs , remainingArgs );
1358
1329
}
1359
1330
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
-
1376
1331
class Native {
1377
- // execve() to JVM/polyglot from native if needed.
1332
+ // execve() to JVM from native if needed.
1378
1333
// Only parses --jvm/--native to find the VMType and --vm.* to pass/set the VM options.
1379
1334
1380
1335
private void setNativeOption (String arg ) {
@@ -1528,18 +1483,6 @@ private void printNativeHelp() {
1528
1483
printBasicNativeHelp ();
1529
1484
}
1530
1485
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
-
1543
1486
private void execJVM (String classpath , List <String > jvmArgs , List <String > args ) {
1544
1487
// TODO use String[] for command to avoid a copy later
1545
1488
List <String > command = new ArrayList <>(jvmArgs .size () + args .size () + 4 );
0 commit comments