Hello,

In our application framework we are extensively using JavaScript, xml
and java.
Sometimes we need to define a java script function in one ScriptEngine
instance (we use BSF) and then carry this defenition to another
ScriptEngine instance. Some of our functions use global variables.
What we discovered is that definition of the function includes all the
global variables defined in the first ScriptEngine and global
variables which have the same names in the other ScriptEngine are just
ignored.

Here is the example:

ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine jsEngine1 = mgr.getEngineByName("JavaScript");
ScriptEngine jsEngine2 = mgr.getEngineByName("JavaScript");

Bindings bindings = new SimpleBindings();
Bindings bindings1 = new SimpleBindings();

jsEngine1.eval("var test ='test'; function h(param){println(param +
test);}; h('func')",bindings);

bindings1.put("h", bindings.get("h"));

jsEngine2.eval("var test='bla';h('func');",bindings1);

The output is:

functest
functest

But I expected:

functest
funcbla

Is it a bug? Or is it how this was initially designed?

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to