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

Comparing jsr166/src/test/tck/Atomic8Test.java (file contents):
Revision 1.1 by dl, Sun Sep 8 23:00:36 2013 UTC vs.
Revision 1.4 by jsr166, Thu Jan 15 18:34:19 2015 UTC

# Line 5 | Line 5
5   * http://creativecommons.org/publicdomain/zero/1.0/
6   */
7  
8 < import junit.framework.*;
9 < import java.util.*;
10 < import java.util.concurrent.*;
11 < import java.util.concurrent.atomic.*;
8 > import java.util.concurrent.atomic.AtomicInteger;
9 > import java.util.concurrent.atomic.AtomicIntegerArray;
10 > import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
11 > import java.util.concurrent.atomic.AtomicLong;
12 > import java.util.concurrent.atomic.AtomicLongArray;
13 > import java.util.concurrent.atomic.AtomicLongFieldUpdater;
14 > import java.util.concurrent.atomic.AtomicReference;
15 > import java.util.concurrent.atomic.AtomicReferenceArray;
16 > import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
17 >
18 > import junit.framework.Test;
19 > import junit.framework.TestSuite;
20  
21   public class Atomic8Test extends JSR166TestCase {
22  
# Line 37 | Line 45 | public class Atomic8Test extends JSR166T
45      volatile int anIntField;
46      volatile Integer anIntegerField;
47  
48 +    AtomicLongFieldUpdater aLongFieldUpdater() {
49 +        return AtomicLongFieldUpdater.newUpdater
50 +            (Atomic8Test.class, "aLongField");
51 +    }
52 +
53 +    AtomicIntegerFieldUpdater anIntFieldUpdater() {
54 +        return AtomicIntegerFieldUpdater.newUpdater
55 +            (Atomic8Test.class, "anIntField");
56 +    }
57 +
58 +    AtomicReferenceFieldUpdater<Atomic8Test,Integer> anIntegerFieldUpdater() {
59 +        return AtomicReferenceFieldUpdater.newUpdater
60 +            (Atomic8Test.class, Integer.class, "anIntegerField");
61 +    }
62 +
63      /**
64       * AtomicLong getAndUpdate returns previous value and updates
65       * result of supplied function
# Line 77 | Line 100 | public class Atomic8Test extends JSR166T
100          AtomicLong a = new AtomicLong(1L);
101          assertEquals(7L, a.accumulateAndGet(6L, Long::sum));
102          assertEquals(10L, a.accumulateAndGet(3L, Long::sum));
103 +        assertEquals(10L, a.get());
104      }
105  
106      /**
# Line 98 | Line 122 | public class Atomic8Test extends JSR166T
122          AtomicInteger a = new AtomicInteger(1);
123          assertEquals(18, a.updateAndGet(Atomic8Test::addInt17));
124          assertEquals(35, a.updateAndGet(Atomic8Test::addInt17));
125 +        assertEquals(35, a.get());
126      }
127  
128      /**
# Line 119 | Line 144 | public class Atomic8Test extends JSR166T
144          AtomicInteger a = new AtomicInteger(1);
145          assertEquals(7, a.accumulateAndGet(6, Integer::sum));
146          assertEquals(10, a.accumulateAndGet(3, Integer::sum));
147 +        assertEquals(10, a.get());
148      }
149  
150      /**
# Line 140 | Line 166 | public class Atomic8Test extends JSR166T
166          AtomicReference<Integer> a = new AtomicReference<Integer>(one);
167          assertEquals(new Integer(18), a.updateAndGet(Atomic8Test::addInteger17));
168          assertEquals(new Integer(35), a.updateAndGet(Atomic8Test::addInteger17));
169 +        assertEquals(new Integer(35), a.get());
170      }
171  
172      /**
# Line 161 | Line 188 | public class Atomic8Test extends JSR166T
188          AtomicReference<Integer> a = new AtomicReference<Integer>(one);
189          assertEquals(new Integer(7), a.accumulateAndGet(6, Atomic8Test::sumInteger));
190          assertEquals(new Integer(10), a.accumulateAndGet(3, Atomic8Test::sumInteger));
191 +        assertEquals(new Integer(10), a.get());
192      }
193  
166
194      /**
195       * AtomicLongArray getAndUpdate returns previous value and updates
196       * result of supplied function
# Line 185 | Line 212 | public class Atomic8Test extends JSR166T
212          a.set(0, 1);
213          assertEquals(18L, a.updateAndGet(0, Atomic8Test::addLong17));
214          assertEquals(35L, a.updateAndGet(0, Atomic8Test::addLong17));
215 +        assertEquals(35L, a.get(0));
216      }
217  
218      /**
# Line 208 | Line 236 | public class Atomic8Test extends JSR166T
236          a.set(0, 1);
237          assertEquals(7L, a.accumulateAndGet(0, 6L, Long::sum));
238          assertEquals(10L, a.accumulateAndGet(0, 3L, Long::sum));
239 +        assertEquals(10L, a.get(0));
240      }
241  
242      /**
# Line 231 | Line 260 | public class Atomic8Test extends JSR166T
260          a.set(0, 1);
261          assertEquals(18, a.updateAndGet(0, Atomic8Test::addInt17));
262          assertEquals(35, a.updateAndGet(0, Atomic8Test::addInt17));
263 +        assertEquals(35, a.get(0));
264      }
265  
266      /**
# Line 307 | Line 337 | public class Atomic8Test extends JSR166T
337       * result of supplied function
338       */
339      public void testLongFieldUpdaterGetAndUpdate() {
340 <        AtomicLongFieldUpdater a = AtomicLongFieldUpdater.
311 <            newUpdater(Atomic8Test.class, "aLongField");
340 >        AtomicLongFieldUpdater a = aLongFieldUpdater();
341          a.set(this, 1);
342          assertEquals(1L, a.getAndUpdate(this, Atomic8Test::addLong17));
343          assertEquals(18L, a.getAndUpdate(this, Atomic8Test::addLong17));
344          assertEquals(35L, a.get(this));
345 +        assertEquals(35L, aLongField);
346      }
347  
348      /**
# Line 320 | Line 350 | public class Atomic8Test extends JSR166T
350       * returns result.
351       */
352      public void testLongFieldUpdaterUpdateAndGet() {
353 <        AtomicLongFieldUpdater a = AtomicLongFieldUpdater.
324 <            newUpdater(Atomic8Test.class, "aLongField");
353 >        AtomicLongFieldUpdater a = aLongFieldUpdater();
354          a.set(this, 1);
355          assertEquals(18L, a.updateAndGet(this, Atomic8Test::addLong17));
356          assertEquals(35L, a.updateAndGet(this, Atomic8Test::addLong17));
357 +        assertEquals(35L, a.get(this));
358 +        assertEquals(35L, aLongField);
359      }
360  
361      /**
# Line 332 | Line 363 | public class Atomic8Test extends JSR166T
363       * and updates with supplied function.
364       */
365      public void testLongFieldUpdaterGetAndAccumulate() {
366 <        AtomicLongFieldUpdater a = AtomicLongFieldUpdater.
336 <            newUpdater(Atomic8Test.class, "aLongField");
366 >        AtomicLongFieldUpdater a = aLongFieldUpdater();
367          a.set(this, 1);
368          assertEquals(1L, a.getAndAccumulate(this, 2L, Long::sum));
369          assertEquals(3L, a.getAndAccumulate(this, 3L, Long::sum));
370          assertEquals(6L, a.get(this));
371 +        assertEquals(6L, aLongField);
372      }
373  
374      /**
# Line 345 | Line 376 | public class Atomic8Test extends JSR166T
376       * function and returns result.
377       */
378      public void testLongFieldUpdaterAccumulateAndGet() {
379 <        AtomicLongFieldUpdater a = AtomicLongFieldUpdater.
349 <            newUpdater(Atomic8Test.class, "aLongField");
379 >        AtomicLongFieldUpdater a = aLongFieldUpdater();
380          a.set(this, 1);
381          assertEquals(7L, a.accumulateAndGet(this, 6L, Long::sum));
382          assertEquals(10L, a.accumulateAndGet(this, 3L, Long::sum));
383 +        assertEquals(10L, a.get(this));
384 +        assertEquals(10L, aLongField);
385      }
386  
387      /**
# Line 357 | Line 389 | public class Atomic8Test extends JSR166T
389       * result of supplied function
390       */
391      public void testIntegerFieldUpdaterGetAndUpdate() {
392 <        AtomicIntegerFieldUpdater a = AtomicIntegerFieldUpdater.
361 <            newUpdater(Atomic8Test.class, "anIntField");
392 >        AtomicIntegerFieldUpdater a = anIntFieldUpdater();
393          a.set(this, 1);
394          assertEquals(1, a.getAndUpdate(this, Atomic8Test::addInt17));
395          assertEquals(18, a.getAndUpdate(this, Atomic8Test::addInt17));
396          assertEquals(35, a.get(this));
397 +        assertEquals(35, anIntField);
398      }
399  
400      /**
# Line 370 | Line 402 | public class Atomic8Test extends JSR166T
402       * returns result.
403       */
404      public void testIntegerFieldUpdaterUpdateAndGet() {
405 <        AtomicIntegerFieldUpdater a = AtomicIntegerFieldUpdater.
374 <            newUpdater(Atomic8Test.class, "anIntField");
405 >        AtomicIntegerFieldUpdater a = anIntFieldUpdater();
406          a.set(this, 1);
407          assertEquals(18, a.updateAndGet(this, Atomic8Test::addInt17));
408          assertEquals(35, a.updateAndGet(this, Atomic8Test::addInt17));
409 +        assertEquals(35, a.get(this));
410 +        assertEquals(35, anIntField);
411      }
412  
413      /**
# Line 382 | Line 415 | public class Atomic8Test extends JSR166T
415       * and updates with supplied function.
416       */
417      public void testIntegerFieldUpdaterGetAndAccumulate() {
418 <        AtomicIntegerFieldUpdater a = AtomicIntegerFieldUpdater.
386 <            newUpdater(Atomic8Test.class, "anIntField");
418 >        AtomicIntegerFieldUpdater a = anIntFieldUpdater();
419          a.set(this, 1);
420          assertEquals(1, a.getAndAccumulate(this, 2, Integer::sum));
421          assertEquals(3, a.getAndAccumulate(this, 3, Integer::sum));
422          assertEquals(6, a.get(this));
423 +        assertEquals(6, anIntField);
424      }
425  
426      /**
# Line 395 | Line 428 | public class Atomic8Test extends JSR166T
428       * function and returns result.
429       */
430      public void testIntegerFieldUpdaterAccumulateAndGet() {
431 <        AtomicIntegerFieldUpdater a = AtomicIntegerFieldUpdater.
399 <            newUpdater(Atomic8Test.class, "anIntField");
431 >        AtomicIntegerFieldUpdater a = anIntFieldUpdater();
432          a.set(this, 1);
433          assertEquals(7, a.accumulateAndGet(this, 6, Integer::sum));
434          assertEquals(10, a.accumulateAndGet(this, 3, Integer::sum));
435 +        assertEquals(10, a.get(this));
436 +        assertEquals(10, anIntField);
437      }
438  
405
439      /**
440       * AtomicReferenceFieldUpdater getAndUpdate returns previous value
441       * and updates result of supplied function
442       */
443      public void testReferenceFieldUpdaterGetAndUpdate() {
444 <        AtomicReferenceFieldUpdater<Atomic8Test,Integer> a = AtomicReferenceFieldUpdater.
412 <            newUpdater(Atomic8Test.class, Integer.class, "anIntegerField");
444 >        AtomicReferenceFieldUpdater<Atomic8Test,Integer> a = anIntegerFieldUpdater();
445          a.set(this, one);
446          assertEquals(new Integer(1), a.getAndUpdate(this, Atomic8Test::addInteger17));
447          assertEquals(new Integer(18), a.getAndUpdate(this, Atomic8Test::addInteger17));
448          assertEquals(new Integer(35), a.get(this));
449 +        assertEquals(new Integer(35), anIntegerField);
450      }
451  
452      /**
# Line 421 | Line 454 | public class Atomic8Test extends JSR166T
454       * function and returns result.
455       */
456      public void testReferenceFieldUpdaterUpdateAndGet() {
457 <        AtomicReferenceFieldUpdater<Atomic8Test,Integer> a = AtomicReferenceFieldUpdater.
425 <            newUpdater(Atomic8Test.class, Integer.class, "anIntegerField");
457 >        AtomicReferenceFieldUpdater<Atomic8Test,Integer> a = anIntegerFieldUpdater();
458          a.set(this, one);
459          assertEquals(new Integer(18), a.updateAndGet(this, Atomic8Test::addInteger17));
460          assertEquals(new Integer(35), a.updateAndGet(this, Atomic8Test::addInteger17));
461 +        assertEquals(new Integer(35), a.get(this));
462 +        assertEquals(new Integer(35), anIntegerField);
463      }
464  
465      /**
# Line 433 | Line 467 | public class Atomic8Test extends JSR166T
467       * with supplied function.
468       */
469      public void testReferenceFieldUpdaterGetAndAccumulate() {
470 <        AtomicReferenceFieldUpdater<Atomic8Test,Integer> a = AtomicReferenceFieldUpdater.
437 <            newUpdater(Atomic8Test.class, Integer.class, "anIntegerField");
470 >        AtomicReferenceFieldUpdater<Atomic8Test,Integer> a = anIntegerFieldUpdater();
471          a.set(this, one);
472          assertEquals(new Integer(1), a.getAndAccumulate(this, 2, Atomic8Test::sumInteger));
473          assertEquals(new Integer(3), a.getAndAccumulate(this, 3, Atomic8Test::sumInteger));
474          assertEquals(new Integer(6), a.get(this));
475 +        assertEquals(new Integer(6), anIntegerField);
476      }
477  
478      /**
# Line 446 | Line 480 | public class Atomic8Test extends JSR166T
480       * supplied function and returns result.
481       */
482      public void testReferenceFieldUpdaterAccumulateAndGet() {
483 <        AtomicReferenceFieldUpdater<Atomic8Test,Integer> a = AtomicReferenceFieldUpdater.
450 <            newUpdater(Atomic8Test.class, Integer.class, "anIntegerField");
483 >        AtomicReferenceFieldUpdater<Atomic8Test,Integer> a = anIntegerFieldUpdater();
484          a.set(this, one);
485          assertEquals(new Integer(7), a.accumulateAndGet(this, 6, Atomic8Test::sumInteger));
486          assertEquals(new Integer(10), a.accumulateAndGet(this, 3, Atomic8Test::sumInteger));
487 +        assertEquals(new Integer(10), a.get(this));
488 +        assertEquals(new Integer(10), anIntegerField);
489      }
490  
491      /**
492 <     * All Atomic getAndUpdate methods throw npe on null function argument
492 >     * All Atomic getAndUpdate methods throw NullPointerException on
493 >     * null function argument
494       */
495      public void testGetAndUpdateNPE() {
496 <        try { new AtomicLong().getAndUpdate(null); shouldThrow();
497 <        } catch(NullPointerException ok) {}
498 <        try { new AtomicInteger().getAndUpdate(null); shouldThrow();
499 <        } catch(NullPointerException ok) {}
500 <        try { new AtomicReference().getAndUpdate(null); shouldThrow();
501 <        } catch(NullPointerException ok) {}
502 <        try { new AtomicLongArray(1).getAndUpdate(0, null); shouldThrow();
503 <        } catch(NullPointerException ok) {}
504 <        try { new AtomicIntegerArray(1).getAndUpdate(0, null); shouldThrow();
505 <        } catch(NullPointerException ok) {}
506 <        try { new AtomicReferenceArray(1).getAndUpdate(0, null); shouldThrow();
507 <        } catch(NullPointerException ok) {}
508 <        try { AtomicLongFieldUpdater.
509 <                newUpdater(Atomic8Test.class, "aLongField").
510 <                getAndUpdate(this, null);
475 <            shouldThrow();
476 <        } catch(NullPointerException ok) {}
477 <        try { AtomicIntegerFieldUpdater.
478 <                newUpdater(Atomic8Test.class, "anIntField").
479 <                getAndUpdate(this, null);
480 <            shouldThrow();
481 <        } catch(NullPointerException ok) {}
482 <        try {  AtomicReferenceFieldUpdater.
483 <                newUpdater(Atomic8Test.class, Integer.class, "anIntegerField").
484 <                getAndUpdate(this, null);
485 <            shouldThrow();
486 <        } catch(NullPointerException ok) {}
487 <    }
488 <
489 <    /**
490 <     * All Atomic updateAndGet methods throw npe on null function argument
491 <     */
492 <    public void testUpdateGetAndNPE() {
493 <        try { new AtomicLong().updateAndGet(null); shouldThrow();
494 <        } catch(NullPointerException ok) {}
495 <        try { new AtomicInteger().updateAndGet(null); shouldThrow();
496 <        } catch(NullPointerException ok) {}
497 <        try { new AtomicReference().updateAndGet(null); shouldThrow();
498 <        } catch(NullPointerException ok) {}
499 <        try { new AtomicLongArray(1).updateAndGet(0, null); shouldThrow();
500 <        } catch(NullPointerException ok) {}
501 <        try { new AtomicIntegerArray(1).updateAndGet(0, null); shouldThrow();
502 <        } catch(NullPointerException ok) {}
503 <        try { new AtomicReferenceArray(1).updateAndGet(0, null); shouldThrow();
504 <        } catch(NullPointerException ok) {}
505 <        try { AtomicLongFieldUpdater.
506 <                newUpdater(Atomic8Test.class, "aLongField").
507 <                updateAndGet(this, null);
508 <            shouldThrow();
509 <        } catch(NullPointerException ok) {}
510 <        try { AtomicIntegerFieldUpdater.
511 <                newUpdater(Atomic8Test.class, "anIntField").
512 <                updateAndGet(this, null);
513 <            shouldThrow();
514 <        } catch(NullPointerException ok) {}
515 <        try {  AtomicReferenceFieldUpdater.
516 <                newUpdater(Atomic8Test.class, Integer.class, "anIntegerField").
517 <                updateAndGet(this, null);
518 <            shouldThrow();
519 <        } catch(NullPointerException ok) {}
496 >        Runnable[] throwingActions = {
497 >            () -> new AtomicLong().getAndUpdate(null),
498 >            () -> new AtomicInteger().getAndUpdate(null),
499 >            () -> new AtomicReference().getAndUpdate(null),
500 >            () -> new AtomicLongArray(1).getAndUpdate(0, null),
501 >            () -> new AtomicIntegerArray(1).getAndUpdate(0, null),
502 >            () -> new AtomicReferenceArray(1).getAndUpdate(0, null),
503 >            () -> aLongFieldUpdater().getAndUpdate(this, null),
504 >            () -> anIntFieldUpdater().getAndUpdate(this, null),
505 >            () -> anIntegerFieldUpdater().getAndUpdate(this, null),
506 >            ////() -> aLongFieldUpdater().getAndUpdate(null, Atomic8Test::addLong17),
507 >            ////() -> anIntFieldUpdater().getAndUpdate(null, Atomic8Test::addInt17),
508 >            ////() -> anIntegerFieldUpdater().getAndUpdate(null, Atomic8Test::addInteger17),
509 >        };
510 >        assertThrows(NullPointerException.class, throwingActions);
511      }
512  
513      /**
514 <     * All Atomic getAndAccumulate methods throw npe on null function argument
514 >     * All Atomic updateAndGet methods throw NullPointerException on null function argument
515 >     */
516 >    public void testUpdateAndGetNPE() {
517 >        Runnable[] throwingActions = {
518 >            () -> new AtomicLong().updateAndGet(null),
519 >            () -> new AtomicInteger().updateAndGet(null),
520 >            () -> new AtomicReference().updateAndGet(null),
521 >            () -> new AtomicLongArray(1).updateAndGet(0, null),
522 >            () -> new AtomicIntegerArray(1).updateAndGet(0, null),
523 >            () -> new AtomicReferenceArray(1).updateAndGet(0, null),
524 >            () -> aLongFieldUpdater().updateAndGet(this, null),
525 >            () -> anIntFieldUpdater().updateAndGet(this, null),
526 >            () -> anIntegerFieldUpdater().updateAndGet(this, null),
527 >        };
528 >        assertThrows(NullPointerException.class, throwingActions);
529 >    }
530 >
531 >    /**
532 >     * All Atomic getAndAccumulate methods throw NullPointerException
533 >     * on null function argument
534       */
535      public void testGetAndAccumulateNPE() {
536 <        try { new AtomicLong().getAndAccumulate(1L, null); shouldThrow();
537 <        } catch(NullPointerException ok) {}
538 <        try { new AtomicInteger().getAndAccumulate(1, null); shouldThrow();
539 <        } catch(NullPointerException ok) {}
540 <        try { new AtomicReference().getAndAccumulate(one, null); shouldThrow();
541 <        } catch(NullPointerException ok) {}
542 <        try { new AtomicLongArray(1).getAndAccumulate(0, 1L, null); shouldThrow();
543 <        } catch(NullPointerException ok) {}
544 <        try { new AtomicIntegerArray(1).getAndAccumulate(0, 1, null); shouldThrow();
545 <        } catch(NullPointerException ok) {}
546 <        try { new AtomicReferenceArray(1).getAndAccumulate(0, one, null); shouldThrow();
547 <        } catch(NullPointerException ok) {}
538 <        try { AtomicLongFieldUpdater.
539 <                newUpdater(Atomic8Test.class, "aLongField").
540 <                getAndAccumulate(this, 1L, null);
541 <            shouldThrow();
542 <        } catch(NullPointerException ok) {}
543 <        try { AtomicIntegerFieldUpdater.
544 <                newUpdater(Atomic8Test.class, "anIntField").
545 <                getAndAccumulate(this, 1, null);
546 <            shouldThrow();
547 <        } catch(NullPointerException ok) {}
548 <        try {  AtomicReferenceFieldUpdater.
549 <                newUpdater(Atomic8Test.class, Integer.class, "anIntegerField").
550 <                getAndAccumulate(this, one, null);
551 <            shouldThrow();
552 <        } catch(NullPointerException ok) {}
536 >        Runnable[] throwingActions = {
537 >            () -> new AtomicLong().getAndAccumulate(1L, null),
538 >            () -> new AtomicInteger().getAndAccumulate(1, null),
539 >            () -> new AtomicReference().getAndAccumulate(one, null),
540 >            () -> new AtomicLongArray(1).getAndAccumulate(0, 1L, null),
541 >            () -> new AtomicIntegerArray(1).getAndAccumulate(0, 1, null),
542 >            () -> new AtomicReferenceArray(1).getAndAccumulate(0, one, null),
543 >            () -> aLongFieldUpdater().getAndAccumulate(this, 1L, null),
544 >            () -> anIntFieldUpdater().getAndAccumulate(this, 1, null),
545 >            () -> anIntegerFieldUpdater().getAndAccumulate(this, one, null),
546 >        };
547 >        assertThrows(NullPointerException.class, throwingActions);
548      }
549  
550      /**
551 <     * All Atomic accumulateAndGet methods throw npe on null function argument
551 >     * All Atomic accumulateAndGet methods throw NullPointerException
552 >     * on null function argument
553       */
554      public void testAccumulateAndGetNPE() {
555 <        try { new AtomicLong().accumulateAndGet(1L, null); shouldThrow();
556 <        } catch(NullPointerException ok) {}
557 <        try { new AtomicInteger().accumulateAndGet(1, null); shouldThrow();
558 <        } catch(NullPointerException ok) {}
559 <        try { new AtomicReference().accumulateAndGet(one, null); shouldThrow();
560 <        } catch(NullPointerException ok) {}
561 <        try { new AtomicLongArray(1).accumulateAndGet(0, 1L, null); shouldThrow();
562 <        } catch(NullPointerException ok) {}
563 <        try { new AtomicIntegerArray(1).accumulateAndGet(0, 1, null); shouldThrow();
564 <        } catch(NullPointerException ok) {}
565 <        try { new AtomicReferenceArray(1).accumulateAndGet(0, one, null); shouldThrow();
566 <        } catch(NullPointerException ok) {}
571 <        try { AtomicLongFieldUpdater.
572 <                newUpdater(Atomic8Test.class, "aLongField").
573 <                accumulateAndGet(this, 1L, null);
574 <            shouldThrow();
575 <        } catch(NullPointerException ok) {}
576 <        try { AtomicIntegerFieldUpdater.
577 <                newUpdater(Atomic8Test.class, "anIntField").
578 <                accumulateAndGet(this, 1, null);
579 <            shouldThrow();
580 <        } catch(NullPointerException ok) {}
581 <        try {  AtomicReferenceFieldUpdater.
582 <                newUpdater(Atomic8Test.class, Integer.class, "anIntegerField").
583 <                accumulateAndGet(this, one, null);
584 <            shouldThrow();
585 <        } catch(NullPointerException ok) {}
555 >        Runnable[] throwingActions = {
556 >            () -> new AtomicLong().accumulateAndGet(1L, null),
557 >            () -> new AtomicInteger().accumulateAndGet(1, null),
558 >            () -> new AtomicReference().accumulateAndGet(one, null),
559 >            () -> new AtomicLongArray(1).accumulateAndGet(0, 1L, null),
560 >            () -> new AtomicIntegerArray(1).accumulateAndGet(0, 1, null),
561 >            () -> new AtomicReferenceArray(1).accumulateAndGet(0, one, null),
562 >            () -> aLongFieldUpdater().accumulateAndGet(this, 1L, null),
563 >            () -> anIntFieldUpdater().accumulateAndGet(this, 1, null),
564 >            () -> anIntegerFieldUpdater().accumulateAndGet(this, one, null),
565 >        };
566 >        assertThrows(NullPointerException.class, throwingActions);
567      }
568  
569   }
589

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines