public abstract class AbstractLanguageLauncher extends LanguageLauncherBase
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractLanguageLauncher.RelaunchException
Used by the native launcher to detect that a relaunch of the VM is needed.
|
Launcher.AbortException, Launcher.OS, Launcher.VersionAction, Launcher.VMType| Modifier and Type | Field and Description |
|---|---|
protected static boolean |
IS_LIBPOLYGLOT |
LAUNCHER_OPTIONS_INDENT| Constructor and Description |
|---|
AbstractLanguageLauncher() |
| Modifier and Type | Method and Description |
|---|---|
protected String[] |
getDefaultLanguages()
The return value specifies what languages should be available by default when not using
--polyglot.
|
protected abstract String |
getLanguageId()
Returns the language id of the language launched by this
launcher.
|
protected int |
getNativeArgc()
The native argument count as passed to the main method of the native launcher.
|
protected long |
getNativeArgv()
The native argument values as passed to the main method of the native launcher.
|
protected abstract void |
launch(org.graalvm.polyglot.Context.Builder contextBuilder)
Launch the scripts as required by the arguments received during the previous call to
AbstractLanguageLauncher.preprocessArguments(List, Map). |
protected void |
launch(String[] args)
This starts the launcher.
|
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 the
polyglotOptions. |
protected void |
printVersion()
Prints version information on stdout.
|
protected void |
printVersion(org.graalvm.polyglot.Engine engine) |
static void |
runLauncher(byte[][] args,
int argc,
long argv,
boolean relaunch)
Entry point for invoking the launcher via JNI.
|
protected void |
runVersionAction(Launcher.VersionAction action,
org.graalvm.polyglot.Engine engine) |
protected void |
validateArguments(Map<String,String> polyglotOptions)
Validates arguments after all arguments have been parsed.
|
protected void |
validateVmArguments(List<String> originalArgs,
List<String> unrecognizedArgs)
Check if the arguments parsing heuristic of the native launcher correctly identified the set
of VM arguments.
|
argumentsProcessingDone, collectArguments, findOptionDescriptor, maybePrintAdditionalHelp, parseCommonOption, printDefaultHelp, printPolyglotVersions, runLauncherActionabort, abort, abort, abort, abort, abort, abortInvalidArgument, abortInvalidArgument, abortUnrecognizedArgument, canPolyglot, executeJVM, executePolyglot, exit, exit, getDefaultVMType, getError, getGraalVMBinaryPath, getGraalVMHome, getLogFile, getMainClass, getOutput, getProgramName, isAOT, isGraalVMAvailable, isStandalone, isTTY, launcherOption, maybeNativeExec, newLogStream, parseUnrecognizedOptions, printHelp, println, println, printOtherHelpCategory, setError, setOptionIndent, setOutput, warn, warnprotected final void launch(String[] args)
public static void main(String[] args) {
new MyLauncher().launch(args);
}
args - the command line arguments.public static void runLauncher(byte[][] args,
int argc,
long argv,
boolean relaunch)
throws Exception
args - 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 argumentsException - if no launcher constructor has been set.protected final void validateVmArguments(List<String> originalArgs, List<String> unrecognizedArgs)
RelaunchException if it hasn't. The exception will be picked
up by the native launcher, which will read the vmArgs, put them in environment
variables and restart the VM with the correct set of VM arguments.originalArgs - original set of arguments (except for argv[0], the program name)unrecognizedArgs - set of arguments returned by preprocessArguments()protected int getNativeArgc()
protected long getNativeArgv()
protected abstract List<String> preprocessArguments(List<String> arguments, Map<String,String> polyglotOptions)
polyglotOptions. 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 by Launcher.parsePolyglotOption(String, Map, boolean, String).
The arguments should 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.
The preprocessArguments implementations can use Engine to inspect the the
installed guest languages and instruments. But creating a Context or inspecting engine
options is forbidden.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 the Engine.protected void validateArguments(Map<String,String> polyglotOptions)
polyglotOptions - the options that will be used to create engine.protected abstract void launch(org.graalvm.polyglot.Context.Builder contextBuilder)
AbstractLanguageLauncher.preprocessArguments(List, Map).contextBuilder - a context builder configured with the
proper language and polyglot options.protected abstract String getLanguageId()
protected void printVersion()
LauncherprintVersion in class Launcherprotected void printVersion(org.graalvm.polyglot.Engine engine)
protected void runVersionAction(Launcher.VersionAction action, org.graalvm.polyglot.Engine engine)
protected String[] getDefaultLanguages()