BSF does not retain local scope between eval calls
--------------------------------------------------

                 Key: JRUBY-3215
                 URL: http://jira.codehaus.org/browse/JRUBY-3215
             Project: JRuby
          Issue Type: Bug
          Components: Java Integration
    Affects Versions: JRuby 1.1.5, JRuby 1.1.6
         Environment: Windows Vista and OS X 10.5.5 with JRuby 1.1.5 / 1.1.6RC1
            Reporter: Adam Murray
            Priority: Minor
             Fix For: JRuby 1.1.6
         Attachments: LocalVariableTest.java

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:

1.1.6RC1
Failed to evaluate: puts x
Exception: (java):2: undefined local variable or method `x' for main:Object 
(NameError)
        ...internal jruby stack elided...
        from (unknown).(unknown)(:1)

A patch for this issue was provided for 1.1.5 by Yoko Harada in this mailing 
list thread:
http://www.ruby-forum.com/topic/170058

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);
to
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?

-- 
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