I expect that when using BSF, the local scope will persist between eval calls until I call the bsfManager.terminate() method. The use case for this is an irb-like interface implemented in Java.
A test case LocalVariableTest is attached that demonstrates this issue. Up until JRuby 1.1.5, this worked, but starting with version JRuby 1.1.5 and in 1.1.6RC1 it has the following behavior:
Failed to evaluate: puts x
Exception: (java):2: undefined local variable or method `x' for main:Object (NameError)
...internal jruby stack elided...
A patch for this issue was provided for 1.1.5 by Yoko Harada in this mailing list thread:
Using that solution, I thought this issue could be resolved for 1.1.6RC1 by changing org.jruby.Ruby.jave line 223 from
Node node = parseEval(script, "<script>", newScope, 0);
Node node = parseEval(script, "<script>", newScope.getNextCapturedScope(), 0);
However, I tried this and it does not seem to work.
Can this be fixed for 1.1.6? If not, what are my options for supporting this use case? Should I be using JavaEmbedUtils?