Multi-catch/final rethrow
Ulf Zibis
Ulf.Zibis at gmx.de
Thu May 6 12:45:11 PDT 2010
No answer for my questions? :-(
-Ulf
Am 04.05.2010 11:30, schrieb Ulf Zibis:
> Am 04.05.2010 02:25, schrieb joe.darcy at oracle.com:
>
>> Greetings,
>>
>> As alluded to as a possibility previously [1], I'm happy to announce
>> that improved exception handling with multi-catch and final rethrow will
>> be part of an upcoming JDK 7 build.
>>
>>
> Great!
>
>
>> } else {
>> throw (Throwable)new Exception();
>>
>>
> I'm wondering that a cast to a throw is valid syntax, or _in other
> words_, what should such a syntax be good for ???
> In fact, an Exception instance is thrown, and should be caught by catch
> (Exception e). Or not ?
>
>
>
>> To address this, the third clause is changed to
>>
>>
>>
>>> - is a subtype/supertype of one of the types in the declaration of the
>>> catch parameter
>>>
>>>
> Does that mean, that following variation wouldn't rethrow
> Exception("b3") (and (Throwable)new Exception() too?),
> as it is nor subtype nor supertype of Exception, as it is itself ?
> That IMO would be weird syntax.
>
> class Neg04 {
> static class A extends Exception {}
> static class B extends Exception {}
>
> void test(boolean b1, boolean b2, boolean b3) throws B {
> try {
> if (b1) {
> throw new A();
> } else if (b2) {
> throw new B();
> } else if (b3) {
> throw new Exception("b3");
> } else {
> throw (Throwable)new Exception();
> }
> }
> catch (A e) {}
> catch (final Exception e) {
> throw e;
> }
> catch (Throwable t) {}
> }
> }
>
>
> -Ulf
>
>
>
>
>
More information about the coin-dev
mailing list