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

Key: JRUBY-2242
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Bill Dortch
Reporter: Ola Bini
Votes: 0
Watchers: 3
Operations

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

Java Exceptions doesn't follow regular exception expectations

Created: 07/Mar/08 11:06 AM   Updated: 13/Aug/08 10:59 PM
Component/s: Java Integration
Affects Version/s: None
Fix Version/s: JRuby 1.2

Time Tracking:
Not Specified


 Description  « Hide
It's highly unintuitive that the following doesn't work:
begin
  java.util.HashMap.new.entrySet.iterator.next
rescue java.util.NoSuchElementException => e
  assert_equal java.util.NoSuchElementException, e.class
end

Instead, the class of e is NativeException. This means that no testing frameworks can test exceptions from Java code the same way they test it from Ruby.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Charles Oliver Nutter - 08/Mar/08 04:31 PM
Yeah, this is pretty obviously stupid. Do we try to attack this before lightweights, by wrapping the exception in an appropriate Ruby-like exception that mirrors the Java exception hierarchy, or do we wait for lightweights to allow just handling all exceptions the same way?

Charles Oliver Nutter - 13/Aug/08 10:59 PM
We can't change this for a 1.1.x release, since it would break anyone's code that's rescuing NativeException right now. But I did modify code in 1.1.4 to allow rescuing normal Java exceptions, and as a result this change is possible in e.g. 1.2. So marking it for 1.2.