8185099: Miscellaneous changes imported from jsr166 CVS 2017-08
Reviewed-by: martin, psandoz
--- a/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/Flow.java Wed Aug 09 17:40:38 2017 -0700
@@ -85,9 +85,9 @@
* this.executor = executor;
* }
* public synchronized void request(long n) {
- * if (n != 0 && !completed) {
+ * if (!completed) {
* completed = true;
- * if (n < 0) {
+ * if (n <= 0) {
* IllegalArgumentException ex = new IllegalArgumentException();
* executor.execute(() -> subscriber.onError(ex));
* } else {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java Wed Aug 09 17:40:38 2017 -0700
@@ -576,7 +576,7 @@
private static final RuntimePermission shutdownPerm =
new RuntimePermission("modifyThread");
- /* The context to be used when executing the finalizer, or null. */
+ /** The context to be used when executing the finalizer, or null. */
private final AccessControlContext acc;
/**
@@ -1314,9 +1314,9 @@
throw new IllegalArgumentException();
if (workQueue == null || threadFactory == null || handler == null)
throw new NullPointerException();
- this.acc = System.getSecurityManager() == null ?
- null :
- AccessController.getContext();
+ this.acc = (System.getSecurityManager() == null)
+ ? null
+ : AccessController.getContext();
this.corePoolSize = corePoolSize;
this.maximumPoolSize = maximumPoolSize;
this.workQueue = workQueue;
--- a/jdk/test/java/util/concurrent/tck/ArrayBlockingQueueTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/ArrayBlockingQueueTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -903,7 +903,7 @@
}
/**
- * A deserialized serialized queue has same elements in same order
+ * A deserialized/reserialized queue has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedQueue(SIZE);
--- a/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -939,7 +939,7 @@
}
/**
- * A deserialized serialized deque has same elements in same order
+ * A deserialized/reserialized deque has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedDeque(SIZE);
--- a/jdk/test/java/util/concurrent/tck/ArrayListTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/ArrayListTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -33,6 +33,7 @@
*/
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import junit.framework.Test;
@@ -61,4 +62,27 @@
CollectionTest.testSuite(new SubListImplementation()));
}
+ /**
+ * A cloned list equals original
+ */
+ public void testClone() throws Exception {
+ ArrayList<Integer> x = new ArrayList<>();
+ x.add(1);
+ x.add(2);
+ x.add(3);
+ ArrayList<Integer> y = (ArrayList<Integer>) x.clone();
+
+ assertNotSame(y, x);
+ assertEquals(x, y);
+ assertEquals(y, x);
+ assertEquals(x.size(), y.size());
+ assertEquals(x.toString(), y.toString());
+ assertTrue(Arrays.equals(x.toArray(), y.toArray()));
+ while (!x.isEmpty()) {
+ assertFalse(y.isEmpty());
+ assertEquals(x.remove(0), y.remove(0));
+ }
+ assertTrue(y.isEmpty());
+ }
+
}
--- a/jdk/test/java/util/concurrent/tck/AtomicBooleanTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/AtomicBooleanTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -147,7 +147,7 @@
}
/**
- * a deserialized serialized atomic holds same value
+ * a deserialized/reserialized atomic holds same value
*/
public void testSerialization() throws Exception {
AtomicBoolean x = new AtomicBoolean();
--- a/jdk/test/java/util/concurrent/tck/AtomicIntegerArrayTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/AtomicIntegerArrayTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -342,7 +342,7 @@
}
/**
- * 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);
--- a/jdk/test/java/util/concurrent/tck/AtomicIntegerTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/AtomicIntegerTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -218,7 +218,7 @@
}
/**
- * a deserialized serialized atomic holds same value
+ * a deserialized/reserialized atomic holds same value
*/
public void testSerialization() throws Exception {
AtomicInteger x = new AtomicInteger();
--- a/jdk/test/java/util/concurrent/tck/AtomicLongArrayTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/AtomicLongArrayTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -341,7 +341,7 @@
}
/**
- * a deserialized serialized array holds same values
+ * a deserialized/reserialized array holds same values in same order
*/
public void testSerialization() throws Exception {
AtomicLongArray x = new AtomicLongArray(SIZE);
--- a/jdk/test/java/util/concurrent/tck/AtomicLongTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/AtomicLongTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -220,7 +220,7 @@
}
/**
- * a deserialized serialized atomic holds same value
+ * a deserialized/reserialized atomic holds same value
*/
public void testSerialization() throws Exception {
AtomicLong x = new AtomicLong();
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceArrayTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceArrayTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -220,7 +220,7 @@
}
/**
- * a deserialized serialized array holds same values
+ * a deserialized/reserialized array holds same values in same order
*/
public void testSerialization() throws Exception {
AtomicReferenceArray x = new AtomicReferenceArray(SIZE);
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -143,7 +143,7 @@
}
/**
- * a deserialized serialized atomic holds same value
+ * a deserialized/reserialized atomic holds same value
*/
public void testSerialization() throws Exception {
AtomicReference x = new AtomicReference();
--- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java Wed Aug 09 17:40:38 2017 -0700
@@ -570,7 +570,7 @@
}
/**
- * A deserialized serialized set is equal
+ * A deserialized/reserialized set equals original
*/
public void testSerialization() throws Exception {
int size = 20;
--- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -811,7 +811,7 @@
}
/**
- * A deserialized map equals original
+ * A deserialized/reserialized map equals original
*/
public void testSerialization() throws Exception {
Map x = map5();
--- a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -889,7 +889,7 @@
}
/**
- * A deserialized serialized deque has same elements in same order
+ * A deserialized/reserialized deque has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedDeque(SIZE);
--- a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -538,7 +538,7 @@
}
/**
- * A deserialized serialized queue has same elements in same order
+ * A deserialized/reserialized queue has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedQueue(SIZE);
--- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListMapTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListMapTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -828,7 +828,24 @@
}
/**
- * A deserialized map equals original
+ * A cloned map equals original
+ */
+ public void testClone() {
+ ConcurrentSkipListMap x = map5();
+ ConcurrentSkipListMap y = x.clone();
+
+ assertNotSame(x, y);
+ assertEquals(x.size(), y.size());
+ assertEquals(x.toString(), y.toString());
+ assertEquals(x, y);
+ assertEquals(y, x);
+ y.clear();
+ assertTrue(y.isEmpty());
+ assertFalse(x.equals(y));
+ }
+
+ /**
+ * A deserialized/reserialized map equals original
*/
public void testSerialization() throws Exception {
NavigableMap x = map5();
@@ -839,6 +856,9 @@
assertEquals(x.toString(), y.toString());
assertEquals(x, y);
assertEquals(y, x);
+ y.clear();
+ assertTrue(y.isEmpty());
+ assertFalse(x.equals(y));
}
/**
--- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubMapTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubMapTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -625,7 +625,7 @@
}
/**
- * A deserialized map equals original
+ * A deserialized/reserialized map equals original
*/
public void testSerialization() throws Exception {
NavigableMap x = map5();
@@ -1299,7 +1299,7 @@
}
/**
- * A deserialized map equals original
+ * A deserialized/reserialized map equals original
*/
public void testDescendingSerialization() throws Exception {
NavigableMap x = dmap5();
--- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -503,7 +503,7 @@
}
/**
- * A deserialized serialized set has same elements
+ * A deserialized/reserialized set equals original
*/
public void testSerialization() throws Exception {
NavigableSet x = populatedSet(SIZE);
@@ -1002,7 +1002,7 @@
}
/**
- * A deserialized serialized set has same elements
+ * A deserialized/reserialized set equals original
*/
public void testDescendingSerialization() throws Exception {
NavigableSet x = dset5();
--- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -774,7 +774,7 @@
}
/**
- * a deserialized serialized list is equal
+ * a deserialized/reserialized list equals original
*/
public void testSerialization() throws Exception {
List x = populatedArray(SIZE);
--- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArraySetTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -403,7 +403,7 @@
}
/**
- * A deserialized serialized set is equal
+ * A deserialized/reserialized set equals original
*/
public void testSerialization() throws Exception {
Set x = populatedSet(SIZE);
--- a/jdk/test/java/util/concurrent/tck/DoubleAdderTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/DoubleAdderTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -89,7 +89,7 @@
}
/**
- * a deserialized serialized adder holds same value
+ * a deserialized/reserialized adder holds same value
*/
public void testSerialization() throws Exception {
DoubleAdder x = new DoubleAdder();
--- a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java Wed Aug 09 17:40:38 2017 -0700
@@ -1143,53 +1143,6 @@
}
/**
- * Checks that thread does not terminate within the default
- * millisecond delay of {@code timeoutMillis()}.
- * TODO: REMOVEME
- */
- void assertThreadStaysAlive(Thread thread) {
- assertThreadStaysAlive(thread, timeoutMillis());
- }
-
- /**
- * Checks that thread does not terminate within the given millisecond delay.
- * TODO: REMOVEME
- */
- void assertThreadStaysAlive(Thread thread, long millis) {
- try {
- // No need to optimize the failing case via Thread.join.
- delay(millis);
- assertTrue(thread.isAlive());
- } catch (InterruptedException fail) {
- threadFail("Unexpected InterruptedException");
- }
- }
-
- /**
- * Checks that the threads do not terminate within the default
- * millisecond delay of {@code timeoutMillis()}.
- * TODO: REMOVEME
- */
- void assertThreadsStayAlive(Thread... threads) {
- assertThreadsStayAlive(timeoutMillis(), threads);
- }
-
- /**
- * Checks that the threads do not terminate within the given millisecond delay.
- * TODO: REMOVEME
- */
- void assertThreadsStayAlive(long millis, Thread... threads) {
- try {
- // No need to optimize the failing case via Thread.join.
- delay(millis);
- for (Thread thread : threads)
- assertTrue(thread.isAlive());
- } catch (InterruptedException fail) {
- threadFail("Unexpected InterruptedException");
- }
- }
-
- /**
* Checks that future.get times out, with the default timeout of
* {@code timeoutMillis()}.
*/
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -1800,7 +1800,7 @@
}
/**
- * A deserialized serialized deque has same elements in same order
+ * A deserialized/reserialized deque has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedDeque(SIZE);
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -823,7 +823,7 @@
}
/**
- * A deserialized serialized queue has same elements in same order
+ * A deserialized/reserialized queue has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedQueue(SIZE);
--- a/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -674,7 +674,7 @@
}
/**
- * A deserialized serialized queue has same elements in same order
+ * A deserialized/reserialized queue has same elements in same order
*/
public void testSerialization() throws Exception {
Queue x = populatedQueue(SIZE);
--- a/jdk/test/java/util/concurrent/tck/LongAdderTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/LongAdderTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -111,7 +111,7 @@
}
/**
- * a deserialized serialized adder holds same value
+ * a deserialized/reserialized adder holds same value
*/
public void testSerialization() throws Exception {
LongAdder x = new LongAdder();
--- a/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -686,7 +686,7 @@
}
/**
- * A deserialized serialized queue has same elements
+ * A deserialized/reserialized queue has same elements
*/
public void testSerialization() throws Exception {
Queue x = populatedQueue(SIZE);
--- a/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -522,7 +522,7 @@
}
/**
- * A deserialized serialized queue has same elements
+ * A deserialized/reserialized queue has same elements
*/
public void testSerialization() throws Exception {
Queue x = populatedQueue(SIZE);
--- a/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -557,7 +557,7 @@
}
/**
- * a deserialized serialized queue is usable
+ * a deserialized/reserialized queue is usable
*/
public void testSerialization() {
final SynchronousQueue x = new SynchronousQueue();
--- a/jdk/test/java/util/concurrent/tck/ThreadLocalRandom8Test.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/ThreadLocalRandom8Test.java Wed Aug 09 17:40:38 2017 -0700
@@ -260,8 +260,8 @@
}
/**
- * A deserialized ThreadLocalRandom is always identical to
- * ThreadLocalRandom.current()
+ * A deserialized/reserialized ThreadLocalRandom is always
+ * identical to ThreadLocalRandom.current()
*/
public void testSerialization() {
assertSame(
--- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -1319,8 +1319,8 @@
public void testMaximumPoolSizeIllegalArgumentException2() {
final ThreadPoolExecutor p =
new CustomTPE(2, 3,
- LONG_DELAY_MS,
- MILLISECONDS,new ArrayBlockingQueue<Runnable>(10));
+ LONG_DELAY_MS, MILLISECONDS,
+ new ArrayBlockingQueue<Runnable>(10));
try (PoolCleaner cleaner = cleaner(p)) {
try {
p.setMaximumPoolSize(-1);
--- a/jdk/test/java/util/concurrent/tck/TimeUnitTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/TimeUnitTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -623,7 +623,7 @@
}
/**
- * a deserialized serialized unit is the same instance
+ * a deserialized/reserialized unit is the same instance
*/
public void testSerialization() throws Exception {
for (TimeUnit x : TimeUnit.values())
--- a/jdk/test/java/util/concurrent/tck/TreeMapTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/TreeMapTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -633,7 +633,7 @@
}
/**
- * A deserialized map equals original
+ * A deserialized/reserialized map equals original
*/
public void testSerialization() throws Exception {
NavigableMap x = map5();
--- a/jdk/test/java/util/concurrent/tck/TreeSetTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/TreeSetTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -549,7 +549,7 @@
}
/**
- * A deserialized serialized set has same elements
+ * A deserialized/reserialized set equals original
*/
public void testSerialization() throws Exception {
NavigableSet x = populatedSet(SIZE);
--- a/jdk/test/java/util/concurrent/tck/TreeSubMapTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/TreeSubMapTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -460,7 +460,7 @@
}
/**
- * A deserialized map equals original
+ * A deserialized/reserialized map equals original
*/
public void testSerialization() throws Exception {
NavigableMap x = map5();
@@ -987,7 +987,7 @@
}
/**
- * A deserialized map equals original
+ * A deserialized/reserialized map equals original
*/
public void testDescendingSerialization() throws Exception {
NavigableMap x = dmap5();
--- a/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java Wed Aug 09 17:30:51 2017 -0700
+++ b/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java Wed Aug 09 17:40:38 2017 -0700
@@ -500,7 +500,7 @@
}
/**
- * A deserialized serialized set has same elements
+ * A deserialized/reserialized set equals original
*/
public void testSerialization() throws Exception {
NavigableSet x = populatedSet(SIZE);
@@ -988,7 +988,7 @@
}
/**
- * A deserialized serialized set has same elements
+ * A deserialized/reserialized set equals original
*/
public void testDescendingSerialization() throws Exception {
NavigableSet x = dset5();