require fails after requiring rubygems in an embedded runtime in 1.9 mode
-------------------------------------------------------------------------

                 Key: JRUBY-5636
                 URL: http://jira.codehaus.org/browse/JRUBY-5636
             Project: JRuby
          Issue Type: Bug
          Components: Embedding
    Affects Versions: JRuby 1.6
            Reporter: Tobias Crawley



Any require fails with a NPE after requiring rubygems in an embedded runtime in 
1.9 mode. The following code recreates the issue:

{code}
import java.util.ArrayList;

import org.jruby.CompatVersion;
import org.jruby.Ruby;
import org.jruby.RubyInstanceConfig;
import org.jruby.javasupport.JavaEmbedUtils;

public class CreateRuntime {
    public static void main(String[] args) throws Exception {
        RubyInstanceConfig config = new RubyInstanceConfig();

        //this works in 1.8 
        config.setCompatVersion( CompatVersion.RUBY1_9 );
        //it fails with JIT on as well, just with a much uglier stack
        config.setCompileMode( RubyInstanceConfig.CompileMode.OFF );
      
        Ruby runtime = JavaEmbedUtils.initialize( new ArrayList<String>(), 
config );

        runtime.getLoadService().require( "rubygems" );
        runtime.getLoadService().require( "date" ); //boom

        //require via evalScriplet shows the same behavior
        //runtime.evalScriptlet("require 'rubygems'");
        //runtime.evalScriptlet("require 'date'");
    }
}
{code}

The stack:
{noformat}
Exception in thread "main" org.jruby.exceptions.RaiseException: (LoadError) 
load error: date -- java.lang.NullPointerException: null
Caused by: java.lang.NullPointerException
        at org.jruby.ast.RescueNode.handleJavaException(RescueNode.java:206)
        at 
org.jruby.ast.RescueNode.interpretWithJavaExceptions(RescueNode.java:141)
        at org.jruby.ast.RescueNode.interpret(RescueNode.java:110)
        at 
org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
        at 
org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:190)
        at 
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:282)
        at 
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:139)
        at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:103)
        at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
        at org.jruby.ast.RootNode.interpret(RootNode.java:129)
        at 
org.jruby.evaluator.ASTInterpreter.INTERPRET_ROOT(ASTInterpreter.java:119)
        at org.jruby.Ruby.runInterpreter(Ruby.java:697)
        at org.jruby.Ruby.loadFile(Ruby.java:2417)
        at org.jruby.runtime.load.ExternalScript.load(ExternalScript.java:66)
        at 
org.jruby.runtime.load.LoadService.tryLoadingLibraryOrScript(LoadService.java:755)
        at org.jruby.runtime.load.LoadService.smartLoad(LoadService.java:334)
        at org.jruby.runtime.load.LoadService.require(LoadService.java:381)
        at CreateRuntime.main(CreateRuntime.java:20)
{noformat}

This was with jruby-complete-1.6.0.jar from maven. I compiled and ran it with:

{noformat}
$ javac -cp 
/Users/tobias/.m2/repository/org/jruby/jruby-complete/1.6.0/jruby-complete-1.6.0.jar
 CreateRuntime.java
$ java -cp 
/Users/tobias/.m2/repository/org/jruby/jruby-complete/1.6.0/jruby-complete-1.6.0.jar:.
 CreateRuntime
{noformat}

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