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

Comparing jsr166/src/test/tck/ForkJoinTask8Test.java (file contents):
Revision 1.4 by jsr166, Mon Jul 22 18:11:57 2013 UTC vs.
Revision 1.15 by dl, Tue Sep 8 23:56:19 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 +
7 + import static java.util.concurrent.TimeUnit.MILLISECONDS;
8 + import static java.util.concurrent.TimeUnit.SECONDS;
9 +
10 + import java.util.Arrays;
11 + import java.util.Collections;
12 + import java.util.concurrent.CountDownLatch;
13   import java.util.concurrent.ExecutionException;
7 import java.util.concurrent.CancellationException;
14   import java.util.concurrent.ForkJoinPool;
15   import java.util.concurrent.ForkJoinTask;
16   import java.util.concurrent.ForkJoinWorkerThread;
17   import java.util.concurrent.RecursiveAction;
12 import java.util.concurrent.TimeUnit;
18   import java.util.concurrent.TimeoutException;
19 < import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
20 < import static java.util.concurrent.TimeUnit.MILLISECONDS;
21 < import static java.util.concurrent.TimeUnit.SECONDS;
17 < import java.util.HashSet;
18 < import junit.framework.*;
19 >
20 > import junit.framework.Test;
21 > import junit.framework.TestSuite;
22  
23   public class ForkJoinTask8Test extends JSR166TestCase {
24  
# Line 34 | Line 37 | public class ForkJoinTask8Test extends J
37      static final short EXCEPTION_STATE = 1;
38  
39      public static void main(String[] args) {
40 <        junit.textui.TestRunner.run(suite());
40 >        main(suite(), args);
41      }
42  
43      public static Test suite() {
# Line 59 | Line 62 | public class ForkJoinTask8Test extends J
62                                  null, true);
63      }
64  
65 +    // Compute fib naively and efficiently
66 +    final int[] fib;
67 +    {
68 +        int[] fib = new int[10];
69 +        fib[0] = 0;
70 +        fib[1] = 1;
71 +        for (int i = 2; i < fib.length; i++)
72 +            fib[i] = fib[i - 1] + fib[i - 2];
73 +        this.fib = fib;
74 +    }
75 +
76      private void testInvokeOnPool(ForkJoinPool pool, RecursiveAction a) {
77          try {
78              assertFalse(a.isDone());
# Line 180 | Line 194 | public class ForkJoinTask8Test extends J
194          } catch (Throwable fail) { threadUnexpectedException(fail); }
195      }
196  
183
197      public static final class FJException extends RuntimeException {
198          FJException() { super(); }
199      }
# Line 280 | Line 293 | public class ForkJoinTask8Test extends J
293  
294      }
295  
296 <    static final class AsyncFib extends BinaryAsyncAction {
296 >    final class AsyncFib extends BinaryAsyncAction {
297          int number;
298 <        public AsyncFib(int n) {
299 <            this.number = n;
298 >        int expectedResult;
299 >        public AsyncFib(int number) {
300 >            this.number = number;
301 >            this.expectedResult = fib[number];
302          }
303  
304          public final boolean exec() {
# Line 312 | Line 327 | public class ForkJoinTask8Test extends J
327              number = ((AsyncFib)x).number + ((AsyncFib)y).number;
328              super.onComplete(x, y);
329          }
330 +
331 +        public void checkCompletedNormally() {
332 +            assertEquals(expectedResult, number);
333 +            ForkJoinTask8Test.this.checkCompletedNormally(this);
334 +        }
335      }
336  
337      static final class FailingAsyncFib extends BinaryAsyncAction {
# Line 348 | Line 368 | public class ForkJoinTask8Test extends J
368       * completed tasks; getRawResult returns null.
369       */
370      public void testInvoke() {
371 +        testInvoke(mainPool());
372 +    }
373 +    public void testInvoke_Singleton() {
374 +        testInvoke(singletonPool());
375 +    }
376 +    public void testInvoke(ForkJoinPool pool) {
377          RecursiveAction a = new CheckedRecursiveAction() {
378              protected void realCompute() {
379                  AsyncFib f = new AsyncFib(8);
380                  assertNull(f.invoke());
381 <                assertEquals(21, f.number);
356 <                checkCompletedNormally(f);
381 >                f.checkCompletedNormally();
382              }};
383 <        testInvokeOnPool(mainPool(), a);
383 >        testInvokeOnPool(pool, a);
384      }
385  
386      /**
# Line 364 | Line 389 | public class ForkJoinTask8Test extends J
389       * completed tasks
390       */
391      public void testQuietlyInvoke() {
392 +        testQuietlyInvoke(mainPool());
393 +    }
394 +    public void testQuietlyInvoke_Singleton() {
395 +        testQuietlyInvoke(singletonPool());
396 +    }
397 +    public void testQuietlyInvoke(ForkJoinPool pool) {
398          RecursiveAction a = new CheckedRecursiveAction() {
399              protected void realCompute() {
400                  AsyncFib f = new AsyncFib(8);
401                  f.quietlyInvoke();
402 <                assertEquals(21, f.number);
372 <                checkCompletedNormally(f);
402 >                f.checkCompletedNormally();
403              }};
404 <        testInvokeOnPool(mainPool(), a);
404 >        testInvokeOnPool(pool, a);
405      }
406  
407      /**
408       * join of a forked task returns when task completes
409       */
410      public void testForkJoin() {
411 +        testForkJoin(mainPool());
412 +    }
413 +    public void testForkJoin_Singleton() {
414 +        testForkJoin(singletonPool());
415 +    }
416 +    public void testForkJoin(ForkJoinPool pool) {
417          RecursiveAction a = new CheckedRecursiveAction() {
418              protected void realCompute() {
419                  AsyncFib f = new AsyncFib(8);
420                  assertSame(f, f.fork());
421                  assertNull(f.join());
422 <                assertEquals(21, f.number);
387 <                checkCompletedNormally(f);
422 >                f.checkCompletedNormally();
423              }};
424 <        testInvokeOnPool(mainPool(), a);
424 >        testInvokeOnPool(pool, a);
425      }
426  
427      /**
428       * get of a forked task returns when task completes
429       */
430      public void testForkGet() {
431 +        testForkGet(mainPool());
432 +    }
433 +    public void testForkGet_Singleton() {
434 +        testForkGet(singletonPool());
435 +    }
436 +    public void testForkGet(ForkJoinPool pool) {
437          RecursiveAction a = new CheckedRecursiveAction() {
438              protected void realCompute() throws Exception {
439                  AsyncFib f = new AsyncFib(8);
440                  assertSame(f, f.fork());
441                  assertNull(f.get());
442 <                assertEquals(21, f.number);
402 <                checkCompletedNormally(f);
442 >                f.checkCompletedNormally();
443              }};
444 <        testInvokeOnPool(mainPool(), a);
444 >        testInvokeOnPool(pool, a);
445      }
446  
447      /**
448       * timed get of a forked task returns when task completes
449       */
450      public void testForkTimedGet() {
451 +        testForkTimedGet(mainPool());
452 +    }
453 +    public void testForkTimedGet_Singleton() {
454 +        testForkTimedGet(singletonPool());
455 +    }
456 +    public void testForkTimedGet(ForkJoinPool pool) {
457          RecursiveAction a = new CheckedRecursiveAction() {
458              protected void realCompute() throws Exception {
459                  AsyncFib f = new AsyncFib(8);
460                  assertSame(f, f.fork());
461                  assertNull(f.get(LONG_DELAY_MS, MILLISECONDS));
462 <                assertEquals(21, f.number);
417 <                checkCompletedNormally(f);
462 >                f.checkCompletedNormally();
463              }};
464 <        testInvokeOnPool(mainPool(), a);
464 >        testInvokeOnPool(pool, a);
465      }
466  
467      /**
468 <     * timed get with null time unit throws NPE
468 >     * timed get with null time unit throws NullPointerException
469       */
470 <    public void testForkTimedGetNPE() {
470 >    public void testForkTimedGetNullTimeUnit() {
471 >        testForkTimedGetNullTimeUnit(mainPool());
472 >    }
473 >    public void testForkTimedGetNullTimeUnit_Singleton() {
474 >        testForkTimedGet(singletonPool());
475 >    }
476 >    public void testForkTimedGetNullTimeUnit(ForkJoinPool pool) {
477          RecursiveAction a = new CheckedRecursiveAction() {
478              protected void realCompute() throws Exception {
479                  AsyncFib f = new AsyncFib(8);
# Line 432 | Line 483 | public class ForkJoinTask8Test extends J
483                      shouldThrow();
484                  } catch (NullPointerException success) {}
485              }};
486 <        testInvokeOnPool(mainPool(), a);
486 >        testInvokeOnPool(pool, a);
487      }
488  
489      /**
490       * quietlyJoin of a forked task returns when task completes
491       */
492      public void testForkQuietlyJoin() {
493 +        testForkQuietlyJoin(mainPool());
494 +    }
495 +    public void testForkQuietlyJoin_Singleton() {
496 +        testForkQuietlyJoin(singletonPool());
497 +    }
498 +    public void testForkQuietlyJoin(ForkJoinPool pool) {
499          RecursiveAction a = new CheckedRecursiveAction() {
500              protected void realCompute() {
501                  AsyncFib f = new AsyncFib(8);
502                  assertSame(f, f.fork());
503                  f.quietlyJoin();
504 <                assertEquals(21, f.number);
448 <                checkCompletedNormally(f);
504 >                f.checkCompletedNormally();
505              }};
506 <        testInvokeOnPool(mainPool(), a);
506 >        testInvokeOnPool(pool, a);
507      }
508  
509      /**
# Line 455 | Line 511 | public class ForkJoinTask8Test extends J
511       * getQueuedTaskCount returns 0 when quiescent
512       */
513      public void testForkHelpQuiesce() {
514 +        testForkHelpQuiesce(mainPool());
515 +    }
516 +    public void testForkHelpQuiesce_Singleton() {
517 +        testForkHelpQuiesce(singletonPool());
518 +    }
519 +    public void testForkHelpQuiesce(ForkJoinPool pool) {
520          RecursiveAction a = new CheckedRecursiveAction() {
521              protected void realCompute() {
522                  AsyncFib f = new AsyncFib(8);
523                  assertSame(f, f.fork());
524                  helpQuiesce();
463                assertEquals(21, f.number);
525                  assertEquals(0, getQueuedTaskCount());
526 <                checkCompletedNormally(f);
526 >                f.checkCompletedNormally();
527              }};
528 <        testInvokeOnPool(mainPool(), a);
528 >        testInvokeOnPool(pool, a);
529      }
530  
531      /**
532       * invoke task throws exception when task completes abnormally
533       */
534      public void testAbnormalInvoke() {
535 +        testAbnormalInvoke(mainPool());
536 +    }
537 +    public void testAbnormalInvoke_Singleton() {
538 +        testAbnormalInvoke(singletonPool());
539 +    }
540 +    public void testAbnormalInvoke(ForkJoinPool pool) {
541          RecursiveAction a = new CheckedRecursiveAction() {
542              protected void realCompute() {
543                  FailingAsyncFib f = new FailingAsyncFib(8);
# Line 481 | Line 548 | public class ForkJoinTask8Test extends J
548                      checkCompletedAbnormally(f, success);
549                  }
550              }};
551 <        testInvokeOnPool(mainPool(), a);
551 >        testInvokeOnPool(pool, a);
552      }
553  
554      /**
555       * quietlyInvoke task returns when task completes abnormally
556       */
557      public void testAbnormalQuietlyInvoke() {
558 +        testAbnormalQuietlyInvoke(mainPool());
559 +    }
560 +    public void testAbnormalQuietlyInvoke_Singleton() {
561 +        testAbnormalQuietlyInvoke(singletonPool());
562 +    }
563 +    public void testAbnormalQuietlyInvoke(ForkJoinPool pool) {
564          RecursiveAction a = new CheckedRecursiveAction() {
565              protected void realCompute() {
566                  FailingAsyncFib f = new FailingAsyncFib(8);
# Line 495 | Line 568 | public class ForkJoinTask8Test extends J
568                  assertTrue(f.getException() instanceof FJException);
569                  checkCompletedAbnormally(f, f.getException());
570              }};
571 <        testInvokeOnPool(mainPool(), a);
571 >        testInvokeOnPool(pool, a);
572      }
573  
574      /**
575       * join of a forked task throws exception when task completes abnormally
576       */
577      public void testAbnormalForkJoin() {
578 +        testAbnormalForkJoin(mainPool());
579 +    }
580 +    public void testAbnormalForkJoin_Singleton() {
581 +        testAbnormalForkJoin(singletonPool());
582 +    }
583 +    public void testAbnormalForkJoin(ForkJoinPool pool) {
584          RecursiveAction a = new CheckedRecursiveAction() {
585              protected void realCompute() {
586                  FailingAsyncFib f = new FailingAsyncFib(8);
# Line 513 | Line 592 | public class ForkJoinTask8Test extends J
592                      checkCompletedAbnormally(f, success);
593                  }
594              }};
595 <        testInvokeOnPool(mainPool(), a);
595 >        testInvokeOnPool(pool, a);
596      }
597  
598      /**
599       * get of a forked task throws exception when task completes abnormally
600       */
601      public void testAbnormalForkGet() {
602 +        testAbnormalForkGet(mainPool());
603 +    }
604 +    public void testAbnormalForkGet_Singleton() {
605 +        testAbnormalForkJoin(singletonPool());
606 +    }
607 +    public void testAbnormalForkGet(ForkJoinPool pool) {
608          RecursiveAction a = new CheckedRecursiveAction() {
609              protected void realCompute() throws Exception {
610                  FailingAsyncFib f = new FailingAsyncFib(8);
# Line 533 | Line 618 | public class ForkJoinTask8Test extends J
618                      checkCompletedAbnormally(f, cause);
619                  }
620              }};
621 <        testInvokeOnPool(mainPool(), a);
621 >        testInvokeOnPool(pool, a);
622      }
623  
624      /**
625       * timed get of a forked task throws exception when task completes abnormally
626       */
627      public void testAbnormalForkTimedGet() {
628 +        testAbnormalForkTimedGet(mainPool());
629 +    }
630 +    public void testAbnormalForkTimedGet_Singleton() {
631 +        testAbnormalForkTimedGet(singletonPool());
632 +    }
633 +    public void testAbnormalForkTimedGet(ForkJoinPool pool) {
634          RecursiveAction a = new CheckedRecursiveAction() {
635              protected void realCompute() throws Exception {
636                  FailingAsyncFib f = new FailingAsyncFib(8);
# Line 553 | Line 644 | public class ForkJoinTask8Test extends J
644                      checkCompletedAbnormally(f, cause);
645                  }
646              }};
647 <        testInvokeOnPool(mainPool(), a);
647 >        testInvokeOnPool(pool, a);
648      }
649  
650      /**
651       * quietlyJoin of a forked task returns when task completes abnormally
652       */
653      public void testAbnormalForkQuietlyJoin() {
654 +        testAbnormalForkQuietlyJoin(mainPool());
655 +    }
656 +    public void testAbnormalForkQuietlyJoin_Singleton() {
657 +        testAbnormalForkQuietlyJoin(singletonPool());
658 +    }
659 +    public void testAbnormalForkQuietlyJoin(ForkJoinPool pool) {
660          RecursiveAction a = new CheckedRecursiveAction() {
661              protected void realCompute() {
662                  FailingAsyncFib f = new FailingAsyncFib(8);
# Line 568 | Line 665 | public class ForkJoinTask8Test extends J
665                  assertTrue(f.getException() instanceof FJException);
666                  checkCompletedAbnormally(f, f.getException());
667              }};
668 <        testInvokeOnPool(mainPool(), a);
668 >        testInvokeOnPool(pool, a);
669      }
670  
671      /**
672       * getPool of executing task returns its pool
673       */
674      public void testGetPool() {
675 <        final ForkJoinPool mainPool = mainPool();
675 >        testGetPool(mainPool());
676 >    }
677 >    public void testGetPool_Singleton() {
678 >        testGetPool(singletonPool());
679 >    }
680 >    public void testGetPool(ForkJoinPool pool) {
681          RecursiveAction a = new CheckedRecursiveAction() {
682              protected void realCompute() {
683 <                assertSame(mainPool, getPool());
683 >                assertSame(pool, getPool());
684              }};
685 <        testInvokeOnPool(mainPool, a);
685 >        testInvokeOnPool(pool, a);
686      }
687  
688      /**
# Line 598 | Line 700 | public class ForkJoinTask8Test extends J
700       * inForkJoinPool of executing task returns true
701       */
702      public void testInForkJoinPool() {
703 +        testInForkJoinPool(mainPool());
704 +    }
705 +    public void testInForkJoinPool_Singleton() {
706 +        testInForkJoinPool(singletonPool());
707 +    }
708 +    public void testInForkJoinPool(ForkJoinPool pool) {
709          RecursiveAction a = new CheckedRecursiveAction() {
710              protected void realCompute() {
711                  assertTrue(inForkJoinPool());
712              }};
713 <        testInvokeOnPool(mainPool(), a);
713 >        testInvokeOnPool(pool, a);
714      }
715  
716      /**
# Line 632 | Line 740 | public class ForkJoinTask8Test extends J
740       * invoke task throws exception after invoking completeExceptionally
741       */
742      public void testCompleteExceptionally() {
743 +        testCompleteExceptionally(mainPool());
744 +    }
745 +    public void testCompleteExceptionally_Singleton() {
746 +        testCompleteExceptionally(singletonPool());
747 +    }
748 +    public void testCompleteExceptionally(ForkJoinPool pool) {
749          RecursiveAction a = new CheckedRecursiveAction() {
750              protected void realCompute() {
751                  AsyncFib f = new AsyncFib(8);
# Line 643 | Line 757 | public class ForkJoinTask8Test extends J
757                      checkCompletedAbnormally(f, success);
758                  }
759              }};
760 <        testInvokeOnPool(mainPool(), a);
760 >        testInvokeOnPool(pool, a);
761      }
762  
763      /**
764 <     * invokeAll(t1, t2) invokes all task arguments
764 >     * invokeAll(tasks) with 1 argument invokes task
765       */
766 <    public void testInvokeAll2() {
766 >    public void testInvokeAll1() {
767 >        testInvokeAll1(mainPool());
768 >    }
769 >    public void testInvokeAll1_Singleton() {
770 >        testInvokeAll1(singletonPool());
771 >    }
772 >    public void testInvokeAll1(ForkJoinPool pool) {
773          RecursiveAction a = new CheckedRecursiveAction() {
774              protected void realCompute() {
775                  AsyncFib f = new AsyncFib(8);
776 <                AsyncFib g = new AsyncFib(9);
777 <                invokeAll(f, g);
658 <                assertEquals(21, f.number);
659 <                assertEquals(34, g.number);
660 <                checkCompletedNormally(f);
661 <                checkCompletedNormally(g);
776 >                invokeAll(f);
777 >                f.checkCompletedNormally();
778              }};
779 <        testInvokeOnPool(mainPool(), a);
779 >        testInvokeOnPool(pool, a);
780      }
781  
782      /**
783 <     * invokeAll(tasks) with 1 argument invokes task
783 >     * invokeAll(t1, t2) invokes all task arguments
784       */
785 <    public void testInvokeAll1() {
785 >    public void testInvokeAll2() {
786 >        testInvokeAll2(mainPool());
787 >    }
788 >    public void testInvokeAll2_Singleton() {
789 >        testInvokeAll2(singletonPool());
790 >    }
791 >    public void testInvokeAll2(ForkJoinPool pool) {
792          RecursiveAction a = new CheckedRecursiveAction() {
793              protected void realCompute() {
794 <                AsyncFib f = new AsyncFib(8);
795 <                invokeAll(f);
796 <                checkCompletedNormally(f);
797 <                assertEquals(21, f.number);
794 >                AsyncFib[] tasks = {
795 >                    new AsyncFib(8),
796 >                    new AsyncFib(9),
797 >                };
798 >                invokeAll(tasks[0], tasks[1]);
799 >                for (AsyncFib task : tasks) assertTrue(task.isDone());
800 >                for (AsyncFib task : tasks) task.checkCompletedNormally();
801              }};
802 <        testInvokeOnPool(mainPool(), a);
802 >        testInvokeOnPool(pool, a);
803      }
804  
805      /**
806       * invokeAll(tasks) with > 2 argument invokes tasks
807       */
808      public void testInvokeAll3() {
809 +        testInvokeAll3(mainPool());
810 +    }
811 +    public void testInvokeAll3_Singleton() {
812 +        testInvokeAll3(singletonPool());
813 +    }
814 +    public void testInvokeAll3(ForkJoinPool pool) {
815          RecursiveAction a = new CheckedRecursiveAction() {
816              protected void realCompute() {
817 <                AsyncFib f = new AsyncFib(8);
818 <                AsyncFib g = new AsyncFib(9);
819 <                AsyncFib h = new AsyncFib(7);
820 <                invokeAll(f, g, h);
821 <                assertEquals(21, f.number);
822 <                assertEquals(34, g.number);
823 <                assertEquals(13, h.number);
824 <                checkCompletedNormally(f);
694 <                checkCompletedNormally(g);
695 <                checkCompletedNormally(h);
817 >                AsyncFib[] tasks = {
818 >                    new AsyncFib(8),
819 >                    new AsyncFib(9),
820 >                    new AsyncFib(7),
821 >                };
822 >                invokeAll(tasks[0], tasks[1], tasks[2]);
823 >                for (AsyncFib task : tasks) assertTrue(task.isDone());
824 >                for (AsyncFib task : tasks) task.checkCompletedNormally();
825              }};
826 <        testInvokeOnPool(mainPool(), a);
826 >        testInvokeOnPool(pool, a);
827      }
828  
829      /**
830       * invokeAll(collection) invokes all tasks in the collection
831       */
832      public void testInvokeAllCollection() {
833 +        testInvokeAllCollection(mainPool());
834 +    }
835 +    public void testInvokeAllCollection_Singleton() {
836 +        testInvokeAllCollection(singletonPool());
837 +    }
838 +    public void testInvokeAllCollection(ForkJoinPool pool) {
839          RecursiveAction a = new CheckedRecursiveAction() {
840              protected void realCompute() {
841 <                AsyncFib f = new AsyncFib(8);
842 <                AsyncFib g = new AsyncFib(9);
843 <                AsyncFib h = new AsyncFib(7);
844 <                HashSet set = new HashSet();
845 <                set.add(f);
846 <                set.add(g);
847 <                set.add(h);
848 <                invokeAll(set);
714 <                assertEquals(21, f.number);
715 <                assertEquals(34, g.number);
716 <                assertEquals(13, h.number);
717 <                checkCompletedNormally(f);
718 <                checkCompletedNormally(g);
719 <                checkCompletedNormally(h);
841 >                AsyncFib[] tasks = {
842 >                    new AsyncFib(8),
843 >                    new AsyncFib(9),
844 >                    new AsyncFib(7),
845 >                };
846 >                invokeAll(Arrays.asList(tasks));
847 >                for (AsyncFib task : tasks) assertTrue(task.isDone());
848 >                for (AsyncFib task : tasks) task.checkCompletedNormally();
849              }};
850 <        testInvokeOnPool(mainPool(), a);
850 >        testInvokeOnPool(pool, a);
851      }
852  
853      /**
854 <     * invokeAll(tasks) with any null task throws NPE
854 >     * invokeAll(tasks) with any null task throws NullPointerException
855       */
856 <    public void testInvokeAllNPE() {
856 >    public void testInvokeAllNullTask() {
857 >        testInvokeAllNullTask(mainPool());
858 >    }
859 >    public void testInvokeAllNullTask_Singleton() {
860 >        testInvokeAllNullTask(singletonPool());
861 >    }
862 >    public void testInvokeAllNullTask(ForkJoinPool pool) {
863          RecursiveAction a = new CheckedRecursiveAction() {
864              protected void realCompute() {
865 <                AsyncFib f = new AsyncFib(8);
866 <                AsyncFib g = new AsyncFib(9);
867 <                AsyncFib h = null;
868 <                try {
869 <                    invokeAll(f, g, h);
870 <                    shouldThrow();
871 <                } catch (NullPointerException success) {}
865 >                AsyncFib nul = null;
866 >                Runnable[] throwingActions = {
867 >                    () -> invokeAll(nul),
868 >                    () -> invokeAll(nul, nul),
869 >                    () -> invokeAll(new AsyncFib(8), new AsyncFib(9), nul),
870 >                    () -> invokeAll(new AsyncFib(8), nul, new AsyncFib(9)),
871 >                    () -> invokeAll(nul, new AsyncFib(8), new AsyncFib(9)),
872 >                };
873 >                assertThrows(NullPointerException.class, throwingActions);
874              }};
875 <        testInvokeOnPool(mainPool(), a);
875 >        testInvokeOnPool(pool, a);
876      }
877  
878      /**
879 <     * invokeAll(t1, t2) throw exception if any task does
879 >     * invokeAll(tasks) with 1 argument throws exception if task does
880       */
881 <    public void testAbnormalInvokeAll2() {
881 >    public void testAbnormalInvokeAll1() {
882 >        testAbnormalInvokeAll1(mainPool());
883 >    }
884 >    public void testAbnormalInvokeAll1_Singleton() {
885 >        testAbnormalInvokeAll1(singletonPool());
886 >    }
887 >    public void testAbnormalInvokeAll1(ForkJoinPool pool) {
888          RecursiveAction a = new CheckedRecursiveAction() {
889              protected void realCompute() {
747                AsyncFib f = new AsyncFib(8);
890                  FailingAsyncFib g = new FailingAsyncFib(9);
891                  try {
892 <                    invokeAll(f, g);
892 >                    invokeAll(g);
893                      shouldThrow();
894                  } catch (FJException success) {
895                      checkCompletedAbnormally(g, success);
896                  }
897              }};
898 <        testInvokeOnPool(mainPool(), a);
898 >        testInvokeOnPool(pool, a);
899      }
900  
901      /**
902 <     * invokeAll(tasks) with 1 argument throws exception if task does
902 >     * invokeAll(t1, t2) throw exception if any task does
903       */
904 <    public void testAbnormalInvokeAll1() {
904 >    public void testAbnormalInvokeAll2() {
905 >        testAbnormalInvokeAll2(mainPool());
906 >    }
907 >    public void testAbnormalInvokeAll2_Singleton() {
908 >        testAbnormalInvokeAll2(singletonPool());
909 >    }
910 >    public void testAbnormalInvokeAll2(ForkJoinPool pool) {
911          RecursiveAction a = new CheckedRecursiveAction() {
912              protected void realCompute() {
913 +                AsyncFib f = new AsyncFib(8);
914                  FailingAsyncFib g = new FailingAsyncFib(9);
915 +                ForkJoinTask[] tasks = { f, g };
916 +                Collections.shuffle(Arrays.asList(tasks));
917                  try {
918 <                    invokeAll(g);
918 >                    invokeAll(tasks[0], tasks[1]);
919                      shouldThrow();
920                  } catch (FJException success) {
921                      checkCompletedAbnormally(g, success);
922                  }
923              }};
924 <        testInvokeOnPool(mainPool(), a);
924 >        testInvokeOnPool(pool, a);
925      }
926  
927      /**
928       * invokeAll(tasks) with > 2 argument throws exception if any task does
929       */
930      public void testAbnormalInvokeAll3() {
931 +        testAbnormalInvokeAll3(mainPool());
932 +    }
933 +    public void testAbnormalInvokeAll3_Singleton() {
934 +        testAbnormalInvokeAll3(singletonPool());
935 +    }
936 +    public void testAbnormalInvokeAll3(ForkJoinPool pool) {
937          RecursiveAction a = new CheckedRecursiveAction() {
938              protected void realCompute() {
939                  AsyncFib f = new AsyncFib(8);
940                  FailingAsyncFib g = new FailingAsyncFib(9);
941                  AsyncFib h = new AsyncFib(7);
942 +                ForkJoinTask[] tasks = { f, g, h };
943 +                Collections.shuffle(Arrays.asList(tasks));
944                  try {
945 <                    invokeAll(f, g, h);
945 >                    invokeAll(tasks[0], tasks[1], tasks[2]);
946                      shouldThrow();
947                  } catch (FJException success) {
948                      checkCompletedAbnormally(g, success);
949                  }
950              }};
951 <        testInvokeOnPool(mainPool(), a);
951 >        testInvokeOnPool(pool, a);
952      }
953  
954      /**
955       * invokeAll(collection) throws exception if any task does
956       */
957      public void testAbnormalInvokeAllCollection() {
958 +        testAbnormalInvokeAllCollection(mainPool());
959 +    }
960 +    public void testAbnormalInvokeAllCollection_Singleton() {
961 +        testAbnormalInvokeAllCollection(singletonPool());
962 +    }
963 +    public void testAbnormalInvokeAllCollection(ForkJoinPool pool) {
964          RecursiveAction a = new CheckedRecursiveAction() {
965              protected void realCompute() {
966                  FailingAsyncFib f = new FailingAsyncFib(8);
967                  AsyncFib g = new AsyncFib(9);
968                  AsyncFib h = new AsyncFib(7);
969 <                HashSet set = new HashSet();
970 <                set.add(f);
806 <                set.add(g);
807 <                set.add(h);
969 >                ForkJoinTask[] tasks = { f, g, h };
970 >                Collections.shuffle(Arrays.asList(tasks));
971                  try {
972 <                    invokeAll(set);
972 >                    invokeAll(Arrays.asList(tasks));
973                      shouldThrow();
974                  } catch (FJException success) {
975                      checkCompletedAbnormally(f, success);
976                  }
977              }};
978 <        testInvokeOnPool(mainPool(), a);
978 >        testInvokeOnPool(pool, a);
979      }
980  
981      /**
# Line 829 | Line 992 | public class ForkJoinTask8Test extends J
992                  assertTrue(f.tryUnfork());
993                  helpQuiesce();
994                  checkNotDone(f);
995 <                checkCompletedNormally(g);
995 >                g.checkCompletedNormally();
996              }};
997          testInvokeOnPool(singletonPool(), a);
998      }
# Line 850 | Line 1013 | public class ForkJoinTask8Test extends J
1013                  assertTrue(getSurplusQueuedTaskCount() > 0);
1014                  helpQuiesce();
1015                  assertEquals(0, getSurplusQueuedTaskCount());
1016 <                checkCompletedNormally(f);
1017 <                checkCompletedNormally(g);
1018 <                checkCompletedNormally(h);
1016 >                f.checkCompletedNormally();
1017 >                g.checkCompletedNormally();
1018 >                h.checkCompletedNormally();
1019              }};
1020          testInvokeOnPool(singletonPool(), a);
1021      }
# Line 869 | Line 1032 | public class ForkJoinTask8Test extends J
1032                  assertSame(f, f.fork());
1033                  assertSame(f, peekNextLocalTask());
1034                  assertNull(f.join());
1035 <                checkCompletedNormally(f);
1035 >                f.checkCompletedNormally();
1036                  helpQuiesce();
1037 <                checkCompletedNormally(g);
1037 >                g.checkCompletedNormally();
1038              }};
1039          testInvokeOnPool(singletonPool(), a);
1040      }
# Line 890 | Line 1053 | public class ForkJoinTask8Test extends J
1053                  assertSame(f, pollNextLocalTask());
1054                  helpQuiesce();
1055                  checkNotDone(f);
1056 <                assertEquals(34, g.number);
894 <                checkCompletedNormally(g);
1056 >                g.checkCompletedNormally();
1057              }};
1058          testInvokeOnPool(singletonPool(), a);
1059      }
# Line 909 | Line 1071 | public class ForkJoinTask8Test extends J
1071                  assertSame(f, pollTask());
1072                  helpQuiesce();
1073                  checkNotDone(f);
1074 <                checkCompletedNormally(g);
1074 >                g.checkCompletedNormally();
1075              }};
1076          testInvokeOnPool(singletonPool(), a);
1077      }
# Line 927 | Line 1089 | public class ForkJoinTask8Test extends J
1089                  assertSame(g, peekNextLocalTask());
1090                  assertNull(f.join());
1091                  helpQuiesce();
1092 <                checkCompletedNormally(f);
1093 <                assertEquals(34, g.number);
932 <                checkCompletedNormally(g);
1092 >                f.checkCompletedNormally();
1093 >                g.checkCompletedNormally();
1094              }};
1095          testInvokeOnPool(asyncSingletonPool(), a);
1096      }
# Line 947 | Line 1108 | public class ForkJoinTask8Test extends J
1108                  assertSame(f, f.fork());
1109                  assertSame(g, pollNextLocalTask());
1110                  helpQuiesce();
1111 <                assertEquals(21, f.number);
951 <                checkCompletedNormally(f);
1111 >                f.checkCompletedNormally();
1112                  checkNotDone(g);
1113              }};
1114          testInvokeOnPool(asyncSingletonPool(), a);
# Line 967 | Line 1127 | public class ForkJoinTask8Test extends J
1127                  assertSame(f, f.fork());
1128                  assertSame(g, pollTask());
1129                  helpQuiesce();
1130 <                assertEquals(21, f.number);
971 <                checkCompletedNormally(f);
1130 >                f.checkCompletedNormally();
1131                  checkNotDone(g);
1132              }};
1133          testInvokeOnPool(asyncSingletonPool(), a);
1134      }
1135  
977    // versions for singleton pools
978
979    /**
980     * invoke returns when task completes normally.
981     * isCompletedAbnormally and isCancelled return false for normally
982     * completed tasks; getRawResult returns null.
983     */
984    public void testInvokeSingleton() {
985        RecursiveAction a = new CheckedRecursiveAction() {
986            protected void realCompute() {
987                AsyncFib f = new AsyncFib(8);
988                assertNull(f.invoke());
989                assertEquals(21, f.number);
990                checkCompletedNormally(f);
991            }};
992        testInvokeOnPool(singletonPool(), a);
993    }
994
995    /**
996     * quietlyInvoke task returns when task completes normally.
997     * isCompletedAbnormally and isCancelled return false for normally
998     * completed tasks
999     */
1000    public void testQuietlyInvokeSingleton() {
1001        RecursiveAction a = new CheckedRecursiveAction() {
1002            protected void realCompute() {
1003                AsyncFib f = new AsyncFib(8);
1004                f.quietlyInvoke();
1005                assertEquals(21, f.number);
1006                checkCompletedNormally(f);
1007            }};
1008        testInvokeOnPool(singletonPool(), a);
1009    }
1010
1011    /**
1012     * join of a forked task returns when task completes
1013     */
1014    public void testForkJoinSingleton() {
1015        RecursiveAction a = new CheckedRecursiveAction() {
1016            protected void realCompute() {
1017                AsyncFib f = new AsyncFib(8);
1018                assertSame(f, f.fork());
1019                assertNull(f.join());
1020                assertEquals(21, f.number);
1021                checkCompletedNormally(f);
1022            }};
1023        testInvokeOnPool(singletonPool(), a);
1024    }
1025
1026    /**
1027     * get of a forked task returns when task completes
1028     */
1029    public void testForkGetSingleton() {
1030        RecursiveAction a = new CheckedRecursiveAction() {
1031            protected void realCompute() throws Exception {
1032                AsyncFib f = new AsyncFib(8);
1033                assertSame(f, f.fork());
1034                assertNull(f.get());
1035                assertEquals(21, f.number);
1036                checkCompletedNormally(f);
1037            }};
1038        testInvokeOnPool(singletonPool(), a);
1039    }
1040
1041    /**
1042     * timed get of a forked task returns when task completes
1043     */
1044    public void testForkTimedGetSingleton() {
1045        RecursiveAction a = new CheckedRecursiveAction() {
1046            protected void realCompute() throws Exception {
1047                AsyncFib f = new AsyncFib(8);
1048                assertSame(f, f.fork());
1049                assertNull(f.get(LONG_DELAY_MS, MILLISECONDS));
1050                assertEquals(21, f.number);
1051                checkCompletedNormally(f);
1052            }};
1053        testInvokeOnPool(singletonPool(), a);
1054    }
1055
1056    /**
1057     * timed get with null time unit throws NPE
1058     */
1059    public void testForkTimedGetNPESingleton() {
1060        RecursiveAction a = new CheckedRecursiveAction() {
1061            protected void realCompute() throws Exception {
1062                AsyncFib f = new AsyncFib(8);
1063                assertSame(f, f.fork());
1064                try {
1065                    f.get(5L, null);
1066                    shouldThrow();
1067                } catch (NullPointerException success) {}
1068            }};
1069        testInvokeOnPool(singletonPool(), a);
1070    }
1071
1072    /**
1073     * quietlyJoin of a forked task returns when task completes
1074     */
1075    public void testForkQuietlyJoinSingleton() {
1076        RecursiveAction a = new CheckedRecursiveAction() {
1077            protected void realCompute() {
1078                AsyncFib f = new AsyncFib(8);
1079                assertSame(f, f.fork());
1080                f.quietlyJoin();
1081                assertEquals(21, f.number);
1082                checkCompletedNormally(f);
1083            }};
1084        testInvokeOnPool(singletonPool(), a);
1085    }
1086
1087    /**
1088     * helpQuiesce returns when tasks are complete.
1089     * getQueuedTaskCount returns 0 when quiescent
1090     */
1091    public void testForkHelpQuiesceSingleton() {
1092        RecursiveAction a = new CheckedRecursiveAction() {
1093            protected void realCompute() {
1094                AsyncFib f = new AsyncFib(8);
1095                assertSame(f, f.fork());
1096                helpQuiesce();
1097                assertEquals(0, getQueuedTaskCount());
1098                assertEquals(21, f.number);
1099                checkCompletedNormally(f);
1100            }};
1101        testInvokeOnPool(singletonPool(), a);
1102    }
1103
1104    /**
1105     * invoke task throws exception when task completes abnormally
1106     */
1107    public void testAbnormalInvokeSingleton() {
1108        RecursiveAction a = new CheckedRecursiveAction() {
1109            protected void realCompute() {
1110                FailingAsyncFib f = new FailingAsyncFib(8);
1111                try {
1112                    f.invoke();
1113                    shouldThrow();
1114                } catch (FJException success) {
1115                    checkCompletedAbnormally(f, success);
1116                }
1117            }};
1118        testInvokeOnPool(singletonPool(), a);
1119    }
1120
1121    /**
1122     * quietlyInvoke task returns when task completes abnormally
1123     */
1124    public void testAbnormalQuietlyInvokeSingleton() {
1125        RecursiveAction a = new CheckedRecursiveAction() {
1126            protected void realCompute() {
1127                FailingAsyncFib f = new FailingAsyncFib(8);
1128                f.quietlyInvoke();
1129                assertTrue(f.getException() instanceof FJException);
1130                checkCompletedAbnormally(f, f.getException());
1131            }};
1132        testInvokeOnPool(singletonPool(), a);
1133    }
1134
1135    /**
1136     * join of a forked task throws exception when task completes abnormally
1137     */
1138    public void testAbnormalForkJoinSingleton() {
1139        RecursiveAction a = new CheckedRecursiveAction() {
1140            protected void realCompute() {
1141                FailingAsyncFib f = new FailingAsyncFib(8);
1142                assertSame(f, f.fork());
1143                try {
1144                    f.join();
1145                    shouldThrow();
1146                } catch (FJException success) {
1147                    checkCompletedAbnormally(f, success);
1148                }
1149            }};
1150        testInvokeOnPool(singletonPool(), a);
1151    }
1152
1153    /**
1154     * get of a forked task throws exception when task completes abnormally
1155     */
1156    public void testAbnormalForkGetSingleton() {
1157        RecursiveAction a = new CheckedRecursiveAction() {
1158            protected void realCompute() throws Exception {
1159                FailingAsyncFib f = new FailingAsyncFib(8);
1160                assertSame(f, f.fork());
1161                try {
1162                    f.get();
1163                    shouldThrow();
1164                } catch (ExecutionException success) {
1165                    Throwable cause = success.getCause();
1166                    assertTrue(cause instanceof FJException);
1167                    checkCompletedAbnormally(f, cause);
1168                }
1169            }};
1170        testInvokeOnPool(singletonPool(), a);
1171    }
1172
1173    /**
1174     * timed get of a forked task throws exception when task completes abnormally
1175     */
1176    public void testAbnormalForkTimedGetSingleton() {
1177        RecursiveAction a = new CheckedRecursiveAction() {
1178            protected void realCompute() throws Exception {
1179                FailingAsyncFib f = new FailingAsyncFib(8);
1180                assertSame(f, f.fork());
1181                try {
1182                    f.get(LONG_DELAY_MS, MILLISECONDS);
1183                    shouldThrow();
1184                } catch (ExecutionException success) {
1185                    Throwable cause = success.getCause();
1186                    assertTrue(cause instanceof FJException);
1187                    checkCompletedAbnormally(f, cause);
1188                }
1189            }};
1190        testInvokeOnPool(singletonPool(), a);
1191    }
1192
1193    /**
1194     * quietlyJoin of a forked task returns when task completes abnormally
1195     */
1196    public void testAbnormalForkQuietlyJoinSingleton() {
1197        RecursiveAction a = new CheckedRecursiveAction() {
1198            protected void realCompute() {
1199                FailingAsyncFib f = new FailingAsyncFib(8);
1200                assertSame(f, f.fork());
1201                f.quietlyJoin();
1202                assertTrue(f.getException() instanceof FJException);
1203                checkCompletedAbnormally(f, f.getException());
1204            }};
1205        testInvokeOnPool(singletonPool(), a);
1206    }
1207
1208    /**
1209     * invoke task throws exception after invoking completeExceptionally
1210     */
1211    public void testCompleteExceptionallySingleton() {
1212        RecursiveAction a = new CheckedRecursiveAction() {
1213            protected void realCompute() {
1214                AsyncFib f = new AsyncFib(8);
1215                f.completeExceptionally(new FJException());
1216                try {
1217                    f.invoke();
1218                    shouldThrow();
1219                } catch (FJException success) {
1220                    checkCompletedAbnormally(f, success);
1221                }
1222            }};
1223        testInvokeOnPool(singletonPool(), a);
1224    }
1225
1226    /**
1227     * invokeAll(t1, t2) invokes all task arguments
1228     */
1229    public void testInvokeAll2Singleton() {
1230        RecursiveAction a = new CheckedRecursiveAction() {
1231            protected void realCompute() {
1232                AsyncFib f = new AsyncFib(8);
1233                AsyncFib g = new AsyncFib(9);
1234                invokeAll(f, g);
1235                assertEquals(21, f.number);
1236                assertEquals(34, g.number);
1237                checkCompletedNormally(f);
1238                checkCompletedNormally(g);
1239            }};
1240        testInvokeOnPool(singletonPool(), a);
1241    }
1242
1243    /**
1244     * invokeAll(tasks) with 1 argument invokes task
1245     */
1246    public void testInvokeAll1Singleton() {
1247        RecursiveAction a = new CheckedRecursiveAction() {
1248            protected void realCompute() {
1249                AsyncFib f = new AsyncFib(8);
1250                invokeAll(f);
1251                checkCompletedNormally(f);
1252                assertEquals(21, f.number);
1253            }};
1254        testInvokeOnPool(singletonPool(), a);
1255    }
1256
1257    /**
1258     * invokeAll(tasks) with > 2 argument invokes tasks
1259     */
1260    public void testInvokeAll3Singleton() {
1261        RecursiveAction a = new CheckedRecursiveAction() {
1262            protected void realCompute() {
1263                AsyncFib f = new AsyncFib(8);
1264                AsyncFib g = new AsyncFib(9);
1265                AsyncFib h = new AsyncFib(7);
1266                invokeAll(f, g, h);
1267                assertEquals(21, f.number);
1268                assertEquals(34, g.number);
1269                assertEquals(13, h.number);
1270                checkCompletedNormally(f);
1271                checkCompletedNormally(g);
1272                checkCompletedNormally(h);
1273            }};
1274        testInvokeOnPool(singletonPool(), a);
1275    }
1276
1277    /**
1278     * invokeAll(collection) invokes all tasks in the collection
1279     */
1280    public void testInvokeAllCollectionSingleton() {
1281        RecursiveAction a = new CheckedRecursiveAction() {
1282            protected void realCompute() {
1283                AsyncFib f = new AsyncFib(8);
1284                AsyncFib g = new AsyncFib(9);
1285                AsyncFib h = new AsyncFib(7);
1286                HashSet set = new HashSet();
1287                set.add(f);
1288                set.add(g);
1289                set.add(h);
1290                invokeAll(set);
1291                assertEquals(21, f.number);
1292                assertEquals(34, g.number);
1293                assertEquals(13, h.number);
1294                checkCompletedNormally(f);
1295                checkCompletedNormally(g);
1296                checkCompletedNormally(h);
1297            }};
1298        testInvokeOnPool(singletonPool(), a);
1299    }
1300
1301    /**
1302     * invokeAll(tasks) with any null task throws NPE
1303     */
1304    public void testInvokeAllNPESingleton() {
1305        RecursiveAction a = new CheckedRecursiveAction() {
1306            protected void realCompute() {
1307                AsyncFib f = new AsyncFib(8);
1308                AsyncFib g = new AsyncFib(9);
1309                AsyncFib h = null;
1310                try {
1311                    invokeAll(f, g, h);
1312                    shouldThrow();
1313                } catch (NullPointerException success) {}
1314            }};
1315        testInvokeOnPool(singletonPool(), a);
1316    }
1317
1318    /**
1319     * invokeAll(t1, t2) throw exception if any task does
1320     */
1321    public void testAbnormalInvokeAll2Singleton() {
1322        RecursiveAction a = new CheckedRecursiveAction() {
1323            protected void realCompute() {
1324                AsyncFib f = new AsyncFib(8);
1325                FailingAsyncFib g = new FailingAsyncFib(9);
1326                try {
1327                    invokeAll(f, g);
1328                    shouldThrow();
1329                } catch (FJException success) {
1330                    checkCompletedAbnormally(g, success);
1331                }
1332            }};
1333        testInvokeOnPool(singletonPool(), a);
1334    }
1335
1336    /**
1337     * invokeAll(tasks) with 1 argument throws exception if task does
1338     */
1339    public void testAbnormalInvokeAll1Singleton() {
1340        RecursiveAction a = new CheckedRecursiveAction() {
1341            protected void realCompute() {
1342                FailingAsyncFib g = new FailingAsyncFib(9);
1343                try {
1344                    invokeAll(g);
1345                    shouldThrow();
1346                } catch (FJException success) {
1347                    checkCompletedAbnormally(g, success);
1348                }
1349            }};
1350        testInvokeOnPool(singletonPool(), a);
1351    }
1352
1353    /**
1354     * invokeAll(tasks) with > 2 argument throws exception if any task does
1355     */
1356    public void testAbnormalInvokeAll3Singleton() {
1357        RecursiveAction a = new CheckedRecursiveAction() {
1358            protected void realCompute() {
1359                AsyncFib f = new AsyncFib(8);
1360                FailingAsyncFib g = new FailingAsyncFib(9);
1361                AsyncFib h = new AsyncFib(7);
1362                try {
1363                    invokeAll(f, g, h);
1364                    shouldThrow();
1365                } catch (FJException success) {
1366                    checkCompletedAbnormally(g, success);
1367                }
1368            }};
1369        testInvokeOnPool(singletonPool(), a);
1370    }
1371
1372    /**
1373     * invokeAll(collection) throws exception if any task does
1374     */
1375    public void testAbnormalInvokeAllCollectionSingleton() {
1376        RecursiveAction a = new CheckedRecursiveAction() {
1377            protected void realCompute() {
1378                FailingAsyncFib f = new FailingAsyncFib(8);
1379                AsyncFib g = new AsyncFib(9);
1380                AsyncFib h = new AsyncFib(7);
1381                HashSet set = new HashSet();
1382                set.add(f);
1383                set.add(g);
1384                set.add(h);
1385                try {
1386                    invokeAll(set);
1387                    shouldThrow();
1388                } catch (FJException success) {
1389                    checkCompletedAbnormally(f, success);
1390                }
1391            }};
1392        testInvokeOnPool(singletonPool(), a);
1393    }
1394
1136      /**
1137       * ForkJoinTask.quietlyComplete returns when task completes
1138       * normally without setting a value. The most recent value
# Line 1413 | Line 1154 | public class ForkJoinTask8Test extends J
1154          testInvokeOnPool(mainPool(), a);
1155      }
1156  
1157 +    // jdk9
1158 +    
1159 +    /**
1160 +     * pollSubmission returns unexecuted submitted task, if present
1161 +     */
1162 +    public void testPollSubmission() {
1163 +        final CountDownLatch done = new CountDownLatch(1);
1164 +        final ForkJoinTask a = ForkJoinTask.adapt(awaiter(done));
1165 +        final ForkJoinTask b = ForkJoinTask.adapt(awaiter(done));
1166 +        final ForkJoinTask c = ForkJoinTask.adapt(awaiter(done));
1167 +        final ForkJoinPool p = singletonPool();
1168 +        Thread external = new Thread() {
1169 +                public void run() {
1170 +                    p.execute(a);
1171 +                    p.execute(b);
1172 +                    p.execute(c);
1173 +                }};
1174 +        RecursiveAction s = new CheckedRecursiveAction() {
1175 +                protected void realCompute() {
1176 +                    external.start();
1177 +                    try {
1178 +                        external.join();
1179 +                    } catch(Exception ex) {
1180 +                        threadUnexpectedException(ex);
1181 +                    }
1182 +                    assertTrue(p.hasQueuedSubmissions());
1183 +                    assertTrue(Thread.currentThread() instanceof ForkJoinWorkerThread);
1184 +                    ForkJoinTask r = ForkJoinTask.pollSubmission();
1185 +                    assertTrue(r == a || r == b || r == c);
1186 +                    assertFalse(r.isDone());
1187 +                }};
1188 +        try {
1189 +            p.invoke(s);
1190 +        } finally {
1191 +            done.countDown();
1192 +            joinPool(p);
1193 +        }
1194 +    }
1195 +
1196 +    
1197   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines