You should call key.intern() when passing vars to the JSR 223 
javax.script.Bindings Object otherwise String Object keys might not be found
------------------------------------------------------------------------------------------------------------------------------------------

                 Key: JRUBY-4437
                 URL: http://jira.codehaus.org/browse/JRUBY-4437
             Project: JRuby
          Issue Type: Bug
          Components: Embedding
    Affects Versions: JRuby 1.4
         Environment: Linux 64bits, JRuby 1.4 and head
            Reporter: Raphael Valyi


Here is a test case that works under Rhino or Jython but fails it JRuby; we 
discovered it wile playing with JRuby in the Kettle ETL ( 
http://github.com/rvalyi/jripple )

The fix should be something like before adding the new key to the binding hash, 
you should call key.intern(). If we do it outside it works too, but the thing 
is that we might not have the control to do it when the JSR233 is used, so it 
would be better doing it by default.

test case:

import javax.script.Bindings;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

ScriptEngineManager m = new ScriptEngineManager();
ScriptEngine rubyEngine = m.getEngineByName("jruby");
Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);

bindings.puts("a", "hello world");
bindings.puts(new String("b"), "cruel world");

try{
rubyEngine.eval("puts a", bindings);//WORKS
rubyEngine.eval("puts b", bindings);//FAILS

} catch (ScriptException e) {
e.printStackTrace();
}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to