History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: JRUBY-2429
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Charles Oliver Nutter
Reporter: Peter K Chan
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
JRuby

Cannot Catch Core Java Exceptions From JRuby Internals in Ruby Code

Created: 22/Apr/08 12:18 PM   Updated: 13/Aug/08 11:03 PM
Component/s: Java Integration
Affects Version/s: JRuby 1.1
Fix Version/s: JRuby 1.1.4

Time Tracking:
Not Specified

Environment: Java 6/Windows XP


 Description  « Hide
If a core Java exceptions, such as NullPointerException, ClassCastException, or ArrayIndexOufOfBoundsException, is thrown from within a JRuby internal code, the exception cannot be caught by any Ruby handler. This includes both exception coming from JRuby interpreter and any other JRuby-optimized Java code (such as AR-JDBC's own Internal adapter).

This is a bug and not merely a feature request, because the inability to catch such core Java exception makes it impossible to guard the thread against any unexpected exception, and directly kills the thread.

I don't have a test case, because I don't know how to intentionally trigger an exception inside JRuby (any such exception will presumably be a bug).

To fix this bug, these core exception should be rescue-able by Ruby code and also have Ruby stack traces available.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Thomas E Enebo - 12/May/08 05:03 PM
Moving to java Integration component

Charles Oliver Nutter - 03/Aug/08 12:44 AM
I committed changes on trunk that make this work, so you can now rescue any Java exception type as well as any Ruby exception type. Note that the exceptions are not wrapped in their usual "NativeException" wrapper...they're just the actual Java object. So existing code that catches NativeException should continue to do so, since we're not going to remove that wrapping in 1.1.x (it would be breaking change).

I think this can make it into 1.1.4, but leaving open while I address JRUBY-2888 and while we discuss the implications of this on mailing list.


Charles Oliver Nutter - 13/Aug/08 11:03 PM
There was little discussion and everyone wants this, so I'm marking it as resolved. The only potential problems that might arise are some amount of additional exception overhead for unrescued exceptions passing through rescues, but I've been unable to show such a performance hit. It remains theoretical, and the ability to actually rescue Java exceptions is rather obviously needed.