diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java index 2ae29aa42f3..d34c74cd9a9 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java @@ -48,7 +48,6 @@ import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.NavigableMap; import java.util.NavigableSet; import java.util.NoSuchElementException; import java.util.Set; diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java index 86be622c78b..ccd7f647d83 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java @@ -43,7 +43,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.Map; -import java.util.NavigableMap; import java.util.NavigableSet; import java.util.Set; import java.util.SortedSet; diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index 330f4fb78a3..d8697970586 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -2354,7 +2354,7 @@ public class ForkJoinPool extends AbstractExecutorService { checkPermission(); } - private Object newInstanceFromSystemProperty(String property) + private static Object newInstanceFromSystemProperty(String property) throws ReflectiveOperationException { String className = System.getProperty(property); return (className == null) @@ -2524,15 +2524,13 @@ public class ForkJoinPool extends AbstractExecutorService { * @throws RejectedExecutionException if the task cannot be * scheduled for execution */ + @SuppressWarnings("unchecked") public ForkJoinTask submit(Runnable task) { if (task == null) throw new NullPointerException(); - ForkJoinTask job; - if (task instanceof ForkJoinTask) // avoid re-wrap - job = (ForkJoinTask) task; - else - job = new ForkJoinTask.AdaptedRunnableAction(task); - return externalSubmit(job); + return externalSubmit((task instanceof ForkJoinTask) + ? (ForkJoinTask) task // avoid re-wrap + : new ForkJoinTask.AdaptedRunnableAction(task)); } /** diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java index a3054b865ba..b1550f9f648 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java @@ -203,21 +203,19 @@ public class ForkJoinWorkerThread extends Thread { static final class InnocuousForkJoinWorkerThread extends ForkJoinWorkerThread { /** The ThreadGroup for all InnocuousForkJoinWorkerThreads */ private static final ThreadGroup innocuousThreadGroup = - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction<>() { - public ThreadGroup run() { - ThreadGroup group = Thread.currentThread().getThreadGroup(); - for (ThreadGroup p; (p = group.getParent()) != null; ) - group = p; - return new ThreadGroup(group, "InnocuousForkJoinWorkerThreadGroup"); - }}); + AccessController.doPrivileged(new PrivilegedAction<>() { + public ThreadGroup run() { + ThreadGroup group = Thread.currentThread().getThreadGroup(); + for (ThreadGroup p; (p = group.getParent()) != null; ) + group = p; + return new ThreadGroup( + group, "InnocuousForkJoinWorkerThreadGroup"); + }}); /** An AccessControlContext supporting no privileges */ private static final AccessControlContext INNOCUOUS_ACC = new AccessControlContext( - new ProtectionDomain[] { - new ProtectionDomain(null, null) - }); + new ProtectionDomain[] { new ProtectionDomain(null, null) }); InnocuousForkJoinWorkerThread(ForkJoinPool pool) { super(pool, diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java index ab43971e84d..4f093bf5631 100644 --- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java +++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java @@ -444,7 +444,7 @@ public class ReentrantReadWriteLock } } - private IllegalMonitorStateException unmatchedUnlockException() { + private static IllegalMonitorStateException unmatchedUnlockException() { return new IllegalMonitorStateException( "attempt to unlock read lock, not locked by current thread"); } diff --git a/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java b/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java index 0a7f26bfe64..c2079555218 100644 --- a/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java +++ b/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java @@ -37,7 +37,6 @@ import java.util.Collections; import java.util.Spliterator; import junit.framework.Test; -import junit.framework.TestSuite; public class ArrayDeque8Test extends JSR166TestCase { public static void main(String[] args) { diff --git a/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java b/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java index 1bbd98106ac..344b63c9b79 100644 --- a/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java +++ b/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java @@ -35,7 +35,6 @@ import java.util.ArrayDeque; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Deque; import java.util.Iterator; import java.util.NoSuchElementException; @@ -44,7 +43,6 @@ import java.util.Random; import java.util.concurrent.ThreadLocalRandom; import junit.framework.Test; -import junit.framework.TestSuite; public class ArrayDequeTest extends JSR166TestCase { public static void main(String[] args) { diff --git a/jdk/test/java/util/concurrent/tck/ArrayListTest.java b/jdk/test/java/util/concurrent/tck/ArrayListTest.java index 193b4af8aca..535f04d34b5 100644 --- a/jdk/test/java/util/concurrent/tck/ArrayListTest.java +++ b/jdk/test/java/util/concurrent/tck/ArrayListTest.java @@ -33,11 +33,9 @@ */ import java.util.ArrayList; -import java.util.Collection; import java.util.List; import junit.framework.Test; -import junit.framework.TestSuite; public class ArrayListTest extends JSR166TestCase { public static void main(String[] args) { diff --git a/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java b/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java index fb50658ea91..5fdf279238c 100644 --- a/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java +++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java @@ -75,7 +75,7 @@ public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase { assertTrue(a.compareAndSet(this, two, m4)); assertSame(m4, a.get(this)); assertFalse(a.compareAndSet(this, m5, seven)); - assertFalse(seven == a.get(this)); + assertNotSame(seven, a.get(this)); assertTrue(a.compareAndSet(this, m4, seven)); assertSame(seven, a.get(this)); } @@ -208,7 +208,7 @@ public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase { assertTrue(a.compareAndSet(this, two, m4)); assertSame(m4, a.get(this)); assertFalse(a.compareAndSet(this, m5, seven)); - assertFalse(seven == a.get(this)); + assertNotSame(seven, a.get(this)); assertTrue(a.compareAndSet(this, m4, seven)); assertSame(seven, a.get(this)); } diff --git a/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java b/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java index 6242374ee89..eb8c0b7b565 100644 --- a/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java +++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java @@ -153,7 +153,7 @@ public class AtomicReferenceTest extends JSR166TestCase { AtomicReference z = serialClone(x); assertNotSame(y, z); assertEquals(one, x.get()); - assertEquals(null, y.get()); + assertNull(y.get()); assertEquals(one, z.get()); } diff --git a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java index 6def2fffb3a..6439a40fcb0 100644 --- a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java +++ b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java @@ -2589,28 +2589,28 @@ public class CompletableFutureTest extends JSR166TestCase { // unspecified behavior - both source completions available try { - assertEquals(null, h0.join()); + assertNull(h0.join()); rs[0].assertValue(v1); } catch (CompletionException ok) { checkCompletedWithWrappedException(h0, ex); rs[0].assertNotInvoked(); } try { - assertEquals(null, h1.join()); + assertNull(h1.join()); rs[1].assertValue(v1); } catch (CompletionException ok) { checkCompletedWithWrappedException(h1, ex); rs[1].assertNotInvoked(); } try { - assertEquals(null, h2.join()); + assertNull(h2.join()); rs[2].assertValue(v1); } catch (CompletionException ok) { checkCompletedWithWrappedException(h2, ex); rs[2].assertNotInvoked(); } try { - assertEquals(null, h3.join()); + assertNull(h3.join()); rs[3].assertValue(v1); } catch (CompletionException ok) { checkCompletedWithWrappedException(h3, ex); @@ -2849,28 +2849,28 @@ public class CompletableFutureTest extends JSR166TestCase { // unspecified behavior - both source completions available try { - assertEquals(null, h0.join()); + assertNull(h0.join()); rs[0].assertInvoked(); } catch (CompletionException ok) { checkCompletedWithWrappedException(h0, ex); rs[0].assertNotInvoked(); } try { - assertEquals(null, h1.join()); + assertNull(h1.join()); rs[1].assertInvoked(); } catch (CompletionException ok) { checkCompletedWithWrappedException(h1, ex); rs[1].assertNotInvoked(); } try { - assertEquals(null, h2.join()); + assertNull(h2.join()); rs[2].assertInvoked(); } catch (CompletionException ok) { checkCompletedWithWrappedException(h2, ex); rs[2].assertNotInvoked(); } try { - assertEquals(null, h3.join()); + assertNull(h3.join()); rs[3].assertInvoked(); } catch (CompletionException ok) { checkCompletedWithWrappedException(h3, ex); diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java index 00f8dc6bb28..e0d9f81a7f1 100644 --- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java +++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java @@ -237,8 +237,8 @@ public class ConcurrentHashMap8Test extends JSR166TestCase { Set set1 = map.keySet(); Set set2 = map.keySet(true); set2.add(six); - assertTrue(((ConcurrentHashMap.KeySetView)set2).getMap() == map); - assertTrue(((ConcurrentHashMap.KeySetView)set1).getMap() == map); + assertSame(map, ((ConcurrentHashMap.KeySetView)set2).getMap()); + assertSame(map, ((ConcurrentHashMap.KeySetView)set1).getMap()); assertEquals(set2.size(), map.size()); assertEquals(set1.size(), map.size()); assertTrue((Boolean)map.get(six)); @@ -332,10 +332,10 @@ public class ConcurrentHashMap8Test extends JSR166TestCase { assertFalse(set.add(one)); assertTrue(set.add(six)); assertTrue(set.add(seven)); - assertTrue(set.getMappedValue() == one); - assertTrue(map.get(one) != one); - assertTrue(map.get(six) == one); - assertTrue(map.get(seven) == one); + assertSame(one, set.getMappedValue()); + assertNotSame(one, map.get(one)); + assertSame(one, map.get(six)); + assertSame(one, map.get(seven)); } void checkSpliteratorCharacteristics(Spliterator sp, diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java index 1485d2c4dca..729a6e3d146 100644 --- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java +++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java @@ -43,8 +43,6 @@ import java.util.Map; import java.util.Random; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import junit.framework.Test; import junit.framework.TestSuite; @@ -148,7 +146,7 @@ public class ConcurrentHashMapTest extends JSR166TestCase { ConcurrentHashMap m = new ConcurrentHashMap(); for (int i = 0; i < size; i++) { - assertTrue(m.put(new CI(i), true) == null); + assertNull(m.put(new CI(i), true)); } for (int i = 0; i < size; i++) { assertTrue(m.containsKey(new CI(i))); @@ -169,7 +167,7 @@ public class ConcurrentHashMapTest extends JSR166TestCase { BS bs = new BS(String.valueOf(i)); LexicographicList bis = new LexicographicList(bi); LexicographicList bss = new LexicographicList(bs); - assertTrue(m.putIfAbsent(bis, true) == null); + assertNull(m.putIfAbsent(bis, true)); assertTrue(m.containsKey(bis)); if (m.putIfAbsent(bss, true) == null) assertTrue(m.containsKey(bss)); diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java index aac0bb73910..8a8ffeb6ff9 100644 --- a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java +++ b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java @@ -43,7 +43,6 @@ import java.util.Random; import java.util.concurrent.ConcurrentLinkedDeque; import junit.framework.Test; -import junit.framework.TestSuite; public class ConcurrentLinkedDequeTest extends JSR166TestCase { @@ -67,7 +66,7 @@ public class ConcurrentLinkedDequeTest extends JSR166TestCase { * Returns a new deque of given size containing consecutive * Integers 0 ... n - 1. */ - private ConcurrentLinkedDeque populatedDeque(int n) { + private static ConcurrentLinkedDeque populatedDeque(int n) { ConcurrentLinkedDeque q = new ConcurrentLinkedDeque<>(); assertTrue(q.isEmpty()); for (int i = 0; i < n; ++i) diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java index 57689cce48d..ee6827a660f 100644 --- a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java +++ b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java @@ -41,7 +41,6 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import junit.framework.Test; -import junit.framework.TestSuite; public class ConcurrentLinkedQueueTest extends JSR166TestCase { @@ -65,7 +64,7 @@ public class ConcurrentLinkedQueueTest extends JSR166TestCase { * Returns a new queue of given size containing consecutive * Integers 0 ... n - 1. */ - private ConcurrentLinkedQueue populatedQueue(int n) { + private static ConcurrentLinkedQueue populatedQueue(int n) { ConcurrentLinkedQueue q = new ConcurrentLinkedQueue<>(); assertTrue(q.isEmpty()); for (int i = 0; i < n; ++i) diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java index ae91219f622..cb28b6ae0e7 100644 --- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java +++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java @@ -64,7 +64,7 @@ public class ConcurrentSkipListSetTest extends JSR166TestCase { * Returns a new set of given size containing consecutive * Integers 0 ... n - 1. */ - private ConcurrentSkipListSet populatedSet(int n) { + private static ConcurrentSkipListSet populatedSet(int n) { ConcurrentSkipListSet q = new ConcurrentSkipListSet(); assertTrue(q.isEmpty()); @@ -80,7 +80,7 @@ public class ConcurrentSkipListSetTest extends JSR166TestCase { /** * Returns a new set of first 5 ints. */ - private ConcurrentSkipListSet set5() { + private static ConcurrentSkipListSet set5() { ConcurrentSkipListSet q = new ConcurrentSkipListSet(); assertTrue(q.isEmpty()); q.add(one); @@ -229,7 +229,7 @@ public class ConcurrentSkipListSetTest extends JSR166TestCase { } catch (ClassCastException success) { assertTrue(q.size() < 2); for (int i = 0, size = q.size(); i < size; i++) - assertTrue(q.pollFirst().getClass() == Object.class); + assertSame(Object.class, q.pollFirst().getClass()); assertNull(q.pollFirst()); assertTrue(q.isEmpty()); assertEquals(0, q.size()); diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java index 4b299e74b83..19d34cc01e1 100644 --- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java +++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java @@ -59,7 +59,7 @@ public class ConcurrentSkipListSubSetTest extends JSR166TestCase { * Returns a new set of given size containing consecutive * Integers 0 ... n - 1. */ - private NavigableSet populatedSet(int n) { + private static NavigableSet populatedSet(int n) { ConcurrentSkipListSet q = new ConcurrentSkipListSet(); assertTrue(q.isEmpty()); @@ -79,7 +79,7 @@ public class ConcurrentSkipListSubSetTest extends JSR166TestCase { /** * Returns a new set of first 5 ints. */ - private NavigableSet set5() { + private static NavigableSet set5() { ConcurrentSkipListSet q = new ConcurrentSkipListSet(); assertTrue(q.isEmpty()); q.add(one); @@ -97,7 +97,7 @@ public class ConcurrentSkipListSubSetTest extends JSR166TestCase { /** * Returns a new set of first 5 negative ints. */ - private NavigableSet dset5() { + private static NavigableSet dset5() { ConcurrentSkipListSet q = new ConcurrentSkipListSet(); assertTrue(q.isEmpty()); q.add(m1); diff --git a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java index 329010b308b..2b13e130701 100644 --- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java +++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java @@ -44,7 +44,6 @@ import java.util.NoSuchElementException; import java.util.concurrent.CopyOnWriteArrayList; import junit.framework.Test; -import junit.framework.TestSuite; public class CopyOnWriteArrayListTest extends JSR166TestCase { diff --git a/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java b/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java index eb23564ed77..77e800c23b3 100644 --- a/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java +++ b/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java @@ -32,9 +32,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static java.util.concurrent.TimeUnit.SECONDS; - import java.util.concurrent.CountedCompleter; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicInteger; diff --git a/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java b/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java index 3113b57a563..66e5bd61761 100644 --- a/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java +++ b/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java @@ -40,7 +40,6 @@ import java.util.concurrent.CountedCompleter; import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinTask; -import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; diff --git a/jdk/test/java/util/concurrent/tck/ExchangerTest.java b/jdk/test/java/util/concurrent/tck/ExchangerTest.java index ba6c5443623..36eacc7891e 100644 --- a/jdk/test/java/util/concurrent/tck/ExchangerTest.java +++ b/jdk/test/java/util/concurrent/tck/ExchangerTest.java @@ -160,12 +160,12 @@ public class ExchangerTest extends JSR166TestCase { public void realRun() throws InterruptedException { assertSame(one, e.exchange(two)); exchanged.countDown(); - interrupted.await(); + await(interrupted); assertSame(three, e.exchange(one)); }}); Thread t3 = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { - interrupted.await(); + await(interrupted); assertSame(one, e.exchange(three)); }}); diff --git a/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java b/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java index 4ca78a09a49..92e92478cbc 100644 --- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java +++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java @@ -37,7 +37,6 @@ import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.Set; -import java.util.HashSet; import java.util.concurrent.Callable; import java.util.concurrent.CompletionService; import java.util.concurrent.ExecutionException; diff --git a/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java b/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java index 0ab6084b978..9b7251e6865 100644 --- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java +++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java @@ -172,7 +172,7 @@ public class ExecutorCompletionServiceTest extends JSR166TestCase { CompletionService cs = new ExecutorCompletionService(cachedThreadPool); final CountDownLatch proceed = new CountDownLatch(1); cs.submit(new Callable() { public String call() throws Exception { - proceed.await(); + await(proceed); return TEST_STRING; }}); assertNull(cs.poll()); diff --git a/jdk/test/java/util/concurrent/tck/ExecutorsTest.java b/jdk/test/java/util/concurrent/tck/ExecutorsTest.java index 441a52a5922..90764242502 100644 --- a/jdk/test/java/util/concurrent/tck/ExecutorsTest.java +++ b/jdk/test/java/util/concurrent/tck/ExecutorsTest.java @@ -333,16 +333,12 @@ public class ExecutorsTest extends JSR166TestCase { public void realRun() { try { Thread current = Thread.currentThread(); - assertTrue(!current.isDaemon()); + assertFalse(current.isDaemon()); assertTrue(current.getPriority() <= Thread.NORM_PRIORITY); - ThreadGroup g = current.getThreadGroup(); SecurityManager s = System.getSecurityManager(); - if (s != null) - assertTrue(g == s.getThreadGroup()); - else - assertTrue(g == egroup); - String name = current.getName(); - assertTrue(name.endsWith("thread-1")); + assertSame(current.getThreadGroup(), + (s == null) ? egroup : s.getThreadGroup()); + assertTrue(current.getName().endsWith("thread-1")); } catch (SecurityException ok) { // Also pass if not allowed to change setting } @@ -370,16 +366,12 @@ public class ExecutorsTest extends JSR166TestCase { Runnable r = new CheckedRunnable() { public void realRun() { Thread current = Thread.currentThread(); - assertTrue(!current.isDaemon()); + assertFalse(current.isDaemon()); assertTrue(current.getPriority() <= Thread.NORM_PRIORITY); - ThreadGroup g = current.getThreadGroup(); SecurityManager s = System.getSecurityManager(); - if (s != null) - assertTrue(g == s.getThreadGroup()); - else - assertTrue(g == egroup); - String name = current.getName(); - assertTrue(name.endsWith("thread-1")); + assertSame(current.getThreadGroup(), + (s == null) ? egroup : s.getThreadGroup()); + assertTrue(current.getName().endsWith("thread-1")); assertSame(thisccl, current.getContextClassLoader()); assertEquals(thisacc, AccessController.getContext()); done.countDown(); diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java b/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java index b0fea9a0bfe..f24de8828dc 100644 --- a/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java +++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java @@ -206,7 +206,7 @@ public class ForkJoinPool8Test extends JSR166TestCase { public FJException(Throwable cause) { super(cause); } } - // A simple recursive action for testing + /** A simple recursive action for testing. */ final class FibAction extends CheckedRecursiveAction { final int number; int result; @@ -224,7 +224,7 @@ public class ForkJoinPool8Test extends JSR166TestCase { } } - // A recursive action failing in base case + /** A recursive action failing in base case. */ static final class FailingFibAction extends RecursiveAction { final int number; int result; @@ -932,7 +932,7 @@ public class ForkJoinPool8Test extends JSR166TestCase { } } - // Version of CCF with forced failure in left completions + /** Version of CCF with forced failure in left completions. */ abstract static class FailingCCF extends CountedCompleter { int number; int rnumber; diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java b/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java index 8a87e473a6f..b4153481d61 100644 --- a/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java +++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java @@ -32,8 +32,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -import static java.util.concurrent.TimeUnit.MILLISECONDS; - import java.lang.invoke.MethodHandles; import java.lang.invoke.VarHandle; import java.util.concurrent.CountDownLatch; @@ -93,7 +91,7 @@ public class ForkJoinPool9Test extends JSR166TestCase { Future f = ForkJoinPool.commonPool().submit(runInCommonPool); // Ensure runInCommonPool is truly running in the common pool, // by giving this thread no opportunity to "help" on get(). - assertTrue(taskStarted.await(LONG_DELAY_MS, MILLISECONDS)); + await(taskStarted); assertNull(f.get()); } diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java b/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java index bf5a3652f09..766e35081e3 100644 --- a/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java +++ b/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java @@ -244,7 +244,7 @@ public class ForkJoinPoolTest extends JSR166TestCase { taskStarted.countDown(); assertEquals(1, p.getPoolSize()); assertEquals(1, p.getActiveThreadCount()); - done.await(); + await(done); }}; Future future = p.submit(task); await(taskStarted); diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java index c1063da31aa..6415111510c 100644 --- a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java +++ b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java @@ -127,7 +127,8 @@ public class ForkJoinTask8Test extends JSR166TestCase { assertNull(a.getException()); assertNull(a.getRawResult()); if (a instanceof BinaryAsyncAction) - assertTrue(((BinaryAsyncAction)a).getForkJoinTaskTag() == INITIAL_STATE); + assertEquals(INITIAL_STATE, + ((BinaryAsyncAction)a).getForkJoinTaskTag()); try { a.get(0L, SECONDS); @@ -148,7 +149,8 @@ public class ForkJoinTask8Test extends JSR166TestCase { assertNull(a.getException()); assertSame(expected, a.getRawResult()); if (a instanceof BinaryAsyncAction) - assertTrue(((BinaryAsyncAction)a).getForkJoinTaskTag() == COMPLETE_STATE); + assertEquals(COMPLETE_STATE, + ((BinaryAsyncAction)a).getForkJoinTaskTag()); { Thread.currentThread().interrupt(); diff --git a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java index 1037eb8f3e7..9625be26fea 100644 --- a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java +++ b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java @@ -26,8 +26,9 @@ * However, the following notice accompanied the original version of this * file: * - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at + * Written by Doug Lea and Martin Buchholz with assistance from + * members of JCP JSR-166 Expert Group and released to the public + * domain, as explained at * http://creativecommons.org/publicdomain/zero/1.0/ * Other contributors include Andrew Wright, Jeffrey Hayes, * Pat Fisher, Mike Judd. @@ -35,32 +36,33 @@ /* * @test - * @summary JSR-166 tck tests (conformance testing mode) + * @summary JSR-166 tck tests, in a number of variations. + * The first is the conformance testing variant, + * while others also test implementation details. * @build * * @modules java.management * @run junit/othervm/timeout=1000 JSR166TestCase - */ - -/* - * @test - * @summary JSR-166 tck tests (whitebox tests allowed) - * @build * - * @modules java.base/java.util.concurrent:open - * java.base/java.lang:open - * java.management * @run junit/othervm/timeout=1000 + * --add-opens java.base/java.util.concurrent=ALL-UNNAMED + * --add-opens java.base/java.lang=ALL-UNNAMED * -Djsr166.testImplementationDetails=true * JSR166TestCase * @run junit/othervm/timeout=1000 + * --add-opens java.base/java.util.concurrent=ALL-UNNAMED + * --add-opens java.base/java.lang=ALL-UNNAMED * -Djsr166.testImplementationDetails=true * -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 * JSR166TestCase * @run junit/othervm/timeout=1000 + * --add-opens java.base/java.util.concurrent=ALL-UNNAMED + * --add-opens java.base/java.lang=ALL-UNNAMED * -Djsr166.testImplementationDetails=true * -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 * -Djava.util.secureRandomSeed=true * JSR166TestCase * @run junit/othervm/timeout=1000/policy=tck.policy + * --add-opens java.base/java.util.concurrent=ALL-UNNAMED + * --add-opens java.base/java.lang=ALL-UNNAMED * -Djsr166.testImplementationDetails=true * JSR166TestCase */ @@ -79,8 +81,6 @@ import java.lang.management.ThreadMXBean; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.nio.file.Files; -import java.nio.file.Paths; import java.security.CodeSource; import java.security.Permission; import java.security.PermissionCollection; @@ -118,7 +118,6 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import java.util.regex.Matcher; import java.util.regex.Pattern; import junit.framework.AssertionFailedError; @@ -328,9 +327,11 @@ public class JSR166TestCase extends TestCase { // public static String cpuModel() { // try { -// Matcher matcher = Pattern.compile("model name\\s*: (.*)") +// java.util.regex.Matcher matcher +// = Pattern.compile("model name\\s*: (.*)") // .matcher(new String( -// Files.readAllBytes(Paths.get("/proc/cpuinfo")), "UTF-8")); +// java.nio.file.Files.readAllBytes( +// java.nio.file.Paths.get("/proc/cpuinfo")), "UTF-8")); // matcher.find(); // return matcher.group(1); // } catch (Exception ex) { return null; } diff --git a/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java b/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java index 44dcedc0f01..cdcc7a27334 100644 --- a/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java +++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java @@ -36,7 +36,6 @@ import java.util.concurrent.LinkedBlockingDeque; import java.util.Spliterator; import junit.framework.Test; -import junit.framework.TestSuite; public class LinkedBlockingDeque8Test extends JSR166TestCase { public static void main(String[] args) { diff --git a/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java b/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java index 2559fdffe9d..00fbcc9734b 100644 --- a/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java +++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java @@ -85,7 +85,7 @@ public class LinkedBlockingDequeTest extends JSR166TestCase { * Returns a new deque of given size containing consecutive * Integers 0 ... n - 1. */ - private LinkedBlockingDeque populatedDeque(int n) { + private static LinkedBlockingDeque populatedDeque(int n) { LinkedBlockingDeque q = new LinkedBlockingDeque(n); assertTrue(q.isEmpty()); @@ -801,7 +801,7 @@ public class LinkedBlockingDequeTest extends JSR166TestCase { } }}); - aboutToWait.await(); + await(aboutToWait); waitForThreadToEnterWaitState(t); t.interrupt(); awaitTermination(t); diff --git a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java index 9900c33da70..2c3e498aeaa 100644 --- a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java +++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java @@ -36,7 +36,6 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.Spliterator; import junit.framework.Test; -import junit.framework.TestSuite; public class LinkedBlockingQueue8Test extends JSR166TestCase { public static void main(String[] args) { diff --git a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java index 153cbce667a..cdccb75ed87 100644 --- a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java +++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java @@ -85,7 +85,7 @@ public class LinkedBlockingQueueTest extends JSR166TestCase { * Returns a new queue of given size containing consecutive * Integers 0 ... n - 1. */ - private LinkedBlockingQueue populatedQueue(int n) { + private static LinkedBlockingQueue populatedQueue(int n) { LinkedBlockingQueue q = new LinkedBlockingQueue(n); assertTrue(q.isEmpty()); diff --git a/jdk/test/java/util/concurrent/tck/LinkedListTest.java b/jdk/test/java/util/concurrent/tck/LinkedListTest.java index 08a2ddd9dab..66dd8c02c7a 100644 --- a/jdk/test/java/util/concurrent/tck/LinkedListTest.java +++ b/jdk/test/java/util/concurrent/tck/LinkedListTest.java @@ -40,7 +40,6 @@ import java.util.LinkedList; import java.util.NoSuchElementException; import junit.framework.Test; -import junit.framework.TestSuite; public class LinkedListTest extends JSR166TestCase { public static void main(String[] args) { @@ -70,7 +69,7 @@ public class LinkedListTest extends JSR166TestCase { * Returns a new queue of given size containing consecutive * Integers 0 ... n - 1. */ - private LinkedList populatedQueue(int n) { + private static LinkedList populatedQueue(int n) { LinkedList q = new LinkedList<>(); assertTrue(q.isEmpty()); for (int i = 0; i < n; ++i) diff --git a/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java b/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java index 6a22b0e20a9..7f38351a30a 100644 --- a/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java +++ b/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java @@ -321,7 +321,7 @@ public class LinkedTransferQueueTest extends JSR166TestCase { assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); }}); - aboutToWait.await(); + await(aboutToWait); waitForThreadToEnterWaitState(t); t.interrupt(); awaitTermination(t); @@ -826,7 +826,7 @@ public class LinkedTransferQueueTest extends JSR166TestCase { Thread first = newStartedThread(new CheckedRunnable() { public void realRun() throws InterruptedException { q.transfer(four); - assertTrue(!q.contains(four)); + assertFalse(q.contains(four)); assertEquals(1, q.size()); }}); diff --git a/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java b/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java index 088c389b2cc..aa826b80f1b 100644 --- a/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java +++ b/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java @@ -93,7 +93,7 @@ public class PriorityBlockingQueueTest extends JSR166TestCase { * Returns a new queue of given size containing consecutive * Integers 0 ... n - 1. */ - private PriorityBlockingQueue populatedQueue(int n) { + private static PriorityBlockingQueue populatedQueue(int n) { PriorityBlockingQueue q = new PriorityBlockingQueue(n); assertTrue(q.isEmpty()); @@ -445,7 +445,7 @@ public class PriorityBlockingQueueTest extends JSR166TestCase { } }}); - aboutToWait.await(); + await(aboutToWait); waitForThreadToEnterWaitState(t); t.interrupt(); awaitTermination(t); diff --git a/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java b/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java index c1564730cdf..1c3984dd197 100644 --- a/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java +++ b/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java @@ -42,7 +42,6 @@ import java.util.PriorityQueue; import java.util.Queue; import junit.framework.Test; -import junit.framework.TestSuite; public class PriorityQueueTest extends JSR166TestCase { public static void main(String[] args) { @@ -70,7 +69,7 @@ public class PriorityQueueTest extends JSR166TestCase { * Returns a new queue of given size containing consecutive * Integers 0 ... n - 1. */ - private PriorityQueue populatedQueue(int n) { + private static PriorityQueue populatedQueue(int n) { PriorityQueue q = new PriorityQueue<>(n); assertTrue(q.isEmpty()); for (int i = n - 1; i >= 0; i -= 2) diff --git a/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java b/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java index 01bd92770b7..132b8dad7b0 100644 --- a/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java +++ b/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java @@ -195,7 +195,7 @@ public class RecursiveActionTest extends JSR166TestCase { public FJException(Throwable cause) { super(cause); } } - // A simple recursive action for testing + /** A simple recursive action for testing. */ final class FibAction extends CheckedRecursiveAction { final int number; int result; @@ -213,7 +213,7 @@ public class RecursiveActionTest extends JSR166TestCase { } } - // A recursive action failing in base case + /** A recursive action failing in base case. */ static final class FailingFibAction extends RecursiveAction { final int number; int result; diff --git a/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java b/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java index ce13daa8e7b..49723adcff7 100644 --- a/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java +++ b/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java @@ -210,10 +210,10 @@ public class RecursiveTaskTest extends JSR166TestCase { public FJException() { super(); } } - // An invalid return value for Fib + /** An invalid return value for Fib. */ static final Integer NoResult = Integer.valueOf(-17); - // A simple recursive task for testing + /** A simple recursive task for testing. */ final class FibTask extends CheckedRecursiveTask { final int number; FibTask(int n) { number = n; } @@ -231,7 +231,7 @@ public class RecursiveTaskTest extends JSR166TestCase { } } - // A recursive action failing in base case + /** A recursive action failing in base case. */ final class FailingFibTask extends RecursiveTask { final int number; int result; diff --git a/jdk/test/java/util/concurrent/tck/StampedLockTest.java b/jdk/test/java/util/concurrent/tck/StampedLockTest.java index 65ef48d046b..5f44312c88c 100644 --- a/jdk/test/java/util/concurrent/tck/StampedLockTest.java +++ b/jdk/test/java/util/concurrent/tck/StampedLockTest.java @@ -518,7 +518,7 @@ public class StampedLockTest extends JSR166TestCase { lock.unlockWrite(s); }}); - aboutToLock.await(); + await(aboutToLock); waitForThreadToEnterWaitState(t); assertFalse(lock.isWriteLocked()); assertTrue(lock.isReadLocked()); @@ -777,7 +777,7 @@ public class StampedLockTest extends JSR166TestCase { lock.writeLockInterruptibly(); }}); - locked.await(); + await(locked); assertFalse(lock.validate(p)); assertEquals(0L, lock.tryOptimisticRead()); waitForThreadToEnterWaitState(t); diff --git a/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java b/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java index 102d1b5e3ef..ecd472f2cbe 100644 --- a/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java +++ b/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java @@ -519,7 +519,7 @@ public class SubmissionPublisherTest extends JSR166TestCase { s1.request = false; p.subscribe(s1); s1.awaitSubscribe(); - assertTrue(p.estimateMinimumDemand() == 0); + assertEquals(0, p.estimateMinimumDemand()); TestSubscriber s2 = new TestSubscriber(); p.subscribe(s2); p.submit(1); diff --git a/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java b/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java index 345ac9c7305..afa4f5c026c 100644 --- a/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java +++ b/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java @@ -596,7 +596,7 @@ public class SynchronousQueueTest extends JSR166TestCase { fail("timed out"); Thread.yield(); } - assertTrue(l.size() == 1); + assertEquals(1, l.size()); assertSame(one, l.get(0)); awaitTermination(t); } diff --git a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java index 38862ceee5d..90065c65790 100644 --- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java +++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java @@ -265,7 +265,7 @@ public class ThreadPoolExecutorSubclassTest extends JSR166TestCase { final Runnable task = new CheckedRunnable() { public void realRun() { done.countDown(); }}; p.execute(task); - assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS)); + await(done); } } @@ -359,13 +359,13 @@ public class ThreadPoolExecutorSubclassTest extends JSR166TestCase { public void realRun() throws InterruptedException { threadStarted.countDown(); assertEquals(0, p.getCompletedTaskCount()); - threadProceed.await(); + await(threadProceed); threadDone.countDown(); }}); await(threadStarted); assertEquals(0, p.getCompletedTaskCount()); threadProceed.countDown(); - threadDone.await(); + await(threadDone); long startTime = System.nanoTime(); while (p.getCompletedTaskCount() != 1) { if (millisElapsedSince(startTime) > LONG_DELAY_MS) @@ -1953,7 +1953,7 @@ public class ThreadPoolExecutorSubclassTest extends JSR166TestCase { public void realRun() { done.countDown(); }}); - assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS)); + await(done); } } diff --git a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java index cf0b0971270..9cbb98562f6 100644 --- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java +++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java @@ -45,7 +45,6 @@ import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; @@ -118,7 +117,7 @@ public class ThreadPoolExecutorTest extends JSR166TestCase { final Runnable task = new CheckedRunnable() { public void realRun() { done.countDown(); }}; p.execute(task); - assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS)); + await(done); } } @@ -212,13 +211,13 @@ public class ThreadPoolExecutorTest extends JSR166TestCase { public void realRun() throws InterruptedException { threadStarted.countDown(); assertEquals(0, p.getCompletedTaskCount()); - threadProceed.await(); + await(threadProceed); threadDone.countDown(); }}); await(threadStarted); assertEquals(0, p.getCompletedTaskCount()); threadProceed.countDown(); - threadDone.await(); + await(threadDone); long startTime = System.nanoTime(); while (p.getCompletedTaskCount() != 1) { if (millisElapsedSince(startTime) > LONG_DELAY_MS) @@ -301,6 +300,20 @@ public class ThreadPoolExecutorTest extends JSR166TestCase { } } + /** + * The default rejected execution handler is AbortPolicy. + */ + public void testDefaultRejectedExecutionHandler() { + final ThreadPoolExecutor p = + new ThreadPoolExecutor(1, 2, + LONG_DELAY_MS, MILLISECONDS, + new ArrayBlockingQueue(10)); + try (PoolCleaner cleaner = cleaner(p)) { + assertTrue(p.getRejectedExecutionHandler() + instanceof ThreadPoolExecutor.AbortPolicy); + } + } + /** * getRejectedExecutionHandler returns handler in constructor if not set */ @@ -1139,7 +1152,7 @@ public class ThreadPoolExecutorTest extends JSR166TestCase { await(done); }}; for (int i = 0; i < 2; ++i) - p.submit(Executors.callable(task)); + p.execute(task); for (int i = 0; i < 2; ++i) { try { p.execute(task); @@ -1955,7 +1968,7 @@ public class ThreadPoolExecutorTest extends JSR166TestCase { public void realRun() { done.countDown(); }}); - assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS)); + await(done); } } @@ -2048,7 +2061,7 @@ public class ThreadPoolExecutorTest extends JSR166TestCase { } } // enough time to run all tasks - assertTrue(done.await(nTasks * SHORT_DELAY_MS, MILLISECONDS)); + await(done, nTasks * SHORT_DELAY_MS); } } diff --git a/jdk/test/java/util/concurrent/tck/ThreadTest.java b/jdk/test/java/util/concurrent/tck/ThreadTest.java index 92b2aca52a6..1cd9f0fbce4 100644 --- a/jdk/test/java/util/concurrent/tck/ThreadTest.java +++ b/jdk/test/java/util/concurrent/tck/ThreadTest.java @@ -76,7 +76,7 @@ public class ThreadTest extends JSR166TestCase { * setDefaultUncaughtExceptionHandler. */ public void testGetAndSetDefaultUncaughtExceptionHandler() { - assertEquals(null, Thread.getDefaultUncaughtExceptionHandler()); + assertNull(Thread.getDefaultUncaughtExceptionHandler()); // failure due to SecurityException is OK. // Would be nice to explicitly test both ways, but cannot yet. Thread.UncaughtExceptionHandler defaultHandler diff --git a/jdk/test/java/util/concurrent/tck/TreeSetTest.java b/jdk/test/java/util/concurrent/tck/TreeSetTest.java index a37922e525b..55b28d613d9 100644 --- a/jdk/test/java/util/concurrent/tck/TreeSetTest.java +++ b/jdk/test/java/util/concurrent/tck/TreeSetTest.java @@ -69,7 +69,7 @@ public class TreeSetTest extends JSR166TestCase { * Returns a new set of given size containing consecutive * Integers 0 ... n - 1. */ - private TreeSet populatedSet(int n) { + private static TreeSet populatedSet(int n) { TreeSet q = new TreeSet<>(); assertTrue(q.isEmpty()); for (int i = n - 1; i >= 0; i -= 2) @@ -84,7 +84,7 @@ public class TreeSetTest extends JSR166TestCase { /** * Returns a new set of first 5 ints. */ - private TreeSet set5() { + private static TreeSet set5() { TreeSet q = new TreeSet(); assertTrue(q.isEmpty()); q.add(one); diff --git a/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java b/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java index 37edc1fb04c..a0f2b96ee57 100644 --- a/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java +++ b/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java @@ -60,7 +60,7 @@ public class TreeSubSetTest extends JSR166TestCase { * Returns a new set of given size containing consecutive * Integers 0 ... n - 1. */ - private NavigableSet populatedSet(int n) { + private static NavigableSet populatedSet(int n) { TreeSet q = new TreeSet<>(); assertTrue(q.isEmpty()); @@ -79,7 +79,7 @@ public class TreeSubSetTest extends JSR166TestCase { /** * Returns a new set of first 5 ints. */ - private NavigableSet set5() { + private static NavigableSet set5() { TreeSet q = new TreeSet(); assertTrue(q.isEmpty()); q.add(one); @@ -94,7 +94,7 @@ public class TreeSubSetTest extends JSR166TestCase { return s; } - private NavigableSet dset5() { + private static NavigableSet dset5() { TreeSet q = new TreeSet(); assertTrue(q.isEmpty()); q.add(m1); diff --git a/jdk/test/java/util/concurrent/tck/VectorTest.java b/jdk/test/java/util/concurrent/tck/VectorTest.java index 78c236402f6..1878a78cc93 100644 --- a/jdk/test/java/util/concurrent/tck/VectorTest.java +++ b/jdk/test/java/util/concurrent/tck/VectorTest.java @@ -33,11 +33,9 @@ */ import java.util.Vector; -import java.util.Collection; import java.util.List; import junit.framework.Test; -import junit.framework.TestSuite; public class VectorTest extends JSR166TestCase { public static void main(String[] args) {