docs/JavaScriptingProgrammersGuide.html

changeset 377
26a345c26e62
parent 279
1fd18f40ab52
child 409
29b2b2ed954c
equal deleted inserted replaced
376:51a5ee93d6bc 377:26a345c26e62
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.*;

mercurial