- java.lang.Object
- 
- javax.script.CompiledScript
 
- 
 public abstract class CompiledScript extends Object Extended by classes that store results of compilations. State might be stored in the form of Java classes, Java class files or scripting language opcodes. The script may be executed repeatedly without reparsing.
 EachCompiledScriptis associated with aScriptEngine-- A call to anevalmethod of theCompiledScriptcauses the execution of the script by theScriptEngine. Changes in the state of theScriptEnginecaused by execution of theCompiledScriptmay visible during subsequent executions of scripts by the engine.- Since:
- 1.6
 
- 
- 
Constructor SummaryConstructors Constructor Description CompiledScript()
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Objecteval()Executes the program stored in theCompiledScriptobject.Objecteval(Bindings bindings)Executes the program stored in theCompiledScriptobject using the suppliedBindingsof attributes as theENGINE_SCOPEof the associatedScriptEngineduring script execution.abstract Objecteval(ScriptContext context)Executes the program stored in thisCompiledScriptobject.abstract ScriptEnginegetEngine()Returns theScriptEnginewhosecompilemethod created thisCompiledScript.
 
- 
- 
- 
Method Detail- 
evalpublic abstract Object eval(ScriptContext context) throws ScriptException Executes the program stored in thisCompiledScriptobject.- Parameters:
- context- A- ScriptContextthat is used in the same way as the- ScriptContextpassed to the- evalmethods of- ScriptEngine.
- Returns:
- The value returned by the script execution, if any.  Should return nullif no value is returned by the script execution.
- Throws:
- ScriptException- if an error occurs.
- NullPointerException- if context is null.
 
 - 
evalpublic Object eval(Bindings bindings) throws ScriptException Executes the program stored in theCompiledScriptobject using the suppliedBindingsof attributes as theENGINE_SCOPEof the associatedScriptEngineduring script execution. If bindings is null, then the effect of calling this method is same as that of eval(getEngine().getContext()).. The GLOBAL_SCOPEBindings,ReaderandWriterassociated with the defaultScriptContextof the associatedScriptEngineare used.- Parameters:
- bindings- The bindings of attributes used for the- ENGINE_SCOPE.
- Returns:
- The return value from the script execution
- Throws:
- ScriptException- if an error occurs.
 
 - 
evalpublic Object eval() throws ScriptException Executes the program stored in theCompiledScriptobject. The defaultScriptContextof the associatedScriptEngineis used. The effect of calling this method is same as that of eval(getEngine().getContext()).- Returns:
- The return value from the script execution
- Throws:
- ScriptException- if an error occurs.
 
 - 
getEnginepublic abstract ScriptEngine getEngine() Returns theScriptEnginewhosecompilemethod created thisCompiledScript. TheCompiledScriptwill execute in this engine.- Returns:
- The ScriptEnginethat created thisCompiledScript
 
 
- 
 
-