--- jsr166/src/test/tck/AtomicIntegerArrayTest.java 2014/12/31 19:21:20 1.30 +++ jsr166/src/test/tck/AtomicIntegerArrayTest.java 2021/01/26 13:33:05 1.39 @@ -15,7 +15,7 @@ import junit.framework.TestSuite; public class AtomicIntegerArrayTest extends JSR166TestCase { public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + main(suite(), args); } public static Test suite() { return new TestSuite(AtomicIntegerArrayTest.class); @@ -36,7 +36,7 @@ public class AtomicIntegerArrayTest exte public void testConstructor2NPE() { try { int[] a = null; - AtomicIntegerArray aa = new AtomicIntegerArray(a); + new AtomicIntegerArray(a); shouldThrow(); } catch (NullPointerException success) {} } @@ -55,6 +55,7 @@ public class AtomicIntegerArrayTest exte /** * get and set for out of bound indices throw IndexOutOfBoundsException */ + @SuppressWarnings("deprecation") public void testIndexing() { AtomicIntegerArray aa = new AtomicIntegerArray(SIZE); for (int index : new int[] { -1, SIZE }) { @@ -160,6 +161,7 @@ public class AtomicIntegerArrayTest exte * repeated weakCompareAndSet succeeds in changing value when equal * to expected */ + @SuppressWarnings("deprecation") public void testWeakCompareAndSet() { AtomicIntegerArray aa = new AtomicIntegerArray(SIZE); for (int i = 0; i < SIZE; i++) { @@ -276,7 +278,7 @@ public class AtomicIntegerArrayTest exte class Counter extends CheckedRunnable { final AtomicIntegerArray aa; - volatile int counts; + int decs; Counter(AtomicIntegerArray a) { aa = a; } public void realRun() { for (;;) { @@ -286,8 +288,8 @@ public class AtomicIntegerArrayTest exte assertTrue(v >= 0); if (v != 0) { done = false; - if (aa.compareAndSet(i, v, v-1)) - ++counts; + if (aa.compareAndSet(i, v, v - 1)) + decs++; } } if (done) @@ -307,17 +309,15 @@ public class AtomicIntegerArrayTest exte aa.set(i, countdown); Counter c1 = new Counter(aa); Counter c2 = new Counter(aa); - Thread t1 = new Thread(c1); - Thread t2 = new Thread(c2); - t1.start(); - t2.start(); + Thread t1 = newStartedThread(c1); + Thread t2 = newStartedThread(c2); t1.join(); t2.join(); - assertEquals(c1.counts+c2.counts, SIZE * countdown); + assertEquals(c1.decs + c2.decs, SIZE * countdown); } /** - * a deserialized serialized array holds same values + * a deserialized/reserialized array holds same values in same order */ public void testSerialization() throws Exception { AtomicIntegerArray x = new AtomicIntegerArray(SIZE);