Explicit catches versus bulk catch + type check?
Charles Oliver Nutter
headius at headius.com
Thu Oct 13 21:01:09 PDT 2011
Ok Hotspot guys, I have a challenge for the JIT. I want to basically do this:
try {
...
} catch (Exception e) {
if (!(e instanceof SomeException)) throw e;
... handle e as SomeException
}
instead of explicitly adding exception-handling for SomeException.
There's a few reasons for this:
* Wiring up exception-handling in method handles is rather cumbersome.
If I could do it with a single wrapper it would make my life easier.
* Similar to the "multicatch" problem in Java 7, I often want nearly
the same boilerplate code for multiple exception types.
* Because Ruby is dynamically typed, we can't statically determine the
*actual* expected exception type at compile time, and so we must do a
bulk catch with type checks.
My question, then, is whether Hotspot can see through this (assuming
everything inlines) and see that although we're doing a bulk catch
only certain cases *actually* handle the resulting exception.
Thoughts?
- Charlie
More information about the mlvm-dev
mailing list