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

Key: JRUBY-106
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Ola Bini
Reporter: Michael Studman
Votes: 0
Watchers: 0
Operations

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

NativeException should proxy its cause

Created: 25/Aug/06 07:51 AM   Updated: 30/Apr/07 03:13 AM
Component/s: None
Affects Version/s: JRuby 0.9.0
Fix Version/s: JRuby 0.9.2

Time Tracking:
Not Specified

File Attachments: 1. Text File NativeException.patch (4 kb)
2. Text File NativeException.patch (4 kb)

Environment: SVN trunk @ rev 2219


 Description  « Hide
Java exceptions caught by JRuby and wrapped in a NativeException aren't proxied by default. This makes it harder to interoperate with Java libraries and forces the low level API to be exposed in code using the high level API just to inspect the underlying exception. Example:

require 'java'
include_class 'java.io.File' { 'JFile' }

begin
JFile.new(nil)
rescue Exception => e
end

e.cause.some_method_on_java_object # raises NoMethodError even if someMethodOnJava exists

Attaching patch and unit test to fix this on NativeException



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Michael Studman - 25/Aug/06 07:55 AM
Patch causes NativeException.cause() to proxy the returned object by calling JavaUtilities.wrap and passing to it the JavaObject that wraps the real cause object.

There may be a better way to do this but it wasn't clear to me.

Unit test also included.


Michael Studman - 25/Aug/06 07:56 AM
Added JIRA issue in test case assert.