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

Comparing jsr166/src/test/tck/CountedCompleterTest.java (file contents):
Revision 1.1 by dl, Thu Mar 21 00:27:10 2013 UTC vs.
Revision 1.35 by dl, Thu Oct 26 22:50:07 2017 UTC

# Line 3 | Line 3
3   * Expert Group and released to the public domain, as explained at
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6 < import java.util.concurrent.ExecutionException;
6 >
7 > import static java.util.concurrent.TimeUnit.MILLISECONDS;
8 >
9 > import java.util.HashSet;
10   import java.util.concurrent.CancellationException;
11 + import java.util.concurrent.CountedCompleter;
12 + import java.util.concurrent.ExecutionException;
13   import java.util.concurrent.ForkJoinPool;
14   import java.util.concurrent.ForkJoinTask;
10 import java.util.concurrent.CountedCompleter;
11 import java.util.concurrent.ForkJoinWorkerThread;
12 import java.util.concurrent.RecursiveAction;
13 import java.util.concurrent.TimeUnit;
15   import java.util.concurrent.TimeoutException;
16 < import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
17 < import static java.util.concurrent.TimeUnit.MILLISECONDS;
18 < import static java.util.concurrent.TimeUnit.SECONDS;
19 < import java.util.HashSet;
20 < import junit.framework.*;
16 > import java.util.concurrent.atomic.AtomicInteger;
17 > import java.util.concurrent.atomic.AtomicReference;
18 >
19 > import junit.framework.Test;
20 > import junit.framework.TestSuite;
21  
22   public class CountedCompleterTest extends JSR166TestCase {
23  
24      public static void main(String[] args) {
25 <        junit.textui.TestRunner.run(suite());
25 >        main(suite(), args);
26      }
27  
28      public static Test suite() {
# Line 32 | Line 33 | public class CountedCompleterTest extend
33      static final int mainPoolSize =
34          Math.max(2, Runtime.getRuntime().availableProcessors());
35  
35    /**
36     * Analog of CheckedRunnable for CountedCompleter
37     */
38    public abstract class CheckedFJTask extends RecursiveAction {
39        protected abstract void realCompute() throws Throwable;
40
41        public final void compute() {
42            try {
43                realCompute();
44            } catch (Throwable t) {
45                threadUnexpectedException(t);
46            }
47        }
48    }
49
36      private static ForkJoinPool mainPool() {
37          return new ForkJoinPool(mainPoolSize);
38      }
# Line 62 | Line 48 | public class CountedCompleterTest extend
48      }
49  
50      private void testInvokeOnPool(ForkJoinPool pool, ForkJoinTask a) {
51 <        try {
51 >        try (PoolCleaner cleaner = cleaner(pool)) {
52              assertFalse(a.isDone());
53              assertFalse(a.isCompletedNormally());
54              assertFalse(a.isCompletedAbnormally());
# Line 78 | Line 64 | public class CountedCompleterTest extend
64              assertFalse(a.isCancelled());
65              assertNull(a.getException());
66              assertNull(a.getRawResult());
81        } finally {
82            joinPool(pool);
67          }
68      }
69  
# Line 92 | Line 76 | public class CountedCompleterTest extend
76          assertNull(a.getRawResult());
77  
78          try {
79 <            a.get(0L, SECONDS);
79 >            a.get(randomExpiredTimeout(), randomTimeUnit());
80              shouldThrow();
81          } catch (TimeoutException success) {
82          } catch (Throwable fail) { threadUnexpectedException(fail); }
83      }
84  
85 <    <T> void checkCompletedNormally(CountedCompleter<T> a) {
102 <        checkCompletedNormally(a, null);
103 <    }
104 <
105 <    <T> void checkCompletedNormally(CountedCompleter<T> a, T expected) {
85 >    void checkCompletedNormally(CountedCompleter<?> a) {
86          assertTrue(a.isDone());
87          assertFalse(a.isCancelled());
88          assertTrue(a.isCompletedNormally());
89          assertFalse(a.isCompletedAbnormally());
90          assertNull(a.getException());
91 <        assertSame(expected, a.getRawResult());
91 >        assertNull(a.getRawResult());
92  
93          {
94              Thread.currentThread().interrupt();
95 <            long t0 = System.nanoTime();
96 <            assertSame(expected, a.join());
97 <            assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
95 >            long startTime = System.nanoTime();
96 >            assertNull(a.join());
97 >            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
98              Thread.interrupted();
99          }
100  
101          {
102              Thread.currentThread().interrupt();
103 <            long t0 = System.nanoTime();
103 >            long startTime = System.nanoTime();
104              a.quietlyJoin();        // should be no-op
105 <            assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
105 >            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
106              Thread.interrupted();
107          }
108  
109          assertFalse(a.cancel(false));
110          assertFalse(a.cancel(true));
111          try {
112 <            assertSame(expected, a.get());
113 <        } catch (Throwable fail) { threadUnexpectedException(fail); }
114 <        try {
135 <            assertSame(expected, a.get(5L, SECONDS));
136 <        } catch (Throwable fail) { threadUnexpectedException(fail); }
112 >            assertNull(a.get());
113 >            assertNull(a.get(randomTimeout(), randomTimeUnit()));
114 >        } catch (Exception fail) { threadUnexpectedException(fail); }
115      }
116  
117      void checkCancelled(CountedCompleter a) {
# Line 155 | Line 133 | public class CountedCompleterTest extend
133          Thread.interrupted();
134  
135          {
136 <            long t0 = System.nanoTime();
136 >            long startTime = System.nanoTime();
137              a.quietlyJoin();        // should be no-op
138 <            assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
138 >            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
139          }
140  
141          try {
# Line 167 | Line 145 | public class CountedCompleterTest extend
145          } catch (Throwable fail) { threadUnexpectedException(fail); }
146  
147          try {
148 <            a.get(5L, SECONDS);
148 >            a.get(randomTimeout(), randomTimeUnit());
149              shouldThrow();
150          } catch (CancellationException success) {
151          } catch (Throwable fail) { threadUnexpectedException(fail); }
# Line 193 | Line 171 | public class CountedCompleterTest extend
171          Thread.interrupted();
172  
173          {
174 <            long t0 = System.nanoTime();
174 >            long startTime = System.nanoTime();
175              a.quietlyJoin();        // should be no-op
176 <            assertTrue(millisElapsedSince(t0) < SMALL_DELAY_MS);
176 >            assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
177          }
178  
179          try {
# Line 206 | Line 184 | public class CountedCompleterTest extend
184          } catch (Throwable fail) { threadUnexpectedException(fail); }
185  
186          try {
187 <            a.get(5L, SECONDS);
187 >            a.get(randomTimeout(), randomTimeUnit());
188              shouldThrow();
189          } catch (ExecutionException success) {
190              assertSame(t.getClass(), success.getCause().getClass());
191          } catch (Throwable fail) { threadUnexpectedException(fail); }
192 +
193 +        try {
194 +            a.invoke();
195 +            shouldThrow();
196 +        } catch (Throwable success) {
197 +            assertSame(t, success);
198 +        }
199      }
200  
201      public static final class FJException extends RuntimeException {
202          FJException() { super(); }
203      }
204  
205 <    static abstract class FailingCCF extends CountedCompleter {
206 <        int number;
207 <        int rnumber;
208 <
209 <        public FailingCCF(CountedCompleter parent, int n) {
210 <            super(parent, 1);
211 <            this.number = n;
212 <        }
213 <
205 >    abstract class CheckedCC extends CountedCompleter<Object> {
206 >        final AtomicInteger computeN = new AtomicInteger(0);
207 >        final AtomicInteger onCompletionN = new AtomicInteger(0);
208 >        final AtomicInteger onExceptionalCompletionN = new AtomicInteger(0);
209 >        final AtomicInteger setRawResultN = new AtomicInteger(0);
210 >        final AtomicReference<Object> rawResult = new AtomicReference<>(null);
211 >        int computeN() { return computeN.get(); }
212 >        int onCompletionN() { return onCompletionN.get(); }
213 >        int onExceptionalCompletionN() { return onExceptionalCompletionN.get(); }
214 >        int setRawResultN() { return setRawResultN.get(); }
215 >
216 >        CheckedCC() { super(); }
217 >        CheckedCC(CountedCompleter p) { super(p); }
218 >        CheckedCC(CountedCompleter p, int n) { super(p, n); }
219 >        abstract void realCompute();
220          public final void compute() {
221 <            CountedCompleter p;
222 <            FailingCCF f = this;
232 <            int n = number;
233 <            while (n >= 2) {
234 <                new RFCCF(f, n - 2).fork();
235 <                f = new LFCCF(f, --n);
236 <            }
237 <            f.number = n;
238 <            f.onCompletion(f);
239 <            if ((p = f.getCompleter()) != null)
240 <                p.tryComplete();
241 <            else
242 <                f.quietlyComplete();
221 >            computeN.incrementAndGet();
222 >            realCompute();
223          }
224 <    }
225 <
226 <    static final class LFCCF extends FailingCCF {
247 <        public LFCCF(CountedCompleter parent, int n) {
248 <            super(parent, n);
224 >        public void onCompletion(CountedCompleter caller) {
225 >            onCompletionN.incrementAndGet();
226 >            super.onCompletion(caller);
227          }
228 <        public final void onCompletion(CountedCompleter caller) {
229 <            FailingCCF p = (FailingCCF)getCompleter();
230 <            int n = number + rnumber;
231 <            if (p != null)
232 <                p.number = n;
233 <            else
234 <                number = n;
228 >        public boolean onExceptionalCompletion(Throwable ex,
229 >                                               CountedCompleter caller) {
230 >            onExceptionalCompletionN.incrementAndGet();
231 >            assertNotNull(ex);
232 >            assertTrue(isCompletedAbnormally());
233 >            assertTrue(super.onExceptionalCompletion(ex, caller));
234 >            return true;
235          }
236 <    }
237 <    static final class RFCCF extends FailingCCF {
238 <        public RFCCF(CountedCompleter parent, int n) {
239 <            super(parent, n);
236 >        protected void setRawResult(Object t) {
237 >            setRawResultN.incrementAndGet();
238 >            rawResult.set(t);
239 >            super.setRawResult(t);
240          }
241 <        public final void onCompletion(CountedCompleter caller) {
242 <            completeExceptionally(new FJException());
241 >        void checkIncomplete() {
242 >            assertEquals(0, computeN());
243 >            assertEquals(0, onCompletionN());
244 >            assertEquals(0, onExceptionalCompletionN());
245 >            assertEquals(0, setRawResultN());
246 >            checkNotDone(this);
247          }
248 <    }
249 <
250 <    static abstract class CCF extends CountedCompleter {
251 <        int number;
252 <        int rnumber;
253 <
254 <        public CCF(CountedCompleter parent, int n) {
255 <            super(parent, 1);
256 <            this.number = n;
257 <        }
258 <
277 <        public final void compute() {
278 <            CountedCompleter p;
279 <            CCF f = this;
280 <            int n = number;
281 <            while (n >= 2) {
282 <                new RCCF(f, n - 2).fork();
283 <                f = new LCCF(f, --n);
284 <            }
285 <            f.number = n;
286 <            f.onCompletion(f);
287 <            if ((p = f.getCompleter()) != null)
288 <                p.tryComplete();
289 <            else
290 <                f.quietlyComplete();
291 <        }
292 <    }
293 <
294 <    static final class LCCF extends CCF {
295 <        public LCCF(CountedCompleter parent, int n) {
296 <            super(parent, n);
297 <        }
298 <        public final void onCompletion(CountedCompleter caller) {
299 <            CCF p = (CCF)getCompleter();
300 <            int n = number + rnumber;
301 <            if (p != null)
302 <                p.number = n;
303 <            else
304 <                number = n;
248 >        void checkCompletes(Object rawResult) {
249 >            checkIncomplete();
250 >            int pendingCount = getPendingCount();
251 >            complete(rawResult);
252 >            assertEquals(pendingCount, getPendingCount());
253 >            assertEquals(0, computeN());
254 >            assertEquals(1, onCompletionN());
255 >            assertEquals(0, onExceptionalCompletionN());
256 >            assertEquals(1, setRawResultN());
257 >            assertSame(rawResult, this.rawResult.get());
258 >            checkCompletedNormally(this);
259          }
260 <    }
261 <    static final class RCCF extends CCF {
262 <        public RCCF(CountedCompleter parent, int n) {
263 <            super(parent, n);
260 >        void checkCompletesExceptionally(Throwable ex) {
261 >            checkIncomplete();
262 >            completeExceptionally(ex);
263 >            checkCompletedExceptionally(ex);
264          }
265 <        public final void onCompletion(CountedCompleter caller) {
266 <            CCF p = (CCF)getCompleter();
267 <            int n = number + rnumber;
268 <            if (p != null)
269 <                p.rnumber = n;
270 <            else
271 <                number = n;
265 >        void checkCompletedExceptionally(Throwable ex) {
266 >            assertEquals(0, computeN());
267 >            assertEquals(0, onCompletionN());
268 >            assertEquals(1, onExceptionalCompletionN());
269 >            assertEquals(0, setRawResultN());
270 >            assertNull(this.rawResult.get());
271 >            checkCompletedAbnormally(this, ex);
272          }
273      }
274  
275 <    static final class NoopCountedCompleter extends CountedCompleter {
276 <        boolean post; // set true if onCompletion called
277 <        NoopCountedCompleter() { super(); }
278 <        NoopCountedCompleter(CountedCompleter p) { super(p); }
279 <        public void compute() {}
326 <        public final void onCompletion(CountedCompleter caller) {
327 <            post = true;
275 >    final class NoopCC extends CheckedCC {
276 >        NoopCC() { super(); }
277 >        NoopCC(CountedCompleter p) { super(p); }
278 >        NoopCC(CountedCompleter p, int initialPendingCount) {
279 >            super(p, initialPendingCount);
280          }
281 +        protected void realCompute() {}
282      }
283  
284      /**
285 <     * A newly constructed CountedCompleter is not completed;
286 <     * complete() causes completion.
285 >     * A newly constructed CountedCompleter is not completed;
286 >     * complete() causes completion. pendingCount is ignored.
287       */
288      public void testComplete() {
289 <        NoopCountedCompleter a = new NoopCountedCompleter();
290 <        assertFalse(a.isDone());
291 <        assertFalse(a.isCompletedNormally());
292 <        assertFalse(a.isCompletedAbnormally());
293 <        assertFalse(a.isCancelled());
294 <        assertNull(a.getException());
295 <        assertNull(a.getRawResult());
296 <        assertFalse(a.post);
297 <        a.complete(null);
298 <        assertTrue(a.post);
299 <        assertTrue(a.isDone());
347 <        assertTrue(a.isCompletedNormally());
348 <        assertFalse(a.isCompletedAbnormally());
349 <        assertFalse(a.isCancelled());
350 <        assertNull(a.getException());
351 <        assertNull(a.getRawResult());
289 >        for (Object x : new Object[] { Boolean.TRUE, null }) {
290 >            for (int pendingCount : new int[] { 0, 42 }) {
291 >                testComplete(new NoopCC(), x, pendingCount);
292 >                testComplete(new NoopCC(new NoopCC()), x, pendingCount);
293 >            }
294 >        }
295 >    }
296 >    void testComplete(NoopCC cc, Object x, int pendingCount) {
297 >        cc.setPendingCount(pendingCount);
298 >        cc.checkCompletes(x);
299 >        assertEquals(pendingCount, cc.getPendingCount());
300      }
301  
302      /**
303       * completeExceptionally completes exceptionally
304       */
305      public void testCompleteExceptionally() {
306 <        NoopCountedCompleter a = new NoopCountedCompleter();
307 <        assertFalse(a.isDone());
308 <        assertFalse(a.isCompletedNormally());
309 <        assertFalse(a.isCompletedAbnormally());
310 <        assertFalse(a.isCancelled());
311 <        assertNull(a.getException());
312 <        assertNull(a.getRawResult());
313 <        assertFalse(a.post);
314 <        a.completeExceptionally(new FJException());
315 <        assertFalse(a.post);
316 <        assertTrue(a.isDone());
317 <        assertFalse(a.isCompletedNormally());
318 <        assertTrue(a.isCompletedAbnormally());
319 <        assertFalse(a.isCancelled());
320 <        assertTrue(a.getException() instanceof FJException);
321 <        assertNull(a.getRawResult());
306 >        new NoopCC()
307 >            .checkCompletesExceptionally(new FJException());
308 >        new NoopCC(new NoopCC())
309 >            .checkCompletesExceptionally(new FJException());
310 >    }
311 >
312 >    /**
313 >     * completeExceptionally(null) surprisingly has the same effect as
314 >     * completeExceptionally(new RuntimeException())
315 >     */
316 >    public void testCompleteExceptionally_null() {
317 >        NoopCC a = new NoopCC();
318 >        a.completeExceptionally(null);
319 >        try {
320 >            a.invoke();
321 >            shouldThrow();
322 >        } catch (RuntimeException success) {
323 >            assertSame(success.getClass(), RuntimeException.class);
324 >            assertNull(success.getCause());
325 >            a.checkCompletedExceptionally(success);
326 >        }
327      }
328  
329      /**
330       * setPendingCount sets the reported pending count
331       */
332      public void testSetPendingCount() {
333 <        NoopCountedCompleter a = new NoopCountedCompleter();
333 >        NoopCC a = new NoopCC();
334          assertEquals(0, a.getPendingCount());
335 <        a.setPendingCount(1);
336 <        assertEquals(1, a.getPendingCount());
337 <        a.setPendingCount(27);
338 <        assertEquals(27, a.getPendingCount());
335 >        int[] vals = {
336 >             -1, 0, 1,
337 >             Integer.MIN_VALUE,
338 >             Integer.MAX_VALUE,
339 >        };
340 >        for (int val : vals) {
341 >            a.setPendingCount(val);
342 >            assertEquals(val, a.getPendingCount());
343 >        }
344      }
345  
346      /**
347       * addToPendingCount adds to the reported pending count
348       */
349      public void testAddToPendingCount() {
350 <        NoopCountedCompleter a = new NoopCountedCompleter();
350 >        NoopCC a = new NoopCC();
351          assertEquals(0, a.getPendingCount());
352          a.addToPendingCount(1);
353          assertEquals(1, a.getPendingCount());
354          a.addToPendingCount(27);
355          assertEquals(28, a.getPendingCount());
356 +        a.addToPendingCount(-28);
357 +        assertEquals(0, a.getPendingCount());
358      }
359  
360      /**
361       * decrementPendingCountUnlessZero decrements reported pending
362       * count unless zero
363       */
364 <    public void testDecrementPendingCount() {
365 <        NoopCountedCompleter a = new NoopCountedCompleter();
366 <        assertEquals(0, a.getPendingCount());
367 <        a.addToPendingCount(1);
364 >    public void testDecrementPendingCountUnlessZero() {
365 >        NoopCC a = new NoopCC(null, 2);
366 >        assertEquals(2, a.getPendingCount());
367 >        assertEquals(2, a.decrementPendingCountUnlessZero());
368          assertEquals(1, a.getPendingCount());
369 <        a.decrementPendingCountUnlessZero();
369 >        assertEquals(1, a.decrementPendingCountUnlessZero());
370          assertEquals(0, a.getPendingCount());
371 <        a.decrementPendingCountUnlessZero();
371 >        assertEquals(0, a.decrementPendingCountUnlessZero());
372 >        assertEquals(0, a.getPendingCount());
373 >        a.setPendingCount(-1);
374 >        assertEquals(-1, a.decrementPendingCountUnlessZero());
375 >        assertEquals(-2, a.getPendingCount());
376 >    }
377 >
378 >    /**
379 >     * compareAndSetPendingCount compares and sets the reported
380 >     * pending count
381 >     */
382 >    public void testCompareAndSetPendingCount() {
383 >        NoopCC a = new NoopCC();
384          assertEquals(0, a.getPendingCount());
385 +        assertTrue(a.compareAndSetPendingCount(0, 1));
386 +        assertEquals(1, a.getPendingCount());
387 +        assertTrue(a.compareAndSetPendingCount(1, 2));
388 +        assertEquals(2, a.getPendingCount());
389 +        assertFalse(a.compareAndSetPendingCount(1, 3));
390 +        assertEquals(2, a.getPendingCount());
391      }
392  
393      /**
394       * getCompleter returns parent or null if at root
395       */
396      public void testGetCompleter() {
397 <        NoopCountedCompleter a = new NoopCountedCompleter();
397 >        NoopCC a = new NoopCC();
398          assertNull(a.getCompleter());
399 <        CountedCompleter b = new NoopCountedCompleter(a);
400 <        assertEquals(a, b.getCompleter());
399 >        CountedCompleter b = new NoopCC(a);
400 >        assertSame(a, b.getCompleter());
401 >        CountedCompleter c = new NoopCC(b);
402 >        assertSame(b, c.getCompleter());
403      }
404 <    
404 >
405      /**
406       * getRoot returns self if no parent, else parent's root
407       */
408      public void testGetRoot() {
409 <        NoopCountedCompleter a = new NoopCountedCompleter();
410 <        NoopCountedCompleter b = new NoopCountedCompleter(a);
411 <        assertEquals(a, a.getRoot());
412 <        assertEquals(a, b.getRoot());
409 >        NoopCC a = new NoopCC();
410 >        NoopCC b = new NoopCC(a);
411 >        NoopCC c = new NoopCC(b);
412 >        assertSame(a, a.getRoot());
413 >        assertSame(a, b.getRoot());
414 >        assertSame(a, c.getRoot());
415      }
416 <              
416 >
417      /**
418 <     * tryComplete causes completion if pending count is zero
418 >     * tryComplete decrements pending count unless zero, in which case
419 >     * causes completion
420       */
421 <    public void testTryComplete1() {
422 <        NoopCountedCompleter a = new NoopCountedCompleter();
421 >    public void testTryComplete() {
422 >        NoopCC a = new NoopCC();
423          assertEquals(0, a.getPendingCount());
424 +        int n = 3;
425 +        a.setPendingCount(n);
426 +        for (; n > 0; n--) {
427 +            assertEquals(n, a.getPendingCount());
428 +            a.tryComplete();
429 +            a.checkIncomplete();
430 +            assertEquals(n - 1, a.getPendingCount());
431 +        }
432          a.tryComplete();
433 <        assertTrue(a.post);
434 <        assertTrue(a.isDone());
433 >        assertEquals(0, a.computeN());
434 >        assertEquals(1, a.onCompletionN());
435 >        assertEquals(0, a.onExceptionalCompletionN());
436 >        assertEquals(0, a.setRawResultN());
437 >        checkCompletedNormally(a);
438      }
439  
440      /**
441 <     * propagateCompletion causes completion without invokein
442 <     * onCompletion if pending count is zero
441 >     * propagateCompletion decrements pending count unless zero, in
442 >     * which case causes completion, without invoking onCompletion
443       */
444      public void testPropagateCompletion() {
445 <        NoopCountedCompleter a = new NoopCountedCompleter();
445 >        NoopCC a = new NoopCC();
446          assertEquals(0, a.getPendingCount());
447 +        int n = 3;
448 +        a.setPendingCount(n);
449 +        for (; n > 0; n--) {
450 +            assertEquals(n, a.getPendingCount());
451 +            a.propagateCompletion();
452 +            a.checkIncomplete();
453 +            assertEquals(n - 1, a.getPendingCount());
454 +        }
455          a.propagateCompletion();
456 <        assertFalse(a.post);
457 <        assertTrue(a.isDone());
458 <    }
459 <
460 <    /**
459 <     * tryComplete decrments pending count unless zero
460 <     */
461 <    public void testTryComplete2() {
462 <        NoopCountedCompleter a = new NoopCountedCompleter();
463 <        assertEquals(0, a.getPendingCount());
464 <        a.setPendingCount(1);
465 <        a.tryComplete();
466 <        assertFalse(a.post);
467 <        assertFalse(a.isDone());
468 <        assertEquals(0, a.getPendingCount());
469 <        a.tryComplete();
470 <        assertTrue(a.post);
471 <        assertTrue(a.isDone());
456 >        assertEquals(0, a.computeN());
457 >        assertEquals(0, a.onCompletionN());
458 >        assertEquals(0, a.onExceptionalCompletionN());
459 >        assertEquals(0, a.setRawResultN());
460 >        checkCompletedNormally(a);
461      }
462  
463      /**
464       * firstComplete returns this if pending count is zero else null
465       */
466      public void testFirstComplete() {
467 <        NoopCountedCompleter a = new NoopCountedCompleter();
467 >        NoopCC a = new NoopCC();
468          a.setPendingCount(1);
469          assertNull(a.firstComplete());
470 <        assertEquals(a, a.firstComplete());
470 >        a.checkIncomplete();
471 >        assertSame(a, a.firstComplete());
472 >        a.checkIncomplete();
473      }
474  
475      /**
# Line 486 | Line 477 | public class CountedCompleterTest extend
477       * zero else null
478       */
479      public void testNextComplete() {
480 <        NoopCountedCompleter a = new NoopCountedCompleter();
481 <        NoopCountedCompleter b = new NoopCountedCompleter(a);
480 >        NoopCC a = new NoopCC();
481 >        NoopCC b = new NoopCC(a);
482          a.setPendingCount(1);
483          b.setPendingCount(1);
484          assertNull(b.firstComplete());
485 <        CountedCompleter c = b.firstComplete();
486 <        assertEquals(b, c);
487 <        CountedCompleter d = c.nextComplete();
488 <        assertNull(d);
489 <        CountedCompleter e = c.nextComplete();
490 <        assertEquals(a, e);
485 >        assertSame(b, b.firstComplete());
486 >        assertNull(b.nextComplete());
487 >        a.checkIncomplete();
488 >        b.checkIncomplete();
489 >        assertSame(a, b.nextComplete());
490 >        assertSame(a, b.nextComplete());
491 >        a.checkIncomplete();
492 >        b.checkIncomplete();
493 >        assertNull(a.nextComplete());
494 >        b.checkIncomplete();
495 >        checkCompletedNormally(a);
496      }
497  
498      /**
499 <     * quietlyCompleteRoot completes root task
499 >     * quietlyCompleteRoot completes root task and only root task
500       */
501      public void testQuietlyCompleteRoot() {
502 <        NoopCountedCompleter a = new NoopCountedCompleter();
503 <        NoopCountedCompleter b = new NoopCountedCompleter(a);
502 >        NoopCC a = new NoopCC();
503 >        NoopCC b = new NoopCC(a);
504 >        NoopCC c = new NoopCC(b);
505          a.setPendingCount(1);
506          b.setPendingCount(1);
507 <        b.quietlyCompleteRoot();
507 >        c.setPendingCount(1);
508 >        c.quietlyCompleteRoot();
509          assertTrue(a.isDone());
510          assertFalse(b.isDone());
511 +        assertFalse(c.isDone());
512      }
513 <    
513 >
514 >    // Invocation tests use some interdependent task classes
515 >    // to better test propagation etc
516 >
517 >    /**
518 >     * Version of Fibonacci with different classes for left vs right forks
519 >     */
520 >    abstract class CCF extends CheckedCC {
521 >        int number;
522 >        int rnumber;
523 >
524 >        public CCF(CountedCompleter parent, int n) {
525 >            super(parent, 1);
526 >            this.number = n;
527 >        }
528 >
529 >        protected final void realCompute() {
530 >            CCF f = this;
531 >            int n = number;
532 >            while (n >= 2) {
533 >                new RCCF(f, n - 2).fork();
534 >                f = new LCCF(f, --n);
535 >            }
536 >            f.complete(null);
537 >        }
538 >    }
539 >
540 >    final class LCCF extends CCF {
541 >        public LCCF(int n) { this(null, n); }
542 >        public LCCF(CountedCompleter parent, int n) {
543 >            super(parent, n);
544 >        }
545 >        public final void onCompletion(CountedCompleter caller) {
546 >            super.onCompletion(caller);
547 >            CCF p = (CCF)getCompleter();
548 >            int n = number + rnumber;
549 >            if (p != null)
550 >                p.number = n;
551 >            else
552 >                number = n;
553 >        }
554 >    }
555 >    final class RCCF extends CCF {
556 >        public RCCF(CountedCompleter parent, int n) {
557 >            super(parent, n);
558 >        }
559 >        public final void onCompletion(CountedCompleter caller) {
560 >            super.onCompletion(caller);
561 >            CCF p = (CCF)getCompleter();
562 >            int n = number + rnumber;
563 >            if (p != null)
564 >                p.rnumber = n;
565 >            else
566 >                number = n;
567 >        }
568 >    }
569 >
570 >    // Version of CCF with forced failure in left completions
571 >    abstract class FailingCCF extends CheckedCC {
572 >        int number;
573 >        int rnumber;
574 >
575 >        public FailingCCF(CountedCompleter parent, int n) {
576 >            super(parent, 1);
577 >            this.number = n;
578 >        }
579 >
580 >        protected final void realCompute() {
581 >            FailingCCF f = this;
582 >            int n = number;
583 >            while (n >= 2) {
584 >                new RFCCF(f, n - 2).fork();
585 >                f = new LFCCF(f, --n);
586 >            }
587 >            f.complete(null);
588 >        }
589 >    }
590 >
591 >    final class LFCCF extends FailingCCF {
592 >        public LFCCF(int n) { this(null, n); }
593 >        public LFCCF(CountedCompleter parent, int n) {
594 >            super(parent, n);
595 >        }
596 >        public final void onCompletion(CountedCompleter caller) {
597 >            super.onCompletion(caller);
598 >            FailingCCF p = (FailingCCF)getCompleter();
599 >            int n = number + rnumber;
600 >            if (p != null)
601 >                p.number = n;
602 >            else
603 >                number = n;
604 >        }
605 >    }
606 >    final class RFCCF extends FailingCCF {
607 >        public RFCCF(CountedCompleter parent, int n) {
608 >            super(parent, n);
609 >        }
610 >        public final void onCompletion(CountedCompleter caller) {
611 >            super.onCompletion(caller);
612 >            completeExceptionally(new FJException());
613 >        }
614 >    }
615 >
616      /**
617       * invoke returns when task completes normally.
618       * isCompletedAbnormally and isCancelled return false for normally
619       * completed tasks; getRawResult returns null.
620       */
621      public void testInvoke() {
622 <       ForkJoinTask a =  new CheckedFJTask() {
623 <            public void realCompute() {
624 <                CCF f = new LCCF(null, 8);
622 >        ForkJoinTask a = new CheckedRecursiveAction() {
623 >            protected void realCompute() {
624 >                CCF f = new LCCF(8);
625                  assertNull(f.invoke());
626                  assertEquals(21, f.number);
627                  checkCompletedNormally(f);
# Line 534 | Line 635 | public class CountedCompleterTest extend
635       * completed tasks
636       */
637      public void testQuietlyInvoke() {
638 <       ForkJoinTask a =  new CheckedFJTask() {
639 <            public void realCompute() {
640 <                CCF f = new LCCF(null, 8);
638 >        ForkJoinTask a = new CheckedRecursiveAction() {
639 >            protected void realCompute() {
640 >                CCF f = new LCCF(8);
641                  f.quietlyInvoke();
642                  assertEquals(21, f.number);
643                  checkCompletedNormally(f);
# Line 548 | Line 649 | public class CountedCompleterTest extend
649       * join of a forked task returns when task completes
650       */
651      public void testForkJoin() {
652 <       ForkJoinTask a =  new CheckedFJTask() {
653 <            public void realCompute() {
654 <                CCF f = new LCCF(null, 8);
652 >        ForkJoinTask a = new CheckedRecursiveAction() {
653 >            protected void realCompute() {
654 >                CCF f = new LCCF(8);
655                  assertSame(f, f.fork());
656                  assertNull(f.join());
657                  assertEquals(21, f.number);
# Line 563 | Line 664 | public class CountedCompleterTest extend
664       * get of a forked task returns when task completes
665       */
666      public void testForkGet() {
667 <       ForkJoinTask a =  new CheckedFJTask() {
668 <            public void realCompute() throws Exception {
669 <                CCF f = new LCCF(null, 8);
667 >        ForkJoinTask a = new CheckedRecursiveAction() {
668 >            protected void realCompute() throws Exception {
669 >                CCF f = new LCCF(8);
670                  assertSame(f, f.fork());
671                  assertNull(f.get());
672                  assertEquals(21, f.number);
# Line 578 | Line 679 | public class CountedCompleterTest extend
679       * timed get of a forked task returns when task completes
680       */
681      public void testForkTimedGet() {
682 <       ForkJoinTask a =  new CheckedFJTask() {
683 <            public void realCompute() throws Exception {
684 <                CCF f = new LCCF(null, 8);
682 >        ForkJoinTask a = new CheckedRecursiveAction() {
683 >            protected void realCompute() throws Exception {
684 >                CCF f = new LCCF(8);
685                  assertSame(f, f.fork());
686                  assertNull(f.get(LONG_DELAY_MS, MILLISECONDS));
687                  assertEquals(21, f.number);
# Line 593 | Line 694 | public class CountedCompleterTest extend
694       * timed get with null time unit throws NPE
695       */
696      public void testForkTimedGetNPE() {
697 <       ForkJoinTask a =  new CheckedFJTask() {
698 <            public void realCompute() throws Exception {
699 <                CCF f = new LCCF(null, 8);
697 >        ForkJoinTask a = new CheckedRecursiveAction() {
698 >            protected void realCompute() throws Exception {
699 >                CCF f = new LCCF(8);
700                  assertSame(f, f.fork());
701                  try {
702 <                    f.get(5L, null);
702 >                    f.get(randomTimeout(), null);
703                      shouldThrow();
704                  } catch (NullPointerException success) {}
705              }};
# Line 609 | Line 710 | public class CountedCompleterTest extend
710       * quietlyJoin of a forked task returns when task completes
711       */
712      public void testForkQuietlyJoin() {
713 <       ForkJoinTask a =  new CheckedFJTask() {
714 <            public void realCompute() {
715 <                CCF f = new LCCF(null, 8);
713 >        ForkJoinTask a = new CheckedRecursiveAction() {
714 >            protected void realCompute() {
715 >                CCF f = new LCCF(8);
716                  assertSame(f, f.fork());
717                  f.quietlyJoin();
718                  assertEquals(21, f.number);
# Line 625 | Line 726 | public class CountedCompleterTest extend
726       * getQueuedTaskCount returns 0 when quiescent
727       */
728      public void testForkHelpQuiesce() {
729 <       ForkJoinTask a =  new CheckedFJTask() {
730 <            public void realCompute() {
731 <                CCF f = new LCCF(null, 8);
729 >        ForkJoinTask a = new CheckedRecursiveAction() {
730 >            protected void realCompute() {
731 >                CCF f = new LCCF(8);
732                  assertSame(f, f.fork());
733                  helpQuiesce();
734 +                while (!f.isDone()) // wait out race
735 +                    ;
736                  assertEquals(21, f.number);
737                  assertEquals(0, getQueuedTaskCount());
738                  checkCompletedNormally(f);
# Line 641 | Line 744 | public class CountedCompleterTest extend
744       * invoke task throws exception when task completes abnormally
745       */
746      public void testAbnormalInvoke() {
747 <       ForkJoinTask a =  new CheckedFJTask() {
748 <            public void realCompute() {
749 <                FailingCCF f = new LFCCF(null, 8);
747 >        ForkJoinTask a = new CheckedRecursiveAction() {
748 >            protected void realCompute() {
749 >                FailingCCF f = new LFCCF(8);
750                  try {
751                      f.invoke();
752                      shouldThrow();
# Line 658 | Line 761 | public class CountedCompleterTest extend
761       * quietlyInvoke task returns when task completes abnormally
762       */
763      public void testAbnormalQuietlyInvoke() {
764 <       ForkJoinTask a =  new CheckedFJTask() {
765 <            public void realCompute() {
766 <                FailingCCF f = new LFCCF(null, 8);
764 >        ForkJoinTask a = new CheckedRecursiveAction() {
765 >            protected void realCompute() {
766 >                FailingCCF f = new LFCCF(8);
767                  f.quietlyInvoke();
768                  assertTrue(f.getException() instanceof FJException);
769                  checkCompletedAbnormally(f, f.getException());
# Line 672 | Line 775 | public class CountedCompleterTest extend
775       * join of a forked task throws exception when task completes abnormally
776       */
777      public void testAbnormalForkJoin() {
778 <       ForkJoinTask a =  new CheckedFJTask() {
779 <            public void realCompute() {
780 <                FailingCCF f = new LFCCF(null, 8);
778 >        ForkJoinTask a = new CheckedRecursiveAction() {
779 >            protected void realCompute() {
780 >                FailingCCF f = new LFCCF(8);
781                  assertSame(f, f.fork());
782                  try {
783                      f.join();
# Line 690 | Line 793 | public class CountedCompleterTest extend
793       * get of a forked task throws exception when task completes abnormally
794       */
795      public void testAbnormalForkGet() {
796 <       ForkJoinTask a =  new CheckedFJTask() {
797 <            public void realCompute() throws Exception {
798 <                FailingCCF f = new LFCCF(null, 8);
796 >        ForkJoinTask a = new CheckedRecursiveAction() {
797 >            protected void realCompute() throws Exception {
798 >                FailingCCF f = new LFCCF(8);
799                  assertSame(f, f.fork());
800                  try {
801                      f.get();
# Line 710 | Line 813 | public class CountedCompleterTest extend
813       * timed get of a forked task throws exception when task completes abnormally
814       */
815      public void testAbnormalForkTimedGet() {
816 <       ForkJoinTask a =  new CheckedFJTask() {
817 <            public void realCompute() throws Exception {
818 <                FailingCCF f = new LFCCF(null, 8);
816 >        ForkJoinTask a = new CheckedRecursiveAction() {
817 >            protected void realCompute() throws Exception {
818 >                FailingCCF f = new LFCCF(8);
819                  assertSame(f, f.fork());
820                  try {
821                      f.get(LONG_DELAY_MS, MILLISECONDS);
# Line 730 | Line 833 | public class CountedCompleterTest extend
833       * quietlyJoin of a forked task returns when task completes abnormally
834       */
835      public void testAbnormalForkQuietlyJoin() {
836 <       ForkJoinTask a =  new CheckedFJTask() {
837 <            public void realCompute() {
838 <                FailingCCF f = new LFCCF(null, 8);
836 >        ForkJoinTask a = new CheckedRecursiveAction() {
837 >            protected void realCompute() {
838 >                FailingCCF f = new LFCCF(8);
839                  assertSame(f, f.fork());
840                  f.quietlyJoin();
841                  assertTrue(f.getException() instanceof FJException);
# Line 745 | Line 848 | public class CountedCompleterTest extend
848       * invoke task throws exception when task cancelled
849       */
850      public void testCancelledInvoke() {
851 <       ForkJoinTask a =  new CheckedFJTask() {
852 <            public void realCompute() {
853 <                CCF f = new LCCF(null, 8);
851 >        ForkJoinTask a = new CheckedRecursiveAction() {
852 >            protected void realCompute() {
853 >                CCF f = new LCCF(8);
854                  assertTrue(f.cancel(true));
855                  try {
856                      f.invoke();
# Line 763 | Line 866 | public class CountedCompleterTest extend
866       * join of a forked task throws exception when task cancelled
867       */
868      public void testCancelledForkJoin() {
869 <       ForkJoinTask a =  new CheckedFJTask() {
870 <            public void realCompute() {
871 <                CCF f = new LCCF(null, 8);
869 >        ForkJoinTask a = new CheckedRecursiveAction() {
870 >            protected void realCompute() {
871 >                CCF f = new LCCF(8);
872                  assertTrue(f.cancel(true));
873                  assertSame(f, f.fork());
874                  try {
# Line 782 | Line 885 | public class CountedCompleterTest extend
885       * get of a forked task throws exception when task cancelled
886       */
887      public void testCancelledForkGet() {
888 <       ForkJoinTask a =  new CheckedFJTask() {
889 <            public void realCompute() throws Exception {
890 <                CCF f = new LCCF(null, 8);
888 >        ForkJoinTask a = new CheckedRecursiveAction() {
889 >            protected void realCompute() throws Exception {
890 >                CCF f = new LCCF(8);
891                  assertTrue(f.cancel(true));
892                  assertSame(f, f.fork());
893                  try {
# Line 801 | Line 904 | public class CountedCompleterTest extend
904       * timed get of a forked task throws exception when task cancelled
905       */
906      public void testCancelledForkTimedGet() throws Exception {
907 <       ForkJoinTask a =  new CheckedFJTask() {
908 <            public void realCompute() throws Exception {
909 <                CCF f = new LCCF(null, 8);
907 >        ForkJoinTask a = new CheckedRecursiveAction() {
908 >            protected void realCompute() throws Exception {
909 >                CCF f = new LCCF(8);
910                  assertTrue(f.cancel(true));
911                  assertSame(f, f.fork());
912                  try {
# Line 820 | Line 923 | public class CountedCompleterTest extend
923       * quietlyJoin of a forked task returns when task cancelled
924       */
925      public void testCancelledForkQuietlyJoin() {
926 <       ForkJoinTask a =  new CheckedFJTask() {
927 <            public void realCompute() {
928 <                CCF f = new LCCF(null, 8);
926 >        ForkJoinTask a = new CheckedRecursiveAction() {
927 >            protected void realCompute() {
928 >                CCF f = new LCCF(8);
929                  assertTrue(f.cancel(true));
930                  assertSame(f, f.fork());
931                  f.quietlyJoin();
# Line 836 | Line 939 | public class CountedCompleterTest extend
939       */
940      public void testGetPool() {
941          final ForkJoinPool mainPool = mainPool();
942 <       ForkJoinTask a =  new CheckedFJTask() {
943 <            public void realCompute() {
942 >        ForkJoinTask a = new CheckedRecursiveAction() {
943 >            protected void realCompute() {
944                  assertSame(mainPool, getPool());
945              }};
946          testInvokeOnPool(mainPool, a);
# Line 847 | Line 950 | public class CountedCompleterTest extend
950       * getPool of non-FJ task returns null
951       */
952      public void testGetPool2() {
953 <       ForkJoinTask a =  new CheckedFJTask() {
954 <            public void realCompute() {
953 >        ForkJoinTask a = new CheckedRecursiveAction() {
954 >            protected void realCompute() {
955                  assertNull(getPool());
956              }};
957          assertNull(a.invoke());
# Line 858 | Line 961 | public class CountedCompleterTest extend
961       * inForkJoinPool of executing task returns true
962       */
963      public void testInForkJoinPool() {
964 <       ForkJoinTask a =  new CheckedFJTask() {
965 <            public void realCompute() {
964 >        ForkJoinTask a = new CheckedRecursiveAction() {
965 >            protected void realCompute() {
966                  assertTrue(inForkJoinPool());
967              }};
968          testInvokeOnPool(mainPool(), a);
# Line 869 | Line 972 | public class CountedCompleterTest extend
972       * inForkJoinPool of non-FJ task returns false
973       */
974      public void testInForkJoinPool2() {
975 <       ForkJoinTask a =  new CheckedFJTask() {
976 <            public void realCompute() {
975 >        ForkJoinTask a = new CheckedRecursiveAction() {
976 >            protected void realCompute() {
977                  assertFalse(inForkJoinPool());
978              }};
979          assertNull(a.invoke());
# Line 880 | Line 983 | public class CountedCompleterTest extend
983       * setRawResult(null) succeeds
984       */
985      public void testSetRawResult() {
986 <       ForkJoinTask a =  new CheckedFJTask() {
987 <            public void realCompute() {
986 >        ForkJoinTask a = new CheckedRecursiveAction() {
987 >            protected void realCompute() {
988                  setRawResult(null);
989                  assertNull(getRawResult());
990              }};
# Line 892 | Line 995 | public class CountedCompleterTest extend
995       * invoke task throws exception after invoking completeExceptionally
996       */
997      public void testCompleteExceptionally2() {
998 <       ForkJoinTask a =  new CheckedFJTask() {
999 <            public void realCompute() {
1000 <                CCF f = new LCCF(null, 8);
1001 <                f.completeExceptionally(new FJException());
1002 <                try {
1003 <                    f.invoke();
1004 <                    shouldThrow();
1005 <                } catch (FJException success) {
903 <                    checkCompletedAbnormally(f, success);
904 <                }
998 >        ForkJoinTask a = new CheckedRecursiveAction() {
999 >            protected void realCompute() {
1000 >                CCF n = new LCCF(8);
1001 >                CCF f = new LCCF(n, 8);
1002 >                FJException ex = new FJException();
1003 >                f.completeExceptionally(ex);
1004 >                f.checkCompletedExceptionally(ex);
1005 >                n.checkCompletedExceptionally(ex);
1006              }};
1007          testInvokeOnPool(mainPool(), a);
1008      }
# Line 910 | Line 1011 | public class CountedCompleterTest extend
1011       * invokeAll(t1, t2) invokes all task arguments
1012       */
1013      public void testInvokeAll2() {
1014 <       ForkJoinTask a =  new CheckedFJTask() {
1015 <            public void realCompute() {
1016 <                CCF f = new LCCF(null, 8);
1017 <                CCF g = new LCCF(null, 9);
1014 >        ForkJoinTask a = new CheckedRecursiveAction() {
1015 >            protected void realCompute() {
1016 >                CCF f = new LCCF(8);
1017 >                CCF g = new LCCF(9);
1018                  invokeAll(f, g);
1019                  assertEquals(21, f.number);
1020                  assertEquals(34, g.number);
# Line 927 | Line 1028 | public class CountedCompleterTest extend
1028       * invokeAll(tasks) with 1 argument invokes task
1029       */
1030      public void testInvokeAll1() {
1031 <       ForkJoinTask a =  new CheckedFJTask() {
1032 <            public void realCompute() {
1033 <                CCF f = new LCCF(null, 8);
1031 >        ForkJoinTask a = new CheckedRecursiveAction() {
1032 >            protected void realCompute() {
1033 >                CCF f = new LCCF(8);
1034                  invokeAll(f);
1035                  checkCompletedNormally(f);
1036                  assertEquals(21, f.number);
# Line 941 | Line 1042 | public class CountedCompleterTest extend
1042       * invokeAll(tasks) with > 2 argument invokes tasks
1043       */
1044      public void testInvokeAll3() {
1045 <       ForkJoinTask a =  new CheckedFJTask() {
1046 <            public void realCompute() {
1047 <                CCF f = new LCCF(null, 8);
1048 <                CCF g = new LCCF(null, 9);
1049 <                CCF h = new LCCF(null, 7);
1045 >        ForkJoinTask a = new CheckedRecursiveAction() {
1046 >            protected void realCompute() {
1047 >                CCF f = new LCCF(8);
1048 >                CCF g = new LCCF(9);
1049 >                CCF h = new LCCF(7);
1050                  invokeAll(f, g, h);
1051                  assertEquals(21, f.number);
1052                  assertEquals(34, g.number);
# Line 961 | Line 1062 | public class CountedCompleterTest extend
1062       * invokeAll(collection) invokes all tasks in the collection
1063       */
1064      public void testInvokeAllCollection() {
1065 <       ForkJoinTask a =  new CheckedFJTask() {
1066 <            public void realCompute() {
1067 <                CCF f = new LCCF(null, 8);
1068 <                CCF g = new LCCF(null, 9);
1069 <                CCF h = new LCCF(null, 7);
1065 >        ForkJoinTask a = new CheckedRecursiveAction() {
1066 >            protected void realCompute() {
1067 >                CCF f = new LCCF(8);
1068 >                CCF g = new LCCF(9);
1069 >                CCF h = new LCCF(7);
1070                  HashSet set = new HashSet();
1071                  set.add(f);
1072                  set.add(g);
# Line 985 | Line 1086 | public class CountedCompleterTest extend
1086       * invokeAll(tasks) with any null task throws NPE
1087       */
1088      public void testInvokeAllNPE() {
1089 <       ForkJoinTask a =  new CheckedFJTask() {
1090 <            public void realCompute() {
1091 <                CCF f = new LCCF(null, 8);
1092 <                CCF g = new LCCF(null, 9);
1089 >        ForkJoinTask a = new CheckedRecursiveAction() {
1090 >            protected void realCompute() {
1091 >                CCF f = new LCCF(8);
1092 >                CCF g = new LCCF(9);
1093                  CCF h = null;
1094                  try {
1095                      invokeAll(f, g, h);
# Line 1002 | Line 1103 | public class CountedCompleterTest extend
1103       * invokeAll(t1, t2) throw exception if any task does
1104       */
1105      public void testAbnormalInvokeAll2() {
1106 <       ForkJoinTask a =  new CheckedFJTask() {
1107 <            public void realCompute() {
1108 <                CCF f = new LCCF(null, 8);
1109 <                FailingCCF g = new LFCCF(null, 9);
1106 >        ForkJoinTask a = new CheckedRecursiveAction() {
1107 >            protected void realCompute() {
1108 >                CCF f = new LCCF(8);
1109 >                FailingCCF g = new LFCCF(9);
1110                  try {
1111                      invokeAll(f, g);
1112                      shouldThrow();
# Line 1020 | Line 1121 | public class CountedCompleterTest extend
1121       * invokeAll(tasks) with 1 argument throws exception if task does
1122       */
1123      public void testAbnormalInvokeAll1() {
1124 <       ForkJoinTask a =  new CheckedFJTask() {
1125 <            public void realCompute() {
1126 <                FailingCCF g = new LFCCF(null, 9);
1124 >        ForkJoinTask a = new CheckedRecursiveAction() {
1125 >            protected void realCompute() {
1126 >                FailingCCF g = new LFCCF(9);
1127                  try {
1128                      invokeAll(g);
1129                      shouldThrow();
# Line 1037 | Line 1138 | public class CountedCompleterTest extend
1138       * invokeAll(tasks) with > 2 argument throws exception if any task does
1139       */
1140      public void testAbnormalInvokeAll3() {
1141 <       ForkJoinTask a =  new CheckedFJTask() {
1142 <            public void realCompute() {
1143 <                CCF f = new LCCF(null, 8);
1144 <                FailingCCF g = new LFCCF(null, 9);
1145 <                CCF h = new LCCF(null, 7);
1141 >        ForkJoinTask a = new CheckedRecursiveAction() {
1142 >            protected void realCompute() {
1143 >                CCF f = new LCCF(8);
1144 >                FailingCCF g = new LFCCF(9);
1145 >                CCF h = new LCCF(7);
1146                  try {
1147                      invokeAll(f, g, h);
1148                      shouldThrow();
# Line 1053 | Line 1154 | public class CountedCompleterTest extend
1154      }
1155  
1156      /**
1157 <     * invokeAll(collection)  throws exception if any task does
1157 >     * invokeAll(collection) throws exception if any task does
1158       */
1159      public void testAbnormalInvokeAllCollection() {
1160 <       ForkJoinTask a =  new CheckedFJTask() {
1161 <            public void realCompute() {
1162 <                FailingCCF f = new LFCCF(null, 8);
1163 <                CCF g = new LCCF(null, 9);
1164 <                CCF h = new LCCF(null, 7);
1160 >        ForkJoinTask a = new CheckedRecursiveAction() {
1161 >            protected void realCompute() {
1162 >                FailingCCF f = new LFCCF(8);
1163 >                CCF g = new LCCF(9);
1164 >                CCF h = new LCCF(7);
1165                  HashSet set = new HashSet();
1166                  set.add(f);
1167                  set.add(g);
# Line 1080 | Line 1181 | public class CountedCompleterTest extend
1181       * and suppresses execution
1182       */
1183      public void testTryUnfork() {
1184 <       ForkJoinTask a =  new CheckedFJTask() {
1185 <            public void realCompute() {
1186 <                CCF g = new LCCF(null, 9);
1184 >        ForkJoinTask a = new CheckedRecursiveAction() {
1185 >            protected void realCompute() {
1186 >                CCF g = new LCCF(9);
1187                  assertSame(g, g.fork());
1188 <                CCF f = new LCCF(null, 8);
1188 >                CCF f = new LCCF(8);
1189                  assertSame(f, f.fork());
1190                  assertTrue(f.tryUnfork());
1191                  helpQuiesce();
# Line 1099 | Line 1200 | public class CountedCompleterTest extend
1200       * there are more tasks than threads
1201       */
1202      public void testGetSurplusQueuedTaskCount() {
1203 <       ForkJoinTask a =  new CheckedFJTask() {
1204 <            public void realCompute() {
1205 <                CCF h = new LCCF(null, 7);
1203 >        ForkJoinTask a = new CheckedRecursiveAction() {
1204 >            protected void realCompute() {
1205 >                CCF h = new LCCF(7);
1206                  assertSame(h, h.fork());
1207 <                CCF g = new LCCF(null, 9);
1207 >                CCF g = new LCCF(9);
1208                  assertSame(g, g.fork());
1209 <                CCF f = new LCCF(null, 8);
1209 >                CCF f = new LCCF(8);
1210                  assertSame(f, f.fork());
1211                  assertTrue(getSurplusQueuedTaskCount() > 0);
1212                  helpQuiesce();
# Line 1121 | Line 1222 | public class CountedCompleterTest extend
1222       * peekNextLocalTask returns most recent unexecuted task.
1223       */
1224      public void testPeekNextLocalTask() {
1225 <       ForkJoinTask a =  new CheckedFJTask() {
1226 <            public void realCompute() {
1227 <                CCF g = new LCCF(null, 9);
1225 >        ForkJoinTask a = new CheckedRecursiveAction() {
1226 >            protected void realCompute() {
1227 >                CCF g = new LCCF(9);
1228                  assertSame(g, g.fork());
1229 <                CCF f = new LCCF(null, 8);
1229 >                CCF f = new LCCF(8);
1230                  assertSame(f, f.fork());
1231                  assertSame(f, peekNextLocalTask());
1232                  assertNull(f.join());
# Line 1141 | Line 1242 | public class CountedCompleterTest extend
1242       * executing it
1243       */
1244      public void testPollNextLocalTask() {
1245 <       ForkJoinTask a =  new CheckedFJTask() {
1246 <            public void realCompute() {
1247 <                CCF g = new LCCF(null, 9);
1245 >        ForkJoinTask a = new CheckedRecursiveAction() {
1246 >            protected void realCompute() {
1247 >                CCF g = new LCCF(9);
1248                  assertSame(g, g.fork());
1249 <                CCF f = new LCCF(null, 8);
1249 >                CCF f = new LCCF(8);
1250                  assertSame(f, f.fork());
1251                  assertSame(f, pollNextLocalTask());
1252                  helpQuiesce();
# Line 1160 | Line 1261 | public class CountedCompleterTest extend
1261       * pollTask returns an unexecuted task without executing it
1262       */
1263      public void testPollTask() {
1264 <       ForkJoinTask a =  new CheckedFJTask() {
1265 <            public void realCompute() {
1266 <                CCF g = new LCCF(null, 9);
1264 >        ForkJoinTask a = new CheckedRecursiveAction() {
1265 >            protected void realCompute() {
1266 >                CCF g = new LCCF(9);
1267                  assertSame(g, g.fork());
1268 <                CCF f = new LCCF(null, 8);
1268 >                CCF f = new LCCF(8);
1269                  assertSame(f, f.fork());
1270                  assertSame(f, pollTask());
1271                  helpQuiesce();
# Line 1178 | Line 1279 | public class CountedCompleterTest extend
1279       * peekNextLocalTask returns least recent unexecuted task in async mode
1280       */
1281      public void testPeekNextLocalTaskAsync() {
1282 <       ForkJoinTask a =  new CheckedFJTask() {
1283 <            public void realCompute() {
1284 <                CCF g = new LCCF(null, 9);
1282 >        ForkJoinTask a = new CheckedRecursiveAction() {
1283 >            protected void realCompute() {
1284 >                CCF g = new LCCF(9);
1285                  assertSame(g, g.fork());
1286 <                CCF f = new LCCF(null, 8);
1286 >                CCF f = new LCCF(8);
1287                  assertSame(f, f.fork());
1288                  assertSame(g, peekNextLocalTask());
1289                  assertNull(f.join());
# Line 1199 | Line 1300 | public class CountedCompleterTest extend
1300       * executing it, in async mode
1301       */
1302      public void testPollNextLocalTaskAsync() {
1303 <       ForkJoinTask a =  new CheckedFJTask() {
1304 <            public void realCompute() {
1305 <                CCF g = new LCCF(null, 9);
1303 >        ForkJoinTask a = new CheckedRecursiveAction() {
1304 >            protected void realCompute() {
1305 >                CCF g = new LCCF(9);
1306                  assertSame(g, g.fork());
1307 <                CCF f = new LCCF(null, 8);
1307 >                CCF f = new LCCF(8);
1308                  assertSame(f, f.fork());
1309                  assertSame(g, pollNextLocalTask());
1310                  helpQuiesce();
# Line 1219 | Line 1320 | public class CountedCompleterTest extend
1320       * async mode
1321       */
1322      public void testPollTaskAsync() {
1323 <       ForkJoinTask a =  new CheckedFJTask() {
1324 <            public void realCompute() {
1325 <                CCF g = new LCCF(null, 9);
1323 >        ForkJoinTask a = new CheckedRecursiveAction() {
1324 >            protected void realCompute() {
1325 >                CCF g = new LCCF(9);
1326                  assertSame(g, g.fork());
1327 <                CCF f = new LCCF(null, 8);
1327 >                CCF f = new LCCF(8);
1328                  assertSame(f, f.fork());
1329                  assertSame(g, pollTask());
1330                  helpQuiesce();
# Line 1242 | Line 1343 | public class CountedCompleterTest extend
1343       * completed tasks; getRawResult returns null.
1344       */
1345      public void testInvokeSingleton() {
1346 <       ForkJoinTask a =  new CheckedFJTask() {
1347 <            public void realCompute() {
1348 <                CCF f = new LCCF(null, 8);
1346 >        ForkJoinTask a = new CheckedRecursiveAction() {
1347 >            protected void realCompute() {
1348 >                CCF f = new LCCF(8);
1349                  assertNull(f.invoke());
1350                  assertEquals(21, f.number);
1351                  checkCompletedNormally(f);
# Line 1258 | Line 1359 | public class CountedCompleterTest extend
1359       * completed tasks
1360       */
1361      public void testQuietlyInvokeSingleton() {
1362 <       ForkJoinTask a =  new CheckedFJTask() {
1363 <            public void realCompute() {
1364 <                CCF f = new LCCF(null, 8);
1362 >        ForkJoinTask a = new CheckedRecursiveAction() {
1363 >            protected void realCompute() {
1364 >                CCF f = new LCCF(8);
1365                  f.quietlyInvoke();
1366                  assertEquals(21, f.number);
1367                  checkCompletedNormally(f);
# Line 1272 | Line 1373 | public class CountedCompleterTest extend
1373       * join of a forked task returns when task completes
1374       */
1375      public void testForkJoinSingleton() {
1376 <       ForkJoinTask a =  new CheckedFJTask() {
1377 <            public void realCompute() {
1378 <                CCF f = new LCCF(null, 8);
1376 >        ForkJoinTask a = new CheckedRecursiveAction() {
1377 >            protected void realCompute() {
1378 >                CCF f = new LCCF(8);
1379                  assertSame(f, f.fork());
1380                  assertNull(f.join());
1381                  assertEquals(21, f.number);
# Line 1287 | Line 1388 | public class CountedCompleterTest extend
1388       * get of a forked task returns when task completes
1389       */
1390      public void testForkGetSingleton() {
1391 <       ForkJoinTask a =  new CheckedFJTask() {
1392 <            public void realCompute() throws Exception {
1393 <                CCF f = new LCCF(null, 8);
1391 >        ForkJoinTask a = new CheckedRecursiveAction() {
1392 >            protected void realCompute() throws Exception {
1393 >                CCF f = new LCCF(8);
1394                  assertSame(f, f.fork());
1395                  assertNull(f.get());
1396                  assertEquals(21, f.number);
# Line 1302 | Line 1403 | public class CountedCompleterTest extend
1403       * timed get of a forked task returns when task completes
1404       */
1405      public void testForkTimedGetSingleton() {
1406 <       ForkJoinTask a =  new CheckedFJTask() {
1407 <            public void realCompute() throws Exception {
1408 <                CCF f = new LCCF(null, 8);
1406 >        ForkJoinTask a = new CheckedRecursiveAction() {
1407 >            protected void realCompute() throws Exception {
1408 >                CCF f = new LCCF(8);
1409                  assertSame(f, f.fork());
1410                  assertNull(f.get(LONG_DELAY_MS, MILLISECONDS));
1411                  assertEquals(21, f.number);
# Line 1317 | Line 1418 | public class CountedCompleterTest extend
1418       * timed get with null time unit throws NPE
1419       */
1420      public void testForkTimedGetNPESingleton() {
1421 <       ForkJoinTask a =  new CheckedFJTask() {
1422 <            public void realCompute() throws Exception {
1423 <                CCF f = new LCCF(null, 8);
1421 >        ForkJoinTask a = new CheckedRecursiveAction() {
1422 >            protected void realCompute() throws Exception {
1423 >                CCF f = new LCCF(8);
1424                  assertSame(f, f.fork());
1425                  try {
1426 <                    f.get(5L, null);
1426 >                    f.get(randomTimeout(), null);
1427                      shouldThrow();
1428                  } catch (NullPointerException success) {}
1429              }};
# Line 1333 | Line 1434 | public class CountedCompleterTest extend
1434       * quietlyJoin of a forked task returns when task completes
1435       */
1436      public void testForkQuietlyJoinSingleton() {
1437 <       ForkJoinTask a =  new CheckedFJTask() {
1438 <            public void realCompute() {
1439 <                CCF f = new LCCF(null, 8);
1437 >        ForkJoinTask a = new CheckedRecursiveAction() {
1438 >            protected void realCompute() {
1439 >                CCF f = new LCCF(8);
1440                  assertSame(f, f.fork());
1441                  f.quietlyJoin();
1442                  assertEquals(21, f.number);
# Line 1349 | Line 1450 | public class CountedCompleterTest extend
1450       * getQueuedTaskCount returns 0 when quiescent
1451       */
1452      public void testForkHelpQuiesceSingleton() {
1453 <       ForkJoinTask a =  new CheckedFJTask() {
1454 <            public void realCompute() {
1455 <                CCF f = new LCCF(null, 8);
1453 >        ForkJoinTask a = new CheckedRecursiveAction() {
1454 >            protected void realCompute() {
1455 >                CCF f = new LCCF(8);
1456                  assertSame(f, f.fork());
1457                  helpQuiesce();
1458                  assertEquals(0, getQueuedTaskCount());
# Line 1365 | Line 1466 | public class CountedCompleterTest extend
1466       * invoke task throws exception when task completes abnormally
1467       */
1468      public void testAbnormalInvokeSingleton() {
1469 <       ForkJoinTask a =  new CheckedFJTask() {
1470 <            public void realCompute() {
1471 <                FailingCCF f = new LFCCF(null, 8);
1469 >        ForkJoinTask a = new CheckedRecursiveAction() {
1470 >            protected void realCompute() {
1471 >                FailingCCF f = new LFCCF(8);
1472                  try {
1473                      f.invoke();
1474                      shouldThrow();
# Line 1382 | Line 1483 | public class CountedCompleterTest extend
1483       * quietlyInvoke task returns when task completes abnormally
1484       */
1485      public void testAbnormalQuietlyInvokeSingleton() {
1486 <       ForkJoinTask a =  new CheckedFJTask() {
1487 <            public void realCompute() {
1488 <                FailingCCF f = new LFCCF(null, 8);
1486 >        ForkJoinTask a = new CheckedRecursiveAction() {
1487 >            protected void realCompute() {
1488 >                FailingCCF f = new LFCCF(8);
1489                  f.quietlyInvoke();
1490                  assertTrue(f.getException() instanceof FJException);
1491                  checkCompletedAbnormally(f, f.getException());
# Line 1396 | Line 1497 | public class CountedCompleterTest extend
1497       * join of a forked task throws exception when task completes abnormally
1498       */
1499      public void testAbnormalForkJoinSingleton() {
1500 <       ForkJoinTask a =  new CheckedFJTask() {
1501 <            public void realCompute() {
1502 <                FailingCCF f = new LFCCF(null, 8);
1500 >        ForkJoinTask a = new CheckedRecursiveAction() {
1501 >            protected void realCompute() {
1502 >                FailingCCF f = new LFCCF(8);
1503                  assertSame(f, f.fork());
1504                  try {
1505                      f.join();
# Line 1414 | Line 1515 | public class CountedCompleterTest extend
1515       * get of a forked task throws exception when task completes abnormally
1516       */
1517      public void testAbnormalForkGetSingleton() {
1518 <       ForkJoinTask a =  new CheckedFJTask() {
1519 <            public void realCompute() throws Exception {
1520 <                FailingCCF f = new LFCCF(null, 8);
1518 >        ForkJoinTask a = new CheckedRecursiveAction() {
1519 >            protected void realCompute() throws Exception {
1520 >                FailingCCF f = new LFCCF(8);
1521                  assertSame(f, f.fork());
1522                  try {
1523                      f.get();
# Line 1434 | Line 1535 | public class CountedCompleterTest extend
1535       * timed get of a forked task throws exception when task completes abnormally
1536       */
1537      public void testAbnormalForkTimedGetSingleton() {
1538 <       ForkJoinTask a =  new CheckedFJTask() {
1539 <            public void realCompute() throws Exception {
1540 <                FailingCCF f = new LFCCF(null, 8);
1538 >        ForkJoinTask a = new CheckedRecursiveAction() {
1539 >            protected void realCompute() throws Exception {
1540 >                FailingCCF f = new LFCCF(8);
1541                  assertSame(f, f.fork());
1542                  try {
1543                      f.get(LONG_DELAY_MS, MILLISECONDS);
# Line 1454 | Line 1555 | public class CountedCompleterTest extend
1555       * quietlyJoin of a forked task returns when task completes abnormally
1556       */
1557      public void testAbnormalForkQuietlyJoinSingleton() {
1558 <       ForkJoinTask a =  new CheckedFJTask() {
1559 <            public void realCompute() {
1560 <                FailingCCF f = new LFCCF(null, 8);
1558 >        ForkJoinTask a = new CheckedRecursiveAction() {
1559 >            protected void realCompute() {
1560 >                FailingCCF f = new LFCCF(8);
1561                  assertSame(f, f.fork());
1562                  f.quietlyJoin();
1563                  assertTrue(f.getException() instanceof FJException);
# Line 1469 | Line 1570 | public class CountedCompleterTest extend
1570       * invoke task throws exception when task cancelled
1571       */
1572      public void testCancelledInvokeSingleton() {
1573 <       ForkJoinTask a =  new CheckedFJTask() {
1574 <            public void realCompute() {
1575 <                CCF f = new LCCF(null, 8);
1573 >        ForkJoinTask a = new CheckedRecursiveAction() {
1574 >            protected void realCompute() {
1575 >                CCF f = new LCCF(8);
1576                  assertTrue(f.cancel(true));
1577                  try {
1578                      f.invoke();
# Line 1487 | Line 1588 | public class CountedCompleterTest extend
1588       * join of a forked task throws exception when task cancelled
1589       */
1590      public void testCancelledForkJoinSingleton() {
1591 <       ForkJoinTask a =  new CheckedFJTask() {
1592 <            public void realCompute() {
1593 <                CCF f = new LCCF(null, 8);
1591 >        ForkJoinTask a = new CheckedRecursiveAction() {
1592 >            protected void realCompute() {
1593 >                CCF f = new LCCF(8);
1594                  assertTrue(f.cancel(true));
1595                  assertSame(f, f.fork());
1596                  try {
# Line 1506 | Line 1607 | public class CountedCompleterTest extend
1607       * get of a forked task throws exception when task cancelled
1608       */
1609      public void testCancelledForkGetSingleton() {
1610 <       ForkJoinTask a =  new CheckedFJTask() {
1611 <            public void realCompute() throws Exception {
1612 <                CCF f = new LCCF(null, 8);
1610 >        ForkJoinTask a = new CheckedRecursiveAction() {
1611 >            protected void realCompute() throws Exception {
1612 >                CCF f = new LCCF(8);
1613                  assertTrue(f.cancel(true));
1614                  assertSame(f, f.fork());
1615                  try {
# Line 1525 | Line 1626 | public class CountedCompleterTest extend
1626       * timed get of a forked task throws exception when task cancelled
1627       */
1628      public void testCancelledForkTimedGetSingleton() throws Exception {
1629 <       ForkJoinTask a =  new CheckedFJTask() {
1630 <            public void realCompute() throws Exception {
1631 <                CCF f = new LCCF(null, 8);
1629 >        ForkJoinTask a = new CheckedRecursiveAction() {
1630 >            protected void realCompute() throws Exception {
1631 >                CCF f = new LCCF(8);
1632                  assertTrue(f.cancel(true));
1633                  assertSame(f, f.fork());
1634                  try {
# Line 1544 | Line 1645 | public class CountedCompleterTest extend
1645       * quietlyJoin of a forked task returns when task cancelled
1646       */
1647      public void testCancelledForkQuietlyJoinSingleton() {
1648 <       ForkJoinTask a =  new CheckedFJTask() {
1649 <            public void realCompute() {
1650 <                CCF f = new LCCF(null, 8);
1648 >        ForkJoinTask a = new CheckedRecursiveAction() {
1649 >            protected void realCompute() {
1650 >                CCF f = new LCCF(8);
1651                  assertTrue(f.cancel(true));
1652                  assertSame(f, f.fork());
1653                  f.quietlyJoin();
# Line 1559 | Line 1660 | public class CountedCompleterTest extend
1660       * invoke task throws exception after invoking completeExceptionally
1661       */
1662      public void testCompleteExceptionallySingleton() {
1663 <       ForkJoinTask a =  new CheckedFJTask() {
1664 <            public void realCompute() {
1665 <                CCF f = new LCCF(null, 8);
1666 <                f.completeExceptionally(new FJException());
1667 <                try {
1668 <                    f.invoke();
1669 <                    shouldThrow();
1670 <                } catch (FJException success) {
1570 <                    checkCompletedAbnormally(f, success);
1571 <                }
1663 >        ForkJoinTask a = new CheckedRecursiveAction() {
1664 >            protected void realCompute() {
1665 >                CCF n = new LCCF(8);
1666 >                CCF f = new LCCF(n, 8);
1667 >                FJException ex = new FJException();
1668 >                f.completeExceptionally(ex);
1669 >                f.checkCompletedExceptionally(ex);
1670 >                n.checkCompletedExceptionally(ex);
1671              }};
1672          testInvokeOnPool(singletonPool(), a);
1673      }
# Line 1577 | Line 1676 | public class CountedCompleterTest extend
1676       * invokeAll(t1, t2) invokes all task arguments
1677       */
1678      public void testInvokeAll2Singleton() {
1679 <       ForkJoinTask a =  new CheckedFJTask() {
1680 <            public void realCompute() {
1681 <                CCF f = new LCCF(null, 8);
1682 <                CCF g = new LCCF(null, 9);
1679 >        ForkJoinTask a = new CheckedRecursiveAction() {
1680 >            protected void realCompute() {
1681 >                CCF f = new LCCF(8);
1682 >                CCF g = new LCCF(9);
1683                  invokeAll(f, g);
1684                  assertEquals(21, f.number);
1685                  assertEquals(34, g.number);
# Line 1594 | Line 1693 | public class CountedCompleterTest extend
1693       * invokeAll(tasks) with 1 argument invokes task
1694       */
1695      public void testInvokeAll1Singleton() {
1696 <       ForkJoinTask a =  new CheckedFJTask() {
1697 <            public void realCompute() {
1698 <                CCF f = new LCCF(null, 8);
1696 >        ForkJoinTask a = new CheckedRecursiveAction() {
1697 >            protected void realCompute() {
1698 >                CCF f = new LCCF(8);
1699                  invokeAll(f);
1700                  checkCompletedNormally(f);
1701                  assertEquals(21, f.number);
# Line 1608 | Line 1707 | public class CountedCompleterTest extend
1707       * invokeAll(tasks) with > 2 argument invokes tasks
1708       */
1709      public void testInvokeAll3Singleton() {
1710 <       ForkJoinTask a =  new CheckedFJTask() {
1711 <            public void realCompute() {
1712 <                CCF f = new LCCF(null, 8);
1713 <                CCF g = new LCCF(null, 9);
1714 <                CCF h = new LCCF(null, 7);
1710 >        ForkJoinTask a = new CheckedRecursiveAction() {
1711 >            protected void realCompute() {
1712 >                CCF f = new LCCF(8);
1713 >                CCF g = new LCCF(9);
1714 >                CCF h = new LCCF(7);
1715                  invokeAll(f, g, h);
1716                  assertEquals(21, f.number);
1717                  assertEquals(34, g.number);
# Line 1628 | Line 1727 | public class CountedCompleterTest extend
1727       * invokeAll(collection) invokes all tasks in the collection
1728       */
1729      public void testInvokeAllCollectionSingleton() {
1730 <       ForkJoinTask a =  new CheckedFJTask() {
1731 <            public void realCompute() {
1732 <                CCF f = new LCCF(null, 8);
1733 <                CCF g = new LCCF(null, 9);
1734 <                CCF h = new LCCF(null, 7);
1730 >        ForkJoinTask a = new CheckedRecursiveAction() {
1731 >            protected void realCompute() {
1732 >                CCF f = new LCCF(8);
1733 >                CCF g = new LCCF(9);
1734 >                CCF h = new LCCF(7);
1735                  HashSet set = new HashSet();
1736                  set.add(f);
1737                  set.add(g);
# Line 1652 | Line 1751 | public class CountedCompleterTest extend
1751       * invokeAll(tasks) with any null task throws NPE
1752       */
1753      public void testInvokeAllNPESingleton() {
1754 <       ForkJoinTask a =  new CheckedFJTask() {
1755 <            public void realCompute() {
1756 <                CCF f = new LCCF(null, 8);
1757 <                CCF g = new LCCF(null, 9);
1754 >        ForkJoinTask a = new CheckedRecursiveAction() {
1755 >            protected void realCompute() {
1756 >                CCF f = new LCCF(8);
1757 >                CCF g = new LCCF(9);
1758                  CCF h = null;
1759                  try {
1760                      invokeAll(f, g, h);
# Line 1669 | Line 1768 | public class CountedCompleterTest extend
1768       * invokeAll(t1, t2) throw exception if any task does
1769       */
1770      public void testAbnormalInvokeAll2Singleton() {
1771 <       ForkJoinTask a =  new CheckedFJTask() {
1772 <            public void realCompute() {
1773 <                CCF f = new LCCF(null, 8);
1774 <                FailingCCF g = new LFCCF(null, 9);
1771 >        ForkJoinTask a = new CheckedRecursiveAction() {
1772 >            protected void realCompute() {
1773 >                CCF f = new LCCF(8);
1774 >                FailingCCF g = new LFCCF(9);
1775                  try {
1776                      invokeAll(f, g);
1777                      shouldThrow();
# Line 1687 | Line 1786 | public class CountedCompleterTest extend
1786       * invokeAll(tasks) with 1 argument throws exception if task does
1787       */
1788      public void testAbnormalInvokeAll1Singleton() {
1789 <       ForkJoinTask a =  new CheckedFJTask() {
1790 <            public void realCompute() {
1791 <                FailingCCF g = new LFCCF(null, 9);
1789 >        ForkJoinTask a = new CheckedRecursiveAction() {
1790 >            protected void realCompute() {
1791 >                FailingCCF g = new LFCCF(9);
1792                  try {
1793                      invokeAll(g);
1794                      shouldThrow();
# Line 1704 | Line 1803 | public class CountedCompleterTest extend
1803       * invokeAll(tasks) with > 2 argument throws exception if any task does
1804       */
1805      public void testAbnormalInvokeAll3Singleton() {
1806 <       ForkJoinTask a =  new CheckedFJTask() {
1807 <            public void realCompute() {
1808 <                CCF f = new LCCF(null, 8);
1809 <                FailingCCF g = new LFCCF(null, 9);
1810 <                CCF h = new LCCF(null, 7);
1806 >        ForkJoinTask a = new CheckedRecursiveAction() {
1807 >            protected void realCompute() {
1808 >                CCF f = new LCCF(8);
1809 >                FailingCCF g = new LFCCF(9);
1810 >                CCF h = new LCCF(7);
1811                  try {
1812                      invokeAll(f, g, h);
1813                      shouldThrow();
# Line 1720 | Line 1819 | public class CountedCompleterTest extend
1819      }
1820  
1821      /**
1822 <     * invokeAll(collection)  throws exception if any task does
1822 >     * invokeAll(collection) throws exception if any task does
1823       */
1824      public void testAbnormalInvokeAllCollectionSingleton() {
1825 <       ForkJoinTask a =  new CheckedFJTask() {
1826 <            public void realCompute() {
1827 <                FailingCCF f = new LFCCF(null, 8);
1828 <                CCF g = new LCCF(null, 9);
1829 <                CCF h = new LCCF(null, 7);
1825 >        ForkJoinTask a = new CheckedRecursiveAction() {
1826 >            protected void realCompute() {
1827 >                FailingCCF f = new LFCCF(8);
1828 >                CCF g = new LCCF(9);
1829 >                CCF h = new LCCF(7);
1830                  HashSet set = new HashSet();
1831                  set.add(f);
1832                  set.add(g);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines