The fix was to also set self on the adopted thread's frame and evaluator. I would LOVE to commit this fix right now, but SF CVS is still down. So here's the changed code. With this fix, your test case runs successfully.
in ThreadContext.java:
public void preAdoptThread() {
pushIter(Iter.ITER_NOT);
pushFrame();
getCurrentFrame().newScope(null);
pushRubyClass(runtime.getObject());
pushCRef(runtime.getObject());
getCurrentFrame().setSelf(runtime.getTopSelf());
getCurrentFrame().getEvalState().setSelf( runtime.getTopSelf());
}
I'll make an additional test case out of your code, and commit both when I am able. Thank you for finding this!
On 3/30/06, Werner Schuster (murphee) <[EMAIL PROTECTED]> wrote:
Charles O Nutter wrote:
>Yes, that AOOB was the one I saw breaking. I'll see if I can find a way to
>reproduce your other issue.
>
>
OK, I created a simple test that reproduces the NPE. If you run this code,
you'll get an NPE when calling the defined "foo" method from a new
thread; it works if
called from the Main Thread where Ruby was instantiated.
This will give an exception in a different place:
java.lang.NullPointerException
at
org.jruby.evaluator.EvaluateVisitor$VCallNodeVisitor.execute(EvaluateVisitor.java:1923)
at
org.jruby.evaluator.EvaluationState.executeNext(EvaluationState.java:211)
at org.jruby.evaluator.EvaluationState.begin(EvaluationState.java:291)
at org.jruby.Ruby.eval(Ruby.java:188)
at org.jruby.Ruby.evalScript(Ruby.java:181)
at Test$1.run(Test.java:17)
at java.lang.Thread.run (Thread.java:595)
Having debugged the issue in the EclipseShell code, it seems like the
InstructionBundles
EvaluationState returns null for it's "self" field.
Test code attached.
murphee
--
Blog @ http://jroller.com/page/murphee
Maintainer of EclipseShell @ http://eclipse-shell.sourceforge.net/
--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com
