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.19 by jsr166, Sun Oct 4 18:40:57 2015 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 >
7 > import static java.util.concurrent.TimeUnit.MILLISECONDS;
8 > import static java.util.concurrent.TimeUnit.SECONDS;
9 >
10 > import java.util.HashSet;
11   import java.util.concurrent.CancellationException;
12 + import java.util.concurrent.CountedCompleter;
13 + import java.util.concurrent.ExecutionException;
14   import java.util.concurrent.ForkJoinPool;
15   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;
16   import java.util.concurrent.TimeoutException;
17 < import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
18 < import static java.util.concurrent.TimeUnit.MILLISECONDS;
19 < import static java.util.concurrent.TimeUnit.SECONDS;
20 < import java.util.HashSet;
21 < import junit.framework.*;
17 > import java.util.concurrent.atomic.AtomicInteger;
18 > import java.util.concurrent.atomic.AtomicReference;
19 >
20 > import junit.framework.Test;
21 > import junit.framework.TestSuite;
22  
23   public class CountedCompleterTest extends JSR166TestCase {
24  
25      public static void main(String[] args) {
26 <        junit.textui.TestRunner.run(suite());
26 >        main(suite(), args);
27      }
28  
29      public static Test suite() {
# Line 47 | Line 49 | public class CountedCompleterTest extend
49      }
50  
51      private void testInvokeOnPool(ForkJoinPool pool, ForkJoinTask a) {
52 <        try {
52 >        try (PoolCleaner cleaner = cleaner(pool)) {
53              assertFalse(a.isDone());
54              assertFalse(a.isCompletedNormally());
55              assertFalse(a.isCompletedAbnormally());
# Line 63 | Line 65 | public class CountedCompleterTest extend
65              assertFalse(a.isCancelled());
66              assertNull(a.getException());
67              assertNull(a.getRawResult());
66        } finally {
67            joinPool(pool);
68          }
69      }
70  
# Line 83 | Line 83 | public class CountedCompleterTest extend
83          } catch (Throwable fail) { threadUnexpectedException(fail); }
84      }
85  
86 <    <T> void checkCompletedNormally(CountedCompleter<T> a) {
87 <        checkCompletedNormally(a, null);
88 <    }
89 <
90 <    <T> void checkCompletedNormally(CountedCompleter<T> a, T expected) {
86 >    void checkCompletedNormally(CountedCompleter<?> a) {
87          assertTrue(a.isDone());
88          assertFalse(a.isCancelled());
89          assertTrue(a.isCompletedNormally());
90          assertFalse(a.isCompletedAbnormally());
91          assertNull(a.getException());
92 <        assertSame(expected, a.getRawResult());
92 >        assertNull(a.getRawResult());
93  
94          {
95              Thread.currentThread().interrupt();
96              long t0 = System.nanoTime();
97 <            assertSame(expected, a.join());
97 >            assertNull(a.join());
98              assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
99              Thread.interrupted();
100          }
# Line 114 | Line 110 | public class CountedCompleterTest extend
110          assertFalse(a.cancel(false));
111          assertFalse(a.cancel(true));
112          try {
113 <            assertSame(expected, a.get());
113 >            assertNull(a.get());
114          } catch (Throwable fail) { threadUnexpectedException(fail); }
115          try {
116 <            assertSame(expected, a.get(5L, SECONDS));
116 >            assertNull(a.get(5L, SECONDS));
117          } catch (Throwable fail) { threadUnexpectedException(fail); }
118      }
119  
# Line 196 | Line 192 | public class CountedCompleterTest extend
192          } catch (ExecutionException success) {
193              assertSame(t.getClass(), success.getCause().getClass());
194          } catch (Throwable fail) { threadUnexpectedException(fail); }
195 +
196 +        try {
197 +            a.invoke();
198 +            shouldThrow();
199 +        } catch (Throwable success) {
200 +            assertSame(t, success);
201 +        }
202      }
203  
204      public static final class FJException extends RuntimeException {
205          FJException() { super(); }
206      }
207  
208 <    static final class NoopCountedCompleter extends CountedCompleter {
209 <        boolean post; // set true if onCompletion called
210 <        NoopCountedCompleter() { super(); }
211 <        NoopCountedCompleter(CountedCompleter p) { super(p); }
212 <        public void compute() {}
213 <        public final void onCompletion(CountedCompleter caller) {
214 <            post = true;
208 >    abstract class CheckedCC extends CountedCompleter<Object> {
209 >        final AtomicInteger computeN = new AtomicInteger(0);
210 >        final AtomicInteger onCompletionN = new AtomicInteger(0);
211 >        final AtomicInteger onExceptionalCompletionN = new AtomicInteger(0);
212 >        final AtomicInteger setRawResultN = new AtomicInteger(0);
213 >        final AtomicReference<Object> rawResult = new AtomicReference<Object>(null);
214 >        int computeN() { return computeN.get(); }
215 >        int onCompletionN() { return onCompletionN.get(); }
216 >        int onExceptionalCompletionN() { return onExceptionalCompletionN.get(); }
217 >        int setRawResultN() { return setRawResultN.get(); }
218 >
219 >        CheckedCC() { super(); }
220 >        CheckedCC(CountedCompleter p) { super(p); }
221 >        CheckedCC(CountedCompleter p, int n) { super(p, n); }
222 >        abstract void realCompute();
223 >        public final void compute() {
224 >            computeN.incrementAndGet();
225 >            realCompute();
226 >        }
227 >        public void onCompletion(CountedCompleter caller) {
228 >            onCompletionN.incrementAndGet();
229 >            super.onCompletion(caller);
230 >        }
231 >        public boolean onExceptionalCompletion(Throwable ex,
232 >                                               CountedCompleter caller) {
233 >            onExceptionalCompletionN.incrementAndGet();
234 >            assertNotNull(ex);
235 >            assertTrue(isCompletedAbnormally());
236 >            assertTrue(super.onExceptionalCompletion(ex, caller));
237 >            return true;
238 >        }
239 >        protected void setRawResult(Object t) {
240 >            setRawResultN.incrementAndGet();
241 >            rawResult.set(t);
242 >            super.setRawResult(t);
243 >        }
244 >        void checkIncomplete() {
245 >            assertEquals(0, computeN());
246 >            assertEquals(0, onCompletionN());
247 >            assertEquals(0, onExceptionalCompletionN());
248 >            assertEquals(0, setRawResultN());
249 >            checkNotDone(this);
250 >        }
251 >        void checkCompletes(Object rawResult) {
252 >            checkIncomplete();
253 >            int pendingCount = getPendingCount();
254 >            complete(rawResult);
255 >            assertEquals(pendingCount, getPendingCount());
256 >            assertEquals(0, computeN());
257 >            assertEquals(1, onCompletionN());
258 >            assertEquals(0, onExceptionalCompletionN());
259 >            assertEquals(1, setRawResultN());
260 >            assertSame(rawResult, this.rawResult.get());
261 >            checkCompletedNormally(this);
262 >        }
263 >        void checkCompletesExceptionally(Throwable ex) {
264 >            checkIncomplete();
265 >            completeExceptionally(ex);
266 >            checkCompletedExceptionally(ex);
267 >        }
268 >        void checkCompletedExceptionally(Throwable ex) {
269 >            assertEquals(0, computeN());
270 >            assertEquals(0, onCompletionN());
271 >            assertEquals(1, onExceptionalCompletionN());
272 >            assertEquals(0, setRawResultN());
273 >            assertNull(this.rawResult.get());
274 >            checkCompletedAbnormally(this, ex);
275          }
276      }
277  
278 +    final class NoopCC extends CheckedCC {
279 +        NoopCC() { super(); }
280 +        NoopCC(CountedCompleter p) { super(p); }
281 +        protected void realCompute() {}
282 +    }
283 +
284      /**
285       * A newly constructed CountedCompleter is not completed;
286 <     * complete() causes completion.
286 >     * complete() causes completion. pendingCount is ignored.
287       */
288      public void testComplete() {
289 <        NoopCountedCompleter a = new NoopCountedCompleter();
290 <        assertFalse(a.isDone());
291 <        assertFalse(a.isCompletedNormally());
292 <        assertFalse(a.isCompletedAbnormally());
293 <        assertFalse(a.isCancelled());
294 <        assertNull(a.getException());
295 <        assertNull(a.getRawResult());
296 <        assertFalse(a.post);
297 <        a.complete(null);
298 <        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());
289 >        for (Object x : new Object[] { Boolean.TRUE, null }) {
290 >            for (int pendingCount : new int[] { 0, 42 }) {
291 >                testComplete(new NoopCC(), x, pendingCount);
292 >                testComplete(new NoopCC(new NoopCC()), x, pendingCount);
293 >            }
294 >        }
295 >    }
296 >    void testComplete(NoopCC cc, Object x, int pendingCount) {
297 >        cc.setPendingCount(pendingCount);
298 >        cc.checkCompletes(x);
299      }
300  
301      /**
302       * completeExceptionally completes exceptionally
303       */
304      public void testCompleteExceptionally() {
305 <        NoopCountedCompleter a = new NoopCountedCompleter();
306 <        assertFalse(a.isDone());
307 <        assertFalse(a.isCompletedNormally());
308 <        assertFalse(a.isCompletedAbnormally());
309 <        assertFalse(a.isCancelled());
310 <        assertNull(a.getException());
311 <        assertNull(a.getRawResult());
312 <        assertFalse(a.post);
313 <        a.completeExceptionally(new FJException());
314 <        assertFalse(a.post);
315 <        assertTrue(a.isDone());
316 <        assertFalse(a.isCompletedNormally());
317 <        assertTrue(a.isCompletedAbnormally());
318 <        assertFalse(a.isCancelled());
319 <        assertTrue(a.getException() instanceof FJException);
257 <        assertNull(a.getRawResult());
305 >        new NoopCC()
306 >            .checkCompletesExceptionally(new FJException());
307 >        new NoopCC(new NoopCC())
308 >            .checkCompletesExceptionally(new FJException());
309 >    }
310 >
311 >    /**
312 >     * completeExceptionally(null) throws NullPointerException
313 >     */
314 >    public void testCompleteExceptionally_null() {
315 >        try {
316 >            new NoopCC()
317 >                .checkCompletesExceptionally(null);
318 >            shouldThrow();
319 >        } catch (NullPointerException success) {}
320      }
321  
322      /**
323       * setPendingCount sets the reported pending count
324       */
325      public void testSetPendingCount() {
326 <        NoopCountedCompleter a = new NoopCountedCompleter();
326 >        NoopCC a = new NoopCC();
327          assertEquals(0, a.getPendingCount());
328          a.setPendingCount(1);
329          assertEquals(1, a.getPendingCount());
# Line 273 | Line 335 | public class CountedCompleterTest extend
335       * addToPendingCount adds to the reported pending count
336       */
337      public void testAddToPendingCount() {
338 <        NoopCountedCompleter a = new NoopCountedCompleter();
338 >        NoopCC a = new NoopCC();
339          assertEquals(0, a.getPendingCount());
340          a.addToPendingCount(1);
341          assertEquals(1, a.getPendingCount());
# Line 286 | Line 348 | public class CountedCompleterTest extend
348       * count unless zero
349       */
350      public void testDecrementPendingCount() {
351 <        NoopCountedCompleter a = new NoopCountedCompleter();
351 >        NoopCC a = new NoopCC();
352          assertEquals(0, a.getPendingCount());
353          a.addToPendingCount(1);
354          assertEquals(1, a.getPendingCount());
# Line 297 | Line 359 | public class CountedCompleterTest extend
359      }
360  
361      /**
362 +     * compareAndSetPendingCount compares and sets the reported
363 +     * pending count
364 +     */
365 +    public void testCompareAndSetPendingCount() {
366 +        NoopCC a = new NoopCC();
367 +        assertEquals(0, a.getPendingCount());
368 +        assertTrue(a.compareAndSetPendingCount(0, 1));
369 +        assertEquals(1, a.getPendingCount());
370 +        assertTrue(a.compareAndSetPendingCount(1, 2));
371 +        assertEquals(2, a.getPendingCount());
372 +        assertFalse(a.compareAndSetPendingCount(1, 3));
373 +        assertEquals(2, a.getPendingCount());
374 +    }
375 +
376 +    /**
377       * getCompleter returns parent or null if at root
378       */
379      public void testGetCompleter() {
380 <        NoopCountedCompleter a = new NoopCountedCompleter();
380 >        NoopCC a = new NoopCC();
381          assertNull(a.getCompleter());
382 <        CountedCompleter b = new NoopCountedCompleter(a);
383 <        assertEquals(a, b.getCompleter());
382 >        CountedCompleter b = new NoopCC(a);
383 >        assertSame(a, b.getCompleter());
384 >        CountedCompleter c = new NoopCC(b);
385 >        assertSame(b, c.getCompleter());
386      }
387  
388      /**
389       * getRoot returns self if no parent, else parent's root
390       */
391      public void testGetRoot() {
392 <        NoopCountedCompleter a = new NoopCountedCompleter();
393 <        NoopCountedCompleter b = new NoopCountedCompleter(a);
394 <        assertEquals(a, a.getRoot());
395 <        assertEquals(a, b.getRoot());
392 >        NoopCC a = new NoopCC();
393 >        NoopCC b = new NoopCC(a);
394 >        NoopCC c = new NoopCC(b);
395 >        assertSame(a, a.getRoot());
396 >        assertSame(a, b.getRoot());
397 >        assertSame(a, c.getRoot());
398      }
399  
400      /**
401 <     * tryComplete causes completion if pending count is zero
401 >     * tryComplete decrements pending count unless zero, in which case
402 >     * causes completion
403       */
404 <    public void testTryComplete1() {
405 <        NoopCountedCompleter a = new NoopCountedCompleter();
404 >    public void testTryComplete() {
405 >        NoopCC a = new NoopCC();
406          assertEquals(0, a.getPendingCount());
407 +        int n = 3;
408 +        a.setPendingCount(n);
409 +        for (; n > 0; n--) {
410 +            assertEquals(n, a.getPendingCount());
411 +            a.tryComplete();
412 +            a.checkIncomplete();
413 +            assertEquals(n - 1, a.getPendingCount());
414 +        }
415          a.tryComplete();
416 <        assertTrue(a.post);
417 <        assertTrue(a.isDone());
416 >        assertEquals(0, a.computeN());
417 >        assertEquals(1, a.onCompletionN());
418 >        assertEquals(0, a.onExceptionalCompletionN());
419 >        assertEquals(0, a.setRawResultN());
420 >        checkCompletedNormally(a);
421      }
422  
423      /**
424 <     * propagateCompletion causes completion without invoking
425 <     * onCompletion if pending count is zero
424 >     * propagateCompletion decrements pending count unless zero, in
425 >     * which case causes completion, without invoking onCompletion
426       */
427      public void testPropagateCompletion() {
428 <        NoopCountedCompleter a = new NoopCountedCompleter();
428 >        NoopCC a = new NoopCC();
429          assertEquals(0, a.getPendingCount());
430 +        int n = 3;
431 +        a.setPendingCount(n);
432 +        for (; n > 0; n--) {
433 +            assertEquals(n, a.getPendingCount());
434 +            a.propagateCompletion();
435 +            a.checkIncomplete();
436 +            assertEquals(n - 1, a.getPendingCount());
437 +        }
438          a.propagateCompletion();
439 <        assertFalse(a.post);
440 <        assertTrue(a.isDone());
441 <    }
442 <
443 <    /**
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());
439 >        assertEquals(0, a.computeN());
440 >        assertEquals(0, a.onCompletionN());
441 >        assertEquals(0, a.onExceptionalCompletionN());
442 >        assertEquals(0, a.setRawResultN());
443 >        checkCompletedNormally(a);
444      }
445  
446      /**
447       * firstComplete returns this if pending count is zero else null
448       */
449      public void testFirstComplete() {
450 <        NoopCountedCompleter a = new NoopCountedCompleter();
450 >        NoopCC a = new NoopCC();
451          a.setPendingCount(1);
452          assertNull(a.firstComplete());
453 <        assertEquals(a, a.firstComplete());
453 >        a.checkIncomplete();
454 >        assertSame(a, a.firstComplete());
455 >        a.checkIncomplete();
456      }
457  
458      /**
# Line 370 | Line 460 | public class CountedCompleterTest extend
460       * zero else null
461       */
462      public void testNextComplete() {
463 <        NoopCountedCompleter a = new NoopCountedCompleter();
464 <        NoopCountedCompleter b = new NoopCountedCompleter(a);
463 >        NoopCC a = new NoopCC();
464 >        NoopCC b = new NoopCC(a);
465          a.setPendingCount(1);
466          b.setPendingCount(1);
467          assertNull(b.firstComplete());
468 <        CountedCompleter c = b.firstComplete();
469 <        assertEquals(b, c);
470 <        CountedCompleter d = c.nextComplete();
471 <        assertNull(d);
472 <        CountedCompleter e = c.nextComplete();
473 <        assertEquals(a, e);
468 >        assertSame(b, b.firstComplete());
469 >        assertNull(b.nextComplete());
470 >        a.checkIncomplete();
471 >        b.checkIncomplete();
472 >        assertSame(a, b.nextComplete());
473 >        assertSame(a, b.nextComplete());
474 >        a.checkIncomplete();
475 >        b.checkIncomplete();
476 >        assertNull(a.nextComplete());
477 >        b.checkIncomplete();
478 >        checkCompletedNormally(a);
479      }
480  
481      /**
482       * quietlyCompleteRoot completes root task
483       */
484      public void testQuietlyCompleteRoot() {
485 <        NoopCountedCompleter a = new NoopCountedCompleter();
486 <        NoopCountedCompleter b = new NoopCountedCompleter(a);
485 >        NoopCC a = new NoopCC();
486 >        NoopCC b = new NoopCC(a);
487 >        NoopCC c = new NoopCC(b);
488          a.setPendingCount(1);
489          b.setPendingCount(1);
490 <        b.quietlyCompleteRoot();
490 >        c.setPendingCount(1);
491 >        c.quietlyCompleteRoot();
492          assertTrue(a.isDone());
493          assertFalse(b.isDone());
494 +        assertFalse(c.isDone());
495      }
496  
497      // Invocation tests use some interdependent task classes
498      // to better test propagation etc
499  
500 <
501 <    // Version of Fibonacci with different classes for left vs right forks
502 <    abstract static class CCF extends CountedCompleter {
500 >    /**
501 >     * Version of Fibonacci with different classes for left vs right forks
502 >     */
503 >    abstract class CCF extends CheckedCC {
504          int number;
505          int rnumber;
506  
# Line 410 | Line 509 | public class CountedCompleterTest extend
509              this.number = n;
510          }
511  
512 <        public final void compute() {
414 <            CountedCompleter p;
512 >        protected final void realCompute() {
513              CCF f = this;
514              int n = number;
515              while (n >= 2) {
516                  new RCCF(f, n - 2).fork();
517                  f = new LCCF(f, --n);
518              }
519 <            f.number = n;
422 <            f.onCompletion(f);
423 <            if ((p = f.getCompleter()) != null)
424 <                p.tryComplete();
425 <            else
426 <                f.quietlyComplete();
519 >            f.complete(null);
520          }
521      }
522  
523 <    static final class LCCF extends CCF {
523 >    final class LCCF extends CCF {
524 >        public LCCF(int n) { this(null, n); }
525          public LCCF(CountedCompleter parent, int n) {
526              super(parent, n);
527          }
528          public final void onCompletion(CountedCompleter caller) {
529 +            super.onCompletion(caller);
530              CCF p = (CCF)getCompleter();
531              int n = number + rnumber;
532              if (p != null)
# Line 440 | Line 535 | public class CountedCompleterTest extend
535                  number = n;
536          }
537      }
538 <    static final class RCCF extends CCF {
538 >    final class RCCF extends CCF {
539          public RCCF(CountedCompleter parent, int n) {
540              super(parent, n);
541          }
542          public final void onCompletion(CountedCompleter caller) {
543 +            super.onCompletion(caller);
544              CCF p = (CCF)getCompleter();
545              int n = number + rnumber;
546              if (p != null)
# Line 455 | Line 551 | public class CountedCompleterTest extend
551      }
552  
553      // Version of CCF with forced failure in left completions
554 <    abstract static class FailingCCF extends CountedCompleter {
554 >    abstract class FailingCCF extends CheckedCC {
555          int number;
556          int rnumber;
557  
# Line 464 | Line 560 | public class CountedCompleterTest extend
560              this.number = n;
561          }
562  
563 <        public final void compute() {
468 <            CountedCompleter p;
563 >        protected final void realCompute() {
564              FailingCCF f = this;
565              int n = number;
566              while (n >= 2) {
567                  new RFCCF(f, n - 2).fork();
568                  f = new LFCCF(f, --n);
569              }
570 <            f.number = n;
476 <            f.onCompletion(f);
477 <            if ((p = f.getCompleter()) != null)
478 <                p.tryComplete();
479 <            else
480 <                f.quietlyComplete();
570 >            f.complete(null);
571          }
572      }
573  
574 <    static final class LFCCF extends FailingCCF {
574 >    final class LFCCF extends FailingCCF {
575 >        public LFCCF(int n) { this(null, n); }
576          public LFCCF(CountedCompleter parent, int n) {
577              super(parent, n);
578          }
579          public final void onCompletion(CountedCompleter caller) {
580 +            super.onCompletion(caller);
581              FailingCCF p = (FailingCCF)getCompleter();
582              int n = number + rnumber;
583              if (p != null)
# Line 494 | Line 586 | public class CountedCompleterTest extend
586                  number = n;
587          }
588      }
589 <    static final class RFCCF extends FailingCCF {
589 >    final class RFCCF extends FailingCCF {
590          public RFCCF(CountedCompleter parent, int n) {
591              super(parent, n);
592          }
593          public final void onCompletion(CountedCompleter caller) {
594 +            super.onCompletion(caller);
595              completeExceptionally(new FJException());
596          }
597      }
# Line 511 | Line 604 | public class CountedCompleterTest extend
604      public void testInvoke() {
605          ForkJoinTask a = new CheckedRecursiveAction() {
606              protected void realCompute() {
607 <                CCF f = new LCCF(null, 8);
607 >                CCF f = new LCCF(8);
608                  assertNull(f.invoke());
609                  assertEquals(21, f.number);
610                  checkCompletedNormally(f);
# Line 527 | Line 620 | public class CountedCompleterTest extend
620      public void testQuietlyInvoke() {
621          ForkJoinTask a = new CheckedRecursiveAction() {
622              protected void realCompute() {
623 <                CCF f = new LCCF(null, 8);
623 >                CCF f = new LCCF(8);
624                  f.quietlyInvoke();
625                  assertEquals(21, f.number);
626                  checkCompletedNormally(f);
# Line 541 | Line 634 | public class CountedCompleterTest extend
634      public void testForkJoin() {
635          ForkJoinTask a = new CheckedRecursiveAction() {
636              protected void realCompute() {
637 <                CCF f = new LCCF(null, 8);
637 >                CCF f = new LCCF(8);
638                  assertSame(f, f.fork());
639                  assertNull(f.join());
640                  assertEquals(21, f.number);
# Line 556 | Line 649 | public class CountedCompleterTest extend
649      public void testForkGet() {
650          ForkJoinTask a = new CheckedRecursiveAction() {
651              protected void realCompute() throws Exception {
652 <                CCF f = new LCCF(null, 8);
652 >                CCF f = new LCCF(8);
653                  assertSame(f, f.fork());
654                  assertNull(f.get());
655                  assertEquals(21, f.number);
# Line 571 | Line 664 | public class CountedCompleterTest extend
664      public void testForkTimedGet() {
665          ForkJoinTask a = new CheckedRecursiveAction() {
666              protected void realCompute() throws Exception {
667 <                CCF f = new LCCF(null, 8);
667 >                CCF f = new LCCF(8);
668                  assertSame(f, f.fork());
669                  assertNull(f.get(LONG_DELAY_MS, MILLISECONDS));
670                  assertEquals(21, f.number);
# Line 586 | Line 679 | public class CountedCompleterTest extend
679      public void testForkTimedGetNPE() {
680          ForkJoinTask a = new CheckedRecursiveAction() {
681              protected void realCompute() throws Exception {
682 <                CCF f = new LCCF(null, 8);
682 >                CCF f = new LCCF(8);
683                  assertSame(f, f.fork());
684                  try {
685                      f.get(5L, null);
# Line 602 | Line 695 | public class CountedCompleterTest extend
695      public void testForkQuietlyJoin() {
696          ForkJoinTask a = new CheckedRecursiveAction() {
697              protected void realCompute() {
698 <                CCF f = new LCCF(null, 8);
698 >                CCF f = new LCCF(8);
699                  assertSame(f, f.fork());
700                  f.quietlyJoin();
701                  assertEquals(21, f.number);
# Line 618 | Line 711 | public class CountedCompleterTest extend
711      public void testForkHelpQuiesce() {
712          ForkJoinTask a = new CheckedRecursiveAction() {
713              protected void realCompute() {
714 <                CCF f = new LCCF(null, 8);
714 >                CCF f = new LCCF(8);
715                  assertSame(f, f.fork());
716                  helpQuiesce();
717                  assertEquals(21, f.number);
# Line 634 | Line 727 | public class CountedCompleterTest extend
727      public void testAbnormalInvoke() {
728          ForkJoinTask a = new CheckedRecursiveAction() {
729              protected void realCompute() {
730 <                FailingCCF f = new LFCCF(null, 8);
730 >                FailingCCF f = new LFCCF(8);
731                  try {
732                      f.invoke();
733                      shouldThrow();
# Line 651 | Line 744 | public class CountedCompleterTest extend
744      public void testAbnormalQuietlyInvoke() {
745          ForkJoinTask a = new CheckedRecursiveAction() {
746              protected void realCompute() {
747 <                FailingCCF f = new LFCCF(null, 8);
747 >                FailingCCF f = new LFCCF(8);
748                  f.quietlyInvoke();
749                  assertTrue(f.getException() instanceof FJException);
750                  checkCompletedAbnormally(f, f.getException());
# Line 665 | Line 758 | public class CountedCompleterTest extend
758      public void testAbnormalForkJoin() {
759          ForkJoinTask a = new CheckedRecursiveAction() {
760              protected void realCompute() {
761 <                FailingCCF f = new LFCCF(null, 8);
761 >                FailingCCF f = new LFCCF(8);
762                  assertSame(f, f.fork());
763                  try {
764                      f.join();
# Line 683 | Line 776 | public class CountedCompleterTest extend
776      public void testAbnormalForkGet() {
777          ForkJoinTask a = new CheckedRecursiveAction() {
778              protected void realCompute() throws Exception {
779 <                FailingCCF f = new LFCCF(null, 8);
779 >                FailingCCF f = new LFCCF(8);
780                  assertSame(f, f.fork());
781                  try {
782                      f.get();
# Line 703 | Line 796 | public class CountedCompleterTest extend
796      public void testAbnormalForkTimedGet() {
797          ForkJoinTask a = new CheckedRecursiveAction() {
798              protected void realCompute() throws Exception {
799 <                FailingCCF f = new LFCCF(null, 8);
799 >                FailingCCF f = new LFCCF(8);
800                  assertSame(f, f.fork());
801                  try {
802                      f.get(LONG_DELAY_MS, MILLISECONDS);
# Line 723 | Line 816 | public class CountedCompleterTest extend
816      public void testAbnormalForkQuietlyJoin() {
817          ForkJoinTask a = new CheckedRecursiveAction() {
818              protected void realCompute() {
819 <                FailingCCF f = new LFCCF(null, 8);
819 >                FailingCCF f = new LFCCF(8);
820                  assertSame(f, f.fork());
821                  f.quietlyJoin();
822                  assertTrue(f.getException() instanceof FJException);
# Line 738 | Line 831 | public class CountedCompleterTest extend
831      public void testCancelledInvoke() {
832          ForkJoinTask a = new CheckedRecursiveAction() {
833              protected void realCompute() {
834 <                CCF f = new LCCF(null, 8);
834 >                CCF f = new LCCF(8);
835                  assertTrue(f.cancel(true));
836                  try {
837                      f.invoke();
# Line 756 | Line 849 | public class CountedCompleterTest extend
849      public void testCancelledForkJoin() {
850          ForkJoinTask a = new CheckedRecursiveAction() {
851              protected void realCompute() {
852 <                CCF f = new LCCF(null, 8);
852 >                CCF f = new LCCF(8);
853                  assertTrue(f.cancel(true));
854                  assertSame(f, f.fork());
855                  try {
# Line 775 | Line 868 | public class CountedCompleterTest extend
868      public void testCancelledForkGet() {
869          ForkJoinTask a = new CheckedRecursiveAction() {
870              protected void realCompute() throws Exception {
871 <                CCF f = new LCCF(null, 8);
871 >                CCF f = new LCCF(8);
872                  assertTrue(f.cancel(true));
873                  assertSame(f, f.fork());
874                  try {
# Line 794 | Line 887 | public class CountedCompleterTest extend
887      public void testCancelledForkTimedGet() throws Exception {
888          ForkJoinTask a = new CheckedRecursiveAction() {
889              protected void realCompute() throws Exception {
890 <                CCF f = new LCCF(null, 8);
890 >                CCF f = new LCCF(8);
891                  assertTrue(f.cancel(true));
892                  assertSame(f, f.fork());
893                  try {
# Line 813 | Line 906 | public class CountedCompleterTest extend
906      public void testCancelledForkQuietlyJoin() {
907          ForkJoinTask a = new CheckedRecursiveAction() {
908              protected void realCompute() {
909 <                CCF f = new LCCF(null, 8);
909 >                CCF f = new LCCF(8);
910                  assertTrue(f.cancel(true));
911                  assertSame(f, f.fork());
912                  f.quietlyJoin();
# Line 885 | Line 978 | public class CountedCompleterTest extend
978      public void testCompleteExceptionally2() {
979          ForkJoinTask a = new CheckedRecursiveAction() {
980              protected void realCompute() {
981 <                CCF f = new LCCF(null, 8);
982 <                f.completeExceptionally(new FJException());
983 <                try {
984 <                    f.invoke();
985 <                    shouldThrow();
986 <                } catch (FJException success) {
894 <                    checkCompletedAbnormally(f, success);
895 <                }
981 >                CCF n = new LCCF(8);
982 >                CCF f = new LCCF(n, 8);
983 >                FJException ex = new FJException();
984 >                f.completeExceptionally(ex);
985 >                f.checkCompletedExceptionally(ex);
986 >                n.checkCompletedExceptionally(ex);
987              }};
988          testInvokeOnPool(mainPool(), a);
989      }
# Line 903 | Line 994 | public class CountedCompleterTest extend
994      public void testInvokeAll2() {
995          ForkJoinTask a = new CheckedRecursiveAction() {
996              protected void realCompute() {
997 <                CCF f = new LCCF(null, 8);
998 <                CCF g = new LCCF(null, 9);
997 >                CCF f = new LCCF(8);
998 >                CCF g = new LCCF(9);
999                  invokeAll(f, g);
1000                  assertEquals(21, f.number);
1001                  assertEquals(34, g.number);
# Line 920 | Line 1011 | public class CountedCompleterTest extend
1011      public void testInvokeAll1() {
1012          ForkJoinTask a = new CheckedRecursiveAction() {
1013              protected void realCompute() {
1014 <                CCF f = new LCCF(null, 8);
1014 >                CCF f = new LCCF(8);
1015                  invokeAll(f);
1016                  checkCompletedNormally(f);
1017                  assertEquals(21, f.number);
# Line 934 | Line 1025 | public class CountedCompleterTest extend
1025      public void testInvokeAll3() {
1026          ForkJoinTask a = new CheckedRecursiveAction() {
1027              protected void realCompute() {
1028 <                CCF f = new LCCF(null, 8);
1029 <                CCF g = new LCCF(null, 9);
1030 <                CCF h = new LCCF(null, 7);
1028 >                CCF f = new LCCF(8);
1029 >                CCF g = new LCCF(9);
1030 >                CCF h = new LCCF(7);
1031                  invokeAll(f, g, h);
1032                  assertEquals(21, f.number);
1033                  assertEquals(34, g.number);
# Line 954 | Line 1045 | public class CountedCompleterTest extend
1045      public void testInvokeAllCollection() {
1046          ForkJoinTask a = new CheckedRecursiveAction() {
1047              protected void realCompute() {
1048 <                CCF f = new LCCF(null, 8);
1049 <                CCF g = new LCCF(null, 9);
1050 <                CCF h = new LCCF(null, 7);
1048 >                CCF f = new LCCF(8);
1049 >                CCF g = new LCCF(9);
1050 >                CCF h = new LCCF(7);
1051                  HashSet set = new HashSet();
1052                  set.add(f);
1053                  set.add(g);
# Line 978 | Line 1069 | public class CountedCompleterTest extend
1069      public void testInvokeAllNPE() {
1070          ForkJoinTask a = new CheckedRecursiveAction() {
1071              protected void realCompute() {
1072 <                CCF f = new LCCF(null, 8);
1073 <                CCF g = new LCCF(null, 9);
1072 >                CCF f = new LCCF(8);
1073 >                CCF g = new LCCF(9);
1074                  CCF h = null;
1075                  try {
1076                      invokeAll(f, g, h);
# Line 995 | Line 1086 | public class CountedCompleterTest extend
1086      public void testAbnormalInvokeAll2() {
1087          ForkJoinTask a = new CheckedRecursiveAction() {
1088              protected void realCompute() {
1089 <                CCF f = new LCCF(null, 8);
1090 <                FailingCCF g = new LFCCF(null, 9);
1089 >                CCF f = new LCCF(8);
1090 >                FailingCCF g = new LFCCF(9);
1091                  try {
1092                      invokeAll(f, g);
1093                      shouldThrow();
# Line 1013 | Line 1104 | public class CountedCompleterTest extend
1104      public void testAbnormalInvokeAll1() {
1105          ForkJoinTask a = new CheckedRecursiveAction() {
1106              protected void realCompute() {
1107 <                FailingCCF g = new LFCCF(null, 9);
1107 >                FailingCCF g = new LFCCF(9);
1108                  try {
1109                      invokeAll(g);
1110                      shouldThrow();
# Line 1030 | Line 1121 | public class CountedCompleterTest extend
1121      public void testAbnormalInvokeAll3() {
1122          ForkJoinTask a = new CheckedRecursiveAction() {
1123              protected void realCompute() {
1124 <                CCF f = new LCCF(null, 8);
1125 <                FailingCCF g = new LFCCF(null, 9);
1126 <                CCF h = new LCCF(null, 7);
1124 >                CCF f = new LCCF(8);
1125 >                FailingCCF g = new LFCCF(9);
1126 >                CCF h = new LCCF(7);
1127                  try {
1128                      invokeAll(f, g, h);
1129                      shouldThrow();
# Line 1044 | Line 1135 | public class CountedCompleterTest extend
1135      }
1136  
1137      /**
1138 <     * invokeAll(collection)  throws exception if any task does
1138 >     * invokeAll(collection) throws exception if any task does
1139       */
1140      public void testAbnormalInvokeAllCollection() {
1141          ForkJoinTask a = new CheckedRecursiveAction() {
1142              protected void realCompute() {
1143 <                FailingCCF f = new LFCCF(null, 8);
1144 <                CCF g = new LCCF(null, 9);
1145 <                CCF h = new LCCF(null, 7);
1143 >                FailingCCF f = new LFCCF(8);
1144 >                CCF g = new LCCF(9);
1145 >                CCF h = new LCCF(7);
1146                  HashSet set = new HashSet();
1147                  set.add(f);
1148                  set.add(g);
# Line 1073 | Line 1164 | public class CountedCompleterTest extend
1164      public void testTryUnfork() {
1165          ForkJoinTask a = new CheckedRecursiveAction() {
1166              protected void realCompute() {
1167 <                CCF g = new LCCF(null, 9);
1167 >                CCF g = new LCCF(9);
1168                  assertSame(g, g.fork());
1169 <                CCF f = new LCCF(null, 8);
1169 >                CCF f = new LCCF(8);
1170                  assertSame(f, f.fork());
1171                  assertTrue(f.tryUnfork());
1172                  helpQuiesce();
# Line 1092 | Line 1183 | public class CountedCompleterTest extend
1183      public void testGetSurplusQueuedTaskCount() {
1184          ForkJoinTask a = new CheckedRecursiveAction() {
1185              protected void realCompute() {
1186 <                CCF h = new LCCF(null, 7);
1186 >                CCF h = new LCCF(7);
1187                  assertSame(h, h.fork());
1188 <                CCF g = new LCCF(null, 9);
1188 >                CCF g = new LCCF(9);
1189                  assertSame(g, g.fork());
1190 <                CCF f = new LCCF(null, 8);
1190 >                CCF f = new LCCF(8);
1191                  assertSame(f, f.fork());
1192                  assertTrue(getSurplusQueuedTaskCount() > 0);
1193                  helpQuiesce();
# Line 1114 | Line 1205 | public class CountedCompleterTest extend
1205      public void testPeekNextLocalTask() {
1206          ForkJoinTask a = new CheckedRecursiveAction() {
1207              protected void realCompute() {
1208 <                CCF g = new LCCF(null, 9);
1208 >                CCF g = new LCCF(9);
1209                  assertSame(g, g.fork());
1210 <                CCF f = new LCCF(null, 8);
1210 >                CCF f = new LCCF(8);
1211                  assertSame(f, f.fork());
1212                  assertSame(f, peekNextLocalTask());
1213                  assertNull(f.join());
# Line 1134 | Line 1225 | public class CountedCompleterTest extend
1225      public void testPollNextLocalTask() {
1226          ForkJoinTask a = new CheckedRecursiveAction() {
1227              protected void realCompute() {
1228 <                CCF g = new LCCF(null, 9);
1228 >                CCF g = new LCCF(9);
1229                  assertSame(g, g.fork());
1230 <                CCF f = new LCCF(null, 8);
1230 >                CCF f = new LCCF(8);
1231                  assertSame(f, f.fork());
1232                  assertSame(f, pollNextLocalTask());
1233                  helpQuiesce();
# Line 1153 | Line 1244 | public class CountedCompleterTest extend
1244      public void testPollTask() {
1245          ForkJoinTask a = new CheckedRecursiveAction() {
1246              protected void realCompute() {
1247 <                CCF g = new LCCF(null, 9);
1247 >                CCF g = new LCCF(9);
1248                  assertSame(g, g.fork());
1249 <                CCF f = new LCCF(null, 8);
1249 >                CCF f = new LCCF(8);
1250                  assertSame(f, f.fork());
1251                  assertSame(f, pollTask());
1252                  helpQuiesce();
# Line 1171 | Line 1262 | public class CountedCompleterTest extend
1262      public void testPeekNextLocalTaskAsync() {
1263          ForkJoinTask a = new CheckedRecursiveAction() {
1264              protected void realCompute() {
1265 <                CCF g = new LCCF(null, 9);
1265 >                CCF g = new LCCF(9);
1266                  assertSame(g, g.fork());
1267 <                CCF f = new LCCF(null, 8);
1267 >                CCF f = new LCCF(8);
1268                  assertSame(f, f.fork());
1269                  assertSame(g, peekNextLocalTask());
1270                  assertNull(f.join());
# Line 1192 | Line 1283 | public class CountedCompleterTest extend
1283      public void testPollNextLocalTaskAsync() {
1284          ForkJoinTask a = new CheckedRecursiveAction() {
1285              protected void realCompute() {
1286 <                CCF g = new LCCF(null, 9);
1286 >                CCF g = new LCCF(9);
1287                  assertSame(g, g.fork());
1288 <                CCF f = new LCCF(null, 8);
1288 >                CCF f = new LCCF(8);
1289                  assertSame(f, f.fork());
1290                  assertSame(g, pollNextLocalTask());
1291                  helpQuiesce();
# Line 1212 | Line 1303 | public class CountedCompleterTest extend
1303      public void testPollTaskAsync() {
1304          ForkJoinTask a = new CheckedRecursiveAction() {
1305              protected void realCompute() {
1306 <                CCF g = new LCCF(null, 9);
1306 >                CCF g = new LCCF(9);
1307                  assertSame(g, g.fork());
1308 <                CCF f = new LCCF(null, 8);
1308 >                CCF f = new LCCF(8);
1309                  assertSame(f, f.fork());
1310                  assertSame(g, pollTask());
1311                  helpQuiesce();
# Line 1235 | Line 1326 | public class CountedCompleterTest extend
1326      public void testInvokeSingleton() {
1327          ForkJoinTask a = new CheckedRecursiveAction() {
1328              protected void realCompute() {
1329 <                CCF f = new LCCF(null, 8);
1329 >                CCF f = new LCCF(8);
1330                  assertNull(f.invoke());
1331                  assertEquals(21, f.number);
1332                  checkCompletedNormally(f);
# Line 1251 | Line 1342 | public class CountedCompleterTest extend
1342      public void testQuietlyInvokeSingleton() {
1343          ForkJoinTask a = new CheckedRecursiveAction() {
1344              protected void realCompute() {
1345 <                CCF f = new LCCF(null, 8);
1345 >                CCF f = new LCCF(8);
1346                  f.quietlyInvoke();
1347                  assertEquals(21, f.number);
1348                  checkCompletedNormally(f);
# Line 1265 | Line 1356 | public class CountedCompleterTest extend
1356      public void testForkJoinSingleton() {
1357          ForkJoinTask a = new CheckedRecursiveAction() {
1358              protected void realCompute() {
1359 <                CCF f = new LCCF(null, 8);
1359 >                CCF f = new LCCF(8);
1360                  assertSame(f, f.fork());
1361                  assertNull(f.join());
1362                  assertEquals(21, f.number);
# Line 1280 | Line 1371 | public class CountedCompleterTest extend
1371      public void testForkGetSingleton() {
1372          ForkJoinTask a = new CheckedRecursiveAction() {
1373              protected void realCompute() throws Exception {
1374 <                CCF f = new LCCF(null, 8);
1374 >                CCF f = new LCCF(8);
1375                  assertSame(f, f.fork());
1376                  assertNull(f.get());
1377                  assertEquals(21, f.number);
# Line 1295 | Line 1386 | public class CountedCompleterTest extend
1386      public void testForkTimedGetSingleton() {
1387          ForkJoinTask a = new CheckedRecursiveAction() {
1388              protected void realCompute() throws Exception {
1389 <                CCF f = new LCCF(null, 8);
1389 >                CCF f = new LCCF(8);
1390                  assertSame(f, f.fork());
1391                  assertNull(f.get(LONG_DELAY_MS, MILLISECONDS));
1392                  assertEquals(21, f.number);
# Line 1310 | Line 1401 | public class CountedCompleterTest extend
1401      public void testForkTimedGetNPESingleton() {
1402          ForkJoinTask a = new CheckedRecursiveAction() {
1403              protected void realCompute() throws Exception {
1404 <                CCF f = new LCCF(null, 8);
1404 >                CCF f = new LCCF(8);
1405                  assertSame(f, f.fork());
1406                  try {
1407                      f.get(5L, null);
# Line 1326 | Line 1417 | public class CountedCompleterTest extend
1417      public void testForkQuietlyJoinSingleton() {
1418          ForkJoinTask a = new CheckedRecursiveAction() {
1419              protected void realCompute() {
1420 <                CCF f = new LCCF(null, 8);
1420 >                CCF f = new LCCF(8);
1421                  assertSame(f, f.fork());
1422                  f.quietlyJoin();
1423                  assertEquals(21, f.number);
# Line 1342 | Line 1433 | public class CountedCompleterTest extend
1433      public void testForkHelpQuiesceSingleton() {
1434          ForkJoinTask a = new CheckedRecursiveAction() {
1435              protected void realCompute() {
1436 <                CCF f = new LCCF(null, 8);
1436 >                CCF f = new LCCF(8);
1437                  assertSame(f, f.fork());
1438                  helpQuiesce();
1439                  assertEquals(0, getQueuedTaskCount());
# Line 1358 | Line 1449 | public class CountedCompleterTest extend
1449      public void testAbnormalInvokeSingleton() {
1450          ForkJoinTask a = new CheckedRecursiveAction() {
1451              protected void realCompute() {
1452 <                FailingCCF f = new LFCCF(null, 8);
1452 >                FailingCCF f = new LFCCF(8);
1453                  try {
1454                      f.invoke();
1455                      shouldThrow();
# Line 1375 | Line 1466 | public class CountedCompleterTest extend
1466      public void testAbnormalQuietlyInvokeSingleton() {
1467          ForkJoinTask a = new CheckedRecursiveAction() {
1468              protected void realCompute() {
1469 <                FailingCCF f = new LFCCF(null, 8);
1469 >                FailingCCF f = new LFCCF(8);
1470                  f.quietlyInvoke();
1471                  assertTrue(f.getException() instanceof FJException);
1472                  checkCompletedAbnormally(f, f.getException());
# Line 1389 | Line 1480 | public class CountedCompleterTest extend
1480      public void testAbnormalForkJoinSingleton() {
1481          ForkJoinTask a = new CheckedRecursiveAction() {
1482              protected void realCompute() {
1483 <                FailingCCF f = new LFCCF(null, 8);
1483 >                FailingCCF f = new LFCCF(8);
1484                  assertSame(f, f.fork());
1485                  try {
1486                      f.join();
# Line 1407 | Line 1498 | public class CountedCompleterTest extend
1498      public void testAbnormalForkGetSingleton() {
1499          ForkJoinTask a = new CheckedRecursiveAction() {
1500              protected void realCompute() throws Exception {
1501 <                FailingCCF f = new LFCCF(null, 8);
1501 >                FailingCCF f = new LFCCF(8);
1502                  assertSame(f, f.fork());
1503                  try {
1504                      f.get();
# Line 1427 | Line 1518 | public class CountedCompleterTest extend
1518      public void testAbnormalForkTimedGetSingleton() {
1519          ForkJoinTask a = new CheckedRecursiveAction() {
1520              protected void realCompute() throws Exception {
1521 <                FailingCCF f = new LFCCF(null, 8);
1521 >                FailingCCF f = new LFCCF(8);
1522                  assertSame(f, f.fork());
1523                  try {
1524                      f.get(LONG_DELAY_MS, MILLISECONDS);
# Line 1447 | Line 1538 | public class CountedCompleterTest extend
1538      public void testAbnormalForkQuietlyJoinSingleton() {
1539          ForkJoinTask a = new CheckedRecursiveAction() {
1540              protected void realCompute() {
1541 <                FailingCCF f = new LFCCF(null, 8);
1541 >                FailingCCF f = new LFCCF(8);
1542                  assertSame(f, f.fork());
1543                  f.quietlyJoin();
1544                  assertTrue(f.getException() instanceof FJException);
# Line 1462 | Line 1553 | public class CountedCompleterTest extend
1553      public void testCancelledInvokeSingleton() {
1554          ForkJoinTask a = new CheckedRecursiveAction() {
1555              protected void realCompute() {
1556 <                CCF f = new LCCF(null, 8);
1556 >                CCF f = new LCCF(8);
1557                  assertTrue(f.cancel(true));
1558                  try {
1559                      f.invoke();
# Line 1480 | Line 1571 | public class CountedCompleterTest extend
1571      public void testCancelledForkJoinSingleton() {
1572          ForkJoinTask a = new CheckedRecursiveAction() {
1573              protected void realCompute() {
1574 <                CCF f = new LCCF(null, 8);
1574 >                CCF f = new LCCF(8);
1575                  assertTrue(f.cancel(true));
1576                  assertSame(f, f.fork());
1577                  try {
# Line 1499 | Line 1590 | public class CountedCompleterTest extend
1590      public void testCancelledForkGetSingleton() {
1591          ForkJoinTask a = new CheckedRecursiveAction() {
1592              protected void realCompute() throws Exception {
1593 <                CCF f = new LCCF(null, 8);
1593 >                CCF f = new LCCF(8);
1594                  assertTrue(f.cancel(true));
1595                  assertSame(f, f.fork());
1596                  try {
# Line 1518 | Line 1609 | public class CountedCompleterTest extend
1609      public void testCancelledForkTimedGetSingleton() throws Exception {
1610          ForkJoinTask a = new CheckedRecursiveAction() {
1611              protected void realCompute() throws Exception {
1612 <                CCF f = new LCCF(null, 8);
1612 >                CCF f = new LCCF(8);
1613                  assertTrue(f.cancel(true));
1614                  assertSame(f, f.fork());
1615                  try {
# Line 1537 | Line 1628 | public class CountedCompleterTest extend
1628      public void testCancelledForkQuietlyJoinSingleton() {
1629          ForkJoinTask a = new CheckedRecursiveAction() {
1630              protected void realCompute() {
1631 <                CCF f = new LCCF(null, 8);
1631 >                CCF f = new LCCF(8);
1632                  assertTrue(f.cancel(true));
1633                  assertSame(f, f.fork());
1634                  f.quietlyJoin();
# Line 1552 | Line 1643 | public class CountedCompleterTest extend
1643      public void testCompleteExceptionallySingleton() {
1644          ForkJoinTask a = new CheckedRecursiveAction() {
1645              protected void realCompute() {
1646 <                CCF f = new LCCF(null, 8);
1647 <                f.completeExceptionally(new FJException());
1648 <                try {
1649 <                    f.invoke();
1650 <                    shouldThrow();
1651 <                } catch (FJException success) {
1561 <                    checkCompletedAbnormally(f, success);
1562 <                }
1646 >                CCF n = new LCCF(8);
1647 >                CCF f = new LCCF(n, 8);
1648 >                FJException ex = new FJException();
1649 >                f.completeExceptionally(ex);
1650 >                f.checkCompletedExceptionally(ex);
1651 >                n.checkCompletedExceptionally(ex);
1652              }};
1653          testInvokeOnPool(singletonPool(), a);
1654      }
# Line 1570 | Line 1659 | public class CountedCompleterTest extend
1659      public void testInvokeAll2Singleton() {
1660          ForkJoinTask a = new CheckedRecursiveAction() {
1661              protected void realCompute() {
1662 <                CCF f = new LCCF(null, 8);
1663 <                CCF g = new LCCF(null, 9);
1662 >                CCF f = new LCCF(8);
1663 >                CCF g = new LCCF(9);
1664                  invokeAll(f, g);
1665                  assertEquals(21, f.number);
1666                  assertEquals(34, g.number);
# Line 1587 | Line 1676 | public class CountedCompleterTest extend
1676      public void testInvokeAll1Singleton() {
1677          ForkJoinTask a = new CheckedRecursiveAction() {
1678              protected void realCompute() {
1679 <                CCF f = new LCCF(null, 8);
1679 >                CCF f = new LCCF(8);
1680                  invokeAll(f);
1681                  checkCompletedNormally(f);
1682                  assertEquals(21, f.number);
# Line 1601 | Line 1690 | public class CountedCompleterTest extend
1690      public void testInvokeAll3Singleton() {
1691          ForkJoinTask a = new CheckedRecursiveAction() {
1692              protected void realCompute() {
1693 <                CCF f = new LCCF(null, 8);
1694 <                CCF g = new LCCF(null, 9);
1695 <                CCF h = new LCCF(null, 7);
1693 >                CCF f = new LCCF(8);
1694 >                CCF g = new LCCF(9);
1695 >                CCF h = new LCCF(7);
1696                  invokeAll(f, g, h);
1697                  assertEquals(21, f.number);
1698                  assertEquals(34, g.number);
# Line 1621 | Line 1710 | public class CountedCompleterTest extend
1710      public void testInvokeAllCollectionSingleton() {
1711          ForkJoinTask a = new CheckedRecursiveAction() {
1712              protected void realCompute() {
1713 <                CCF f = new LCCF(null, 8);
1714 <                CCF g = new LCCF(null, 9);
1715 <                CCF h = new LCCF(null, 7);
1713 >                CCF f = new LCCF(8);
1714 >                CCF g = new LCCF(9);
1715 >                CCF h = new LCCF(7);
1716                  HashSet set = new HashSet();
1717                  set.add(f);
1718                  set.add(g);
# Line 1645 | Line 1734 | public class CountedCompleterTest extend
1734      public void testInvokeAllNPESingleton() {
1735          ForkJoinTask a = new CheckedRecursiveAction() {
1736              protected void realCompute() {
1737 <                CCF f = new LCCF(null, 8);
1738 <                CCF g = new LCCF(null, 9);
1737 >                CCF f = new LCCF(8);
1738 >                CCF g = new LCCF(9);
1739                  CCF h = null;
1740                  try {
1741                      invokeAll(f, g, h);
# Line 1662 | Line 1751 | public class CountedCompleterTest extend
1751      public void testAbnormalInvokeAll2Singleton() {
1752          ForkJoinTask a = new CheckedRecursiveAction() {
1753              protected void realCompute() {
1754 <                CCF f = new LCCF(null, 8);
1755 <                FailingCCF g = new LFCCF(null, 9);
1754 >                CCF f = new LCCF(8);
1755 >                FailingCCF g = new LFCCF(9);
1756                  try {
1757                      invokeAll(f, g);
1758                      shouldThrow();
# Line 1680 | Line 1769 | public class CountedCompleterTest extend
1769      public void testAbnormalInvokeAll1Singleton() {
1770          ForkJoinTask a = new CheckedRecursiveAction() {
1771              protected void realCompute() {
1772 <                FailingCCF g = new LFCCF(null, 9);
1772 >                FailingCCF g = new LFCCF(9);
1773                  try {
1774                      invokeAll(g);
1775                      shouldThrow();
# Line 1697 | Line 1786 | public class CountedCompleterTest extend
1786      public void testAbnormalInvokeAll3Singleton() {
1787          ForkJoinTask a = new CheckedRecursiveAction() {
1788              protected void realCompute() {
1789 <                CCF f = new LCCF(null, 8);
1790 <                FailingCCF g = new LFCCF(null, 9);
1791 <                CCF h = new LCCF(null, 7);
1789 >                CCF f = new LCCF(8);
1790 >                FailingCCF g = new LFCCF(9);
1791 >                CCF h = new LCCF(7);
1792                  try {
1793                      invokeAll(f, g, h);
1794                      shouldThrow();
# Line 1711 | Line 1800 | public class CountedCompleterTest extend
1800      }
1801  
1802      /**
1803 <     * invokeAll(collection)  throws exception if any task does
1803 >     * invokeAll(collection) throws exception if any task does
1804       */
1805      public void testAbnormalInvokeAllCollectionSingleton() {
1806          ForkJoinTask a = new CheckedRecursiveAction() {
1807              protected void realCompute() {
1808 <                FailingCCF f = new LFCCF(null, 8);
1809 <                CCF g = new LCCF(null, 9);
1810 <                CCF h = new LCCF(null, 7);
1808 >                FailingCCF f = new LFCCF(8);
1809 >                CCF g = new LCCF(9);
1810 >                CCF h = new LCCF(7);
1811                  HashSet set = new HashSet();
1812                  set.add(f);
1813                  set.add(g);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines