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 String
Key used to associate Nashorn global object mirror with arbitrary Bindings instance.Fields inherited from class javax.script.AbstractScriptEngine
context
Fields inherited from interface javax.script.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> T
getInterface
(Class<T> clazz) <T> T
getInterface
(Object thiz, Class<T> clazz) invokeFunction
(String name, Object... args) invokeMethod
(Object thiz, String name, Object... args) Methods inherited from class javax.script.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:
eval
in interfaceScriptEngine
- Throws:
ScriptException
-
eval
- Specified by:
eval
in interfaceScriptEngine
- Throws:
ScriptException
-
getFactory
- Specified by:
getFactory
in interfaceScriptEngine
-
createBindings
- Specified by:
createBindings
in interfaceScriptEngine
-
compile
- Specified by:
compile
in interfaceCompilable
- Throws:
ScriptException
-
compile
- Specified by:
compile
in interfaceCompilable
- Throws:
ScriptException
-
invokeFunction
public Object invokeFunction(String name, Object... args) throws ScriptException, NoSuchMethodException - Specified by:
invokeFunction
in interfaceInvocable
- Throws:
ScriptException
NoSuchMethodException
-
invokeMethod
public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException - Specified by:
invokeMethod
in interfaceInvocable
- Throws:
ScriptException
NoSuchMethodException
-
getInterface
- Specified by:
getInterface
in interfaceInvocable
-
getInterface
- Specified by:
getInterface
in interfaceInvocable
-