Package org.graalvm.launcher
Class AbstractLanguageLauncher
java.lang.Object
org.graalvm.launcher.Launcher
org.graalvm.launcher.LanguageLauncherBase
org.graalvm.launcher.AbstractLanguageLauncher
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classUsed by the native launcher to detect that a relaunch of the VM is needed.Nested classes/interfaces inherited from class org.graalvm.launcher.Launcher
Launcher.AbortException, Launcher.OS, Launcher.VersionAction, Launcher.VMType -
Field Summary
FieldsFields inherited from class org.graalvm.launcher.Launcher
LAUNCHER_OPTIONS_INDENT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String[]The return value specifies what languages should be available by default when not using --polyglot.protected abstract StringReturns the language id of the language launched by this launcher.protected intThe native argument count as passed to the main method of the native launcher.protected longThe native argument values as passed to the main method of the native launcher.protected final voidThis starts the launcher.protected abstract voidlaunch(org.graalvm.polyglot.Context.Builder contextBuilder) Launch the scripts as required by the arguments received during the previous call topreprocessArguments(List, Map).Process command line arguments by either saving the necessary state or adding it to thepolyglotOptions.protected voidPrints version information on stdout.protected voidprintVersion(org.graalvm.polyglot.Engine engine) static voidrunLauncher(byte[][] optionVarsArgs, byte[][] args, int argc, long argv, boolean relaunch) Entry point for invoking the launcher via JNI.protected voidrunVersionAction(Launcher.VersionAction action, org.graalvm.polyglot.Engine engine) protected voidvalidateArguments(Map<String, String> polyglotOptions) Validates arguments after all arguments have been parsed.protected final voidvalidateVmArguments(List<String> originalArgs, List<String> unrecognizedArgs) Check if the arguments parsing heuristic of the native launcher correctly identified the set of VM arguments.Methods inherited from class org.graalvm.launcher.LanguageLauncherBase
argumentsProcessingDone, collectArguments, findOptionDescriptor, maybePrintAdditionalHelp, parseCommonOption, printDefaultHelp, printPolyglotVersions, runLauncherActionMethods inherited from class org.graalvm.launcher.Launcher
abort, abort, abort, abort, abort, abort, abortInvalidArgument, abortInvalidArgument, abortUnrecognizedArgument, canPolyglot, executeJVM, executeJVM, executePolyglot, executePolyglot, exit, exit, getDefaultVMType, getError, getGraalVMBinaryPath, getGraalVMHome, getLogFile, getMainClass, getOutput, getProgramName, isAOT, isGraalVMAvailable, isStandalone, isTTY, launcherOption, maybeNativeExec, maybeNativeExec, newLogStream, parseUnrecognizedOptions, printHelp, println, println, printOtherHelpCategory, setError, setOptionIndent, setOutput, warn, warn
-
Field Details
-
IS_LIBPOLYGLOT
protected static final boolean IS_LIBPOLYGLOT
-
-
Constructor Details
-
AbstractLanguageLauncher
public AbstractLanguageLauncher()
-
-
Method Details
-
launch
This starts the launcher. it should be called from the main method:public static void main(String[] args) { new MyLauncher().launch(args); }- Parameters:
args- the command line arguments.
-
runLauncher
public static void runLauncher(byte[][] optionVarsArgs, byte[][] args, int argc, long argv, boolean relaunch) throws Exception Entry point for invoking the launcher via JNI. Relies on a launcher constructor to be set via the org.graalvm.launcher.class system property.- Parameters:
optionVarsArgs- the arguments from the option_vars environment variablesargs- the command line arguments as an encoding-agnostic byte arrayargc- the number of native command line argumentsargv- pointer to argvrelaunch- indicates if this is a relaunch with previously identified --vm.* arguments- Throws:
Exception- if no launcher constructor has been set.
-
validateVmArguments
Check if the arguments parsing heuristic of the native launcher correctly identified the set of VM arguments. Throw aRelaunchExceptionif it hasn't. The exception will be picked up by the native launcher, which will read thevmArgs, put them in environment variables and restart the VM with the correct set of VM arguments.- Parameters:
originalArgs- original set of arguments (except for argv[0], the program name)unrecognizedArgs- set of arguments returned bypreprocessArguments()
-
getNativeArgc
protected int getNativeArgc()The native argument count as passed to the main method of the native launcher.- Returns:
- native argument count, including the program name
-
getNativeArgv
protected long getNativeArgv()The native argument values as passed to the main method of the native launcher.- Returns:
- pointer to the native argument values, including the program name
-
preprocessArguments
protected abstract List<String> preprocessArguments(List<String> arguments, Map<String, String> polyglotOptions) Process command line arguments by either saving the necessary state or adding it to thepolyglotOptions. Any unrecognized arguments should be accumulated and returned as a list. VM (--jvm/--native/--polyglot/--vm.*) and polyglot options (--language.option or --option) should be returned as unrecognized arguments to be automatically parsed and validated byLauncher.parsePolyglotOption(String, Map, boolean, String). Theargumentsshould not be modified, but doing so also has no effect.polyglotOptions.put()can be used to set launcher-specific default values when they do not match the OptionKey's default. ThepreprocessArgumentsimplementations can useEngineto inspect the the installedguest languagesandinstruments. But creating aContextor inspectingengine optionsis forbidden.- Parameters:
arguments- the command line arguments that were passed to the launcher.polyglotOptions- a map where polyglot options can be set. These will be used when creating theEngine.- Returns:
- the list of arguments that were not recognized.
-
validateArguments
Validates arguments after all arguments have been parsed.- Parameters:
polyglotOptions- the options that will be used to create engine.
-
launch
protected abstract void launch(org.graalvm.polyglot.Context.Builder contextBuilder) Launch the scripts as required by the arguments received during the previous call topreprocessArguments(List, Map).- Parameters:
contextBuilder- a context builder configured with the proper language and polyglot options.
-
getLanguageId
Returns the language id of the language launched by this launcher. -
printVersion
protected void printVersion()Description copied from class:LauncherPrints version information on stdout.- Specified by:
printVersionin classLauncher
-
printVersion
protected void printVersion(org.graalvm.polyglot.Engine engine) -
runVersionAction
-
getDefaultLanguages
The return value specifies what languages should be available by default when not using --polyglot. Note that TruffleLanguage.Registration#dependentLanguages() should be preferred in most cases.- Returns:
- an array of required language ids
-