ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166y/ForkJoinTask.java
(Generate patch)

Comparing jsr166/src/jsr166y/ForkJoinTask.java (file contents):
Revision 1.91 by dl, Sun Oct 28 22:36:01 2012 UTC vs.
Revision 1.92 by dl, Wed Oct 31 12:49:24 2012 UTC

# Line 601 | Line 601 | public abstract class ForkJoinTask<V> im
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
# Line 735 | Line 757 | public abstract class ForkJoinTask<V> im
757              }
758          }
759          if (ex != null)
760 <            U.throwException(ex);
760 >            rethrow(ex);
761      }
762  
763      /**
# Line 786 | Line 808 | public abstract class ForkJoinTask<V> im
808              }
809          }
810          if (ex != null)
811 <            U.throwException(ex);
811 >            rethrow(ex);
812          return tasks;
813      }
814  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines