Details
-
Bug
-
Resolution: Fixed
-
P4
-
8
-
None
-
b94
-
Verified
Description
The pasted example shows it all.
In java the Map contains the declaration, in JS it doesn't. Retrieving the property using the property name
gets you the property.
// Works in Java.
//final ScriptEngineManager m = new ScriptEngineManager();
//final ScriptEngine e = m.getEngineByName("nashorn");
//e.eval("function doIt(){}");
//System.out.println(" Contains obj ? " + e.getBindings(ScriptContext.ENGINE_SCOPE).containsKey("doIt"));
// Doesn't work in JS
var se = new javax.script.ScriptEngineManager();
var e = se.getEngineByName("nashorn");
e.eval("function doIt(){}");
// The returned bindings is not iterable...
var b = e.getBindings(javax.script.ScriptContext.ENGINE_SCOPE);
// Returns nothing
for( k in b){
print("K " + b[k]);
}
// returns the function
print(b["doIt"]);
In java the Map contains the declaration, in JS it doesn't. Retrieving the property using the property name
gets you the property.
// Works in Java.
//final ScriptEngineManager m = new ScriptEngineManager();
//final ScriptEngine e = m.getEngineByName("nashorn");
//e.eval("function doIt(){}");
//System.out.println(" Contains obj ? " + e.getBindings(ScriptContext.ENGINE_SCOPE).containsKey("doIt"));
// Doesn't work in JS
var se = new javax.script.ScriptEngineManager();
var e = se.getEngineByName("nashorn");
e.eval("function doIt(){}");
// The returned bindings is not iterable...
var b = e.getBindings(javax.script.ScriptContext.ENGINE_SCOPE);
// Returns nothing
for( k in b){
print("K " + b[k]);
}
// returns the function
print(b["doIt"]);