- 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 throughNashornScriptEngineFactory.getScriptEngine(). Note that this engine implements theCompilableandInvocableinterfaces, allowing for efficient precompilation and repeated execution of scripts.- Since:
- 1.8u40
- See Also:
NashornScriptEngineFactory
-
-
Field Summary
Fields Modifier and Type Field Description static StringNASHORN_GLOBALKey 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompiledScriptcompile(Reader reader)CompiledScriptcompile(String str)BindingscreateBindings()Objecteval(Reader reader, ScriptContext ctxt)Objecteval(String script, ScriptContext ctxt)ScriptEngineFactorygetFactory()<T> TgetInterface(Class<T> clazz)<T> TgetInterface(Object thiz, Class<T> clazz)ObjectinvokeFunction(String name, Object... args)ObjectinvokeMethod(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 Detail
-
NASHORN_GLOBAL
public static final String NASHORN_GLOBAL
Key used to associate Nashorn global object mirror with arbitrary Bindings instance.- See Also:
- Constant Field Values
-
-
Method Detail
-
eval
public Object eval(Reader reader, ScriptContext ctxt) throws ScriptException
- Specified by:
evalin interfaceScriptEngine- Throws:
ScriptException
-
eval
public Object eval(String script, ScriptContext ctxt) throws ScriptException
- Specified by:
evalin interfaceScriptEngine- Throws:
ScriptException
-
getFactory
public ScriptEngineFactory getFactory()
- Specified by:
getFactoryin interfaceScriptEngine
-
createBindings
public Bindings createBindings()
- Specified by:
createBindingsin interfaceScriptEngine
-
compile
public CompiledScript compile(Reader reader) throws ScriptException
- Specified by:
compilein interfaceCompilable- Throws:
ScriptException
-
compile
public CompiledScript compile(String str) throws ScriptException
- 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
public <T> T getInterface(Class<T> clazz)
- Specified by:
getInterfacein interfaceInvocable
-
getInterface
public <T> T getInterface(Object thiz, Class<T> clazz)
- Specified by:
getInterfacein interfaceInvocable
-
-