-
Notifications
You must be signed in to change notification settings - Fork 3
JRuby 1.1.5 Patch
I patched JRuby 1.1.5 to support “incremental evaluation” for ajm.ruby. This means you can send a message like “x=1” and then later send “x” and get the value 1. This used to work fine in previous versions of JRuby, but it broke in 1.1.5. The local scope is destroyed after every eval call.
In general it is safest to use CONSTANTS or $global_variables when you want to persist state in ajm.ruby. Even with the bug in JRuby 1.1.5, this would work fine. But I thought it worth patching JRuby to try to maintain the old behavior, especially if this may get corrected for future releases.
Thanks to Yoko Harada for providing me with a solution:
Hi Adam,The reason of wrong behaivor of BSF engine is that the implementation
of Ruby.evalScriptlet method has been changed and probably had a bug.
Since I submitted a patch, I hope future releases won’t have this
trouble.If you want to use JRuby 1.1.5 and BSF engine now, edit evalScriptlet
method in org.jruby.Ruby.java as in below://Node node = parseEval(script, “<script>”, newScope, 0);
Node node = parseEval(script, “<script>”, newScope.getNextCapturedScope(), 0);and build JRuby. Then your code will work again.
-Yoko
Adam Murray wrote:
> Let me rephrase my question: is it possible to do “incremental evaluation”
> of Ruby code from Java by remembering the exact state of the Ruby
> interpreter when the BSF eval() call finishes?