public final class Engine extends Object implements AutoCloseable
guest languages, instruments and
their available options.
By default every context creates its own engine instance implicitly when
instantiated. Multiple contexts can use an
explicit engine when using a context builder. If contexts
share the same engine instance then they share instruments and their configuration.
It can be useful to create an engine instance without a context to only
access meta-data for installed languages, instruments and their available options.
| Modifier and Type | Class and Description |
|---|---|
class |
Engine.Builder |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this engine and frees up allocated native resources.
|
void |
close(boolean cancelIfExecuting)
Closes this engine and frees up allocated native resources.
|
static Engine |
create()
Creates a new engine instance with default configuration.
|
static Path |
findHome()
Finds the GraalVM home folder.
|
String |
getImplementationName()
Gets a human-readable name of the polyglot implementation (for example, "Default Truffle
Engine" or "Graal Truffle Engine").
|
Map<String,Instrument> |
getInstruments()
Gets all installed instruments of this engine.
|
Map<String,Language> |
getLanguages()
Gets a map of all installed languages with the language id as key and the language object as
value.
|
OptionDescriptors |
getOptions()
Returns all options available for the engine.
|
String |
getVersion()
Gets the version string of the engine in an unspecified format.
|
static Engine.Builder |
newBuilder()
Creates a new context builder that allows to configure an engine instance.
|
public Map<String,Language> getLanguages()
public Map<String,Instrument> getInstruments()
options passed to the engine when the engine or
context is constructed.public OptionDescriptors getOptions()
groups:
Instrument.getOptions() or Language.getOptions().public String getVersion()
public void close(boolean cancelIfExecuting)
PolyglotException. The exception indicates that it was
cancelled.cancelIfExecuting - if true then currently executing contexts will be
cancelled, else an IllegalStateException is thrown.public void close()
close in interface AutoCloseableIllegalStateException - if there currently executing open context instances.Engine.close(boolean),
Engine.close()public String getImplementationName()
null.public static Engine create()
to create a new execution context.public static Engine.Builder newBuilder()
to construct a new execution context.public static Path findHome()
HomeFinder.getHomeFolder() which should be preferred.null if it cannot be found