[1.9] Rescuing a specific error throws up a Java Exception when $DEBUG is true
------------------------------------------------------------------------------

                 Key: JRUBY-5341
                 URL: http://jira.codehaus.org/browse/JRUBY-5341
             Project: JRuby
          Issue Type: Bug
          Components: Ruby 1.9
    Affects Versions: JRuby 1.6RC1
            Reporter: Hiro Asari
            Assignee: Thomas E Enebo
            Priority: Critical
             Fix For: JRuby 1.6


Compare:
{noformat}
$ jruby --1.9 -e '$DEBUG=true; begin; require "Win32API"; rescue LoadError; 
end; p "bar"'
/Users/asari/Development/src/jruby/lib/ruby/site_ruby/shared/Win32API.rb:2:in 
`(root)': can't convert LoadError into String (TypeError)
        from org/jruby/RubyKernel.java:1050:in `require19'
        from 
/Users/asari/Development/src/jruby/lib/ruby/site_ruby/shared/Win32API.rb:29:in 
`require'
        from -e:1:in `__file__'
{noformat}
with
{noformat}
$ jruby --1.9 -e 'begin; require "Win32API"; rescue LoadError; end; p "bar"'
"bar"
{noformat}
and
{noformat}
$ jruby --1.9 -e '$DEBUG=true; begin; require "Win32API"; rescue; end; p "bar"'
"bar"
{noformat}

The combination of {{$DEBUG}} being true and rescuing a {{LoadError}} (rather 
than a generic {{rescue}}) results in the Java exception being thrown out of 
the JRuby stack.

