Class NashornScriptEngine
java.lang.Object
javax.script.AbstractScriptEngine
org.openjdk.nashorn.api.scripting.NashornScriptEngine
- All Implemented Interfaces:
Compilable, Invocable, ScriptEngine
public final class NashornScriptEngine
extends AbstractScriptEngine
implements Compilable, Invocable
JSR-223 compliant script engine for Nashorn. Instances are not created directly, but rather returned through
NashornScriptEngineFactory.getScriptEngine(). Note that this engine implements the Compilable and
Invocable interfaces, allowing for efficient precompilation and repeated execution of scripts.- Since:
- 1.8u40
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringKey used to associate Nashorn global object mirror with arbitrary Bindings instance.Fields inherited from class AbstractScriptEngine
contextFields inherited from interface ScriptEngine
ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME -
Method Summary
Modifier and TypeMethodDescriptioneval(Reader reader, ScriptContext ctxt) eval(String script, ScriptContext ctxt) <T> TgetInterface(Class<T> clazz) <T> TgetInterface(Object thiz, Class<T> clazz) invokeFunction(String name, Object... args) invokeMethod(Object thiz, String name, Object... args) Methods inherited from class AbstractScriptEngine
eval, eval, eval, eval, get, getBindings, getContext, getScriptContext, put, setBindings, setContext
-
Field Details
-
NASHORN_GLOBAL
Key used to associate Nashorn global object mirror with arbitrary Bindings instance.- See Also:
-
-
Method Details
-
eval
- Specified by:
evalin interfaceScriptEngine- Throws:
ScriptException
-
eval
- Specified by:
evalin interfaceScriptEngine- Throws:
ScriptException
-
getFactory
- Specified by:
getFactoryin interfaceScriptEngine
-
createBindings
- Specified by:
createBindingsin interfaceScriptEngine
-
compile
- Specified by:
compilein interfaceCompilable- Throws:
ScriptException
-
compile
- Specified by:
compilein interfaceCompilable- Throws:
ScriptException
-
invokeFunction
public Object invokeFunction(String name, Object... args) throws ScriptException, NoSuchMethodException - Specified by:
invokeFunctionin interfaceInvocable- Throws:
ScriptExceptionNoSuchMethodException
-
invokeMethod
public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException - Specified by:
invokeMethodin interfaceInvocable- Throws:
ScriptExceptionNoSuchMethodException
-
getInterface
- Specified by:
getInterfacein interfaceInvocable
-
getInterface
- Specified by:
getInterfacein interfaceInvocable
-