ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CompletableFuture.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/CompletableFuture.java (file contents):
Revision 1.189 by jsr166, Tue Apr 19 22:55:29 2016 UTC vs.
Revision 1.190 by jsr166, Sun May 1 04:26:48 2016 UTC

# Line 345 | Line 345 | public class CompletableFuture<T> implem
345      /**
346       * Reports result using Future.get conventions.
347       */
348 <    private static <T> T reportGet(Object r)
348 >    private static Object reportGet(Object r)
349          throws InterruptedException, ExecutionException {
350          if (r == null) // by convention below, null means interrupted
351              throw new InterruptedException();
# Line 360 | Line 360 | public class CompletableFuture<T> implem
360                  x = cause;
361              throw new ExecutionException(x);
362          }
363 <        @SuppressWarnings("unchecked") T t = (T) r;
364 <        return t;
363 >        return r;
364      }
365  
366      /**
367       * Decodes outcome to return result or throw unchecked exception.
368       */
369 <    private static <T> T reportJoin(Object r) {
369 >    private static Object reportJoin(Object r) {
370          if (r instanceof AltResult) {
371              Throwable x;
372              if ((x = ((AltResult)r).ex) == null)
# Line 378 | Line 377 | public class CompletableFuture<T> implem
377                  throw (CompletionException)x;
378              throw new CompletionException(x);
379          }
380 <        @SuppressWarnings("unchecked") T t = (T) r;
382 <        return t;
380 >        return r;
381      }
382  
383      /* ------------- Async task preliminaries -------------- */
# Line 2014 | Line 2012 | public class CompletableFuture<T> implem
2012       * @throws InterruptedException if the current thread was interrupted
2013       * while waiting
2014       */
2015 +    @SuppressWarnings("unchecked")
2016      public T get() throws InterruptedException, ExecutionException {
2017          Object r;
2018 <        return reportGet((r = result) == null ? waitingGet(true) : r);
2018 >        return (T) reportGet((r = result) == null ? waitingGet(true) : r);
2019      }
2020  
2021      /**
# Line 2032 | Line 2031 | public class CompletableFuture<T> implem
2031       * while waiting
2032       * @throws TimeoutException if the wait timed out
2033       */
2034 +    @SuppressWarnings("unchecked")
2035      public T get(long timeout, TimeUnit unit)
2036          throws InterruptedException, ExecutionException, TimeoutException {
2037          Object r;
2038          long nanos = unit.toNanos(timeout);
2039 <        return reportGet((r = result) == null ? timedGet(nanos) : r);
2039 >        return (T) reportGet((r = result) == null ? timedGet(nanos) : r);
2040      }
2041  
2042      /**
# Line 2053 | Line 2053 | public class CompletableFuture<T> implem
2053       * @throws CompletionException if this future completed
2054       * exceptionally or a completion computation threw an exception
2055       */
2056 +    @SuppressWarnings("unchecked")
2057      public T join() {
2058          Object r;
2059 <        return reportJoin((r = result) == null ? waitingGet(false) : r);
2059 >        return (T) reportJoin((r = result) == null ? waitingGet(false) : r);
2060      }
2061  
2062      /**
# Line 2068 | Line 2069 | public class CompletableFuture<T> implem
2069       * @throws CompletionException if this future completed
2070       * exceptionally or a completion computation threw an exception
2071       */
2072 +    @SuppressWarnings("unchecked")
2073      public T getNow(T valueIfAbsent) {
2074          Object r;
2075 <        return ((r = result) == null) ? valueIfAbsent : reportJoin(r);
2075 >        return ((r = result) == null) ? valueIfAbsent : (T) reportJoin(r);
2076      }
2077  
2078      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines