public final class GraalJSScriptEngine extends AbstractScriptEngine implements Compilable, Invocable, AutoCloseable
GraalJSScriptEngine.getPolyglotContext().contextARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the current context and makes it unusable.
|
CompiledScript |
compile(Reader reader) |
CompiledScript |
compile(String script) |
static GraalJSScriptEngine |
create()
Creates a new GraalJSScriptEngine with default configuration.
|
static GraalJSScriptEngine |
create(org.graalvm.polyglot.Engine engine,
org.graalvm.polyglot.Context.Builder newContextConfig)
Creates a new GraalJS script engine from a polyglot Engine instance with a base configuration
for new polyglot
Context instances. |
Bindings |
createBindings() |
Object |
eval(Reader reader,
ScriptContext ctxt) |
Object |
eval(String script,
ScriptContext ctxt) |
GraalJSEngineFactory |
getFactory() |
<T> T |
getInterface(Class<T> clasz) |
<T> T |
getInterface(Object thiz,
Class<T> clasz) |
org.graalvm.polyglot.Context |
getPolyglotContext()
Returns the polyglot context associated with the default ScriptContext of the engine.
|
org.graalvm.polyglot.Context |
getPolyglotContext(ScriptContext ctxt)
Returns the polyglot context associated with a ScriptContext.
|
org.graalvm.polyglot.Engine |
getPolyglotEngine()
Returns the polyglot engine associated with this script engine.
|
Object |
invokeFunction(String name,
Object... args) |
Object |
invokeMethod(Object thiz,
String name,
Object... args) |
void |
setBindings(Bindings bindings,
int scope) |
eval, eval, eval, eval, get, getBindings, getContext, getScriptContext, put, setContextpublic void close()
IllegalStateException.close in interface AutoCloseablepublic org.graalvm.polyglot.Engine getPolyglotEngine()
public org.graalvm.polyglot.Context getPolyglotContext()
public org.graalvm.polyglot.Context getPolyglotContext(ScriptContext ctxt)
GraalJSScriptEngine.create(Engine, org.graalvm.polyglot.Context.Builder).public Bindings createBindings()
createBindings in interface ScriptEnginepublic void setBindings(Bindings bindings, int scope)
setBindings in interface ScriptEnginesetBindings in class AbstractScriptEnginepublic Object eval(Reader reader, ScriptContext ctxt) throws ScriptException
eval in interface ScriptEngineScriptExceptionpublic Object eval(String script, ScriptContext ctxt) throws ScriptException
eval in interface ScriptEngineScriptExceptionpublic GraalJSEngineFactory getFactory()
getFactory in interface ScriptEnginepublic Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException
invokeMethod in interface InvocableScriptExceptionNoSuchMethodExceptionpublic Object invokeFunction(String name, Object... args) throws ScriptException, NoSuchMethodException
invokeFunction in interface InvocableScriptExceptionNoSuchMethodExceptionpublic <T> T getInterface(Class<T> clasz)
getInterface in interface Invocablepublic <T> T getInterface(Object thiz, Class<T> clasz)
getInterface in interface Invocablepublic CompiledScript compile(String script) throws ScriptException
compile in interface CompilableScriptExceptionpublic CompiledScript compile(Reader reader) throws ScriptException
compile in interface CompilableScriptExceptionpublic static GraalJSScriptEngine create()
to customize the configuration.public static GraalJSScriptEngine create(org.graalvm.polyglot.Engine engine, org.graalvm.polyglot.Context.Builder newContextConfig)
Context instances. Polyglot context instances can be accessed from
ScriptContext instances using GraalJSScriptEngine.getPolyglotContext(). The
out,err and
in stream configuration are not inherited from the provided
polyglot context config. Instead ScriptContext output and input streams are used.engine - the engine to be used for context configurations or null if a
default engine should be used.newContextConfig - a base configuration to create new context instances or
null if the default configuration should be used to construct new
context instances.