After thinking about the previous discussion #714, I think I can probably rework the Java implementation of exceptions to have Err subclass directly from RuntimeException. This would clean stuff up a bit in the Java runtime APIs and make FFI cleaner. The existing design predates using String, BigDecimal directly - but now the infrastructure to handle that stuff should be in place.
brianTue 11 Aug 2009
Promoted to ticket #717 and assigned to brian
brianWed 1 Jun 2011
Ticket resolved in 1.0.59
I have made this change for the upcoming build. This new design does not effect Fantom code, but it is a significant change to the Java runtime and if you have developed Java code which interacts with Fantom exceptions.
Previously, sys::Err was represented in Java like all classes by subclassing the root fan.sys.FanObj class. But to leverage Java's exception infrastructure we needed a subclass of Throwable. I handled that by creating a peer Err.Val class for each Fantom exception class that could be used for throw/catch in the Java bytecode. But it was an awkward design, especially when using Fantom code from Java.
The new design is quite simple: I changed the Java class fan.sys.Err to subclass from RuntimeException instead of FanObj. That change was enabled by all the work I did in 2008 to leverage Java types for boxed value types. So the new design is actually much simpler.
If you have Java code working with Fantom exceptions, you can get rid of all the Err.Val mess:
// old code
throw ArgErr.make("foo").val;
// new code
throw ArgErr.make("foo");
// old code
catch (UnknownSlotErr.Val e) {}
// new code
catch (UnknownSlotErr e) {}
brian Tue 11 Aug 2009
After thinking about the previous discussion #714, I think I can probably rework the Java implementation of exceptions to have Err subclass directly from RuntimeException. This would clean stuff up a bit in the Java runtime APIs and make FFI cleaner. The existing design predates using String, BigDecimal directly - but now the infrastructure to handle that stuff should be in place.
brian Tue 11 Aug 2009
Promoted to ticket #717 and assigned to brian
brian Wed 1 Jun 2011
Ticket resolved in 1.0.59
I have made this change for the upcoming build. This new design does not effect Fantom code, but it is a significant change to the Java runtime and if you have developed Java code which interacts with Fantom exceptions.
Previously,
sys::Err
was represented in Java like all classes by subclassing the rootfan.sys.FanObj
class. But to leverage Java's exception infrastructure we needed a subclass ofThrowable
. I handled that by creating a peerErr.Val
class for each Fantom exception class that could be used for throw/catch in the Java bytecode. But it was an awkward design, especially when using Fantom code from Java.The new design is quite simple: I changed the Java class
fan.sys.Err
to subclass fromRuntimeException
instead ofFanObj
. That change was enabled by all the work I did in 2008 to leverage Java types for boxed value types. So the new design is actually much simpler.If you have Java code working with Fantom exceptions, you can get rid of all the Err.Val mess: