nashorn/docs/JavaScriptingProgrammersGuide.html
changeset 18615 3f6e6adcbc1a
parent 17758 2b056941e4dd
child 18846 4ef5f2321c67
equal deleted inserted replaced
18614:addca7a10167 18615:3f6e6adcbc1a
   225 the same as a global variable with the name "file". The script can
   225 the same as a global variable with the name "file". The script can
   226 access the variable - for example, it can call public methods on
   226 access the variable - for example, it can call public methods on
   227 it. Note that the syntax to access Java objects, methods and fields
   227 it. Note that the syntax to access Java objects, methods and fields
   228 is dependent on the scripting language. JavaScript supports the
   228 is dependent on the scripting language. JavaScript supports the
   229 most "natural" Java-like syntax.</p>
   229 most "natural" Java-like syntax.</p>
       
   230 <p>
       
   231 Nashorn script engine pre-defines two global variables named "context"
       
   232 and "engine". The "context" variable is of type javax.script.ScriptContext
       
   233 and refers to the current ScriptContext instance passed to script engine's
       
   234 eval method. The "engine" variable is of type javax.script.ScriptEngine and
       
   235 refers to the current nashorn script engine instance evaluating the script.
       
   236 Both of these variables are non-writable, non-enumerable and non-configurable
       
   237 - which implies script code can not write overwrite the value, for..loop iteration
       
   238 on global object will not iterate these variables and these variables can not be
       
   239 deleted by script.
   230 <pre><code>
   240 <pre><code>
   231 // <a href="source/ScriptVars.java">ScriptVars.java</a>
   241 // <a href="source/ScriptVars.java">ScriptVars.java</a>
   232 
   242 
   233 import javax.script.*;
   243 import javax.script.*;
   234 import java.io.*;
   244 import java.io.*;