8164169: Miscellaneous changes imported from jsr166 CVS 2016-09
Reviewed-by: martin, psandoz, shade
--- a/jdk/src/java.base/share/classes/java/util/ArrayDeque.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/ArrayDeque.java Mon Sep 12 13:14:49 2016 -0700
@@ -81,8 +81,8 @@
* Java Collections Framework</a>.
*
* @author Josh Bloch and Doug Lea
+ * @param <E> the type of elements held in this deque
* @since 1.6
- * @param <E> the type of elements held in this deque
*/
public class ArrayDeque<E> extends AbstractCollection<E>
implements Deque<E>, Cloneable, Serializable
--- a/jdk/src/java.base/share/classes/java/util/PriorityQueue.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/PriorityQueue.java Mon Sep 12 13:14:49 2016 -0700
@@ -749,11 +749,11 @@
/**
* Saves this queue to a stream (that is, serializes it).
*
+ * @param s the stream
+ * @throws java.io.IOException if an I/O error occurs
* @serialData The length of the array backing the instance is
* emitted (int), followed by all of its elements
* (each an {@code Object}) in the proper order.
- * @param s the stream
- * @throws java.io.IOException if an I/O error occurs
*/
private void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java Mon Sep 12 13:14:49 2016 -0700
@@ -136,9 +136,9 @@
* }}</pre>
*
* @author Doug Lea
- * @since 1.8
* @param <T> The result type returned by this future's {@code join}
* and {@code get} methods
+ * @since 1.8
*/
public class CompletableFuture<T> implements Future<T>, CompletionStage<T> {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/CyclicBarrier.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/CyclicBarrier.java Mon Sep 12 13:14:49 2016 -0700
@@ -132,10 +132,10 @@
* <i>happen-before</i> actions following a successful return from the
* corresponding {@code await()} in other threads.
*
- * @since 1.5
* @see CountDownLatch
*
* @author Doug Lea
+ * @since 1.5
*/
public class CyclicBarrier {
/**
--- a/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java Mon Sep 12 13:14:49 2016 -0700
@@ -68,7 +68,7 @@
* private boolean subscribed; // true after first subscribe
* public synchronized void subscribe(Subscriber<? super Boolean> subscriber) {
* if (subscribed)
- * subscriber.onError(new IllegalStateException()); // only one allowed
+ * subscriber.onError(new IllegalStateException()); // only one allowed
* else {
* subscribed = true;
* subscriber.onSubscribe(new OneShotSubscription(subscriber, executor));
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java Mon Sep 12 13:14:49 2016 -0700
@@ -130,7 +130,7 @@
* </table>
*
* <p>The common pool is by default constructed with default
- * parameters, but these may be controlled by setting three
+ * parameters, but these may be controlled by setting the following
* {@linkplain System#getProperty system properties}:
* <ul>
* <li>{@code java.util.concurrent.ForkJoinPool.common.parallelism}
@@ -3241,7 +3241,7 @@
* An ACC to restrict permissions for the factory itself.
* The constructed workers have no permissions set.
*/
- private static final AccessControlContext innocuousAcc;
+ private static final AccessControlContext INNOCUOUS_ACC;
static {
Permissions innocuousPerms = new Permissions();
innocuousPerms.add(modifyThreadPermission);
@@ -3249,7 +3249,7 @@
"enableContextClassLoaderOverride"));
innocuousPerms.add(new RuntimePermission(
"modifyThreadGroup"));
- innocuousAcc = new AccessControlContext(new ProtectionDomain[] {
+ INNOCUOUS_ACC = new AccessControlContext(new ProtectionDomain[] {
new ProtectionDomain(null, innocuousPerms)
});
}
@@ -3260,7 +3260,7 @@
public ForkJoinWorkerThread run() {
return new ForkJoinWorkerThread.
InnocuousForkJoinWorkerThread(pool);
- }}, innocuousAcc);
+ }}, INNOCUOUS_ACC);
}
}
--- a/jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java Mon Sep 12 13:14:49 2016 -0700
@@ -72,8 +72,8 @@
* protected synchronized Object getNextAvailableItem() {
* for (int i = 0; i < MAX_AVAILABLE; ++i) {
* if (!used[i]) {
- * used[i] = true;
- * return items[i];
+ * used[i] = true;
+ * return items[i];
* }
* }
* return null; // not reached
@@ -82,11 +82,11 @@
* protected synchronized boolean markAsUnused(Object item) {
* for (int i = 0; i < MAX_AVAILABLE; ++i) {
* if (item == items[i]) {
- * if (used[i]) {
- * used[i] = false;
- * return true;
- * } else
- * return false;
+ * if (used[i]) {
+ * used[i] = false;
+ * return true;
+ * } else
+ * return false;
* }
* }
* return false;
--- a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java Mon Sep 12 13:14:49 2016 -0700
@@ -554,8 +554,9 @@
while (r != null) {
BufferedSubscription<T> nextRetry = r.nextRetry;
r.nextRetry = null;
- int stat = (nanos > 0L) ? r.timedOffer(item, nanos) :
- r.offer(item);
+ int stat = (nanos > 0L)
+ ? r.timedOffer(item, nanos)
+ : r.offer(item);
if (stat == 0 && onDrop != null &&
onDrop.test(r.subscriber, item))
stat = r.offer(item);
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java Mon Sep 12 13:14:49 2016 -0700
@@ -617,6 +617,9 @@
/** Per-thread task counter */
volatile long completedTasks;
+ // TODO: switch to AbstractQueuedLongSynchronizer and move
+ // completedTasks into the lock word.
+
/**
* Creates with given first task and thread from ThreadFactory.
* @param firstTask the first task (null if none)
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java Mon Sep 12 13:14:49 2016 -0700
@@ -193,7 +193,7 @@
/**
* Atomically increments the current value,
- * with memory effects as specified by {@link VarHandle#addAndGet}.
+ * with memory effects as specified by {@link VarHandle#getAndAdd}.
*
* <p>Equivalent to {@code addAndGet(1)}.
*
@@ -205,7 +205,7 @@
/**
* Atomically decrements the current value,
- * with memory effects as specified by {@link VarHandle#addAndGet}.
+ * with memory effects as specified by {@link VarHandle#getAndAdd}.
*
* <p>Equivalent to {@code addAndGet(-1)}.
*
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/StampedLock.java Mon Sep 12 13:14:49 2016 -0700
@@ -154,13 +154,13 @@
* long stamp = sl.tryOptimisticRead();
* double currentX = x, currentY = y;
* if (!sl.validate(stamp)) {
- * stamp = sl.readLock();
- * try {
- * currentX = x;
- * currentY = y;
- * } finally {
- * sl.unlockRead(stamp);
- * }
+ * stamp = sl.readLock();
+ * try {
+ * currentX = x;
+ * currentY = y;
+ * } finally {
+ * sl.unlockRead(stamp);
+ * }
* }
* return Math.sqrt(currentX * currentX + currentY * currentY);
* }
--- a/jdk/test/java/util/PriorityQueue/NoNulls.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/PriorityQueue/NoNulls.java Mon Sep 12 13:14:49 2016 -0700
@@ -38,10 +38,8 @@
*/
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Comparator;
import java.util.Collection;
-import java.util.Collections;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.TreeSet;
--- a/jdk/test/java/util/concurrent/BlockingQueue/LoopHelpers.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/BlockingQueue/LoopHelpers.java Mon Sep 12 13:14:49 2016 -0700
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
--- a/jdk/test/java/util/concurrent/BlockingQueue/OfferDrainToLoops.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/BlockingQueue/OfferDrainToLoops.java Mon Sep 12 13:14:49 2016 -0700
@@ -43,7 +43,6 @@
import java.util.SplittableRandom;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.LinkedTransferQueue;
--- a/jdk/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java Mon Sep 12 13:14:49 2016 -0700
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
--- a/jdk/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/ConcurrentQueues/LoopHelpers.java Mon Sep 12 13:14:49 2016 -0700
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
--- a/jdk/test/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java Mon Sep 12 13:14:49 2016 -0700
@@ -43,7 +43,6 @@
import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.Semaphore;
-import java.util.concurrent.ThreadLocalRandom;
@SuppressWarnings({"unchecked", "rawtypes", "deprecation"})
public class OfferRemoveLoops {
--- a/jdk/test/java/util/concurrent/DelayQueue/Stress.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/DelayQueue/Stress.java Mon Sep 12 13:14:49 2016 -0700
@@ -22,7 +22,6 @@
*/
import static java.util.concurrent.TimeUnit.NANOSECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.Delayed;
--- a/jdk/test/java/util/concurrent/Exchanger/LoopHelpers.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/Exchanger/LoopHelpers.java Mon Sep 12 13:14:49 2016 -0700
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
--- a/jdk/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java Mon Sep 12 13:14:49 2016 -0700
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
--- a/jdk/test/java/util/concurrent/FutureTask/LoopHelpers.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/FutureTask/LoopHelpers.java Mon Sep 12 13:14:49 2016 -0700
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
--- a/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCorePoolSize.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCorePoolSize.java Mon Sep 12 13:14:49 2016 -0700
@@ -33,7 +33,6 @@
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import jdk.testlibrary.Utils;
/**
--- a/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCoreThreads.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/ScheduledThreadPoolExecutor/ZeroCoreThreads.java Mon Sep 12 13:14:49 2016 -0700
@@ -40,7 +40,6 @@
import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
import java.lang.reflect.Field;
import java.util.concurrent.BlockingQueue;
--- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThreadRestarts.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ThreadRestarts.java Mon Sep 12 13:14:49 2016 -0700
@@ -40,7 +40,6 @@
*/
import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
--- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/TimeOutShrink.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/TimeOutShrink.java Mon Sep 12 13:14:49 2016 -0700
@@ -34,7 +34,6 @@
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import jdk.testlibrary.Utils;
public class TimeOutShrink {
--- a/jdk/test/java/util/concurrent/atomic/AtomicReferenceTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/atomic/AtomicReferenceTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -22,7 +22,6 @@
*/
import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.UnaryOperator;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
--- a/jdk/test/java/util/concurrent/forkjoin/SubmissionTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/forkjoin/SubmissionTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -22,27 +22,35 @@
*/
import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import jdk.testlibrary.Utils;
/*
* @test
* @bug 8078490
* @summary Test submission and execution of task without joining
+ * @library /lib/testlibrary/
*/
public class SubmissionTest {
+ static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
+
+ static long millisElapsedSince(long startTime) {
+ return (System.nanoTime() - startTime) / (1000L * 1000L);
+ }
+
public static void main(String[] args) throws Throwable {
final ForkJoinPool e = new ForkJoinPool(1);
final AtomicBoolean b = new AtomicBoolean();
final Runnable setFalse = () -> b.set(false);
- for (int i = 0; i < 100000; i++) {
+ for (int i = 0; i < 30_000; i++) {
b.set(true);
e.execute(setFalse);
- long st = System.nanoTime();
+ long startTime = System.nanoTime();
while (b.get()) {
- if (System.nanoTime() - st >= TimeUnit.SECONDS.toNanos(10)) {
+ if (millisElapsedSince(startTime) >= LONG_DELAY_MS) {
throw new RuntimeException("Submitted task failed to execute");
}
+ Thread.yield();
}
}
}
--- a/jdk/test/java/util/concurrent/locks/Lock/LoopHelpers.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/locks/Lock/LoopHelpers.java Mon Sep 12 13:14:49 2016 -0700
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
--- a/jdk/test/java/util/concurrent/locks/Lock/Mutex.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/locks/Lock/Mutex.java Mon Sep 12 13:14:49 2016 -0700
@@ -35,7 +35,6 @@
import java.util.concurrent.locks.AbstractQueuedSynchronizer;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
-import java.util.concurrent.atomic.AtomicInteger;
import java.io.IOException;
import java.io.ObjectInputStream;
--- a/jdk/test/java/util/concurrent/locks/LockSupport/ParkLoops.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/locks/LockSupport/ParkLoops.java Mon Sep 12 13:14:49 2016 -0700
@@ -43,7 +43,6 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.concurrent.locks.LockSupport;
--- a/jdk/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java Mon Sep 12 13:14:49 2016 -0700
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
--- a/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java Mon Sep 12 13:14:49 2016 -0700
@@ -31,8 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.concurrent.atomic.AtomicLong;
-
/**
* Misc utilities in JSR166 performance tests
*/
--- a/jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/locks/StampedLock/ReadersUnlockAfterWriteUnlock.java Mon Sep 12 13:14:49 2016 -0700
@@ -22,7 +22,6 @@
/*
* @test
- * @run main/othervm/timeout=60 ReadersUnlockAfterWriteUnlock
* @bug 8023234
* @summary StampedLock serializes readers on writer unlock
* @author Dmitry Chyuko
@@ -30,26 +29,23 @@
*/
import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.StampedLock;
public class ReadersUnlockAfterWriteUnlock {
- static final int RNUM = 2;
- static final StampedLock sl = new StampedLock();
- static volatile boolean isDone;
-
- static CyclicBarrier iterationStart = new CyclicBarrier(RNUM + 1);
- static CyclicBarrier readersHaveLocks = new CyclicBarrier(RNUM);
- static CyclicBarrier writerHasLock = new CyclicBarrier(RNUM + 1);
+ public static void main(String[] args) throws InterruptedException {
+ final int RNUM = 2;
+ final int REPS = 128;
+ final StampedLock sl = new StampedLock();
+ final AtomicReference<Throwable> bad = new AtomicReference<>();
- static class Reader extends Thread {
- final String name;
- Reader(String name) {
- super();
- this.name = name;
- }
- public void run() {
- while (!isDone && !isInterrupted()) {
- try {
+ final CyclicBarrier iterationStart = new CyclicBarrier(RNUM + 1);
+ final CyclicBarrier readersHaveLocks = new CyclicBarrier(RNUM);
+ final CyclicBarrier writerHasLock = new CyclicBarrier(RNUM + 1);
+
+ Runnable reader = () -> {
+ try {
+ for (int i = 0; i < REPS; i++) {
iterationStart.await();
writerHasLock.await();
long rs = sl.readLock();
@@ -59,30 +55,45 @@
readersHaveLocks.await();
sl.unlockRead(rs);
- } catch (Exception e) {
- throw new IllegalStateException(e);
}
+ } catch (Throwable ex) {
+ ex.printStackTrace();
+ bad.set(ex);
}
- }
- }
+ };
- public static void main(String[] args) throws InterruptedException {
- for (int r = 0 ; r < RNUM; ++r) {
- new Reader("r" + r).start();
+ Thread[] threads = new Thread[RNUM];
+ for (int i = 0 ; i < RNUM; i++) {
+ Thread thread = new Thread(reader, "Reader");
+ threads[i] = thread;
+ thread.start();
}
- int i;
- for (i = 0; i < 1024; ++i) {
+ for (int i = 0; i < REPS; i++) {
try {
iterationStart.await();
long ws = sl.writeLock();
writerHasLock.await();
- Thread.sleep(10);
+ awaitWaitState(threads);
sl.unlockWrite(ws);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
- isDone = true;
+ for (Thread thread : threads)
+ thread.join();
+ if (bad.get() != null)
+ throw new AssertionError(bad.get());
}
+ static void awaitWaitState(Thread[] threads) {
+ restart: for (;;) {
+ for (Thread thread : threads) {
+ if (thread.getState() != Thread.State.WAITING) {
+ Thread.yield();
+ continue restart;
+ }
+ }
+ break;
+ }
+ }
}
--- a/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/AtomicIntegerArray9Test.java Mon Sep 12 13:14:49 2016 -0700
@@ -31,7 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.Arrays;
import java.util.concurrent.atomic.AtomicIntegerArray;
import junit.framework.Test;
--- a/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/AtomicLongArray9Test.java Mon Sep 12 13:14:49 2016 -0700
@@ -31,7 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.Arrays;
import java.util.concurrent.atomic.AtomicLongArray;
import junit.framework.Test;
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceArray9Test.java Mon Sep 12 13:14:49 2016 -0700
@@ -31,7 +31,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-import java.util.Arrays;
import java.util.concurrent.atomic.AtomicReferenceArray;
import junit.framework.Test;
--- a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -59,7 +59,6 @@
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeoutException;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
--- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java Mon Sep 12 13:14:49 2016 -0700
@@ -38,7 +38,6 @@
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.NoSuchElementException;
--- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -36,7 +36,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
--- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -36,7 +36,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
--- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java Mon Sep 12 13:14:49 2016 -0700
@@ -42,7 +42,6 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorCompletionService;
-import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import junit.framework.Test;
--- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -40,7 +40,6 @@
import java.util.concurrent.CompletionService;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java Mon Sep 12 13:14:49 2016 -0700
@@ -296,12 +296,11 @@
RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
- final Thread myself = Thread.currentThread();
+ final Thread currentThread = Thread.currentThread();
// test join()
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
assertNull(f.join());
Thread.interrupted();
assertEquals(21, f.result);
@@ -310,8 +309,7 @@
f = new FibAction(8);
f.cancel(true);
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
try {
f.join();
shouldThrow();
@@ -323,8 +321,7 @@
f = new FibAction(8);
f.completeExceptionally(new FJException());
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
try {
f.join();
shouldThrow();
@@ -336,8 +333,7 @@
// test quietlyJoin()
f = new FibAction(8);
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
assertEquals(21, f.result);
@@ -346,8 +342,7 @@
f = new FibAction(8);
f.cancel(true);
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
checkCancelled(f);
@@ -355,8 +350,7 @@
f = new FibAction(8);
f.completeExceptionally(new FJException());
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
checkCompletedAbnormally(f, f.getException());
--- a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java Mon Sep 12 13:14:49 2016 -0700
@@ -35,7 +35,6 @@
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.Arrays;
-import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
--- a/jdk/test/java/util/concurrent/tck/ForkJoinTaskTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinTaskTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -35,9 +35,7 @@
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
-import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
--- a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java Mon Sep 12 13:14:49 2016 -0700
@@ -1264,7 +1264,7 @@
* Sleeps until the given time has elapsed.
* Throws AssertionFailedError if interrupted.
*/
- void sleep(long millis) {
+ static void sleep(long millis) {
try {
delay(millis);
} catch (InterruptedException fail) {
--- a/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -285,12 +285,11 @@
RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() {
FibAction f = new FibAction(8);
- final Thread myself = Thread.currentThread();
+ final Thread currentThread = Thread.currentThread();
// test join()
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
assertNull(f.join());
Thread.interrupted();
assertEquals(21, f.result);
@@ -299,8 +298,7 @@
f = new FibAction(8);
f.cancel(true);
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
try {
f.join();
shouldThrow();
@@ -312,8 +310,7 @@
f = new FibAction(8);
f.completeExceptionally(new FJException());
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
try {
f.join();
shouldThrow();
@@ -325,8 +322,7 @@
// test quietlyJoin()
f = new FibAction(8);
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
assertEquals(21, f.result);
@@ -335,8 +331,7 @@
f = new FibAction(8);
f.cancel(true);
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
checkCancelled(f);
@@ -344,8 +339,7 @@
f = new FibAction(8);
f.completeExceptionally(new FJException());
assertSame(f, f.fork());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
Thread.interrupted();
checkCompletedAbnormally(f, f.getException());
@@ -385,22 +379,20 @@
public void realRun() throws InterruptedException {
FibAction[] fibActions = sq.take();
FibAction f;
- final Thread myself = Thread.currentThread();
+ final Thread currentThread = Thread.currentThread();
// test join() ------------
f = fibActions[0];
assertFalse(ForkJoinTask.inForkJoinPool());
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
assertNull(f.join());
assertTrue(Thread.interrupted());
assertEquals(21, f.result);
checkCompletedNormally(f);
f = fibActions[1];
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
try {
f.join();
shouldThrow();
@@ -410,8 +402,7 @@
}
f = fibActions[2];
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
try {
f.join();
shouldThrow();
@@ -423,23 +414,20 @@
// test quietlyJoin() ---------
f = fibActions[3];
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
assertTrue(Thread.interrupted());
assertEquals(21, f.result);
checkCompletedNormally(f);
f = fibActions[4];
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
assertTrue(Thread.interrupted());
checkCancelled(f);
f = fibActions[5];
- myself.interrupt();
- assertTrue(myself.isInterrupted());
+ currentThread.interrupt();
f.quietlyJoin();
assertTrue(Thread.interrupted());
assertTrue(f.getException() instanceof FJException);
--- a/jdk/test/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -44,7 +44,6 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Delayed;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
--- a/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/ScheduledExecutorTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -45,7 +45,6 @@
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.RejectedExecutionException;
--- a/jdk/test/java/util/concurrent/tck/StampedLockTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/StampedLockTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -44,7 +44,6 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.StampedLock;
import java.util.function.BiConsumer;
-import java.util.function.Consumer;
import java.util.function.Function;
import junit.framework.Test;
--- a/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -37,24 +37,14 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Flow;
import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.SubmissionPublisher;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.BiConsumer;
-import java.util.function.BiFunction;
-import java.util.function.BiPredicate;
-import java.util.stream.Stream;
import junit.framework.Test;
import junit.framework.TestSuite;
-import static java.util.concurrent.Flow.Publisher;
import static java.util.concurrent.Flow.Subscriber;
import static java.util.concurrent.Flow.Subscription;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
public class SubmissionPublisherTest extends JSR166TestCase {
--- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -44,7 +44,6 @@
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;
--- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java Mon Sep 12 13:11:38 2016 -0700
+++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java Mon Sep 12 13:14:49 2016 -0700
@@ -55,7 +55,6 @@
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import junit.framework.Test;