--- jsr166/src/test/tck/CountedCompleterTest.java 2013/06/03 16:46:12 1.6 +++ jsr166/src/test/tck/CountedCompleterTest.java 2013/06/04 23:07:11 1.8 @@ -12,7 +12,9 @@ import java.util.concurrent.ForkJoinWork import java.util.concurrent.RecursiveAction; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; +import java.util.concurrent.atomic.AtomicReference; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; import java.util.HashSet; @@ -32,21 +34,6 @@ public class CountedCompleterTest extend static final int mainPoolSize = Math.max(2, Runtime.getRuntime().availableProcessors()); - /** - * Analog of CheckedRunnable for ForkJoinTasks - */ - public abstract class CheckedFJTask extends RecursiveAction { - protected abstract void realCompute() throws Throwable; - - public final void compute() { - try { - realCompute(); - } catch (Throwable t) { - threadUnexpectedException(t); - } - } - } - private static ForkJoinPool mainPool() { return new ForkJoinPool(mainPoolSize); } @@ -98,22 +85,18 @@ public class CountedCompleterTest extend } catch (Throwable fail) { threadUnexpectedException(fail); } } - void checkCompletedNormally(CountedCompleter a) { - checkCompletedNormally(a, null); - } - - void checkCompletedNormally(CountedCompleter a, T expected) { + void checkCompletedNormally(CountedCompleter a) { assertTrue(a.isDone()); assertFalse(a.isCancelled()); assertTrue(a.isCompletedNormally()); assertFalse(a.isCompletedAbnormally()); assertNull(a.getException()); - assertSame(expected, a.getRawResult()); + assertNull(a.getRawResult()); { Thread.currentThread().interrupt(); long t0 = System.nanoTime(); - assertSame(expected, a.join()); + assertNull(a.join()); assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS); Thread.interrupted(); } @@ -129,10 +112,10 @@ public class CountedCompleterTest extend assertFalse(a.cancel(false)); assertFalse(a.cancel(true)); try { - assertSame(expected, a.get()); + assertNull(a.get()); } catch (Throwable fail) { threadUnexpectedException(fail); } try { - assertSame(expected, a.get(5L, SECONDS)); + assertNull(a.get(5L, SECONDS)); } catch (Throwable fail) { threadUnexpectedException(fail); } } @@ -211,72 +194,132 @@ public class CountedCompleterTest extend } catch (ExecutionException success) { assertSame(t.getClass(), success.getCause().getClass()); } catch (Throwable fail) { threadUnexpectedException(fail); } + + try { + a.invoke(); + shouldThrow(); + } catch (Throwable ex) { + assertSame(t, ex); + } } public static final class FJException extends RuntimeException { FJException() { super(); } } - static final class NoopCountedCompleter extends CountedCompleter { - boolean post; // set true if onCompletion called - NoopCountedCompleter() { super(); } - NoopCountedCompleter(CountedCompleter p) { super(p); } - public void compute() {} - public final void onCompletion(CountedCompleter caller) { - post = true; + abstract class CheckedCC extends CountedCompleter { + final AtomicInteger computeN = new AtomicInteger(0); + final AtomicInteger onCompletionN = new AtomicInteger(0); + final AtomicInteger onExceptionalCompletionN = new AtomicInteger(0); + final AtomicInteger setRawResultN = new AtomicInteger(0); + final AtomicReference rawResult = new AtomicReference<>(null); + int computeN() { return computeN.get(); } + int onCompletionN() { return onCompletionN.get(); } + int onExceptionalCompletionN() { return onExceptionalCompletionN.get(); } + int setRawResultN() { return setRawResultN.get(); } + + CheckedCC() { super(); } + CheckedCC(CountedCompleter p) { super(p); } + CheckedCC(CountedCompleter p, int n) { super(p, n); } + abstract void realCompute(); + public final void compute() { + computeN.incrementAndGet(); + realCompute(); + } + public void onCompletion(CountedCompleter caller) { + onCompletionN.incrementAndGet(); + super.onCompletion(caller); + } + public boolean onExceptionalCompletion(Throwable ex, + CountedCompleter caller) { + onExceptionalCompletionN.incrementAndGet(); + assertNotNull(ex); + assertTrue(isCompletedAbnormally()); + assertTrue(super.onExceptionalCompletion(ex, caller)); + return true; + } + protected void setRawResult(Object t) { + setRawResultN.incrementAndGet(); + rawResult.set(t); + super.setRawResult(t); + } + void checkIncomplete() { + assertEquals(0, computeN()); + assertEquals(0, onCompletionN()); + assertEquals(0, onExceptionalCompletionN()); + assertEquals(0, setRawResultN()); + checkNotDone(this); + } + void checkCompletes(Object rawResult) { + checkIncomplete(); + complete(rawResult); + assertEquals(0, computeN()); + assertEquals(1, onCompletionN()); + assertEquals(0, onExceptionalCompletionN()); + assertEquals(1, setRawResultN()); + assertSame(rawResult, this.rawResult.get()); + checkCompletedNormally(this); + } + void checkCompletesExceptionally(Throwable ex) { + checkIncomplete(); + completeExceptionally(ex); + checkCompletedExceptionally(ex); + } + void checkCompletedExceptionally(Throwable ex) { + assertEquals(0, computeN()); + assertEquals(0, onCompletionN()); + assertEquals(1, onExceptionalCompletionN()); + assertEquals(0, setRawResultN()); + assertNull(this.rawResult.get()); + checkCompletedAbnormally(this, ex); } } + final class NoopCC extends CheckedCC { + NoopCC() { super(); } + NoopCC(CountedCompleter p) { super(p); } + protected void realCompute() {} + } + /** * A newly constructed CountedCompleter is not completed; * complete() causes completion. */ public void testComplete() { - NoopCountedCompleter a = new NoopCountedCompleter(); - assertFalse(a.isDone()); - assertFalse(a.isCompletedNormally()); - assertFalse(a.isCompletedAbnormally()); - assertFalse(a.isCancelled()); - assertNull(a.getException()); - assertNull(a.getRawResult()); - assertFalse(a.post); - a.complete(null); - assertTrue(a.post); - assertTrue(a.isDone()); - assertTrue(a.isCompletedNormally()); - assertFalse(a.isCompletedAbnormally()); - assertFalse(a.isCancelled()); - assertNull(a.getException()); - assertNull(a.getRawResult()); + for (Object x : new Object[] { Boolean.TRUE, null }) { + new NoopCC() + .checkCompletes(x); + new NoopCC(new NoopCC()) + .checkCompletes(x); + } } /** * completeExceptionally completes exceptionally */ public void testCompleteExceptionally() { - NoopCountedCompleter a = new NoopCountedCompleter(); - assertFalse(a.isDone()); - assertFalse(a.isCompletedNormally()); - assertFalse(a.isCompletedAbnormally()); - assertFalse(a.isCancelled()); - assertNull(a.getException()); - assertNull(a.getRawResult()); - assertFalse(a.post); - a.completeExceptionally(new FJException()); - assertFalse(a.post); - assertTrue(a.isDone()); - assertFalse(a.isCompletedNormally()); - assertTrue(a.isCompletedAbnormally()); - assertFalse(a.isCancelled()); - assertTrue(a.getException() instanceof FJException); - assertNull(a.getRawResult()); + new NoopCC() + .checkCompletesExceptionally(new FJException()); + new NoopCC(new NoopCC()) + .checkCompletesExceptionally(new FJException()); + } + + /** + * completeExceptionally(null) throws NullPointerException + */ + public void testCompleteExceptionally_null() { + try { + new NoopCC() + .checkCompletesExceptionally(null); + shouldThrow(); + } catch (NullPointerException success) {} } /** * setPendingCount sets the reported pending count */ public void testSetPendingCount() { - NoopCountedCompleter a = new NoopCountedCompleter(); + NoopCC a = new NoopCC(); assertEquals(0, a.getPendingCount()); a.setPendingCount(1); assertEquals(1, a.getPendingCount()); @@ -288,7 +331,7 @@ public class CountedCompleterTest extend * addToPendingCount adds to the reported pending count */ public void testAddToPendingCount() { - NoopCountedCompleter a = new NoopCountedCompleter(); + NoopCC a = new NoopCC(); assertEquals(0, a.getPendingCount()); a.addToPendingCount(1); assertEquals(1, a.getPendingCount()); @@ -301,7 +344,7 @@ public class CountedCompleterTest extend * count unless zero */ public void testDecrementPendingCount() { - NoopCountedCompleter a = new NoopCountedCompleter(); + NoopCC a = new NoopCC(); assertEquals(0, a.getPendingCount()); a.addToPendingCount(1); assertEquals(1, a.getPendingCount()); @@ -312,69 +355,95 @@ public class CountedCompleterTest extend } /** + * compareAndSetPendingCount compares and sets the reported + * pending count + */ + public void testCompareAndSetPendingCount() { + NoopCC a = new NoopCC(); + assertEquals(0, a.getPendingCount()); + assertTrue(a.compareAndSetPendingCount(0, 1)); + assertEquals(1, a.getPendingCount()); + assertTrue(a.compareAndSetPendingCount(1, 2)); + assertEquals(2, a.getPendingCount()); + assertFalse(a.compareAndSetPendingCount(1, 3)); + assertEquals(2, a.getPendingCount()); + } + + /** * getCompleter returns parent or null if at root */ public void testGetCompleter() { - NoopCountedCompleter a = new NoopCountedCompleter(); + NoopCC a = new NoopCC(); assertNull(a.getCompleter()); - CountedCompleter b = new NoopCountedCompleter(a); - assertEquals(a, b.getCompleter()); + CountedCompleter b = new NoopCC(a); + assertSame(a, b.getCompleter()); + CountedCompleter c = new NoopCC(b); + assertSame(b, c.getCompleter()); } /** * getRoot returns self if no parent, else parent's root */ public void testGetRoot() { - NoopCountedCompleter a = new NoopCountedCompleter(); - NoopCountedCompleter b = new NoopCountedCompleter(a); - assertEquals(a, a.getRoot()); - assertEquals(a, b.getRoot()); + NoopCC a = new NoopCC(); + NoopCC b = new NoopCC(a); + NoopCC c = new NoopCC(b); + assertSame(a, a.getRoot()); + assertSame(a, b.getRoot()); + assertSame(a, c.getRoot()); } /** - * tryComplete causes completion if pending count is zero + * tryComplete decrements pending count unless zero, in which case + * causes completion */ - public void testTryComplete1() { - NoopCountedCompleter a = new NoopCountedCompleter(); + public void testTryComplete() { + NoopCC a = new NoopCC(); assertEquals(0, a.getPendingCount()); + int n = 3; + a.setPendingCount(n); + for (; n > 0; n--) { + assertEquals(n, a.getPendingCount()); + a.tryComplete(); + a.checkIncomplete(); + assertEquals(n - 1, a.getPendingCount()); + } a.tryComplete(); - assertTrue(a.post); - assertTrue(a.isDone()); + assertEquals(0, a.computeN()); + assertEquals(1, a.onCompletionN()); + assertEquals(0, a.onExceptionalCompletionN()); + assertEquals(0, a.setRawResultN()); + checkCompletedNormally(a); } /** - * propagateCompletion causes completion without invoking - * onCompletion if pending count is zero + * propagateCompletion decrements pending count unless zero, in + * which case causes completion, without invoking onCompletion */ public void testPropagateCompletion() { - NoopCountedCompleter a = new NoopCountedCompleter(); + NoopCC a = new NoopCC(); assertEquals(0, a.getPendingCount()); + int n = 3; + a.setPendingCount(n); + for (; n > 0; n--) { + assertEquals(n, a.getPendingCount()); + a.propagateCompletion(); + a.checkIncomplete(); + assertEquals(n - 1, a.getPendingCount()); + } a.propagateCompletion(); - assertFalse(a.post); - assertTrue(a.isDone()); - } - - /** - * tryComplete decrements pending count unless zero - */ - public void testTryComplete2() { - NoopCountedCompleter a = new NoopCountedCompleter(); - assertEquals(0, a.getPendingCount()); - a.setPendingCount(1); - a.tryComplete(); - assertFalse(a.post); - assertFalse(a.isDone()); - assertEquals(0, a.getPendingCount()); - a.tryComplete(); - assertTrue(a.post); - assertTrue(a.isDone()); + assertEquals(0, a.computeN()); + assertEquals(0, a.onCompletionN()); + assertEquals(0, a.onExceptionalCompletionN()); + assertEquals(0, a.setRawResultN()); + checkCompletedNormally(a); } /** * firstComplete returns this if pending count is zero else null */ public void testFirstComplete() { - NoopCountedCompleter a = new NoopCountedCompleter(); + NoopCC a = new NoopCC(); a.setPendingCount(1); assertNull(a.firstComplete()); assertEquals(a, a.firstComplete()); @@ -385,30 +454,33 @@ public class CountedCompleterTest extend * zero else null */ public void testNextComplete() { - NoopCountedCompleter a = new NoopCountedCompleter(); - NoopCountedCompleter b = new NoopCountedCompleter(a); + NoopCC a = new NoopCC(); + NoopCC b = new NoopCC(a); a.setPendingCount(1); b.setPendingCount(1); assertNull(b.firstComplete()); CountedCompleter c = b.firstComplete(); - assertEquals(b, c); + assertSame(b, c); CountedCompleter d = c.nextComplete(); assertNull(d); CountedCompleter e = c.nextComplete(); - assertEquals(a, e); + assertSame(a, e); } /** * quietlyCompleteRoot completes root task */ public void testQuietlyCompleteRoot() { - NoopCountedCompleter a = new NoopCountedCompleter(); - NoopCountedCompleter b = new NoopCountedCompleter(a); + NoopCC a = new NoopCC(); + NoopCC b = new NoopCC(a); + NoopCC c = new NoopCC(b); a.setPendingCount(1); b.setPendingCount(1); - b.quietlyCompleteRoot(); + c.setPendingCount(1); + c.quietlyCompleteRoot(); assertTrue(a.isDone()); assertFalse(b.isDone()); + assertFalse(c.isDone()); } // Invocation tests use some interdependent task classes @@ -416,7 +488,7 @@ public class CountedCompleterTest extend // Version of Fibonacci with different classes for left vs right forks - abstract static class CCF extends CountedCompleter { + abstract class CCF extends CheckedCC { int number; int rnumber; @@ -425,28 +497,24 @@ public class CountedCompleterTest extend this.number = n; } - public final void compute() { - CountedCompleter p; + protected final void realCompute() { CCF f = this; int n = number; while (n >= 2) { new RCCF(f, n - 2).fork(); f = new LCCF(f, --n); } - f.number = n; - f.onCompletion(f); - if ((p = f.getCompleter()) != null) - p.tryComplete(); - else - f.quietlyComplete(); + f.complete(null); } } - static final class LCCF extends CCF { + final class LCCF extends CCF { + public LCCF(int n) { this(null, n); } public LCCF(CountedCompleter parent, int n) { super(parent, n); } public final void onCompletion(CountedCompleter caller) { + super.onCompletion(caller); CCF p = (CCF)getCompleter(); int n = number + rnumber; if (p != null) @@ -455,11 +523,12 @@ public class CountedCompleterTest extend number = n; } } - static final class RCCF extends CCF { + final class RCCF extends CCF { public RCCF(CountedCompleter parent, int n) { super(parent, n); } public final void onCompletion(CountedCompleter caller) { + super.onCompletion(caller); CCF p = (CCF)getCompleter(); int n = number + rnumber; if (p != null) @@ -470,7 +539,7 @@ public class CountedCompleterTest extend } // Version of CCF with forced failure in left completions - abstract static class FailingCCF extends CountedCompleter { + abstract class FailingCCF extends CheckedCC { int number; int rnumber; @@ -479,28 +548,24 @@ public class CountedCompleterTest extend this.number = n; } - public final void compute() { - CountedCompleter p; + protected final void realCompute() { FailingCCF f = this; int n = number; while (n >= 2) { new RFCCF(f, n - 2).fork(); f = new LFCCF(f, --n); } - f.number = n; - f.onCompletion(f); - if ((p = f.getCompleter()) != null) - p.tryComplete(); - else - f.quietlyComplete(); + f.complete(null); } } - static final class LFCCF extends FailingCCF { + final class LFCCF extends FailingCCF { + public LFCCF(int n) { this(null, n); } public LFCCF(CountedCompleter parent, int n) { super(parent, n); } public final void onCompletion(CountedCompleter caller) { + super.onCompletion(caller); FailingCCF p = (FailingCCF)getCompleter(); int n = number + rnumber; if (p != null) @@ -509,11 +574,12 @@ public class CountedCompleterTest extend number = n; } } - static final class RFCCF extends FailingCCF { + final class RFCCF extends FailingCCF { public RFCCF(CountedCompleter parent, int n) { super(parent, n); } public final void onCompletion(CountedCompleter caller) { + super.onCompletion(caller); completeExceptionally(new FJException()); } } @@ -524,9 +590,9 @@ public class CountedCompleterTest extend * completed tasks; getRawResult returns null. */ public void testInvoke() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertNull(f.invoke()); assertEquals(21, f.number); checkCompletedNormally(f); @@ -540,9 +606,9 @@ public class CountedCompleterTest extend * completed tasks */ public void testQuietlyInvoke() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); f.quietlyInvoke(); assertEquals(21, f.number); checkCompletedNormally(f); @@ -554,9 +620,9 @@ public class CountedCompleterTest extend * join of a forked task returns when task completes */ public void testForkJoin() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertSame(f, f.fork()); assertNull(f.join()); assertEquals(21, f.number); @@ -569,9 +635,9 @@ public class CountedCompleterTest extend * get of a forked task returns when task completes */ public void testForkGet() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + CCF f = new LCCF(8); assertSame(f, f.fork()); assertNull(f.get()); assertEquals(21, f.number); @@ -584,9 +650,9 @@ public class CountedCompleterTest extend * timed get of a forked task returns when task completes */ public void testForkTimedGet() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + CCF f = new LCCF(8); assertSame(f, f.fork()); assertNull(f.get(LONG_DELAY_MS, MILLISECONDS)); assertEquals(21, f.number); @@ -599,9 +665,9 @@ public class CountedCompleterTest extend * timed get with null time unit throws NPE */ public void testForkTimedGetNPE() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + CCF f = new LCCF(8); assertSame(f, f.fork()); try { f.get(5L, null); @@ -615,9 +681,9 @@ public class CountedCompleterTest extend * quietlyJoin of a forked task returns when task completes */ public void testForkQuietlyJoin() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertSame(f, f.fork()); f.quietlyJoin(); assertEquals(21, f.number); @@ -631,9 +697,9 @@ public class CountedCompleterTest extend * getQueuedTaskCount returns 0 when quiescent */ public void testForkHelpQuiesce() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertSame(f, f.fork()); helpQuiesce(); assertEquals(21, f.number); @@ -647,9 +713,9 @@ public class CountedCompleterTest extend * invoke task throws exception when task completes abnormally */ public void testAbnormalInvoke() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - FailingCCF f = new LFCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + FailingCCF f = new LFCCF(8); try { f.invoke(); shouldThrow(); @@ -664,9 +730,9 @@ public class CountedCompleterTest extend * quietlyInvoke task returns when task completes abnormally */ public void testAbnormalQuietlyInvoke() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - FailingCCF f = new LFCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + FailingCCF f = new LFCCF(8); f.quietlyInvoke(); assertTrue(f.getException() instanceof FJException); checkCompletedAbnormally(f, f.getException()); @@ -678,9 +744,9 @@ public class CountedCompleterTest extend * join of a forked task throws exception when task completes abnormally */ public void testAbnormalForkJoin() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - FailingCCF f = new LFCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); try { f.join(); @@ -696,9 +762,9 @@ public class CountedCompleterTest extend * get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkGet() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - FailingCCF f = new LFCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); try { f.get(); @@ -716,9 +782,9 @@ public class CountedCompleterTest extend * timed get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkTimedGet() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - FailingCCF f = new LFCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); try { f.get(LONG_DELAY_MS, MILLISECONDS); @@ -736,9 +802,9 @@ public class CountedCompleterTest extend * quietlyJoin of a forked task returns when task completes abnormally */ public void testAbnormalForkQuietlyJoin() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - FailingCCF f = new LFCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); f.quietlyJoin(); assertTrue(f.getException() instanceof FJException); @@ -751,9 +817,9 @@ public class CountedCompleterTest extend * invoke task throws exception when task cancelled */ public void testCancelledInvoke() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertTrue(f.cancel(true)); try { f.invoke(); @@ -769,9 +835,9 @@ public class CountedCompleterTest extend * join of a forked task throws exception when task cancelled */ public void testCancelledForkJoin() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { @@ -788,9 +854,9 @@ public class CountedCompleterTest extend * get of a forked task throws exception when task cancelled */ public void testCancelledForkGet() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + CCF f = new LCCF(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { @@ -807,9 +873,9 @@ public class CountedCompleterTest extend * timed get of a forked task throws exception when task cancelled */ public void testCancelledForkTimedGet() throws Exception { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + CCF f = new LCCF(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { @@ -826,9 +892,9 @@ public class CountedCompleterTest extend * quietlyJoin of a forked task returns when task cancelled */ public void testCancelledForkQuietlyJoin() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); f.quietlyJoin(); @@ -842,8 +908,8 @@ public class CountedCompleterTest extend */ public void testGetPool() { final ForkJoinPool mainPool = mainPool(); - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { assertSame(mainPool, getPool()); }}; testInvokeOnPool(mainPool, a); @@ -853,8 +919,8 @@ public class CountedCompleterTest extend * getPool of non-FJ task returns null */ public void testGetPool2() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { assertNull(getPool()); }}; assertNull(a.invoke()); @@ -864,8 +930,8 @@ public class CountedCompleterTest extend * inForkJoinPool of executing task returns true */ public void testInForkJoinPool() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { assertTrue(inForkJoinPool()); }}; testInvokeOnPool(mainPool(), a); @@ -875,8 +941,8 @@ public class CountedCompleterTest extend * inForkJoinPool of non-FJ task returns false */ public void testInForkJoinPool2() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { assertFalse(inForkJoinPool()); }}; assertNull(a.invoke()); @@ -886,8 +952,8 @@ public class CountedCompleterTest extend * setRawResult(null) succeeds */ public void testSetRawResult() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { setRawResult(null); assertNull(getRawResult()); }}; @@ -898,16 +964,14 @@ public class CountedCompleterTest extend * invoke task throws exception after invoking completeExceptionally */ public void testCompleteExceptionally2() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - f.completeExceptionally(new FJException()); - try { - f.invoke(); - shouldThrow(); - } catch (FJException success) { - checkCompletedAbnormally(f, success); - } + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF n = new LCCF(8); + CCF f = new LCCF(n, 8); + FJException ex = new FJException(); + f.completeExceptionally(ex); + f.checkCompletedExceptionally(ex); + n.checkCompletedExceptionally(ex); }}; testInvokeOnPool(mainPool(), a); } @@ -916,10 +980,10 @@ public class CountedCompleterTest extend * invokeAll(t1, t2) invokes all task arguments */ public void testInvokeAll2() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - CCF g = new LCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); + CCF g = new LCCF(9); invokeAll(f, g); assertEquals(21, f.number); assertEquals(34, g.number); @@ -933,9 +997,9 @@ public class CountedCompleterTest extend * invokeAll(tasks) with 1 argument invokes task */ public void testInvokeAll1() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); invokeAll(f); checkCompletedNormally(f); assertEquals(21, f.number); @@ -947,11 +1011,11 @@ public class CountedCompleterTest extend * invokeAll(tasks) with > 2 argument invokes tasks */ public void testInvokeAll3() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - CCF g = new LCCF(null, 9); - CCF h = new LCCF(null, 7); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); + CCF g = new LCCF(9); + CCF h = new LCCF(7); invokeAll(f, g, h); assertEquals(21, f.number); assertEquals(34, g.number); @@ -967,11 +1031,11 @@ public class CountedCompleterTest extend * invokeAll(collection) invokes all tasks in the collection */ public void testInvokeAllCollection() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - CCF g = new LCCF(null, 9); - CCF h = new LCCF(null, 7); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); + CCF g = new LCCF(9); + CCF h = new LCCF(7); HashSet set = new HashSet(); set.add(f); set.add(g); @@ -991,10 +1055,10 @@ public class CountedCompleterTest extend * invokeAll(tasks) with any null task throws NPE */ public void testInvokeAllNPE() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - CCF g = new LCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); + CCF g = new LCCF(9); CCF h = null; try { invokeAll(f, g, h); @@ -1008,10 +1072,10 @@ public class CountedCompleterTest extend * invokeAll(t1, t2) throw exception if any task does */ public void testAbnormalInvokeAll2() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - FailingCCF g = new LFCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); + FailingCCF g = new LFCCF(9); try { invokeAll(f, g); shouldThrow(); @@ -1026,9 +1090,9 @@ public class CountedCompleterTest extend * invokeAll(tasks) with 1 argument throws exception if task does */ public void testAbnormalInvokeAll1() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - FailingCCF g = new LFCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + FailingCCF g = new LFCCF(9); try { invokeAll(g); shouldThrow(); @@ -1043,11 +1107,11 @@ public class CountedCompleterTest extend * invokeAll(tasks) with > 2 argument throws exception if any task does */ public void testAbnormalInvokeAll3() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - FailingCCF g = new LFCCF(null, 9); - CCF h = new LCCF(null, 7); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); + FailingCCF g = new LFCCF(9); + CCF h = new LCCF(7); try { invokeAll(f, g, h); shouldThrow(); @@ -1062,11 +1126,11 @@ public class CountedCompleterTest extend * invokeAll(collection) throws exception if any task does */ public void testAbnormalInvokeAllCollection() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - FailingCCF f = new LFCCF(null, 8); - CCF g = new LCCF(null, 9); - CCF h = new LCCF(null, 7); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + FailingCCF f = new LFCCF(8); + CCF g = new LCCF(9); + CCF h = new LCCF(7); HashSet set = new HashSet(); set.add(f); set.add(g); @@ -1086,11 +1150,11 @@ public class CountedCompleterTest extend * and suppresses execution */ public void testTryUnfork() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF g = new LCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF g = new LCCF(9); assertSame(g, g.fork()); - CCF f = new LCCF(null, 8); + CCF f = new LCCF(8); assertSame(f, f.fork()); assertTrue(f.tryUnfork()); helpQuiesce(); @@ -1105,13 +1169,13 @@ public class CountedCompleterTest extend * there are more tasks than threads */ public void testGetSurplusQueuedTaskCount() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF h = new LCCF(null, 7); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF h = new LCCF(7); assertSame(h, h.fork()); - CCF g = new LCCF(null, 9); + CCF g = new LCCF(9); assertSame(g, g.fork()); - CCF f = new LCCF(null, 8); + CCF f = new LCCF(8); assertSame(f, f.fork()); assertTrue(getSurplusQueuedTaskCount() > 0); helpQuiesce(); @@ -1127,11 +1191,11 @@ public class CountedCompleterTest extend * peekNextLocalTask returns most recent unexecuted task. */ public void testPeekNextLocalTask() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF g = new LCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF g = new LCCF(9); assertSame(g, g.fork()); - CCF f = new LCCF(null, 8); + CCF f = new LCCF(8); assertSame(f, f.fork()); assertSame(f, peekNextLocalTask()); assertNull(f.join()); @@ -1147,11 +1211,11 @@ public class CountedCompleterTest extend * executing it */ public void testPollNextLocalTask() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF g = new LCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF g = new LCCF(9); assertSame(g, g.fork()); - CCF f = new LCCF(null, 8); + CCF f = new LCCF(8); assertSame(f, f.fork()); assertSame(f, pollNextLocalTask()); helpQuiesce(); @@ -1166,11 +1230,11 @@ public class CountedCompleterTest extend * pollTask returns an unexecuted task without executing it */ public void testPollTask() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF g = new LCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF g = new LCCF(9); assertSame(g, g.fork()); - CCF f = new LCCF(null, 8); + CCF f = new LCCF(8); assertSame(f, f.fork()); assertSame(f, pollTask()); helpQuiesce(); @@ -1184,11 +1248,11 @@ public class CountedCompleterTest extend * peekNextLocalTask returns least recent unexecuted task in async mode */ public void testPeekNextLocalTaskAsync() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF g = new LCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF g = new LCCF(9); assertSame(g, g.fork()); - CCF f = new LCCF(null, 8); + CCF f = new LCCF(8); assertSame(f, f.fork()); assertSame(g, peekNextLocalTask()); assertNull(f.join()); @@ -1205,11 +1269,11 @@ public class CountedCompleterTest extend * executing it, in async mode */ public void testPollNextLocalTaskAsync() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF g = new LCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF g = new LCCF(9); assertSame(g, g.fork()); - CCF f = new LCCF(null, 8); + CCF f = new LCCF(8); assertSame(f, f.fork()); assertSame(g, pollNextLocalTask()); helpQuiesce(); @@ -1225,11 +1289,11 @@ public class CountedCompleterTest extend * async mode */ public void testPollTaskAsync() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF g = new LCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF g = new LCCF(9); assertSame(g, g.fork()); - CCF f = new LCCF(null, 8); + CCF f = new LCCF(8); assertSame(f, f.fork()); assertSame(g, pollTask()); helpQuiesce(); @@ -1248,9 +1312,9 @@ public class CountedCompleterTest extend * completed tasks; getRawResult returns null. */ public void testInvokeSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertNull(f.invoke()); assertEquals(21, f.number); checkCompletedNormally(f); @@ -1264,9 +1328,9 @@ public class CountedCompleterTest extend * completed tasks */ public void testQuietlyInvokeSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); f.quietlyInvoke(); assertEquals(21, f.number); checkCompletedNormally(f); @@ -1278,9 +1342,9 @@ public class CountedCompleterTest extend * join of a forked task returns when task completes */ public void testForkJoinSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertSame(f, f.fork()); assertNull(f.join()); assertEquals(21, f.number); @@ -1293,9 +1357,9 @@ public class CountedCompleterTest extend * get of a forked task returns when task completes */ public void testForkGetSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + CCF f = new LCCF(8); assertSame(f, f.fork()); assertNull(f.get()); assertEquals(21, f.number); @@ -1308,9 +1372,9 @@ public class CountedCompleterTest extend * timed get of a forked task returns when task completes */ public void testForkTimedGetSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + CCF f = new LCCF(8); assertSame(f, f.fork()); assertNull(f.get(LONG_DELAY_MS, MILLISECONDS)); assertEquals(21, f.number); @@ -1323,9 +1387,9 @@ public class CountedCompleterTest extend * timed get with null time unit throws NPE */ public void testForkTimedGetNPESingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + CCF f = new LCCF(8); assertSame(f, f.fork()); try { f.get(5L, null); @@ -1339,9 +1403,9 @@ public class CountedCompleterTest extend * quietlyJoin of a forked task returns when task completes */ public void testForkQuietlyJoinSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertSame(f, f.fork()); f.quietlyJoin(); assertEquals(21, f.number); @@ -1355,9 +1419,9 @@ public class CountedCompleterTest extend * getQueuedTaskCount returns 0 when quiescent */ public void testForkHelpQuiesceSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertSame(f, f.fork()); helpQuiesce(); assertEquals(0, getQueuedTaskCount()); @@ -1371,9 +1435,9 @@ public class CountedCompleterTest extend * invoke task throws exception when task completes abnormally */ public void testAbnormalInvokeSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - FailingCCF f = new LFCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + FailingCCF f = new LFCCF(8); try { f.invoke(); shouldThrow(); @@ -1388,9 +1452,9 @@ public class CountedCompleterTest extend * quietlyInvoke task returns when task completes abnormally */ public void testAbnormalQuietlyInvokeSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - FailingCCF f = new LFCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + FailingCCF f = new LFCCF(8); f.quietlyInvoke(); assertTrue(f.getException() instanceof FJException); checkCompletedAbnormally(f, f.getException()); @@ -1402,9 +1466,9 @@ public class CountedCompleterTest extend * join of a forked task throws exception when task completes abnormally */ public void testAbnormalForkJoinSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - FailingCCF f = new LFCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); try { f.join(); @@ -1420,9 +1484,9 @@ public class CountedCompleterTest extend * get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkGetSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - FailingCCF f = new LFCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); try { f.get(); @@ -1440,9 +1504,9 @@ public class CountedCompleterTest extend * timed get of a forked task throws exception when task completes abnormally */ public void testAbnormalForkTimedGetSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - FailingCCF f = new LFCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); try { f.get(LONG_DELAY_MS, MILLISECONDS); @@ -1460,9 +1524,9 @@ public class CountedCompleterTest extend * quietlyJoin of a forked task returns when task completes abnormally */ public void testAbnormalForkQuietlyJoinSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - FailingCCF f = new LFCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + FailingCCF f = new LFCCF(8); assertSame(f, f.fork()); f.quietlyJoin(); assertTrue(f.getException() instanceof FJException); @@ -1475,9 +1539,9 @@ public class CountedCompleterTest extend * invoke task throws exception when task cancelled */ public void testCancelledInvokeSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertTrue(f.cancel(true)); try { f.invoke(); @@ -1493,9 +1557,9 @@ public class CountedCompleterTest extend * join of a forked task throws exception when task cancelled */ public void testCancelledForkJoinSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { @@ -1512,9 +1576,9 @@ public class CountedCompleterTest extend * get of a forked task throws exception when task cancelled */ public void testCancelledForkGetSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + CCF f = new LCCF(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { @@ -1531,9 +1595,9 @@ public class CountedCompleterTest extend * timed get of a forked task throws exception when task cancelled */ public void testCancelledForkTimedGetSingleton() throws Exception { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() throws Exception { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() throws Exception { + CCF f = new LCCF(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); try { @@ -1550,9 +1614,9 @@ public class CountedCompleterTest extend * quietlyJoin of a forked task returns when task cancelled */ public void testCancelledForkQuietlyJoinSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); assertTrue(f.cancel(true)); assertSame(f, f.fork()); f.quietlyJoin(); @@ -1565,16 +1629,14 @@ public class CountedCompleterTest extend * invoke task throws exception after invoking completeExceptionally */ public void testCompleteExceptionallySingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - f.completeExceptionally(new FJException()); - try { - f.invoke(); - shouldThrow(); - } catch (FJException success) { - checkCompletedAbnormally(f, success); - } + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF n = new LCCF(8); + CCF f = new LCCF(n, 8); + FJException ex = new FJException(); + f.completeExceptionally(ex); + f.checkCompletedExceptionally(ex); + n.checkCompletedExceptionally(ex); }}; testInvokeOnPool(singletonPool(), a); } @@ -1583,10 +1645,10 @@ public class CountedCompleterTest extend * invokeAll(t1, t2) invokes all task arguments */ public void testInvokeAll2Singleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - CCF g = new LCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); + CCF g = new LCCF(9); invokeAll(f, g); assertEquals(21, f.number); assertEquals(34, g.number); @@ -1600,9 +1662,9 @@ public class CountedCompleterTest extend * invokeAll(tasks) with 1 argument invokes task */ public void testInvokeAll1Singleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); invokeAll(f); checkCompletedNormally(f); assertEquals(21, f.number); @@ -1614,11 +1676,11 @@ public class CountedCompleterTest extend * invokeAll(tasks) with > 2 argument invokes tasks */ public void testInvokeAll3Singleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - CCF g = new LCCF(null, 9); - CCF h = new LCCF(null, 7); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); + CCF g = new LCCF(9); + CCF h = new LCCF(7); invokeAll(f, g, h); assertEquals(21, f.number); assertEquals(34, g.number); @@ -1634,11 +1696,11 @@ public class CountedCompleterTest extend * invokeAll(collection) invokes all tasks in the collection */ public void testInvokeAllCollectionSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - CCF g = new LCCF(null, 9); - CCF h = new LCCF(null, 7); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); + CCF g = new LCCF(9); + CCF h = new LCCF(7); HashSet set = new HashSet(); set.add(f); set.add(g); @@ -1658,10 +1720,10 @@ public class CountedCompleterTest extend * invokeAll(tasks) with any null task throws NPE */ public void testInvokeAllNPESingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - CCF g = new LCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); + CCF g = new LCCF(9); CCF h = null; try { invokeAll(f, g, h); @@ -1675,10 +1737,10 @@ public class CountedCompleterTest extend * invokeAll(t1, t2) throw exception if any task does */ public void testAbnormalInvokeAll2Singleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - FailingCCF g = new LFCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); + FailingCCF g = new LFCCF(9); try { invokeAll(f, g); shouldThrow(); @@ -1693,9 +1755,9 @@ public class CountedCompleterTest extend * invokeAll(tasks) with 1 argument throws exception if task does */ public void testAbnormalInvokeAll1Singleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - FailingCCF g = new LFCCF(null, 9); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + FailingCCF g = new LFCCF(9); try { invokeAll(g); shouldThrow(); @@ -1710,11 +1772,11 @@ public class CountedCompleterTest extend * invokeAll(tasks) with > 2 argument throws exception if any task does */ public void testAbnormalInvokeAll3Singleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - CCF f = new LCCF(null, 8); - FailingCCF g = new LFCCF(null, 9); - CCF h = new LCCF(null, 7); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + CCF f = new LCCF(8); + FailingCCF g = new LFCCF(9); + CCF h = new LCCF(7); try { invokeAll(f, g, h); shouldThrow(); @@ -1729,11 +1791,11 @@ public class CountedCompleterTest extend * invokeAll(collection) throws exception if any task does */ public void testAbnormalInvokeAllCollectionSingleton() { - ForkJoinTask a = new CheckedFJTask() { - public void realCompute() { - FailingCCF f = new LFCCF(null, 8); - CCF g = new LCCF(null, 9); - CCF h = new LCCF(null, 7); + ForkJoinTask a = new CheckedRecursiveAction() { + protected void realCompute() { + FailingCCF f = new LFCCF(8); + CCF g = new LCCF(9); + CCF h = new LCCF(7); HashSet set = new HashSet(); set.add(f); set.add(g);