Skip to content

Commit

Permalink
8260461: Modernize jsr166 tck tests
Browse files Browse the repository at this point in the history
Reviewed-by: dl
  • Loading branch information
Martin Buchholz committed Jan 28, 2021
1 parent 2b166d8 commit 81e9e6a
Show file tree
Hide file tree
Showing 71 changed files with 7,429 additions and 7,298 deletions.
Expand Up @@ -74,7 +74,7 @@ static class DirectExecutorService extends AbstractExecutorService {
public void shutdown() { shutdown = true; }
public List<Runnable> shutdownNow() {
shutdown = true;
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
public boolean isShutdown() { return shutdown; }
public boolean isTerminated() { return isShutdown(); }
Expand Down Expand Up @@ -138,7 +138,7 @@ public void testSubmitPrivilegedAction() throws Exception {
Runnable r = new CheckedRunnable() {
public void realRun() throws Exception {
ExecutorService e = new DirectExecutorService();
Future future = e.submit(Executors.callable(new PrivilegedAction() {
Future<?> future = e.submit(Executors.callable(new PrivilegedAction<Object>() {
public Object run() {
return TEST_STRING;
}}));
Expand All @@ -159,7 +159,7 @@ public void testSubmitPrivilegedExceptionAction() throws Exception {
Runnable r = new CheckedRunnable() {
public void realRun() throws Exception {
ExecutorService e = new DirectExecutorService();
Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
Future<?> future = e.submit(Executors.callable(new PrivilegedExceptionAction<Object>() {
public Object run() {
return TEST_STRING;
}}));
Expand All @@ -177,7 +177,7 @@ public void testSubmitFailedPrivilegedExceptionAction() throws Exception {
Runnable r = new CheckedRunnable() {
public void realRun() throws Exception {
ExecutorService e = new DirectExecutorService();
Future future = e.submit(Executors.callable(new PrivilegedExceptionAction() {
Future<?> future = e.submit(Executors.callable(new PrivilegedExceptionAction<Object>() {
public Object run() throws Exception {
throw new IndexOutOfBoundsException();
}}));
Expand Down Expand Up @@ -208,7 +208,7 @@ public void testNullTaskSubmission() {
public void testInterruptedSubmit() throws InterruptedException {
final CountDownLatch submitted = new CountDownLatch(1);
final CountDownLatch quittingTime = new CountDownLatch(1);
final Callable<Void> awaiter = new CheckedCallable<Void>() {
final Callable<Void> awaiter = new CheckedCallable<>() {
public Void realCall() throws InterruptedException {
assertTrue(quittingTime.await(2*LONG_DELAY_MS, MILLISECONDS));
return null;
Expand Down Expand Up @@ -240,7 +240,7 @@ public void testSubmitEE() throws InterruptedException {
60, TimeUnit.SECONDS,
new ArrayBlockingQueue<Runnable>(10));
try (PoolCleaner cleaner = cleaner(p)) {
Callable c = new Callable() {
Callable<Object> c = new Callable<>() {
public Object call() { throw new ArithmeticException(); }};
try {
p.submit(c).get();
Expand Down Expand Up @@ -611,7 +611,7 @@ public void testTimedInvokeAll6() throws Exception {
e.invokeAll(tasks, timeout, MILLISECONDS);
assertEquals(tasks.size(), futures.size());
assertTrue(millisElapsedSince(startTime) >= timeout);
for (Future future : futures)
for (Future<?> future : futures)
assertTrue(future.isDone());
try {
assertEquals("0", futures.get(0).get());
Expand Down
36 changes: 17 additions & 19 deletions test/jdk/java/util/concurrent/tck/AbstractQueueTest.java
Expand Up @@ -49,26 +49,26 @@ public static Test suite() {
return new TestSuite(AbstractQueueTest.class);
}

static class Succeed extends AbstractQueue<Integer> {
public boolean offer(Integer x) {
static class Succeed extends AbstractQueue<Item> {
public boolean offer(Item x) {
if (x == null) throw new NullPointerException();
return true;
}
public Integer peek() { return one; }
public Integer poll() { return one; }
public Item peek() { return one; }
public Item poll() { return one; }
public int size() { return 0; }
public Iterator iterator() { return null; } // not needed
public Iterator<Item> iterator() { return null; } // not needed
}

static class Fail extends AbstractQueue<Integer> {
public boolean offer(Integer x) {
static class Fail extends AbstractQueue<Item> {
public boolean offer(Item x) {
if (x == null) throw new NullPointerException();
return false;
}
public Integer peek() { return null; }
public Integer poll() { return null; }
public Item peek() { return null; }
public Item poll() { return null; }
public int size() { return 0; }
public Iterator iterator() { return null; } // not needed
public Iterator<Item> iterator() { return null; } // not needed
}

/**
Expand Down Expand Up @@ -166,9 +166,9 @@ public void testAddAllSelf() {
*/
public void testAddAll2() {
Succeed q = new Succeed();
Integer[] ints = new Integer[SIZE];
Item[] items = new Item[SIZE];
try {
q.addAll(Arrays.asList(ints));
q.addAll(Arrays.asList(items));
shouldThrow();
} catch (NullPointerException success) {}
}
Expand All @@ -179,11 +179,11 @@ public void testAddAll2() {
*/
public void testAddAll3() {
Succeed q = new Succeed();
Integer[] ints = new Integer[SIZE];
Item[] items = new Item[SIZE];
for (int i = 0; i < SIZE - 1; ++i)
ints[i] = new Integer(i);
items[i] = itemFor(i);
try {
q.addAll(Arrays.asList(ints));
q.addAll(Arrays.asList(items));
shouldThrow();
} catch (NullPointerException success) {}
}
Expand All @@ -193,11 +193,9 @@ public void testAddAll3() {
*/
public void testAddAll4() {
Fail q = new Fail();
Integer[] ints = new Integer[SIZE];
for (int i = 0; i < SIZE; ++i)
ints[i] = new Integer(i);
Item[] items = seqItems(SIZE);
try {
q.addAll(Arrays.asList(ints));
q.addAll(Arrays.asList(items));
shouldThrow();
} catch (IllegalStateException success) {}
}
Expand Down

1 comment on commit 81e9e6a

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.