public final class NashornScriptEngine extends AbstractScriptEngine implements Compilable, Invocable
NashornScriptEngineFactory.getScriptEngine()
. Note that this engine implements the Compilable
and
Invocable
interfaces, allowing for efficient precompilation and repeated execution of scripts.NashornScriptEngineFactory
Modifier and Type | Field and Description |
---|---|
static String |
NASHORN_GLOBAL
Key used to associate Nashorn global object mirror with arbitrary Bindings instance.
|
context
ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME
Modifier and Type | Method and Description |
---|---|
CompiledScript |
compile(Reader reader) |
CompiledScript |
compile(String str) |
Bindings |
createBindings() |
Object |
eval(Reader reader,
ScriptContext ctxt) |
Object |
eval(String script,
ScriptContext ctxt) |
ScriptEngineFactory |
getFactory() |
<T> T |
getInterface(Class<T> clazz) |
<T> T |
getInterface(Object thiz,
Class<T> clazz) |
Object |
invokeFunction(String name,
Object... args) |
Object |
invokeMethod(Object thiz,
String name,
Object... args) |
eval, eval, eval, eval, get, getBindings, getContext, getScriptContext, put, setBindings, setContext
public static final String NASHORN_GLOBAL
public Object eval(Reader reader, ScriptContext ctxt) throws ScriptException
eval
in interface ScriptEngine
ScriptException
public Object eval(String script, ScriptContext ctxt) throws ScriptException
eval
in interface ScriptEngine
ScriptException
public ScriptEngineFactory getFactory()
getFactory
in interface ScriptEngine
public Bindings createBindings()
createBindings
in interface ScriptEngine
public CompiledScript compile(Reader reader) throws ScriptException
compile
in interface Compilable
ScriptException
public CompiledScript compile(String str) throws ScriptException
compile
in interface Compilable
ScriptException
public Object invokeFunction(String name, Object... args) throws ScriptException, NoSuchMethodException
invokeFunction
in interface Invocable
ScriptException
NoSuchMethodException
public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException
invokeMethod
in interface Invocable
ScriptException
NoSuchMethodException
public <T> T getInterface(Class<T> clazz)
getInterface
in interface Invocable
public <T> T getInterface(Object thiz, Class<T> clazz)
getInterface
in interface Invocable