There is nothing special about {{LoadError}}:
{noformat}
$ jruby --1.9 -e '$DEBUG=true; begin; raise RuntimeError; rescue RuntimeError; 
end; p "bar"'
-e:1:in `__file__': can't convert RuntimeError into String (TypeError)
{noformat}


I set the priority to critical, because this has a profound consequence, where 
we can't turn on the debug mode in 1.9:
{noformat}
$ jruby --1.9 -d -v
jruby 1.6.0.RC1 (ruby 1.9.2 patchlevel 136) (2011-01-12 75ced7c) (Java 
HotSpot(TM) 64-Bit Server VM 1.6.0_22) [darwin-x86_64-java]
org.jruby.exceptions.RaiseException: (TypeError) can't convert LoadError into 
String
        at 
#<Class:0x125a41cc7>.(root)(/Users/asari/Development/src/jruby/lib/ruby/site_ruby/shared/Win32API.rb:2)
        at org.jruby.RubyKernel.require19(org/jruby/RubyKernel.java:1050)
        at #<Class:0x11b0952e8>.(class 
ConfigFile)(/Users/asari/Development/src/jruby/lib/ruby/site_ruby/shared/Win32API.rb:50)
        at 
#<Class:0x125a41cc7>.(root)(/Users/asari/Development/src/jruby/lib/ruby/site_ruby/1.8/rubygems/config_file.rb:28)
        at org.jruby.RubyKernel.require19(org/jruby/RubyKernel.java:1050)
        at 
#<Class:0x125a41cc7>.(root)(/Users/asari/Development/src/jruby/lib/ruby/site_ruby/1.8/rubygems/config_file.rb:1)
        at org.jruby.RubyKernel.require19(org/jruby/RubyKernel.java:1050)
        at 
#<Class:0x125a41cc7>.(root)(/Users/asari/Development/src/jruby/lib/ruby/site_ruby/1.8/rubygems/defaults/jruby.rb:1180)
        at org.jruby.RubyKernel.require19(org/jruby/RubyKernel.java:1050)
        at 
#<Class:0x125a41cc7>.(root)(/Users/asari/Development/src/jruby/lib/ruby/site_ruby/1.8/rubygems.rb:11)
{noformat}
{noformat}
$ jruby -J-Djruby.backtrace.style=raw -J-Djruby.debug.fullTrace=true --1.9 -d -v
jruby 1.6.0.RC1 (ruby 1.9.2 patchlevel 136) (2011-01-12 75ced7c) (Java 
HotSpot(TM) 64-Bit Server VM 1.6.0_22) [darwin-x86_64-java]
org.jruby.exceptions.RaiseException: (TypeError) can't convert LoadError into 
String
        at java.lang.Thread.getStackTrace(Thread.java:1503)
        at org.jruby.RubyException.prepareBacktrace(RubyException.java:154)
        at org.jruby.exceptions.RaiseException.preRaise(RaiseException.java:156)
        at org.jruby.Ruby.newRaiseException(Ruby.java:3432)
        at org.jruby.Ruby.newTypeError(Ruby.java:3249)
        at 
org.jruby.util.TypeConverter.handleUncoercibleObject(TypeConverter.java:243)
        at org.jruby.util.TypeConverter.convertToType(TypeConverter.java:66)
        at org.jruby.util.TypeConverter.convertToType(TypeConverter.java:117)
        at org.jruby.RubyBasicObject.convertToString(RubyBasicObject.java:726)
        at org.jruby.RubyKernel.printExceptionSummary(RubyKernel.java:1024)
        at org.jruby.RubyKernel.raise(RubyKernel.java:998)
        at 
org.jruby.RubyKernel$s_method_0_3$RUBYINVOKER$raise_DBG.call(org/jruby/RubyKernel$s_method_0_3$RUBYINVOKER$raise_DBG.gen:65535)
        at 
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:208)
        at 
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:204)
        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.IfNode.interpret(IfNode.java:119)
        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:115)
        at org.jruby.Ruby.runInterpreter(Ruby.java:729)
        at org.jruby.Ruby.loadFile(Ruby.java:2609)
        at org.jruby.runtime.load.ExternalScript.load(ExternalScript.java:66)
        at 
org.jruby.runtime.load.LoadService.tryLoadingLibraryOrScript(LoadService.java:748)
        at org.jruby.runtime.load.LoadService.smartLoad(LoadService.java:332)
        at org.jruby.runtime.load.LoadService.require(LoadService.java:379)
        at 
org.jruby.runtime.load.LoadService.lockAndRequire(LoadService.java:304)
        at org.jruby.RubyKernel.requireCommon(RubyKernel.java:1058)
        at org.jruby.RubyKernel.require19(RubyKernel.java:1050)
        at 
org.jruby.RubyKernel$s_method_1_0$RUBYINVOKER$require19_DBG.call(org/jruby/RubyKernel$s_method_1_0$RUBYINVOKER$require19_DBG.gen:65535)
        at 
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrNBlock.call(JavaMethod.java:319)
        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.RescueNode.executeBody(RescueNode.java:216)
        at 
org.jruby.ast.RescueNode.interpretWithJavaExceptions(RescueNode.java:120)
        at org.jruby.ast.RescueNode.interpret(RescueNode.java:110)
        at org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
        at org.jruby.ast.LocalAsgnNode.interpret(LocalAsgnNode.java:123)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:103)
        at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
        at 
org.jruby.evaluator.ASTInterpreter.INTERPRET_CLASS(ASTInterpreter.java:99)
        at 
org.jruby.evaluator.ASTInterpreter.evalClassDefinitionBody(ASTInterpreter.java:232)
        at org.jruby.ast.ClassNode.interpret(ClassNode.java:138)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:103)
        at org.jruby.ast.RootNode.interpret(RootNode.java:129)
        at 
org.jruby.evaluator.ASTInterpreter.INTERPRET_ROOT(ASTInterpreter.java:115)
        at org.jruby.Ruby.runInterpreter(Ruby.java:729)
        at org.jruby.Ruby.loadFile(Ruby.java:2609)
        at org.jruby.runtime.load.ExternalScript.load(ExternalScript.java:66)
        at 
org.jruby.runtime.load.LoadService.tryLoadingLibraryOrScript(LoadService.java:748)
        at org.jruby.runtime.load.LoadService.smartLoad(LoadService.java:332)
        at org.jruby.runtime.load.LoadService.require(LoadService.java:379)
        at 
org.jruby.runtime.load.LoadService.lockAndRequire(LoadService.java:304)
        at org.jruby.RubyKernel.requireCommon(RubyKernel.java:1058)
        at org.jruby.RubyKernel.require19(RubyKernel.java:1050)
        at 
org.jruby.RubyKernel$s_method_1_0$RUBYINVOKER$require19_DBG.call(org/jruby/RubyKernel$s_method_1_0$RUBYINVOKER$require19_DBG.gen:65535)
        at 
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrNBlock.call(JavaMethod.java:319)
        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:115)
        at org.jruby.Ruby.runInterpreter(Ruby.java:729)
        at org.jruby.Ruby.loadFile(Ruby.java:2609)
        at org.jruby.runtime.load.ExternalScript.load(ExternalScript.java:66)
        at 
org.jruby.runtime.load.LoadService.tryLoadingLibraryOrScript(LoadService.java:748)
        at org.jruby.runtime.load.LoadService.smartLoad(LoadService.java:332)
        at org.jruby.runtime.load.LoadService.require(LoadService.java:379)
        at 
org.jruby.runtime.load.LoadService.lockAndRequire(LoadService.java:304)
        at org.jruby.RubyKernel.requireCommon(RubyKernel.java:1058)
        at org.jruby.RubyKernel.require19(RubyKernel.java:1050)
        at 
org.jruby.RubyKernel$s_method_1_0$RUBYINVOKER$require19_DBG.call(org/jruby/RubyKernel$s_method_1_0$RUBYINVOKER$require19_DBG.gen:65535)
        at 
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrNBlock.call(JavaMethod.java:319)
        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.RescueNode.executeBody(RescueNode.java:216)
        at 
org.jruby.ast.RescueNode.interpretWithJavaExceptions(RescueNode.java:120)
        at org.jruby.ast.RescueNode.interpret(RescueNode.java:110)
        at org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
        at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:103)
        at org.jruby.ast.IfNode.interpret(IfNode.java:117)
        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:115)
        at org.jruby.Ruby.runInterpreter(Ruby.java:729)
        at org.jruby.Ruby.loadFile(Ruby.java:2609)
        at org.jruby.runtime.load.ExternalScript.load(ExternalScript.java:66)
        at 
org.jruby.runtime.load.LoadService.tryLoadingLibraryOrScript(LoadService.java:748)
        at org.jruby.runtime.load.LoadService.smartLoad(LoadService.java:332)
        at org.jruby.runtime.load.LoadService.require(LoadService.java:379)
        at 
org.jruby.runtime.load.LoadService.lockAndRequire(LoadService.java:304)
        at org.jruby.RubyKernel.requireCommon(RubyKernel.java:1058)
        at org.jruby.RubyKernel.require19(RubyKernel.java:1050)
        at 
org.jruby.RubyKernel$s_method_1_0$RUBYINVOKER$require19_DBG.call(org/jruby/RubyKernel$s_method_1_0$RUBYINVOKER$require19_DBG.gen:65535)
        at 
org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrNBlock.call(JavaMethod.java:319)
        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.RootNode.interpret(RootNode.java:129)
        at 
org.jruby.evaluator.ASTInterpreter.INTERPRET_ROOT(ASTInterpreter.java:115)
        at org.jruby.Ruby.runInterpreter(Ruby.java:729)
        at org.jruby.Ruby.loadFile(Ruby.java:2609)
        at org.jruby.Ruby.initBuiltins(Ruby.java:1546)
        at org.jruby.Ruby.init(Ruby.java:1107)
        at org.jruby.Ruby.newInstance(Ruby.java:180)
        at org.jruby.Main.run(Main.java:234)
        at org.jruby.Main.run(Main.java:144)
        at org.jruby.Main.main(Main.java:113)
{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