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/

import org.jruby.IRuby;
import org.jruby.Ruby;
import org.jruby.runtime.builtin.IRubyObject;

public class JRubyTestIssue{

	public static IRuby r;
	public static Object object;
	public static void main(String[] args) {
		r = Ruby.getDefaultInstance();
		// define new method
		r.evalScript("def foo\n \"Hello\" \n end");
		
		// will run on non main thread
		Runnable run = new Runnable(){
			public void run(){
				object = r.evalScript("foo");
			}
		};
		Thread n = new Thread(run);
		System.out.println("--------------- Calling Foo on Non-Main Thread --------------");
		n.start();		
		try {
			n.join();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
//			e.printStackTrace();
		}
		System.out.println("Output: " + object);
		
		// Now from the same thread
		System.out.println("----------- Calling from Thread ---------------");
		object = r.evalScript("foo");
		System.out.println("Output: " + object);

	}
}

Reply via email to