601 |
|
} |
602 |
|
|
603 |
|
/** |
604 |
+ |
* A version of "sneaky throw" to relay exceptions |
605 |
+ |
*/ |
606 |
+ |
static void rethrow(final Throwable ex) { |
607 |
+ |
if (ex != null) { |
608 |
+ |
if (ex instanceof Error) |
609 |
+ |
throw (Error)ex; |
610 |
+ |
if (ex instanceof RuntimeException) |
611 |
+ |
throw (RuntimeException)ex; |
612 |
+ |
throw uncheckedThrowable(ex, RuntimeException.class); |
613 |
+ |
} |
614 |
+ |
} |
615 |
+ |
|
616 |
+ |
/** |
617 |
+ |
* The sneaky part of sneaky throw, relying on generics |
618 |
+ |
* limitations to evade compiler complaints about rethrowing |
619 |
+ |
* unchecked exceptions |
620 |
+ |
*/ |
621 |
+ |
@SuppressWarnings("unchecked") static <T extends Throwable> |
622 |
+ |
T uncheckedThrowable(final Throwable t, final Class<T> c) { |
623 |
+ |
return (T)t; // rely on vacuous cast |
624 |
+ |
} |
625 |
+ |
|
626 |
+ |
/** |
627 |
|
* Throws exception, if any, associated with the given status. |
628 |
|
*/ |
629 |
|
private void reportException(int s) { |
630 |
< |
Throwable ex = ((s == CANCELLED) ? new CancellationException() : |
631 |
< |
(s == EXCEPTIONAL) ? getThrowableException() : |
632 |
< |
null); |
633 |
< |
if (ex != null) |
611 |
< |
U.throwException(ex); |
630 |
> |
if (s == CANCELLED) |
631 |
> |
throw new CancellationException(); |
632 |
> |
if (s == EXCEPTIONAL) |
633 |
> |
rethrow(getThrowableException()); |
634 |
|
} |
635 |
|
|
636 |
|
// public methods |
757 |
|
} |
758 |
|
} |
759 |
|
if (ex != null) |
760 |
< |
U.throwException(ex); |
760 |
> |
rethrow(ex); |
761 |
|
} |
762 |
|
|
763 |
|
/** |
808 |
|
} |
809 |
|
} |
810 |
|
if (ex != null) |
811 |
< |
U.throwException(ex); |
811 |
> |
rethrow(ex); |
812 |
|
return tasks; |
813 |
|
} |
814 |
|
|