- java.lang.Object
-
- javax.script.AbstractScriptEngine
-
- org.openjdk.nashorn.api.scripting.NashornScriptEngine
-
- All Implemented Interfaces:
javax.script.Compilable,javax.script.Invocable,javax.script.ScriptEngine
public final class NashornScriptEngine extends javax.script.AbstractScriptEngine implements javax.script.Compilable, javax.script.InvocableJSR-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 java.lang.StringNASHORN_GLOBALKey used to associate Nashorn global object mirror with arbitrary Bindings instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.script.CompiledScriptcompile(java.io.Reader reader)javax.script.CompiledScriptcompile(java.lang.String str)javax.script.BindingscreateBindings()java.lang.Objecteval(java.io.Reader reader, javax.script.ScriptContext ctxt)java.lang.Objecteval(java.lang.String script, javax.script.ScriptContext ctxt)javax.script.ScriptEngineFactorygetFactory()<T> TgetInterface(java.lang.Class<T> clazz)<T> TgetInterface(java.lang.Object thiz, java.lang.Class<T> clazz)java.lang.ObjectinvokeFunction(java.lang.String name, java.lang.Object... args)java.lang.ObjectinvokeMethod(java.lang.Object thiz, java.lang.String name, java.lang.Object... args)
-
-
-
Field Detail
-
NASHORN_GLOBAL
public static final java.lang.String NASHORN_GLOBAL
Key used to associate Nashorn global object mirror with arbitrary Bindings instance.- See Also:
- Constant Field Values
-
-
Method Detail
-
eval
public java.lang.Object eval(java.io.Reader reader, javax.script.ScriptContext ctxt) throws javax.script.ScriptException- Specified by:
evalin interfacejavax.script.ScriptEngine- Throws:
javax.script.ScriptException
-
eval
public java.lang.Object eval(java.lang.String script, javax.script.ScriptContext ctxt) throws javax.script.ScriptException- Specified by:
evalin interfacejavax.script.ScriptEngine- Throws:
javax.script.ScriptException
-
getFactory
public javax.script.ScriptEngineFactory getFactory()
- Specified by:
getFactoryin interfacejavax.script.ScriptEngine
-
createBindings
public javax.script.Bindings createBindings()
- Specified by:
createBindingsin interfacejavax.script.ScriptEngine
-
compile
public javax.script.CompiledScript compile(java.io.Reader reader) throws javax.script.ScriptException- Specified by:
compilein interfacejavax.script.Compilable- Throws:
javax.script.ScriptException
-
compile
public javax.script.CompiledScript compile(java.lang.String str) throws javax.script.ScriptException- Specified by:
compilein interfacejavax.script.Compilable- Throws:
javax.script.ScriptException
-
invokeFunction
public java.lang.Object invokeFunction(java.lang.String name, java.lang.Object... args) throws javax.script.ScriptException, java.lang.NoSuchMethodException- Specified by:
invokeFunctionin interfacejavax.script.Invocable- Throws:
javax.script.ScriptExceptionjava.lang.NoSuchMethodException
-
invokeMethod
public java.lang.Object invokeMethod(java.lang.Object thiz, java.lang.String name, java.lang.Object... args) throws javax.script.ScriptException, java.lang.NoSuchMethodException- Specified by:
invokeMethodin interfacejavax.script.Invocable- Throws:
javax.script.ScriptExceptionjava.lang.NoSuchMethodException
-
getInterface
public <T> T getInterface(java.lang.Class<T> clazz)
- Specified by:
getInterfacein interfacejavax.script.Invocable
-
getInterface
public <T> T getInterface(java.lang.Object thiz, java.lang.Class<T> clazz)- Specified by:
getInterfacein interfacejavax.script.Invocable
-
-