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

Comparing jsr166/src/test/tck/CountedCompleterTest.java (file contents):
Revision 1.7 by jsr166, Mon Jun 3 18:20:05 2013 UTC vs.
Revision 1.15 by jsr166, Wed Dec 31 17:00:58 2014 UTC

# Line 3 | Line 3
3   * Expert Group and released to the public domain, as explained at
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6 < import java.util.concurrent.ExecutionException;
6 > import java.util.HashSet;
7   import java.util.concurrent.CancellationException;
8 + import java.util.concurrent.CountedCompleter;
9 + import java.util.concurrent.ExecutionException;
10   import java.util.concurrent.ForkJoinPool;
11   import java.util.concurrent.ForkJoinTask;
10 import java.util.concurrent.CountedCompleter;
11 import java.util.concurrent.ForkJoinWorkerThread;
12 import java.util.concurrent.RecursiveAction;
13 import java.util.concurrent.TimeUnit;
12   import java.util.concurrent.TimeoutException;
13 < import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
13 > import java.util.concurrent.atomic.AtomicInteger;
14 > import java.util.concurrent.atomic.AtomicReference;
15   import static java.util.concurrent.TimeUnit.MILLISECONDS;
16   import static java.util.concurrent.TimeUnit.SECONDS;
18 import java.util.HashSet;
17   import junit.framework.*;
18  
19   public class CountedCompleterTest extends JSR166TestCase {
# Line 83 | Line 81 | public class CountedCompleterTest extend
81          } catch (Throwable fail) { threadUnexpectedException(fail); }
82      }
83  
84 <    <T> void checkCompletedNormally(CountedCompleter<T> a) {
87 <        checkCompletedNormally(a, null);
88 <    }
89 <
90 <    <T> void checkCompletedNormally(CountedCompleter<T> a, T expected) {
84 >    void checkCompletedNormally(CountedCompleter<?> a) {
85          assertTrue(a.isDone());
86          assertFalse(a.isCancelled());
87          assertTrue(a.isCompletedNormally());
88          assertFalse(a.isCompletedAbnormally());
89          assertNull(a.getException());
90 <        assertSame(expected, a.getRawResult());
90 >        assertNull(a.getRawResult());
91  
92          {
93              Thread.currentThread().interrupt();
94              long t0 = System.nanoTime();
95 <            assertSame(expected, a.join());
95 >            assertNull(a.join());
96              assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
97              Thread.interrupted();
98          }
# Line 114 | Line 108 | public class CountedCompleterTest extend
108          assertFalse(a.cancel(false));
109          assertFalse(a.cancel(true));
110          try {
111 <            assertSame(expected, a.get());
111 >            assertNull(a.get());
112          } catch (Throwable fail) { threadUnexpectedException(fail); }
113          try {
114 <            assertSame(expected, a.get(5L, SECONDS));
114 >            assertNull(a.get(5L, SECONDS));
115          } catch (Throwable fail) { threadUnexpectedException(fail); }
116      }
117  
# Line 196 | Line 190 | public class CountedCompleterTest extend
190          } catch (ExecutionException success) {
191              assertSame(t.getClass(), success.getCause().getClass());
192          } catch (Throwable fail) { threadUnexpectedException(fail); }
193 +
194 +        try {
195 +            a.invoke();
196 +            shouldThrow();
197 +        } catch (Throwable ex) {
198 +            assertSame(t, ex);
199 +        }
200      }
201  
202      public static final class FJException extends RuntimeException {
203          FJException() { super(); }
204      }
205  
206 <    static final class NoopCountedCompleter extends CountedCompleter {
207 <        boolean post; // set true if onCompletion called
208 <        NoopCountedCompleter() { super(); }
209 <        NoopCountedCompleter(CountedCompleter p) { super(p); }
210 <        public void compute() {}
211 <        public final void onCompletion(CountedCompleter caller) {
212 <            post = true;
206 >    abstract class CheckedCC extends CountedCompleter<Object> {
207 >        final AtomicInteger computeN = new AtomicInteger(0);
208 >        final AtomicInteger onCompletionN = new AtomicInteger(0);
209 >        final AtomicInteger onExceptionalCompletionN = new AtomicInteger(0);
210 >        final AtomicInteger setRawResultN = new AtomicInteger(0);
211 >        final AtomicReference<Object> rawResult = new AtomicReference<Object>(null);
212 >        int computeN() { return computeN.get(); }
213 >        int onCompletionN() { return onCompletionN.get(); }
214 >        int onExceptionalCompletionN() { return onExceptionalCompletionN.get(); }
215 >        int setRawResultN() { return setRawResultN.get(); }
216 >
217 >        CheckedCC() { super(); }
218 >        CheckedCC(CountedCompleter p) { super(p); }
219 >        CheckedCC(CountedCompleter p, int n) { super(p, n); }
220 >        abstract void realCompute();
221 >        public final void compute() {
222 >            computeN.incrementAndGet();
223 >            realCompute();
224 >        }
225 >        public void onCompletion(CountedCompleter caller) {
226 >            onCompletionN.incrementAndGet();
227 >            super.onCompletion(caller);
228 >        }
229 >        public boolean onExceptionalCompletion(Throwable ex,
230 >                                               CountedCompleter caller) {
231 >            onExceptionalCompletionN.incrementAndGet();
232 >            assertNotNull(ex);
233 >            assertTrue(isCompletedAbnormally());
234 >            assertTrue(super.onExceptionalCompletion(ex, caller));
235 >            return true;
236 >        }
237 >        protected void setRawResult(Object t) {
238 >            setRawResultN.incrementAndGet();
239 >            rawResult.set(t);
240 >            super.setRawResult(t);
241          }
242 +        void checkIncomplete() {
243 +            assertEquals(0, computeN());
244 +            assertEquals(0, onCompletionN());
245 +            assertEquals(0, onExceptionalCompletionN());
246 +            assertEquals(0, setRawResultN());
247 +            checkNotDone(this);
248 +        }
249 +        void checkCompletes(Object rawResult) {
250 +            checkIncomplete();
251 +            int pendingCount = getPendingCount();
252 +            complete(rawResult);
253 +            assertEquals(pendingCount, getPendingCount());
254 +            assertEquals(0, computeN());
255 +            assertEquals(1, onCompletionN());
256 +            assertEquals(0, onExceptionalCompletionN());
257 +            assertEquals(1, setRawResultN());
258 +            assertSame(rawResult, this.rawResult.get());
259 +            checkCompletedNormally(this);
260 +        }
261 +        void checkCompletesExceptionally(Throwable ex) {
262 +            checkIncomplete();
263 +            completeExceptionally(ex);
264 +            checkCompletedExceptionally(ex);
265 +        }
266 +        void checkCompletedExceptionally(Throwable ex) {
267 +            assertEquals(0, computeN());
268 +            assertEquals(0, onCompletionN());
269 +            assertEquals(1, onExceptionalCompletionN());
270 +            assertEquals(0, setRawResultN());
271 +            assertNull(this.rawResult.get());
272 +            checkCompletedAbnormally(this, ex);
273 +        }
274 +    }
275 +
276 +    final class NoopCC extends CheckedCC {
277 +        NoopCC() { super(); }
278 +        NoopCC(CountedCompleter p) { super(p); }
279 +        protected void realCompute() {}
280      }
281  
282      /**
283       * A newly constructed CountedCompleter is not completed;
284 <     * complete() causes completion.
284 >     * complete() causes completion. pendingCount is ignored.
285       */
286      public void testComplete() {
287 <        NoopCountedCompleter a = new NoopCountedCompleter();
288 <        assertFalse(a.isDone());
289 <        assertFalse(a.isCompletedNormally());
290 <        assertFalse(a.isCompletedAbnormally());
291 <        assertFalse(a.isCancelled());
292 <        assertNull(a.getException());
293 <        assertNull(a.getRawResult());
294 <        assertFalse(a.post);
295 <        a.complete(null);
296 <        assertTrue(a.post);
230 <        assertTrue(a.isDone());
231 <        assertTrue(a.isCompletedNormally());
232 <        assertFalse(a.isCompletedAbnormally());
233 <        assertFalse(a.isCancelled());
234 <        assertNull(a.getException());
235 <        assertNull(a.getRawResult());
287 >        for (Object x : new Object[] { Boolean.TRUE, null }) {
288 >            for (int pendingCount : new int[] { 0, 42 }) {
289 >                testComplete(new NoopCC(), x, pendingCount);
290 >                testComplete(new NoopCC(new NoopCC()), x, pendingCount);
291 >            }
292 >        }
293 >    }
294 >    void testComplete(NoopCC cc, Object x, int pendingCount) {
295 >        cc.setPendingCount(pendingCount);
296 >        cc.checkCompletes(x);
297      }
298  
299      /**
300       * completeExceptionally completes exceptionally
301       */
302      public void testCompleteExceptionally() {
303 <        NoopCountedCompleter a = new NoopCountedCompleter();
304 <        assertFalse(a.isDone());
305 <        assertFalse(a.isCompletedNormally());
306 <        assertFalse(a.isCompletedAbnormally());
307 <        assertFalse(a.isCancelled());
308 <        assertNull(a.getException());
309 <        assertNull(a.getRawResult());
310 <        assertFalse(a.post);
311 <        a.completeExceptionally(new FJException());
312 <        assertFalse(a.post);
313 <        assertTrue(a.isDone());
314 <        assertFalse(a.isCompletedNormally());
315 <        assertTrue(a.isCompletedAbnormally());
316 <        assertFalse(a.isCancelled());
317 <        assertTrue(a.getException() instanceof FJException);
257 <        assertNull(a.getRawResult());
303 >        new NoopCC()
304 >            .checkCompletesExceptionally(new FJException());
305 >        new NoopCC(new NoopCC())
306 >            .checkCompletesExceptionally(new FJException());
307 >    }
308 >
309 >    /**
310 >     * completeExceptionally(null) throws NullPointerException
311 >     */
312 >    public void testCompleteExceptionally_null() {
313 >        try {
314 >            new NoopCC()
315 >                .checkCompletesExceptionally(null);
316 >            shouldThrow();
317 >        } catch (NullPointerException success) {}
318      }
319  
320      /**
321       * setPendingCount sets the reported pending count
322       */
323      public void testSetPendingCount() {
324 <        NoopCountedCompleter a = new NoopCountedCompleter();
324 >        NoopCC a = new NoopCC();
325          assertEquals(0, a.getPendingCount());
326          a.setPendingCount(1);
327          assertEquals(1, a.getPendingCount());
# Line 273 | Line 333 | public class CountedCompleterTest extend
333       * addToPendingCount adds to the reported pending count
334       */
335      public void testAddToPendingCount() {
336 <        NoopCountedCompleter a = new NoopCountedCompleter();
336 >        NoopCC a = new NoopCC();
337          assertEquals(0, a.getPendingCount());
338          a.addToPendingCount(1);
339          assertEquals(1, a.getPendingCount());
# Line 286 | Line 346 | public class CountedCompleterTest extend
346       * count unless zero
347       */
348      public void testDecrementPendingCount() {
349 <        NoopCountedCompleter a = new NoopCountedCompleter();
349 >        NoopCC a = new NoopCC();
350          assertEquals(0, a.getPendingCount());
351          a.addToPendingCount(1);
352          assertEquals(1, a.getPendingCount());
# Line 297 | Line 357 | public class CountedCompleterTest extend
357      }
358  
359      /**
360 +     * compareAndSetPendingCount compares and sets the reported
361 +     * pending count
362 +     */
363 +    public void testCompareAndSetPendingCount() {
364 +        NoopCC a = new NoopCC();
365 +        assertEquals(0, a.getPendingCount());
366 +        assertTrue(a.compareAndSetPendingCount(0, 1));
367 +        assertEquals(1, a.getPendingCount());
368 +        assertTrue(a.compareAndSetPendingCount(1, 2));
369 +        assertEquals(2, a.getPendingCount());
370 +        assertFalse(a.compareAndSetPendingCount(1, 3));
371 +        assertEquals(2, a.getPendingCount());
372 +    }
373 +
374 +    /**
375       * getCompleter returns parent or null if at root
376       */
377      public void testGetCompleter() {
378 <        NoopCountedCompleter a = new NoopCountedCompleter();
378 >        NoopCC a = new NoopCC();
379          assertNull(a.getCompleter());
380 <        CountedCompleter b = new NoopCountedCompleter(a);
381 <        assertEquals(a, b.getCompleter());
380 >        CountedCompleter b = new NoopCC(a);
381 >        assertSame(a, b.getCompleter());
382 >        CountedCompleter c = new NoopCC(b);
383 >        assertSame(b, c.getCompleter());
384      }
385  
386      /**
387       * getRoot returns self if no parent, else parent's root
388       */
389      public void testGetRoot() {
390 <        NoopCountedCompleter a = new NoopCountedCompleter();
391 <        NoopCountedCompleter b = new NoopCountedCompleter(a);
392 <        assertEquals(a, a.getRoot());
393 <        assertEquals(a, b.getRoot());
390 >        NoopCC a = new NoopCC();
391 >        NoopCC b = new NoopCC(a);
392 >        NoopCC c = new NoopCC(b);
393 >        assertSame(a, a.getRoot());
394 >        assertSame(a, b.getRoot());
395 >        assertSame(a, c.getRoot());
396      }
397  
398      /**
399 <     * tryComplete causes completion if pending count is zero
399 >     * tryComplete decrements pending count unless zero, in which case
400 >     * causes completion
401       */
402 <    public void testTryComplete1() {
403 <        NoopCountedCompleter a = new NoopCountedCompleter();
402 >    public void testTryComplete() {
403 >        NoopCC a = new NoopCC();
404          assertEquals(0, a.getPendingCount());
405 +        int n = 3;
406 +        a.setPendingCount(n);
407 +        for (; n > 0; n--) {
408 +            assertEquals(n, a.getPendingCount());
409 +            a.tryComplete();
410 +            a.checkIncomplete();
411 +            assertEquals(n - 1, a.getPendingCount());
412 +        }
413          a.tryComplete();
414 <        assertTrue(a.post);
415 <        assertTrue(a.isDone());
414 >        assertEquals(0, a.computeN());
415 >        assertEquals(1, a.onCompletionN());
416 >        assertEquals(0, a.onExceptionalCompletionN());
417 >        assertEquals(0, a.setRawResultN());
418 >        checkCompletedNormally(a);
419      }
420  
421      /**
422 <     * propagateCompletion causes completion without invoking
423 <     * onCompletion if pending count is zero
422 >     * propagateCompletion decrements pending count unless zero, in
423 >     * which case causes completion, without invoking onCompletion
424       */
425      public void testPropagateCompletion() {
426 <        NoopCountedCompleter a = new NoopCountedCompleter();
426 >        NoopCC a = new NoopCC();
427          assertEquals(0, a.getPendingCount());
428 +        int n = 3;
429 +        a.setPendingCount(n);
430 +        for (; n > 0; n--) {
431 +            assertEquals(n, a.getPendingCount());
432 +            a.propagateCompletion();
433 +            a.checkIncomplete();
434 +            assertEquals(n - 1, a.getPendingCount());
435 +        }
436          a.propagateCompletion();
437 <        assertFalse(a.post);
438 <        assertTrue(a.isDone());
439 <    }
440 <
441 <    /**
343 <     * tryComplete decrements pending count unless zero
344 <     */
345 <    public void testTryComplete2() {
346 <        NoopCountedCompleter a = new NoopCountedCompleter();
347 <        assertEquals(0, a.getPendingCount());
348 <        a.setPendingCount(1);
349 <        a.tryComplete();
350 <        assertFalse(a.post);
351 <        assertFalse(a.isDone());
352 <        assertEquals(0, a.getPendingCount());
353 <        a.tryComplete();
354 <        assertTrue(a.post);
355 <        assertTrue(a.isDone());
437 >        assertEquals(0, a.computeN());
438 >        assertEquals(0, a.onCompletionN());
439 >        assertEquals(0, a.onExceptionalCompletionN());
440 >        assertEquals(0, a.setRawResultN());
441 >        checkCompletedNormally(a);
442      }
443  
444      /**
445       * firstComplete returns this if pending count is zero else null
446       */
447      public void testFirstComplete() {
448 <        NoopCountedCompleter a = new NoopCountedCompleter();
448 >        NoopCC a = new NoopCC();
449          a.setPendingCount(1);
450          assertNull(a.firstComplete());
451 <        assertEquals(a, a.firstComplete());
451 >        a.checkIncomplete();
452 >        assertSame(a, a.firstComplete());
453 >        a.checkIncomplete();
454      }
455  
456      /**
# Line 370 | Line 458 | public class CountedCompleterTest extend
458       * zero else null
459       */
460      public void testNextComplete() {
461 <        NoopCountedCompleter a = new NoopCountedCompleter();
462 <        NoopCountedCompleter b = new NoopCountedCompleter(a);
461 >        NoopCC a = new NoopCC();
462 >        NoopCC b = new NoopCC(a);
463          a.setPendingCount(1);
464          b.setPendingCount(1);
465          assertNull(b.firstComplete());
466 <        CountedCompleter c = b.firstComplete();
467 <        assertEquals(b, c);
468 <        CountedCompleter d = c.nextComplete();
469 <        assertNull(d);
470 <        CountedCompleter e = c.nextComplete();
471 <        assertEquals(a, e);
466 >        assertSame(b, b.firstComplete());
467 >        assertNull(b.nextComplete());
468 >        a.checkIncomplete();
469 >        b.checkIncomplete();
470 >        assertSame(a, b.nextComplete());
471 >        assertSame(a, b.nextComplete());
472 >        a.checkIncomplete();
473 >        b.checkIncomplete();
474 >        assertNull(a.nextComplete());
475 >        b.checkIncomplete();
476 >        checkCompletedNormally(a);
477      }
478  
479      /**
480       * quietlyCompleteRoot completes root task
481       */
482      public void testQuietlyCompleteRoot() {
483 <        NoopCountedCompleter a = new NoopCountedCompleter();
484 <        NoopCountedCompleter b = new NoopCountedCompleter(a);
483 >        NoopCC a = new NoopCC();
484 >        NoopCC b = new NoopCC(a);
485 >        NoopCC c = new NoopCC(b);
486          a.setPendingCount(1);
487          b.setPendingCount(1);
488 <        b.quietlyCompleteRoot();
488 >        c.setPendingCount(1);
489 >        c.quietlyCompleteRoot();
490          assertTrue(a.isDone());
491          assertFalse(b.isDone());
492 +        assertFalse(c.isDone());
493      }
494  
495      // Invocation tests use some interdependent task classes
496      // to better test propagation etc
497  
498 <
499 <    // Version of Fibonacci with different classes for left vs right forks
500 <    abstract static class CCF extends CountedCompleter {
498 >    /**
499 >     * Version of Fibonacci with different classes for left vs right forks
500 >     */
501 >    abstract class CCF extends CheckedCC {
502          int number;
503          int rnumber;
504  
# Line 410 | Line 507 | public class CountedCompleterTest extend
507              this.number = n;
508          }
509  
510 <        public final void compute() {
414 <            CountedCompleter p;
510 >        protected final void realCompute() {
511              CCF f = this;
512              int n = number;
513              while (n >= 2) {
514                  new RCCF(f, n - 2).fork();
515                  f = new LCCF(f, --n);
516              }
517 <            f.number = n;
422 <            f.onCompletion(f);
423 <            if ((p = f.getCompleter()) != null)
424 <                p.tryComplete();
425 <            else
426 <                f.quietlyComplete();
517 >            f.complete(null);
518          }
519      }
520  
521 <    static final class LCCF extends CCF {
521 >    final class LCCF extends CCF {
522 >        public LCCF(int n) { this(null, n); }
523          public LCCF(CountedCompleter parent, int n) {
524              super(parent, n);
525          }
526          public final void onCompletion(CountedCompleter caller) {
527 +            super.onCompletion(caller);
528              CCF p = (CCF)getCompleter();
529              int n = number + rnumber;
530              if (p != null)
# Line 440 | Line 533 | public class CountedCompleterTest extend
533                  number = n;
534          }
535      }
536 <    static final class RCCF extends CCF {
536 >    final class RCCF extends CCF {
537          public RCCF(CountedCompleter parent, int n) {
538              super(parent, n);
539          }
540          public final void onCompletion(CountedCompleter caller) {
541 +            super.onCompletion(caller);
542              CCF p = (CCF)getCompleter();
543              int n = number + rnumber;
544              if (p != null)
# Line 455 | Line 549 | public class CountedCompleterTest extend
549      }
550  
551      // Version of CCF with forced failure in left completions
552 <    abstract static class FailingCCF extends CountedCompleter {
552 >    abstract class FailingCCF extends CheckedCC {
553          int number;
554          int rnumber;
555  
# Line 464 | Line 558 | public class CountedCompleterTest extend
558              this.number = n;
559          }
560  
561 <        public final void compute() {
468 <            CountedCompleter p;
561 >        protected final void realCompute() {
562              FailingCCF f = this;
563              int n = number;
564              while (n >= 2) {
565                  new RFCCF(f, n - 2).fork();
566                  f = new LFCCF(f, --n);
567              }
568 <            f.number = n;
476 <            f.onCompletion(f);
477 <            if ((p = f.getCompleter()) != null)
478 <                p.tryComplete();
479 <            else
480 <                f.quietlyComplete();
568 >            f.complete(null);
569          }
570      }
571  
572 <    static final class LFCCF extends FailingCCF {
572 >    final class LFCCF extends FailingCCF {
573 >        public LFCCF(int n) { this(null, n); }
574          public LFCCF(CountedCompleter parent, int n) {
575              super(parent, n);
576          }
577          public final void onCompletion(CountedCompleter caller) {
578 +            super.onCompletion(caller);
579              FailingCCF p = (FailingCCF)getCompleter();
580              int n = number + rnumber;
581              if (p != null)
# Line 494 | Line 584 | public class CountedCompleterTest extend
584                  number = n;
585          }
586      }
587 <    static final class RFCCF extends FailingCCF {
587 >    final class RFCCF extends FailingCCF {
588          public RFCCF(CountedCompleter parent, int n) {
589              super(parent, n);
590          }
591          public final void onCompletion(CountedCompleter caller) {
592 +            super.onCompletion(caller);
593              completeExceptionally(new FJException());
594          }
595      }
# Line 511 | Line 602 | public class CountedCompleterTest extend
602      public void testInvoke() {
603          ForkJoinTask a = new CheckedRecursiveAction() {
604              protected void realCompute() {
605 <                CCF f = new LCCF(null, 8);
605 >                CCF f = new LCCF(8);
606                  assertNull(f.invoke());
607                  assertEquals(21, f.number);
608                  checkCompletedNormally(f);
# Line 527 | Line 618 | public class CountedCompleterTest extend
618      public void testQuietlyInvoke() {
619          ForkJoinTask a = new CheckedRecursiveAction() {
620              protected void realCompute() {
621 <                CCF f = new LCCF(null, 8);
621 >                CCF f = new LCCF(8);
622                  f.quietlyInvoke();
623                  assertEquals(21, f.number);
624                  checkCompletedNormally(f);
# Line 541 | Line 632 | public class CountedCompleterTest extend
632      public void testForkJoin() {
633          ForkJoinTask a = new CheckedRecursiveAction() {
634              protected void realCompute() {
635 <                CCF f = new LCCF(null, 8);
635 >                CCF f = new LCCF(8);
636                  assertSame(f, f.fork());
637                  assertNull(f.join());
638                  assertEquals(21, f.number);
# Line 556 | Line 647 | public class CountedCompleterTest extend
647      public void testForkGet() {
648          ForkJoinTask a = new CheckedRecursiveAction() {
649              protected void realCompute() throws Exception {
650 <                CCF f = new LCCF(null, 8);
650 >                CCF f = new LCCF(8);
651                  assertSame(f, f.fork());
652                  assertNull(f.get());
653                  assertEquals(21, f.number);
# Line 571 | Line 662 | public class CountedCompleterTest extend
662      public void testForkTimedGet() {
663          ForkJoinTask a = new CheckedRecursiveAction() {
664              protected void realCompute() throws Exception {
665 <                CCF f = new LCCF(null, 8);
665 >                CCF f = new LCCF(8);
666                  assertSame(f, f.fork());
667                  assertNull(f.get(LONG_DELAY_MS, MILLISECONDS));
668                  assertEquals(21, f.number);
# Line 586 | Line 677 | public class CountedCompleterTest extend
677      public void testForkTimedGetNPE() {
678          ForkJoinTask a = new CheckedRecursiveAction() {
679              protected void realCompute() throws Exception {
680 <                CCF f = new LCCF(null, 8);
680 >                CCF f = new LCCF(8);
681                  assertSame(f, f.fork());
682                  try {
683                      f.get(5L, null);
# Line 602 | Line 693 | public class CountedCompleterTest extend
693      public void testForkQuietlyJoin() {
694          ForkJoinTask a = new CheckedRecursiveAction() {
695              protected void realCompute() {
696 <                CCF f = new LCCF(null, 8);
696 >                CCF f = new LCCF(8);
697                  assertSame(f, f.fork());
698                  f.quietlyJoin();
699                  assertEquals(21, f.number);
# Line 618 | Line 709 | public class CountedCompleterTest extend
709      public void testForkHelpQuiesce() {
710          ForkJoinTask a = new CheckedRecursiveAction() {
711              protected void realCompute() {
712 <                CCF f = new LCCF(null, 8);
712 >                CCF f = new LCCF(8);
713                  assertSame(f, f.fork());
714                  helpQuiesce();
715                  assertEquals(21, f.number);
# Line 634 | Line 725 | public class CountedCompleterTest extend
725      public void testAbnormalInvoke() {
726          ForkJoinTask a = new CheckedRecursiveAction() {
727              protected void realCompute() {
728 <                FailingCCF f = new LFCCF(null, 8);
728 >                FailingCCF f = new LFCCF(8);
729                  try {
730                      f.invoke();
731                      shouldThrow();
# Line 651 | Line 742 | public class CountedCompleterTest extend
742      public void testAbnormalQuietlyInvoke() {
743          ForkJoinTask a = new CheckedRecursiveAction() {
744              protected void realCompute() {
745 <                FailingCCF f = new LFCCF(null, 8);
745 >                FailingCCF f = new LFCCF(8);
746                  f.quietlyInvoke();
747                  assertTrue(f.getException() instanceof FJException);
748                  checkCompletedAbnormally(f, f.getException());
# Line 665 | Line 756 | public class CountedCompleterTest extend
756      public void testAbnormalForkJoin() {
757          ForkJoinTask a = new CheckedRecursiveAction() {
758              protected void realCompute() {
759 <                FailingCCF f = new LFCCF(null, 8);
759 >                FailingCCF f = new LFCCF(8);
760                  assertSame(f, f.fork());
761                  try {
762                      f.join();
# Line 683 | Line 774 | public class CountedCompleterTest extend
774      public void testAbnormalForkGet() {
775          ForkJoinTask a = new CheckedRecursiveAction() {
776              protected void realCompute() throws Exception {
777 <                FailingCCF f = new LFCCF(null, 8);
777 >                FailingCCF f = new LFCCF(8);
778                  assertSame(f, f.fork());
779                  try {
780                      f.get();
# Line 703 | Line 794 | public class CountedCompleterTest extend
794      public void testAbnormalForkTimedGet() {
795          ForkJoinTask a = new CheckedRecursiveAction() {
796              protected void realCompute() throws Exception {
797 <                FailingCCF f = new LFCCF(null, 8);
797 >                FailingCCF f = new LFCCF(8);
798                  assertSame(f, f.fork());
799                  try {
800                      f.get(LONG_DELAY_MS, MILLISECONDS);
# Line 723 | Line 814 | public class CountedCompleterTest extend
814      public void testAbnormalForkQuietlyJoin() {
815          ForkJoinTask a = new CheckedRecursiveAction() {
816              protected void realCompute() {
817 <                FailingCCF f = new LFCCF(null, 8);
817 >                FailingCCF f = new LFCCF(8);
818                  assertSame(f, f.fork());
819                  f.quietlyJoin();
820                  assertTrue(f.getException() instanceof FJException);
# Line 738 | Line 829 | public class CountedCompleterTest extend
829      public void testCancelledInvoke() {
830          ForkJoinTask a = new CheckedRecursiveAction() {
831              protected void realCompute() {
832 <                CCF f = new LCCF(null, 8);
832 >                CCF f = new LCCF(8);
833                  assertTrue(f.cancel(true));
834                  try {
835                      f.invoke();
# Line 756 | Line 847 | public class CountedCompleterTest extend
847      public void testCancelledForkJoin() {
848          ForkJoinTask a = new CheckedRecursiveAction() {
849              protected void realCompute() {
850 <                CCF f = new LCCF(null, 8);
850 >                CCF f = new LCCF(8);
851                  assertTrue(f.cancel(true));
852                  assertSame(f, f.fork());
853                  try {
# Line 775 | Line 866 | public class CountedCompleterTest extend
866      public void testCancelledForkGet() {
867          ForkJoinTask a = new CheckedRecursiveAction() {
868              protected void realCompute() throws Exception {
869 <                CCF f = new LCCF(null, 8);
869 >                CCF f = new LCCF(8);
870                  assertTrue(f.cancel(true));
871                  assertSame(f, f.fork());
872                  try {
# Line 794 | Line 885 | public class CountedCompleterTest extend
885      public void testCancelledForkTimedGet() throws Exception {
886          ForkJoinTask a = new CheckedRecursiveAction() {
887              protected void realCompute() throws Exception {
888 <                CCF f = new LCCF(null, 8);
888 >                CCF f = new LCCF(8);
889                  assertTrue(f.cancel(true));
890                  assertSame(f, f.fork());
891                  try {
# Line 813 | Line 904 | public class CountedCompleterTest extend
904      public void testCancelledForkQuietlyJoin() {
905          ForkJoinTask a = new CheckedRecursiveAction() {
906              protected void realCompute() {
907 <                CCF f = new LCCF(null, 8);
907 >                CCF f = new LCCF(8);
908                  assertTrue(f.cancel(true));
909                  assertSame(f, f.fork());
910                  f.quietlyJoin();
# Line 885 | Line 976 | public class CountedCompleterTest extend
976      public void testCompleteExceptionally2() {
977          ForkJoinTask a = new CheckedRecursiveAction() {
978              protected void realCompute() {
979 <                CCF f = new LCCF(null, 8);
980 <                f.completeExceptionally(new FJException());
981 <                try {
982 <                    f.invoke();
983 <                    shouldThrow();
984 <                } catch (FJException success) {
894 <                    checkCompletedAbnormally(f, success);
895 <                }
979 >                CCF n = new LCCF(8);
980 >                CCF f = new LCCF(n, 8);
981 >                FJException ex = new FJException();
982 >                f.completeExceptionally(ex);
983 >                f.checkCompletedExceptionally(ex);
984 >                n.checkCompletedExceptionally(ex);
985              }};
986          testInvokeOnPool(mainPool(), a);
987      }
# Line 903 | Line 992 | public class CountedCompleterTest extend
992      public void testInvokeAll2() {
993          ForkJoinTask a = new CheckedRecursiveAction() {
994              protected void realCompute() {
995 <                CCF f = new LCCF(null, 8);
996 <                CCF g = new LCCF(null, 9);
995 >                CCF f = new LCCF(8);
996 >                CCF g = new LCCF(9);
997                  invokeAll(f, g);
998                  assertEquals(21, f.number);
999                  assertEquals(34, g.number);
# Line 920 | Line 1009 | public class CountedCompleterTest extend
1009      public void testInvokeAll1() {
1010          ForkJoinTask a = new CheckedRecursiveAction() {
1011              protected void realCompute() {
1012 <                CCF f = new LCCF(null, 8);
1012 >                CCF f = new LCCF(8);
1013                  invokeAll(f);
1014                  checkCompletedNormally(f);
1015                  assertEquals(21, f.number);
# Line 934 | Line 1023 | public class CountedCompleterTest extend
1023      public void testInvokeAll3() {
1024          ForkJoinTask a = new CheckedRecursiveAction() {
1025              protected void realCompute() {
1026 <                CCF f = new LCCF(null, 8);
1027 <                CCF g = new LCCF(null, 9);
1028 <                CCF h = new LCCF(null, 7);
1026 >                CCF f = new LCCF(8);
1027 >                CCF g = new LCCF(9);
1028 >                CCF h = new LCCF(7);
1029                  invokeAll(f, g, h);
1030                  assertEquals(21, f.number);
1031                  assertEquals(34, g.number);
# Line 954 | Line 1043 | public class CountedCompleterTest extend
1043      public void testInvokeAllCollection() {
1044          ForkJoinTask a = new CheckedRecursiveAction() {
1045              protected void realCompute() {
1046 <                CCF f = new LCCF(null, 8);
1047 <                CCF g = new LCCF(null, 9);
1048 <                CCF h = new LCCF(null, 7);
1046 >                CCF f = new LCCF(8);
1047 >                CCF g = new LCCF(9);
1048 >                CCF h = new LCCF(7);
1049                  HashSet set = new HashSet();
1050                  set.add(f);
1051                  set.add(g);
# Line 978 | Line 1067 | public class CountedCompleterTest extend
1067      public void testInvokeAllNPE() {
1068          ForkJoinTask a = new CheckedRecursiveAction() {
1069              protected void realCompute() {
1070 <                CCF f = new LCCF(null, 8);
1071 <                CCF g = new LCCF(null, 9);
1070 >                CCF f = new LCCF(8);
1071 >                CCF g = new LCCF(9);
1072                  CCF h = null;
1073                  try {
1074                      invokeAll(f, g, h);
# Line 995 | Line 1084 | public class CountedCompleterTest extend
1084      public void testAbnormalInvokeAll2() {
1085          ForkJoinTask a = new CheckedRecursiveAction() {
1086              protected void realCompute() {
1087 <                CCF f = new LCCF(null, 8);
1088 <                FailingCCF g = new LFCCF(null, 9);
1087 >                CCF f = new LCCF(8);
1088 >                FailingCCF g = new LFCCF(9);
1089                  try {
1090                      invokeAll(f, g);
1091                      shouldThrow();
# Line 1013 | Line 1102 | public class CountedCompleterTest extend
1102      public void testAbnormalInvokeAll1() {
1103          ForkJoinTask a = new CheckedRecursiveAction() {
1104              protected void realCompute() {
1105 <                FailingCCF g = new LFCCF(null, 9);
1105 >                FailingCCF g = new LFCCF(9);
1106                  try {
1107                      invokeAll(g);
1108                      shouldThrow();
# Line 1030 | Line 1119 | public class CountedCompleterTest extend
1119      public void testAbnormalInvokeAll3() {
1120          ForkJoinTask a = new CheckedRecursiveAction() {
1121              protected void realCompute() {
1122 <                CCF f = new LCCF(null, 8);
1123 <                FailingCCF g = new LFCCF(null, 9);
1124 <                CCF h = new LCCF(null, 7);
1122 >                CCF f = new LCCF(8);
1123 >                FailingCCF g = new LFCCF(9);
1124 >                CCF h = new LCCF(7);
1125                  try {
1126                      invokeAll(f, g, h);
1127                      shouldThrow();
# Line 1044 | Line 1133 | public class CountedCompleterTest extend
1133      }
1134  
1135      /**
1136 <     * invokeAll(collection)  throws exception if any task does
1136 >     * invokeAll(collection) throws exception if any task does
1137       */
1138      public void testAbnormalInvokeAllCollection() {
1139          ForkJoinTask a = new CheckedRecursiveAction() {
1140              protected void realCompute() {
1141 <                FailingCCF f = new LFCCF(null, 8);
1142 <                CCF g = new LCCF(null, 9);
1143 <                CCF h = new LCCF(null, 7);
1141 >                FailingCCF f = new LFCCF(8);
1142 >                CCF g = new LCCF(9);
1143 >                CCF h = new LCCF(7);
1144                  HashSet set = new HashSet();
1145                  set.add(f);
1146                  set.add(g);
# Line 1073 | Line 1162 | public class CountedCompleterTest extend
1162      public void testTryUnfork() {
1163          ForkJoinTask a = new CheckedRecursiveAction() {
1164              protected void realCompute() {
1165 <                CCF g = new LCCF(null, 9);
1165 >                CCF g = new LCCF(9);
1166                  assertSame(g, g.fork());
1167 <                CCF f = new LCCF(null, 8);
1167 >                CCF f = new LCCF(8);
1168                  assertSame(f, f.fork());
1169                  assertTrue(f.tryUnfork());
1170                  helpQuiesce();
# Line 1092 | Line 1181 | public class CountedCompleterTest extend
1181      public void testGetSurplusQueuedTaskCount() {
1182          ForkJoinTask a = new CheckedRecursiveAction() {
1183              protected void realCompute() {
1184 <                CCF h = new LCCF(null, 7);
1184 >                CCF h = new LCCF(7);
1185                  assertSame(h, h.fork());
1186 <                CCF g = new LCCF(null, 9);
1186 >                CCF g = new LCCF(9);
1187                  assertSame(g, g.fork());
1188 <                CCF f = new LCCF(null, 8);
1188 >                CCF f = new LCCF(8);
1189                  assertSame(f, f.fork());
1190                  assertTrue(getSurplusQueuedTaskCount() > 0);
1191                  helpQuiesce();
# Line 1114 | Line 1203 | public class CountedCompleterTest extend
1203      public void testPeekNextLocalTask() {
1204          ForkJoinTask a = new CheckedRecursiveAction() {
1205              protected void realCompute() {
1206 <                CCF g = new LCCF(null, 9);
1206 >                CCF g = new LCCF(9);
1207                  assertSame(g, g.fork());
1208 <                CCF f = new LCCF(null, 8);
1208 >                CCF f = new LCCF(8);
1209                  assertSame(f, f.fork());
1210                  assertSame(f, peekNextLocalTask());
1211                  assertNull(f.join());
# Line 1134 | Line 1223 | public class CountedCompleterTest extend
1223      public void testPollNextLocalTask() {
1224          ForkJoinTask a = new CheckedRecursiveAction() {
1225              protected void realCompute() {
1226 <                CCF g = new LCCF(null, 9);
1226 >                CCF g = new LCCF(9);
1227                  assertSame(g, g.fork());
1228 <                CCF f = new LCCF(null, 8);
1228 >                CCF f = new LCCF(8);
1229                  assertSame(f, f.fork());
1230                  assertSame(f, pollNextLocalTask());
1231                  helpQuiesce();
# Line 1153 | Line 1242 | public class CountedCompleterTest extend
1242      public void testPollTask() {
1243          ForkJoinTask a = new CheckedRecursiveAction() {
1244              protected void realCompute() {
1245 <                CCF g = new LCCF(null, 9);
1245 >                CCF g = new LCCF(9);
1246                  assertSame(g, g.fork());
1247 <                CCF f = new LCCF(null, 8);
1247 >                CCF f = new LCCF(8);
1248                  assertSame(f, f.fork());
1249                  assertSame(f, pollTask());
1250                  helpQuiesce();
# Line 1171 | Line 1260 | public class CountedCompleterTest extend
1260      public void testPeekNextLocalTaskAsync() {
1261          ForkJoinTask a = new CheckedRecursiveAction() {
1262              protected void realCompute() {
1263 <                CCF g = new LCCF(null, 9);
1263 >                CCF g = new LCCF(9);
1264                  assertSame(g, g.fork());
1265 <                CCF f = new LCCF(null, 8);
1265 >                CCF f = new LCCF(8);
1266                  assertSame(f, f.fork());
1267                  assertSame(g, peekNextLocalTask());
1268                  assertNull(f.join());
# Line 1192 | Line 1281 | public class CountedCompleterTest extend
1281      public void testPollNextLocalTaskAsync() {
1282          ForkJoinTask a = new CheckedRecursiveAction() {
1283              protected void realCompute() {
1284 <                CCF g = new LCCF(null, 9);
1284 >                CCF g = new LCCF(9);
1285                  assertSame(g, g.fork());
1286 <                CCF f = new LCCF(null, 8);
1286 >                CCF f = new LCCF(8);
1287                  assertSame(f, f.fork());
1288                  assertSame(g, pollNextLocalTask());
1289                  helpQuiesce();
# Line 1212 | Line 1301 | public class CountedCompleterTest extend
1301      public void testPollTaskAsync() {
1302          ForkJoinTask a = new CheckedRecursiveAction() {
1303              protected void realCompute() {
1304 <                CCF g = new LCCF(null, 9);
1304 >                CCF g = new LCCF(9);
1305                  assertSame(g, g.fork());
1306 <                CCF f = new LCCF(null, 8);
1306 >                CCF f = new LCCF(8);
1307                  assertSame(f, f.fork());
1308                  assertSame(g, pollTask());
1309                  helpQuiesce();
# Line 1235 | Line 1324 | public class CountedCompleterTest extend
1324      public void testInvokeSingleton() {
1325          ForkJoinTask a = new CheckedRecursiveAction() {
1326              protected void realCompute() {
1327 <                CCF f = new LCCF(null, 8);
1327 >                CCF f = new LCCF(8);
1328                  assertNull(f.invoke());
1329                  assertEquals(21, f.number);
1330                  checkCompletedNormally(f);
# Line 1251 | Line 1340 | public class CountedCompleterTest extend
1340      public void testQuietlyInvokeSingleton() {
1341          ForkJoinTask a = new CheckedRecursiveAction() {
1342              protected void realCompute() {
1343 <                CCF f = new LCCF(null, 8);
1343 >                CCF f = new LCCF(8);
1344                  f.quietlyInvoke();
1345                  assertEquals(21, f.number);
1346                  checkCompletedNormally(f);
# Line 1265 | Line 1354 | public class CountedCompleterTest extend
1354      public void testForkJoinSingleton() {
1355          ForkJoinTask a = new CheckedRecursiveAction() {
1356              protected void realCompute() {
1357 <                CCF f = new LCCF(null, 8);
1357 >                CCF f = new LCCF(8);
1358                  assertSame(f, f.fork());
1359                  assertNull(f.join());
1360                  assertEquals(21, f.number);
# Line 1280 | Line 1369 | public class CountedCompleterTest extend
1369      public void testForkGetSingleton() {
1370          ForkJoinTask a = new CheckedRecursiveAction() {
1371              protected void realCompute() throws Exception {
1372 <                CCF f = new LCCF(null, 8);
1372 >                CCF f = new LCCF(8);
1373                  assertSame(f, f.fork());
1374                  assertNull(f.get());
1375                  assertEquals(21, f.number);
# Line 1295 | Line 1384 | public class CountedCompleterTest extend
1384      public void testForkTimedGetSingleton() {
1385          ForkJoinTask a = new CheckedRecursiveAction() {
1386              protected void realCompute() throws Exception {
1387 <                CCF f = new LCCF(null, 8);
1387 >                CCF f = new LCCF(8);
1388                  assertSame(f, f.fork());
1389                  assertNull(f.get(LONG_DELAY_MS, MILLISECONDS));
1390                  assertEquals(21, f.number);
# Line 1310 | Line 1399 | public class CountedCompleterTest extend
1399      public void testForkTimedGetNPESingleton() {
1400          ForkJoinTask a = new CheckedRecursiveAction() {
1401              protected void realCompute() throws Exception {
1402 <                CCF f = new LCCF(null, 8);
1402 >                CCF f = new LCCF(8);
1403                  assertSame(f, f.fork());
1404                  try {
1405                      f.get(5L, null);
# Line 1326 | Line 1415 | public class CountedCompleterTest extend
1415      public void testForkQuietlyJoinSingleton() {
1416          ForkJoinTask a = new CheckedRecursiveAction() {
1417              protected void realCompute() {
1418 <                CCF f = new LCCF(null, 8);
1418 >                CCF f = new LCCF(8);
1419                  assertSame(f, f.fork());
1420                  f.quietlyJoin();
1421                  assertEquals(21, f.number);
# Line 1342 | Line 1431 | public class CountedCompleterTest extend
1431      public void testForkHelpQuiesceSingleton() {
1432          ForkJoinTask a = new CheckedRecursiveAction() {
1433              protected void realCompute() {
1434 <                CCF f = new LCCF(null, 8);
1434 >                CCF f = new LCCF(8);
1435                  assertSame(f, f.fork());
1436                  helpQuiesce();
1437                  assertEquals(0, getQueuedTaskCount());
# Line 1358 | Line 1447 | public class CountedCompleterTest extend
1447      public void testAbnormalInvokeSingleton() {
1448          ForkJoinTask a = new CheckedRecursiveAction() {
1449              protected void realCompute() {
1450 <                FailingCCF f = new LFCCF(null, 8);
1450 >                FailingCCF f = new LFCCF(8);
1451                  try {
1452                      f.invoke();
1453                      shouldThrow();
# Line 1375 | Line 1464 | public class CountedCompleterTest extend
1464      public void testAbnormalQuietlyInvokeSingleton() {
1465          ForkJoinTask a = new CheckedRecursiveAction() {
1466              protected void realCompute() {
1467 <                FailingCCF f = new LFCCF(null, 8);
1467 >                FailingCCF f = new LFCCF(8);
1468                  f.quietlyInvoke();
1469                  assertTrue(f.getException() instanceof FJException);
1470                  checkCompletedAbnormally(f, f.getException());
# Line 1389 | Line 1478 | public class CountedCompleterTest extend
1478      public void testAbnormalForkJoinSingleton() {
1479          ForkJoinTask a = new CheckedRecursiveAction() {
1480              protected void realCompute() {
1481 <                FailingCCF f = new LFCCF(null, 8);
1481 >                FailingCCF f = new LFCCF(8);
1482                  assertSame(f, f.fork());
1483                  try {
1484                      f.join();
# Line 1407 | Line 1496 | public class CountedCompleterTest extend
1496      public void testAbnormalForkGetSingleton() {
1497          ForkJoinTask a = new CheckedRecursiveAction() {
1498              protected void realCompute() throws Exception {
1499 <                FailingCCF f = new LFCCF(null, 8);
1499 >                FailingCCF f = new LFCCF(8);
1500                  assertSame(f, f.fork());
1501                  try {
1502                      f.get();
# Line 1427 | Line 1516 | public class CountedCompleterTest extend
1516      public void testAbnormalForkTimedGetSingleton() {
1517          ForkJoinTask a = new CheckedRecursiveAction() {
1518              protected void realCompute() throws Exception {
1519 <                FailingCCF f = new LFCCF(null, 8);
1519 >                FailingCCF f = new LFCCF(8);
1520                  assertSame(f, f.fork());
1521                  try {
1522                      f.get(LONG_DELAY_MS, MILLISECONDS);
# Line 1447 | Line 1536 | public class CountedCompleterTest extend
1536      public void testAbnormalForkQuietlyJoinSingleton() {
1537          ForkJoinTask a = new CheckedRecursiveAction() {
1538              protected void realCompute() {
1539 <                FailingCCF f = new LFCCF(null, 8);
1539 >                FailingCCF f = new LFCCF(8);
1540                  assertSame(f, f.fork());
1541                  f.quietlyJoin();
1542                  assertTrue(f.getException() instanceof FJException);
# Line 1462 | Line 1551 | public class CountedCompleterTest extend
1551      public void testCancelledInvokeSingleton() {
1552          ForkJoinTask a = new CheckedRecursiveAction() {
1553              protected void realCompute() {
1554 <                CCF f = new LCCF(null, 8);
1554 >                CCF f = new LCCF(8);
1555                  assertTrue(f.cancel(true));
1556                  try {
1557                      f.invoke();
# Line 1480 | Line 1569 | public class CountedCompleterTest extend
1569      public void testCancelledForkJoinSingleton() {
1570          ForkJoinTask a = new CheckedRecursiveAction() {
1571              protected void realCompute() {
1572 <                CCF f = new LCCF(null, 8);
1572 >                CCF f = new LCCF(8);
1573                  assertTrue(f.cancel(true));
1574                  assertSame(f, f.fork());
1575                  try {
# Line 1499 | Line 1588 | public class CountedCompleterTest extend
1588      public void testCancelledForkGetSingleton() {
1589          ForkJoinTask a = new CheckedRecursiveAction() {
1590              protected void realCompute() throws Exception {
1591 <                CCF f = new LCCF(null, 8);
1591 >                CCF f = new LCCF(8);
1592                  assertTrue(f.cancel(true));
1593                  assertSame(f, f.fork());
1594                  try {
# Line 1518 | Line 1607 | public class CountedCompleterTest extend
1607      public void testCancelledForkTimedGetSingleton() throws Exception {
1608          ForkJoinTask a = new CheckedRecursiveAction() {
1609              protected void realCompute() throws Exception {
1610 <                CCF f = new LCCF(null, 8);
1610 >                CCF f = new LCCF(8);
1611                  assertTrue(f.cancel(true));
1612                  assertSame(f, f.fork());
1613                  try {
# Line 1537 | Line 1626 | public class CountedCompleterTest extend
1626      public void testCancelledForkQuietlyJoinSingleton() {
1627          ForkJoinTask a = new CheckedRecursiveAction() {
1628              protected void realCompute() {
1629 <                CCF f = new LCCF(null, 8);
1629 >                CCF f = new LCCF(8);
1630                  assertTrue(f.cancel(true));
1631                  assertSame(f, f.fork());
1632                  f.quietlyJoin();
# Line 1552 | Line 1641 | public class CountedCompleterTest extend
1641      public void testCompleteExceptionallySingleton() {
1642          ForkJoinTask a = new CheckedRecursiveAction() {
1643              protected void realCompute() {
1644 <                CCF f = new LCCF(null, 8);
1645 <                f.completeExceptionally(new FJException());
1646 <                try {
1647 <                    f.invoke();
1648 <                    shouldThrow();
1649 <                } catch (FJException success) {
1561 <                    checkCompletedAbnormally(f, success);
1562 <                }
1644 >                CCF n = new LCCF(8);
1645 >                CCF f = new LCCF(n, 8);
1646 >                FJException ex = new FJException();
1647 >                f.completeExceptionally(ex);
1648 >                f.checkCompletedExceptionally(ex);
1649 >                n.checkCompletedExceptionally(ex);
1650              }};
1651          testInvokeOnPool(singletonPool(), a);
1652      }
# Line 1570 | Line 1657 | public class CountedCompleterTest extend
1657      public void testInvokeAll2Singleton() {
1658          ForkJoinTask a = new CheckedRecursiveAction() {
1659              protected void realCompute() {
1660 <                CCF f = new LCCF(null, 8);
1661 <                CCF g = new LCCF(null, 9);
1660 >                CCF f = new LCCF(8);
1661 >                CCF g = new LCCF(9);
1662                  invokeAll(f, g);
1663                  assertEquals(21, f.number);
1664                  assertEquals(34, g.number);
# Line 1587 | Line 1674 | public class CountedCompleterTest extend
1674      public void testInvokeAll1Singleton() {
1675          ForkJoinTask a = new CheckedRecursiveAction() {
1676              protected void realCompute() {
1677 <                CCF f = new LCCF(null, 8);
1677 >                CCF f = new LCCF(8);
1678                  invokeAll(f);
1679                  checkCompletedNormally(f);
1680                  assertEquals(21, f.number);
# Line 1601 | Line 1688 | public class CountedCompleterTest extend
1688      public void testInvokeAll3Singleton() {
1689          ForkJoinTask a = new CheckedRecursiveAction() {
1690              protected void realCompute() {
1691 <                CCF f = new LCCF(null, 8);
1692 <                CCF g = new LCCF(null, 9);
1693 <                CCF h = new LCCF(null, 7);
1691 >                CCF f = new LCCF(8);
1692 >                CCF g = new LCCF(9);
1693 >                CCF h = new LCCF(7);
1694                  invokeAll(f, g, h);
1695                  assertEquals(21, f.number);
1696                  assertEquals(34, g.number);
# Line 1621 | Line 1708 | public class CountedCompleterTest extend
1708      public void testInvokeAllCollectionSingleton() {
1709          ForkJoinTask a = new CheckedRecursiveAction() {
1710              protected void realCompute() {
1711 <                CCF f = new LCCF(null, 8);
1712 <                CCF g = new LCCF(null, 9);
1713 <                CCF h = new LCCF(null, 7);
1711 >                CCF f = new LCCF(8);
1712 >                CCF g = new LCCF(9);
1713 >                CCF h = new LCCF(7);
1714                  HashSet set = new HashSet();
1715                  set.add(f);
1716                  set.add(g);
# Line 1645 | Line 1732 | public class CountedCompleterTest extend
1732      public void testInvokeAllNPESingleton() {
1733          ForkJoinTask a = new CheckedRecursiveAction() {
1734              protected void realCompute() {
1735 <                CCF f = new LCCF(null, 8);
1736 <                CCF g = new LCCF(null, 9);
1735 >                CCF f = new LCCF(8);
1736 >                CCF g = new LCCF(9);
1737                  CCF h = null;
1738                  try {
1739                      invokeAll(f, g, h);
# Line 1662 | Line 1749 | public class CountedCompleterTest extend
1749      public void testAbnormalInvokeAll2Singleton() {
1750          ForkJoinTask a = new CheckedRecursiveAction() {
1751              protected void realCompute() {
1752 <                CCF f = new LCCF(null, 8);
1753 <                FailingCCF g = new LFCCF(null, 9);
1752 >                CCF f = new LCCF(8);
1753 >                FailingCCF g = new LFCCF(9);
1754                  try {
1755                      invokeAll(f, g);
1756                      shouldThrow();
# Line 1680 | Line 1767 | public class CountedCompleterTest extend
1767      public void testAbnormalInvokeAll1Singleton() {
1768          ForkJoinTask a = new CheckedRecursiveAction() {
1769              protected void realCompute() {
1770 <                FailingCCF g = new LFCCF(null, 9);
1770 >                FailingCCF g = new LFCCF(9);
1771                  try {
1772                      invokeAll(g);
1773                      shouldThrow();
# Line 1697 | Line 1784 | public class CountedCompleterTest extend
1784      public void testAbnormalInvokeAll3Singleton() {
1785          ForkJoinTask a = new CheckedRecursiveAction() {
1786              protected void realCompute() {
1787 <                CCF f = new LCCF(null, 8);
1788 <                FailingCCF g = new LFCCF(null, 9);
1789 <                CCF h = new LCCF(null, 7);
1787 >                CCF f = new LCCF(8);
1788 >                FailingCCF g = new LFCCF(9);
1789 >                CCF h = new LCCF(7);
1790                  try {
1791                      invokeAll(f, g, h);
1792                      shouldThrow();
# Line 1711 | Line 1798 | public class CountedCompleterTest extend
1798      }
1799  
1800      /**
1801 <     * invokeAll(collection)  throws exception if any task does
1801 >     * invokeAll(collection) throws exception if any task does
1802       */
1803      public void testAbnormalInvokeAllCollectionSingleton() {
1804          ForkJoinTask a = new CheckedRecursiveAction() {
1805              protected void realCompute() {
1806 <                FailingCCF f = new LFCCF(null, 8);
1807 <                CCF g = new LCCF(null, 9);
1808 <                CCF h = new LCCF(null, 7);
1806 >                FailingCCF f = new LFCCF(8);
1807 >                CCF g = new LCCF(9);
1808 >                CCF h = new LCCF(7);
1809                  HashSet set = new HashSet();
1810                  set.add(f);
1811                  set.add(g);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines