mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-21 15:55:15 +00:00
8185099: Miscellaneous changes imported from jsr166 CVS 2017-08
Reviewed-by: martin, psandoz
This commit is contained in:
parent
9f28d43df5
commit
2f31db126d
@ -85,9 +85,9 @@ package java.util.concurrent;
|
||||
* 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 {
|
||||
|
||||
@ -576,7 +576,7 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
||||
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 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
||||
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;
|
||||
|
||||
@ -903,7 +903,7 @@ public class ArrayBlockingQueueTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@ -939,7 +939,7 @@ public class ArrayDequeTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Test;
|
||||
@ -61,4 +62,27 @@ public class ArrayListTest extends JSR166TestCase {
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ public class AtomicBooleanTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* a deserialized serialized atomic holds same value
|
||||
* a deserialized/reserialized atomic holds same value
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
AtomicBoolean x = new AtomicBoolean();
|
||||
|
||||
@ -342,7 +342,7 @@ public class AtomicIntegerArrayTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@ -218,7 +218,7 @@ public class AtomicIntegerTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* a deserialized serialized atomic holds same value
|
||||
* a deserialized/reserialized atomic holds same value
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
AtomicInteger x = new AtomicInteger();
|
||||
|
||||
@ -341,7 +341,7 @@ public class AtomicLongArrayTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@ -220,7 +220,7 @@ public class AtomicLongTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* a deserialized serialized atomic holds same value
|
||||
* a deserialized/reserialized atomic holds same value
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
AtomicLong x = new AtomicLong();
|
||||
|
||||
@ -220,7 +220,7 @@ public class AtomicReferenceArrayTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@ -143,7 +143,7 @@ public class AtomicReferenceTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* a deserialized serialized atomic holds same value
|
||||
* a deserialized/reserialized atomic holds same value
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
AtomicReference x = new AtomicReference();
|
||||
|
||||
@ -570,7 +570,7 @@ public class ConcurrentHashMap8Test extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized serialized set is equal
|
||||
* A deserialized/reserialized set equals original
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
int size = 20;
|
||||
|
||||
@ -811,7 +811,7 @@ public class ConcurrentHashMapTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized map equals original
|
||||
* A deserialized/reserialized map equals original
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
Map x = map5();
|
||||
|
||||
@ -889,7 +889,7 @@ public class ConcurrentLinkedDequeTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@ -538,7 +538,7 @@ public class ConcurrentLinkedQueueTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@ -828,7 +828,24 @@ public class ConcurrentSkipListMapTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ public class ConcurrentSkipListMapTest extends JSR166TestCase {
|
||||
assertEquals(x.toString(), y.toString());
|
||||
assertEquals(x, y);
|
||||
assertEquals(y, x);
|
||||
y.clear();
|
||||
assertTrue(y.isEmpty());
|
||||
assertFalse(x.equals(y));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -625,7 +625,7 @@ public class ConcurrentSkipListSubMapTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized map equals original
|
||||
* A deserialized/reserialized map equals original
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
NavigableMap x = map5();
|
||||
@ -1299,7 +1299,7 @@ public class ConcurrentSkipListSubMapTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized map equals original
|
||||
* A deserialized/reserialized map equals original
|
||||
*/
|
||||
public void testDescendingSerialization() throws Exception {
|
||||
NavigableMap x = dmap5();
|
||||
|
||||
@ -503,7 +503,7 @@ public class ConcurrentSkipListSubSetTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ public class ConcurrentSkipListSubSetTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized serialized set has same elements
|
||||
* A deserialized/reserialized set equals original
|
||||
*/
|
||||
public void testDescendingSerialization() throws Exception {
|
||||
NavigableSet x = dset5();
|
||||
|
||||
@ -774,7 +774,7 @@ public class CopyOnWriteArrayListTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* a deserialized serialized list is equal
|
||||
* a deserialized/reserialized list equals original
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
List x = populatedArray(SIZE);
|
||||
|
||||
@ -403,7 +403,7 @@ public class CopyOnWriteArraySetTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized serialized set is equal
|
||||
* A deserialized/reserialized set equals original
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
Set x = populatedSet(SIZE);
|
||||
|
||||
@ -89,7 +89,7 @@ public class DoubleAdderTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* a deserialized serialized adder holds same value
|
||||
* a deserialized/reserialized adder holds same value
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
DoubleAdder x = new DoubleAdder();
|
||||
|
||||
@ -1142,53 +1142,6 @@ public class JSR166TestCase extends TestCase {
|
||||
fail("timed out waiting for thread to enter thread state " + expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()}.
|
||||
|
||||
@ -1800,7 +1800,7 @@ public class LinkedBlockingDequeTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@ -823,7 +823,7 @@ public class LinkedBlockingQueueTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@ -674,7 +674,7 @@ public class LinkedTransferQueueTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
@ -111,7 +111,7 @@ public class LongAdderTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* a deserialized serialized adder holds same value
|
||||
* a deserialized/reserialized adder holds same value
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
LongAdder x = new LongAdder();
|
||||
|
||||
@ -686,7 +686,7 @@ public class PriorityBlockingQueueTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized serialized queue has same elements
|
||||
* A deserialized/reserialized queue has same elements
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
Queue x = populatedQueue(SIZE);
|
||||
|
||||
@ -522,7 +522,7 @@ public class PriorityQueueTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized serialized queue has same elements
|
||||
* A deserialized/reserialized queue has same elements
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
Queue x = populatedQueue(SIZE);
|
||||
|
||||
@ -557,7 +557,7 @@ public class SynchronousQueueTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* a deserialized serialized queue is usable
|
||||
* a deserialized/reserialized queue is usable
|
||||
*/
|
||||
public void testSerialization() {
|
||||
final SynchronousQueue x = new SynchronousQueue();
|
||||
|
||||
@ -260,8 +260,8 @@ public class ThreadLocalRandom8Test extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized ThreadLocalRandom is always identical to
|
||||
* ThreadLocalRandom.current()
|
||||
* A deserialized/reserialized ThreadLocalRandom is always
|
||||
* identical to ThreadLocalRandom.current()
|
||||
*/
|
||||
public void testSerialization() {
|
||||
assertSame(
|
||||
|
||||
@ -1319,8 +1319,8 @@ public class ThreadPoolExecutorSubclassTest extends JSR166TestCase {
|
||||
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);
|
||||
|
||||
@ -623,7 +623,7 @@ public class TimeUnitTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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())
|
||||
|
||||
@ -633,7 +633,7 @@ public class TreeMapTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized map equals original
|
||||
* A deserialized/reserialized map equals original
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
NavigableMap x = map5();
|
||||
|
||||
@ -549,7 +549,7 @@ public class TreeSetTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized serialized set has same elements
|
||||
* A deserialized/reserialized set equals original
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
NavigableSet x = populatedSet(SIZE);
|
||||
|
||||
@ -460,7 +460,7 @@ public class TreeSubMapTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized map equals original
|
||||
* A deserialized/reserialized map equals original
|
||||
*/
|
||||
public void testSerialization() throws Exception {
|
||||
NavigableMap x = map5();
|
||||
@ -987,7 +987,7 @@ public class TreeSubMapTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized map equals original
|
||||
* A deserialized/reserialized map equals original
|
||||
*/
|
||||
public void testDescendingSerialization() throws Exception {
|
||||
NavigableMap x = dmap5();
|
||||
|
||||
@ -500,7 +500,7 @@ public class TreeSubSetTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ public class TreeSubSetTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* A deserialized serialized set has same elements
|
||||
* A deserialized/reserialized set equals original
|
||||
*/
|
||||
public void testDescendingSerialization() throws Exception {
|
||||
NavigableSet x = dset5();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user