Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 0.9.0
-
Fix Version/s: JRuby 0.9.2
-
Component/s: None
-
Labels:None
-
Environment:SVN trunk @ rev 2219
-
Number of attachments :
Description
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
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.