Top Description Inners Fields Constructors Methods
org.graalvm.polyglot

public final Class Engine

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Imports
java.io.File, .IOException, .InputStream, .OutputStream, .PrintStream, java.lang.ModuleLayer.Controller, java.lang.invoke.MethodHandles, java.lang.module.Configuration, .FindException, .ModuleDescriptor, .ModuleDescriptor.Provides, .ModuleDescriptor.Requires, .ModuleFinder, .ModuleReference, .ResolvedModule, java.lang.reflect.AnnotatedElement, .Executable, .Field, .InvocationTargetException, .Method, .Type, java.net.URI, .URISyntaxException, .URL, .URLClassLoader, java.nio.charset.Charset, java.nio.file.Path, .Paths, java.security.AccessController, .PrivilegedAction, java.time.Duration, .Instant, .LocalDate, .LocalTime, .ZoneId, java.util.ArrayList, .Arrays, .Collection, .Collections, .Comparator, .HashMap, .HashSet, .Iterator, .LinkedHashSet, .List, .ListIterator, .Map, .Objects, .Optional, .Properties, .ServiceLoader, .Set, .WeakHashMap, java.util.concurrent.atomic.AtomicReference, java.util.function.Consumer, .Function, .Predicate, java.util.logging.Handler, java.util.logging.Level, org.graalvm.home.HomeFinder, org.graalvm.nativeimage.ImageInfo, org.graalvm.options.OptionDescriptor, .OptionDescriptors, org.graalvm.polyglot.HostAccess.MutableTargetMapping, .HostAccess.TargetMappingPrecedence, .PolyglotException.StackFrame, org.graalvm.polyglot.impl.AbstractPolyglotImpl, .AbstractPolyglotImpl.AbstractContextDispatch, .AbstractPolyglotImpl.AbstractEngineDispatch, .AbstractPolyglotImpl.AbstractExceptionDispatch, .AbstractPolyglotImpl.AbstractInstrumentDispatch, .AbstractPolyglotImpl.AbstractLanguageDispatch, .AbstractPolyglotImpl.AbstractSourceDispatch, .AbstractPolyglotImpl.AbstractSourceSectionDispatch, .AbstractPolyglotImpl.AbstractStackFrameImpl, .AbstractPolyglotImpl.AbstractValueDispatch, .AbstractPolyglotImpl.IOAccessor, .AbstractPolyglotImpl.ManagementAccess, .UnnamedToModuleBridge, org.graalvm.polyglot.io.ByteSequence, .FileSystem, .IOAccess, .MessageTransport, .ProcessHandler, org.graalvm.polyglot.proxy.Proxy, .ProxyArray, .ProxyDate, .ProxyDuration, .ProxyExecutable, .ProxyHashMap, .ProxyInstant, .ProxyInstantiable, .ProxyIterable, .ProxyIterator, .ProxyNativeObject, .ProxyObject, .ProxyTime, .ProxyTimeZone

An execution engine for Graal guest languages that allows to inspect the the installed 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.

Since
19.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
public class
private static class
Engine.ClassPathIsolation

If Truffle is on the class-path (or a language), we do not want to expose these classes to embedders (users of the polyglot API).

private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
pack-priv final Engine
pack-priv final AbstractPolyglotImpl.AbstractEngineDispatch
private static final Engine
private static final Map<Engine, Void>
private static volatile Throwable
pack-priv final Object
private static volatile boolean

Constructor Summary

AccessConstructor and Description
pack-priv <T>
private <T>
Engine(Engine engine)

Method Summary

Modifier and TypeMethod and Description
public void
close(boolean
if true then currently executing contexts will be cancelled, else an IllegalStateException is thrown.
cancelIfExecuting
)

Closes this engine and frees up allocated native resources.

public void
close()

Implements java.lang.AutoCloseable.close.

Closes this engine and frees up allocated native resources.

public static boolean

Returns:

true if at least one of the components has associated resources that were unpacked into targetFolder
copyResources
(Path
the folder to unpack resources into
targetFolder
,
String...
names of languages or instruments whose resources should be unpacked. If no languages or instruments are provided, then all installed languages and instruments are used
components
)

Unpacks the language or instrument internal resources specified by the components into the targetFolder directory.

public static Engine
create()

Creates a new engine instance with default configuration.

public static Engine
create(String... permittedLanguages)

Creates a new engine instance with default configuration with a set of permitted languages.

pack-priv static Iterator<? extends AbstractPolyglotImpl>
pack-priv static Collection<Engine>
public static Path

Returns:

the path to a folder containing the GraalVM or null if it cannot be found
findHome
()

Finds the GraalVM home folder.

public Set<Source>
getCachedSources()

Returns the sources previously cached by this engine.

pack-priv static AbstractPolyglotImpl
public String
getImplementationName()

Gets a human-readable name of the polyglot implementation (for example, "Default Truffle Engine" or "Graal Truffle Engine").

public Map<String, Instrument>
getInstruments()

Gets all installed instruments of this engine.

public Map<String, Language>
getLanguages()

Gets a map of all installed languages with the language id as key and the language object as value.

public OptionDescriptors
getOptions()

Returns all options available for the engine.

public String
getVersion()

Gets the version string of the engine in an unspecified format.

private static AbstractPolyglotImpl
pack-priv static boolean
pack-priv static boolean
private static AbstractPolyglotImpl
pack-priv static Class<?>
public static Engine.Builder
newBuilder()

Creates a new engine builder that allows to configure an engine instance.

public static Engine.Builder

Returns:

a builder that can create a context
newBuilder
(String...
names of languages permitted in the engine. If no languages are provided, then all installed languages will be permitted. All contexts created with this engine will inherit the set of permitted languages.
permittedLanguages
)

Creates a new engine builder that allows to configure an engine instance.

pack-priv static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait