8015969: Needs to enforce and document that global "context" and "engine" can't be modified when running via jsr223

Reviewed-by: hannesw, jlaskey
This commit is contained in:
Athijegannathan Sundararajan 2013-06-25 17:31:19 +05:30
parent 02e0b5c3f1
commit 249d0ae5b4
6 changed files with 102 additions and 10 deletions

View file

@ -227,6 +227,16 @@ access the variable - for example, it can call public methods on
it. Note that the syntax to access Java objects, methods and fields
is dependent on the scripting language. JavaScript supports the
most "natural" Java-like syntax.</p>
<p>
Nashorn script engine pre-defines two global variables named "context"
and "engine". The "context" variable is of type javax.script.ScriptContext
and refers to the current ScriptContext instance passed to script engine's
eval method. The "engine" variable is of type javax.script.ScriptEngine and
refers to the current nashorn script engine instance evaluating the script.
Both of these variables are non-writable, non-enumerable and non-configurable
- which implies script code can not write overwrite the value, for..loop iteration
on global object will not iterate these variables and these variables can not be
deleted by script.
<pre><code>
// <a href="source/ScriptVars.java">ScriptVars.java</a>