ArrayIndexOutOfBoundsException for compiled JRuby script
--------------------------------------------------------
Key: JRUBY-5553
URL: http://jira.codehaus.org/browse/JRUBY-5553
Project: JRuby
Issue Type: Bug
Components: Embedding
Affects Versions: JRuby 1.6RC2
Environment: WindowsXP, JavaSDK 1.6.0_07; The bug also occurs with
JRuby 1.5.0 and 1.5.6
Reporter: Daniel Lang
Priority: Critical
If you use ScriptContext.setAttribute() in combination with compiled JRuby
script then JRuby throws an exception:
java.lang.ArrayIndexOutOfBoundsException: 0
at
org.jruby.runtime.scope.ManyVarsDynamicScope.setValueDepthZero(ManyVarsDynamicScope.java:158)
at
org.jruby.runtime.scope.ManyVarsDynamicScope.setValue(ManyVarsDynamicScope.java:151)
at
org.jruby.embed.variable.VariableInterceptor.inject(VariableInterceptor.java:128)
at org.jruby.embed.internal.BiVariableMap.inject(BiVariableMap.java:381)
at
org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:111)
at
org.jruby.embed.jsr223.JRubyCompiledScript.eval(JRubyCompiledScript.java:87)
at at.alphagate.mesgateway.NewMain.<init>(NewMain.java:100)
Test Code:
System.setProperty("org.jruby.embed.localcontext.scope", "threadsafe");
System.setProperty("org.jruby.embed.localvariable.behavior",
"transient");
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine rbEngine = manager.getEngineByName("jruby");
ScriptContext context = new SimpleScriptContext();
String[] texts = new String[] {"ab", "cd"};
context.setAttribute("texts", texts, ScriptContext.ENGINE_SCOPE);
String rbScript =
" require 'java'\n" +
" puts 'test script'\n" +
" puts texts[0]\n";
rbEngine.eval(rbScript, context); // is OK
CompiledScript compiledScript = ((Compilable)
rbEngine).compile(rbScript);
compiledScript.eval(context); // throws exception
--
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