8193300: Miscellaneous changes imported from jsr166 CVS 2018-01
Reviewed-by: martin
This commit is contained in:
parent
c19d18871c
commit
d771fc3a6b
src/java.base/share/classes/java/util
test/jdk/java/util
AbstractCollection
AbstractList
AbstractMap
AbstractSequentialList
ArrayList
Collection
BiggernYours.javaHotPotatoes.javaIteratorAtEnd.javaIteratorMicroBenchmark.javaRemoveMicroBenchmark.java
Collections
AddAll.javaBigBinarySearch.javaBinarySearchNullComparator.javaCheckedIdentityMap.javaCheckedListBash.javaCheckedMapBash.javaCheckedNull.javaCheckedSetBash.javaDisjoint.javaEmptyCollectionSerialization.javaEmptyIterator.javaEmptyNavigableMap.javaEmptyNavigableSet.javaEnum.javaFindSubList.javaFrequency.javaMinMax.javaNCopies.javaNullComparator.javaRacingCollections.javaReplaceAll.javaReverseOrder.javaReverseOrder2.javaRotate.javaRotateEmpty.javaSer.javaSetFromMap.javaSwap.javaT5078378.javaT6433170.javaViewSynch.javaWrappedNull.java
HashMap
Hashtable
IdentityHashMap
LinkedHashMap
LinkedHashSet
LinkedList
List
Map
NavigableMap
PriorityQueue
Random
TimSort
TreeMap
ContainsValue.javaHeadTailTypeError.javaNullAtEnd.javaNullPermissiveComparator.javaSubMap.javaSubMapClear.java
Vector
@ -1550,7 +1550,6 @@ public class ArrayList<E> extends AbstractList<E>
|
||||
setBit(deathRow, i - beg);
|
||||
if (modCount != expectedModCount)
|
||||
throw new ConcurrentModificationException();
|
||||
expectedModCount++;
|
||||
modCount++;
|
||||
int w = beg;
|
||||
for (i = beg; i < end; i++)
|
||||
|
@ -1023,7 +1023,6 @@ public class Vector<E>
|
||||
setBit(deathRow, i - beg);
|
||||
if (modCount != expectedModCount)
|
||||
throw new ConcurrentModificationException();
|
||||
expectedModCount++;
|
||||
modCount++;
|
||||
int w = beg;
|
||||
for (i = beg; i < end; i++)
|
||||
|
@ -245,8 +245,7 @@ public abstract class AbstractExecutorService implements ExecutorService {
|
||||
Future<T> f = futures.get(i);
|
||||
if (!f.isDone()) {
|
||||
try { f.get(); }
|
||||
catch (CancellationException ignore) {}
|
||||
catch (ExecutionException ignore) {}
|
||||
catch (CancellationException | ExecutionException ignore) {}
|
||||
}
|
||||
}
|
||||
return futures;
|
||||
@ -283,8 +282,7 @@ public abstract class AbstractExecutorService implements ExecutorService {
|
||||
Future<T> f = futures.get(j);
|
||||
if (!f.isDone()) {
|
||||
try { f.get(deadline - System.nanoTime(), NANOSECONDS); }
|
||||
catch (CancellationException ignore) {}
|
||||
catch (ExecutionException ignore) {}
|
||||
catch (CancellationException | ExecutionException ignore) {}
|
||||
catch (TimeoutException timedOut) {
|
||||
break timedOut;
|
||||
}
|
||||
|
@ -717,12 +717,12 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
|
||||
*/
|
||||
static Class<?> comparableClassFor(Object x) {
|
||||
if (x instanceof Comparable) {
|
||||
Class<?> c; Type[] ts, as; Type t; ParameterizedType p;
|
||||
Class<?> c; Type[] ts, as; ParameterizedType p;
|
||||
if ((c = x.getClass()) == String.class) // bypass checks
|
||||
return c;
|
||||
if ((ts = c.getGenericInterfaces()) != null) {
|
||||
for (int i = 0; i < ts.length; ++i) {
|
||||
if (((t = ts[i]) instanceof ParameterizedType) &&
|
||||
for (Type t : ts) {
|
||||
if ((t instanceof ParameterizedType) &&
|
||||
((p = (ParameterizedType)t).getRawType() ==
|
||||
Comparable.class) &&
|
||||
(as = p.getActualTypeArguments()) != null &&
|
||||
@ -2328,15 +2328,15 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
|
||||
* @param check if <0, don't check resize, if <= 1 only check if uncontended
|
||||
*/
|
||||
private final void addCount(long x, int check) {
|
||||
CounterCell[] as; long b, s;
|
||||
if ((as = counterCells) != null ||
|
||||
CounterCell[] cs; long b, s;
|
||||
if ((cs = counterCells) != null ||
|
||||
!U.compareAndSetLong(this, BASECOUNT, b = baseCount, s = b + x)) {
|
||||
CounterCell a; long v; int m;
|
||||
CounterCell c; long v; int m;
|
||||
boolean uncontended = true;
|
||||
if (as == null || (m = as.length - 1) < 0 ||
|
||||
(a = as[ThreadLocalRandom.getProbe() & m]) == null ||
|
||||
if (cs == null || (m = cs.length - 1) < 0 ||
|
||||
(c = cs[ThreadLocalRandom.getProbe() & m]) == null ||
|
||||
!(uncontended =
|
||||
U.compareAndSetLong(a, CELLVALUE, v = a.value, v + x))) {
|
||||
U.compareAndSetLong(c, CELLVALUE, v = c.value, v + x))) {
|
||||
fullAddCount(x, uncontended);
|
||||
return;
|
||||
}
|
||||
@ -2574,13 +2574,12 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
|
||||
}
|
||||
|
||||
final long sumCount() {
|
||||
CounterCell[] as = counterCells; CounterCell a;
|
||||
CounterCell[] cs = counterCells;
|
||||
long sum = baseCount;
|
||||
if (as != null) {
|
||||
for (int i = 0; i < as.length; ++i) {
|
||||
if ((a = as[i]) != null)
|
||||
sum += a.value;
|
||||
}
|
||||
if (cs != null) {
|
||||
for (CounterCell c : cs)
|
||||
if (c != null)
|
||||
sum += c.value;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
@ -2595,9 +2594,9 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
|
||||
}
|
||||
boolean collide = false; // True if last slot nonempty
|
||||
for (;;) {
|
||||
CounterCell[] as; CounterCell a; int n; long v;
|
||||
if ((as = counterCells) != null && (n = as.length) > 0) {
|
||||
if ((a = as[(n - 1) & h]) == null) {
|
||||
CounterCell[] cs; CounterCell c; int n; long v;
|
||||
if ((cs = counterCells) != null && (n = cs.length) > 0) {
|
||||
if ((c = cs[(n - 1) & h]) == null) {
|
||||
if (cellsBusy == 0) { // Try to attach new Cell
|
||||
CounterCell r = new CounterCell(x); // Optimistic create
|
||||
if (cellsBusy == 0 &&
|
||||
@ -2623,21 +2622,17 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
|
||||
}
|
||||
else if (!wasUncontended) // CAS already known to fail
|
||||
wasUncontended = true; // Continue after rehash
|
||||
else if (U.compareAndSetLong(a, CELLVALUE, v = a.value, v + x))
|
||||
else if (U.compareAndSetLong(c, CELLVALUE, v = c.value, v + x))
|
||||
break;
|
||||
else if (counterCells != as || n >= NCPU)
|
||||
else if (counterCells != cs || n >= NCPU)
|
||||
collide = false; // At max size or stale
|
||||
else if (!collide)
|
||||
collide = true;
|
||||
else if (cellsBusy == 0 &&
|
||||
U.compareAndSetInt(this, CELLSBUSY, 0, 1)) {
|
||||
try {
|
||||
if (counterCells == as) {// Expand table unless stale
|
||||
CounterCell[] rs = new CounterCell[n << 1];
|
||||
for (int i = 0; i < n; ++i)
|
||||
rs[i] = as[i];
|
||||
counterCells = rs;
|
||||
}
|
||||
if (counterCells == cs) // Expand table unless stale
|
||||
counterCells = Arrays.copyOf(cs, n << 1);
|
||||
} finally {
|
||||
cellsBusy = 0;
|
||||
}
|
||||
@ -2646,11 +2641,11 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
|
||||
}
|
||||
h = ThreadLocalRandom.advanceProbe(h);
|
||||
}
|
||||
else if (cellsBusy == 0 && counterCells == as &&
|
||||
else if (cellsBusy == 0 && counterCells == cs &&
|
||||
U.compareAndSetInt(this, CELLSBUSY, 0, 1)) {
|
||||
boolean init = false;
|
||||
try { // Initialize table
|
||||
if (counterCells == as) {
|
||||
if (counterCells == cs) {
|
||||
CounterCell[] rs = new CounterCell[2];
|
||||
rs[h & 1] = new CounterCell(x);
|
||||
counterCells = rs;
|
||||
|
@ -2204,9 +2204,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
|
||||
Collection<?> c = (Collection<?>) o;
|
||||
try {
|
||||
return containsAll(c) && c.containsAll(this);
|
||||
} catch (ClassCastException unused) {
|
||||
return false;
|
||||
} catch (NullPointerException unused) {
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2331,9 +2329,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
|
||||
Collection<?> c = (Collection<?>) o;
|
||||
try {
|
||||
return containsAll(c) && c.containsAll(this);
|
||||
} catch (ClassCastException unused) {
|
||||
return false;
|
||||
} catch (NullPointerException unused) {
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -2453,9 +2449,7 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
|
||||
if (k == null) // pass by markers and headers
|
||||
return true;
|
||||
int c = cpr(cmp, k, hi);
|
||||
if (c > 0 || (c == 0 && !hiInclusive))
|
||||
return false;
|
||||
return true;
|
||||
return c < 0 || (c == 0 && hiInclusive);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -309,9 +309,7 @@ public class ConcurrentSkipListSet<E>
|
||||
Collection<?> c = (Collection<?>) o;
|
||||
try {
|
||||
return containsAll(c) && c.containsAll(this);
|
||||
} catch (ClassCastException unused) {
|
||||
return false;
|
||||
} catch (NullPointerException unused) {
|
||||
} catch (ClassCastException | NullPointerException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ public class CopyOnWriteArrayList<E>
|
||||
public boolean remove(Object o) {
|
||||
Object[] snapshot = getArray();
|
||||
int index = indexOf(o, snapshot, 0, snapshot.length);
|
||||
return (index < 0) ? false : remove(o, snapshot, index);
|
||||
return index >= 0 && remove(o, snapshot, index);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -587,8 +587,8 @@ public class CopyOnWriteArrayList<E>
|
||||
*/
|
||||
public boolean addIfAbsent(E e) {
|
||||
Object[] snapshot = getArray();
|
||||
return indexOf(e, snapshot, 0, snapshot.length) >= 0 ? false :
|
||||
addIfAbsent(e, snapshot);
|
||||
return indexOf(e, snapshot, 0, snapshot.length) < 0
|
||||
&& addIfAbsent(e, snapshot);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -980,13 +980,10 @@ public class CopyOnWriteArrayList<E>
|
||||
|
||||
List<?> list = (List<?>)o;
|
||||
Iterator<?> it = list.iterator();
|
||||
Object[] elements = getArray();
|
||||
for (int i = 0, len = elements.length; i < len; i++)
|
||||
if (!it.hasNext() || !Objects.equals(elements[i], it.next()))
|
||||
for (Object element : getArray())
|
||||
if (!it.hasNext() || !Objects.equals(element, it.next()))
|
||||
return false;
|
||||
if (it.hasNext())
|
||||
return false;
|
||||
return true;
|
||||
return !it.hasNext();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1353,17 +1353,16 @@ public class LinkedBlockingDeque<E>
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean bulkRemove(Predicate<? super E> filter) {
|
||||
boolean removed = false;
|
||||
Node<E> p = null;
|
||||
final ReentrantLock lock = this.lock;
|
||||
Node<E> p = null;
|
||||
Node<E>[] nodes = null;
|
||||
int n, len = 0;
|
||||
do {
|
||||
// 1. Extract batch of up to 64 elements while holding the lock.
|
||||
long deathRow = 0; // "bitset" of size 64
|
||||
lock.lock();
|
||||
try {
|
||||
if (nodes == null) {
|
||||
if (p == null) p = first;
|
||||
if (nodes == null) { // first batch; initialize
|
||||
p = first;
|
||||
for (Node<E> q = p; q != null; q = succ(q))
|
||||
if (q.item != null && ++len == 64)
|
||||
break;
|
||||
@ -1376,6 +1375,7 @@ public class LinkedBlockingDeque<E>
|
||||
}
|
||||
|
||||
// 2. Run the filter on the elements while lock is free.
|
||||
long deathRow = 0L; // "bitset" of size 64
|
||||
for (int i = 0; i < n; i++) {
|
||||
final E e;
|
||||
if ((e = nodes[i].item) != null && filter.test(e))
|
||||
@ -1393,6 +1393,7 @@ public class LinkedBlockingDeque<E>
|
||||
unlink(q);
|
||||
removed = true;
|
||||
}
|
||||
nodes[i] = null; // help GC
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
|
@ -1060,11 +1060,10 @@ public class LinkedBlockingQueue<E> extends AbstractQueue<E>
|
||||
int n, len = 0;
|
||||
do {
|
||||
// 1. Extract batch of up to 64 elements while holding the lock.
|
||||
long deathRow = 0; // "bitset" of size 64
|
||||
fullyLock();
|
||||
try {
|
||||
if (nodes == null) {
|
||||
if (p == null) p = head.next;
|
||||
if (nodes == null) { // first batch; initialize
|
||||
p = head.next;
|
||||
for (Node<E> q = p; q != null; q = succ(q))
|
||||
if (q.item != null && ++len == 64)
|
||||
break;
|
||||
@ -1077,6 +1076,7 @@ public class LinkedBlockingQueue<E> extends AbstractQueue<E>
|
||||
}
|
||||
|
||||
// 2. Run the filter on the elements while lock is free.
|
||||
long deathRow = 0L; // "bitset" of size 64
|
||||
for (int i = 0; i < n; i++) {
|
||||
final E e;
|
||||
if ((e = nodes[i].item) != null && filter.test(e))
|
||||
@ -1095,6 +1095,7 @@ public class LinkedBlockingQueue<E> extends AbstractQueue<E>
|
||||
unlink(q, ancestor);
|
||||
removed = true;
|
||||
}
|
||||
nodes[i] = null; // help GC
|
||||
}
|
||||
} finally {
|
||||
fullyUnlock();
|
||||
|
@ -772,9 +772,8 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
|
||||
Node first = null;
|
||||
restartFromHead: for (;;) {
|
||||
Node h = head, p = h;
|
||||
for (; p != null;) {
|
||||
final Object item;
|
||||
if ((item = p.item) != null) {
|
||||
while (p != null) {
|
||||
if (p.item != null) {
|
||||
if (p.isData) {
|
||||
first = p;
|
||||
break;
|
||||
@ -1602,8 +1601,7 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
|
||||
// Read in elements until trailing null sentinel found
|
||||
Node h = null, t = null;
|
||||
for (Object item; (item = s.readObject()) != null; ) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Node newNode = new Node((E) item);
|
||||
Node newNode = new Node(item);
|
||||
if (h == null)
|
||||
h = t = newNode;
|
||||
else
|
||||
|
@ -269,8 +269,8 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E>
|
||||
if (a.getClass() != Object[].class)
|
||||
a = Arrays.copyOf(a, n, Object[].class);
|
||||
if (screen && (n == 1 || this.comparator != null)) {
|
||||
for (int i = 0; i < n; ++i)
|
||||
if (a[i] == null)
|
||||
for (Object elt : a)
|
||||
if (elt == null)
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.queue = a;
|
||||
|
@ -753,8 +753,10 @@ public class SubmissionPublisher<T> implements Publisher<T>,
|
||||
else
|
||||
pred.next = next;
|
||||
}
|
||||
else
|
||||
else {
|
||||
subs.add(b.subscriber);
|
||||
pred = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
return subs;
|
||||
|
@ -67,7 +67,7 @@ import jdk.internal.misc.VM;
|
||||
* {@code ThreadLocalRandom.current().nextX(...)} (where
|
||||
* {@code X} is {@code Int}, {@code Long}, etc).
|
||||
* When all usages are of this form, it is never possible to
|
||||
* accidently share a {@code ThreadLocalRandom} across multiple threads.
|
||||
* accidentally share a {@code ThreadLocalRandom} across multiple threads.
|
||||
*
|
||||
* <p>This class also provides additional commonly used bounded random
|
||||
* generation methods.
|
||||
|
@ -264,13 +264,12 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
* assist in storage reclamation when large numbers of queued tasks
|
||||
* become cancelled.</dd>
|
||||
*
|
||||
* <dt>Finalization</dt>
|
||||
* <dt>Reclamation</dt>
|
||||
*
|
||||
* <dd>A pool that is no longer referenced in a program <em>AND</em>
|
||||
* has no remaining threads will be {@code shutdown} automatically. If
|
||||
* you would like to ensure that unreferenced pools are reclaimed even
|
||||
* if users forget to call {@link #shutdown}, then you must arrange
|
||||
* that unused threads eventually die, by setting appropriate
|
||||
* has no remaining threads may be reclaimed (garbage collected)
|
||||
* without being explicity shutdown. You can configure a pool to allow
|
||||
* all unused threads to eventually die by setting appropriate
|
||||
* keep-alive times, using a lower bound of zero core threads and/or
|
||||
* setting {@link #allowCoreThreadTimeOut(boolean)}. </dd>
|
||||
*
|
||||
@ -361,7 +360,7 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
||||
* time, but need not hit each state. The transitions are:
|
||||
*
|
||||
* RUNNING -> SHUTDOWN
|
||||
* On invocation of shutdown(), perhaps implicitly in finalize()
|
||||
* On invocation of shutdown()
|
||||
* (RUNNING or SHUTDOWN) -> STOP
|
||||
* On invocation of shutdownNow()
|
||||
* SHUTDOWN -> TIDYING
|
||||
@ -581,9 +580,6 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
||||
private static final RuntimePermission shutdownPerm =
|
||||
new RuntimePermission("modifyThread");
|
||||
|
||||
/** The context to be used when executing the finalizer, or null. */
|
||||
private final AccessControlContext acc;
|
||||
|
||||
/**
|
||||
* Class Worker mainly maintains interrupt control state for
|
||||
* threads running tasks, along with other minor bookkeeping.
|
||||
@ -1300,9 +1296,6 @@ 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.corePoolSize = corePoolSize;
|
||||
this.maximumPoolSize = maximumPoolSize;
|
||||
this.workQueue = workQueue;
|
||||
@ -1469,33 +1462,6 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes {@code shutdown} when this executor is no longer
|
||||
* referenced and it has no threads.
|
||||
*
|
||||
* <p>This method is invoked with privileges that are restricted by
|
||||
* the security context of the caller that invokes the constructor.
|
||||
*
|
||||
* @deprecated The {@code finalize} method has been deprecated.
|
||||
* Subclasses that override {@code finalize} in order to perform cleanup
|
||||
* should be modified to use alternative cleanup mechanisms and
|
||||
* to remove the overriding {@code finalize} method.
|
||||
* When overriding the {@code finalize} method, its implementation must explicitly
|
||||
* ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
|
||||
* See the specification for {@link Object#finalize()} for further
|
||||
* information about migration options.
|
||||
*/
|
||||
@Deprecated(since="9")
|
||||
protected void finalize() {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm == null || acc == null) {
|
||||
shutdown();
|
||||
} else {
|
||||
PrivilegedAction<Void> pa = () -> { shutdown(); return null; };
|
||||
AccessController.doPrivileged(pa, acc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the thread factory used to create new threads.
|
||||
*
|
||||
|
@ -29,8 +29,13 @@
|
||||
* @author Josh Bloch, Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
public class ToString {
|
||||
private static void realMain(String[] args) {
|
||||
|
@ -30,7 +30,9 @@
|
||||
* @ignore Bug fix temporarily removed as it uncovered other bugs (4992226)
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.List;
|
||||
|
||||
public class CheckForComodification {
|
||||
private static final int LENGTH = 10;
|
||||
|
@ -28,7 +28,10 @@
|
||||
* *after* the set/add/remove operations were performed.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
public class FailFastIterator {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -30,7 +30,10 @@
|
||||
* @author Konstantin Kladko
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class HasNextAfterException {
|
||||
public static void main(String[] args) {
|
||||
|
@ -30,7 +30,10 @@
|
||||
* @author Konstantin Kladko
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class AbstractMapClone extends AbstractMap implements Cloneable {
|
||||
|
||||
|
@ -21,7 +21,12 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* @test
|
||||
|
@ -28,9 +28,10 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import static java.util.AbstractMap.*;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.AbstractMap.SimpleEntry;
|
||||
import static java.util.AbstractMap.SimpleImmutableEntry;
|
||||
|
||||
public class SimpleEntries {
|
||||
private static String k = "foo";
|
||||
|
@ -29,7 +29,8 @@
|
||||
* @author Josh Bloch
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ToString {
|
||||
public static void main(String[] args) {
|
||||
|
@ -27,7 +27,11 @@
|
||||
* @summary AddAll(int, Collection) intersperses the Collection with this List.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.AbstractSequentialList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
public class AddAll {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -28,7 +28,12 @@
|
||||
* @author Josh Bloch
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class AddAll {
|
||||
public static void main(String[] args) {
|
||||
|
@ -27,7 +27,9 @@
|
||||
* @summary AbstractList.ListItr.add might corrupt iterator state if enclosing add throws
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
@SuppressWarnings({"serial","unchecked"})
|
||||
public class Bug6533203 {
|
||||
|
@ -27,9 +27,12 @@
|
||||
* @run main IteratorMicroBenchmark iterations=1 size=8 warmup=0
|
||||
*/
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -165,16 +168,11 @@ public class IteratorMicroBenchmark {
|
||||
}
|
||||
|
||||
private static Job[] filter(Pattern filter, Job[] jobs) {
|
||||
if (filter == null) return jobs;
|
||||
Job[] newJobs = new Job[jobs.length];
|
||||
int n = 0;
|
||||
for (Job job : jobs)
|
||||
if (filter.matcher(job.name()).find())
|
||||
newJobs[n++] = job;
|
||||
// Arrays.copyOf not available in JDK 5
|
||||
Job[] ret = new Job[n];
|
||||
System.arraycopy(newJobs, 0, ret, 0, n);
|
||||
return ret;
|
||||
return (filter == null) ? jobs
|
||||
: Arrays.stream(jobs)
|
||||
.filter(job -> filter.matcher(job.name()).find())
|
||||
.collect(toList())
|
||||
.toArray(new Job[0]);
|
||||
}
|
||||
|
||||
private static void deoptimize(int sum) {
|
||||
|
@ -32,9 +32,14 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
public class RangeCheckMicroBenchmark {
|
||||
abstract static class Job {
|
||||
@ -133,16 +138,11 @@ public class RangeCheckMicroBenchmark {
|
||||
}
|
||||
|
||||
private static Job[] filter(Pattern filter, Job[] jobs) {
|
||||
if (filter == null) return jobs;
|
||||
Job[] newJobs = new Job[jobs.length];
|
||||
int n = 0;
|
||||
for (Job job : jobs)
|
||||
if (filter.matcher(job.name()).find())
|
||||
newJobs[n++] = job;
|
||||
// Arrays.copyOf not available in JDK 5
|
||||
Job[] ret = new Job[n];
|
||||
System.arraycopy(newJobs, 0, ret, 0, n);
|
||||
return ret;
|
||||
return (filter == null) ? jobs
|
||||
: Arrays.stream(jobs)
|
||||
.filter(job -> filter.matcher(job.name()).find())
|
||||
.collect(toList())
|
||||
.toArray(new Job[0]);
|
||||
}
|
||||
|
||||
private static void deoptimize(ArrayList<Integer> list) {
|
||||
|
@ -28,9 +28,27 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.NavigableSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.LinkedTransferQueue;
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class BiggernYours {
|
||||
@ -152,7 +170,7 @@ public class BiggernYours {
|
||||
static int randomize(int size) { return rnd.nextInt(size + 2); }
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private static void realMain(String[] args) throws Throwable {
|
||||
private static void realMain(String[] args) {
|
||||
testNavigableMaps(
|
||||
new ConcurrentSkipListMap(),
|
||||
new ConcurrentSkipListMap() {
|
||||
@ -232,7 +250,7 @@ public class BiggernYours {
|
||||
static void arrayEqual(Object[] x, Object[] y) {
|
||||
if (x == null ? y == null : Arrays.equals(x, y)) pass();
|
||||
else fail(Arrays.toString(x) + " not equal to " + Arrays.toString(y));}
|
||||
public static void main(String[] args) throws Throwable {
|
||||
public static void main(String[] args) {
|
||||
try {realMain(args);} catch (Throwable t) {unexpected(t);}
|
||||
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
|
||||
if (failed > 0) throw new AssertionError("Some tests failed");}
|
||||
|
@ -28,9 +28,16 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class HotPotatoes {
|
||||
|
@ -28,8 +28,34 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Vector;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.LinkedTransferQueue;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class IteratorAtEnd {
|
||||
|
@ -28,10 +28,10 @@
|
||||
*/
|
||||
|
||||
import static java.util.stream.Collectors.summingInt;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -205,12 +205,10 @@ public class IteratorMicroBenchmark {
|
||||
}
|
||||
|
||||
private static List<Job> filter(Pattern filter, List<Job> jobs) {
|
||||
if (filter == null) return jobs;
|
||||
ArrayList<Job> newJobs = new ArrayList<>();
|
||||
for (Job job : jobs)
|
||||
if (filter.matcher(job.name()).find())
|
||||
newJobs.add(job);
|
||||
return newJobs;
|
||||
return (filter == null) ? jobs
|
||||
: jobs.stream()
|
||||
.filter(job -> filter.matcher(job.name()).find())
|
||||
.collect(toList());
|
||||
}
|
||||
|
||||
private static void deoptimize(int sum) {
|
||||
@ -270,24 +268,24 @@ public class IteratorMicroBenchmark {
|
||||
abq.add(abq.remove());
|
||||
}
|
||||
|
||||
ArrayList<Job> jobs = new ArrayList<>(Arrays.asList());
|
||||
ArrayList<Job> jobs = new ArrayList<>();
|
||||
|
||||
List.of(al, ad, abq,
|
||||
new LinkedList<>(al),
|
||||
new PriorityQueue<>(al),
|
||||
new Vector<>(al),
|
||||
new ConcurrentLinkedQueue<>(al),
|
||||
new ConcurrentLinkedDeque<>(al),
|
||||
new LinkedBlockingQueue<>(al),
|
||||
new LinkedBlockingDeque<>(al),
|
||||
new LinkedTransferQueue<>(al),
|
||||
new PriorityBlockingQueue<>(al))
|
||||
.stream()
|
||||
.forEach(x -> {
|
||||
jobs.addAll(collectionJobs(x));
|
||||
if (x instanceof Deque)
|
||||
jobs.addAll(dequeJobs((Deque<Integer>)x));
|
||||
});
|
||||
List.<Collection<Integer>>of(
|
||||
al, ad, abq,
|
||||
new LinkedList<>(al),
|
||||
new PriorityQueue<>(al),
|
||||
new Vector<>(al),
|
||||
new ConcurrentLinkedQueue<>(al),
|
||||
new ConcurrentLinkedDeque<>(al),
|
||||
new LinkedBlockingQueue<>(al),
|
||||
new LinkedBlockingDeque<>(al),
|
||||
new LinkedTransferQueue<>(al),
|
||||
new PriorityBlockingQueue<>(al)).forEach(
|
||||
x -> {
|
||||
jobs.addAll(collectionJobs(x));
|
||||
if (x instanceof Deque)
|
||||
jobs.addAll(dequeJobs((Deque<Integer>)x));
|
||||
});
|
||||
|
||||
if (reverse) Collections.reverse(jobs);
|
||||
if (shuffle) Collections.shuffle(jobs);
|
||||
|
@ -27,6 +27,8 @@
|
||||
* @run main RemoveMicroBenchmark iterations=1 size=8 warmup=0
|
||||
*/
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
@ -202,12 +204,10 @@ public class RemoveMicroBenchmark {
|
||||
}
|
||||
|
||||
private static List<Job> filter(Pattern filter, List<Job> jobs) {
|
||||
if (filter == null) return jobs;
|
||||
ArrayList<Job> newJobs = new ArrayList<>();
|
||||
for (Job job : jobs)
|
||||
if (filter.matcher(job.name()).find())
|
||||
newJobs.add(job);
|
||||
return newJobs;
|
||||
return (filter == null) ? jobs
|
||||
: jobs.stream()
|
||||
.filter(job -> filter.matcher(job.name()).find())
|
||||
.collect(toList());
|
||||
}
|
||||
|
||||
private static void deoptimize(int sum) {
|
||||
@ -271,8 +271,7 @@ public class RemoveMicroBenchmark {
|
||||
new LinkedBlockingQueue<>(),
|
||||
new LinkedBlockingDeque<>(),
|
||||
new LinkedTransferQueue<>(),
|
||||
new PriorityBlockingQueue<>())
|
||||
.stream().forEach(
|
||||
new PriorityBlockingQueue<>()).forEach(
|
||||
x -> {
|
||||
String klazz = x.getClass().getSimpleName();
|
||||
jobs.addAll(collectionJobs(klazz, () -> x, al));
|
||||
|
@ -29,7 +29,15 @@
|
||||
* @key randomness
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class AddAll {
|
||||
static final int N = 100;
|
||||
|
@ -28,7 +28,13 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.AbstractList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.RandomAccess;
|
||||
|
||||
public class BigBinarySearch {
|
||||
|
||||
|
@ -27,7 +27,9 @@
|
||||
* @summary Test Collections.binarySearch() with a null comparator
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BinarySearchNullComparator {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -28,14 +28,15 @@
|
||||
* @summary Checked collections with underlying maps with identity comparisons
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import static java.util.Collections.*;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.Collections.checkedMap;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotEquals;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class CheckedIdentityMap {
|
||||
|
||||
@Test
|
||||
|
@ -29,7 +29,13 @@
|
||||
* @key randomness
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Random;
|
||||
|
||||
public class CheckedListBash {
|
||||
static Random rnd = new Random();
|
||||
|
@ -30,10 +30,20 @@
|
||||
* @key randomness
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
|
@ -27,8 +27,18 @@
|
||||
* @summary Test behavior of nulls in checked collections
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import static java.util.Collections.*;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static java.util.Collections.singleton;
|
||||
import static java.util.Collections.singletonMap;
|
||||
|
||||
@SuppressWarnings({"unchecked","serial"})
|
||||
public class CheckedNull {
|
||||
|
@ -30,13 +30,23 @@
|
||||
* @key randomness
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static org.testng.Assert.fail;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
public class CheckedSetBash {
|
||||
static final int numItr = 100;
|
||||
|
@ -29,7 +29,11 @@
|
||||
* @key randomness
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class Disjoint {
|
||||
static final int N = 20;
|
||||
|
@ -29,14 +29,22 @@
|
||||
* @run testng EmptyCollectionSerialization
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Supplier;
|
||||
import java.io.*;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static org.testng.Assert.fail;
|
||||
import static org.testng.Assert.assertSame;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
public class EmptyCollectionSerialization {
|
||||
private static Object patheticDeepCopy(Object o) throws Exception {
|
||||
|
@ -27,10 +27,25 @@
|
||||
* @summary Test empty iterators, enumerations, and collections
|
||||
*/
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
|
||||
import static java.util.Collections.emptyEnumeration;
|
||||
import static java.util.Collections.emptyIterator;
|
||||
import static java.util.Collections.emptyList;
|
||||
import static java.util.Collections.emptyListIterator;
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.emptySet;
|
||||
import static java.util.Collections.nCopies;
|
||||
import static java.util.Collections.unmodifiableMap;
|
||||
|
||||
public class EmptyIterator {
|
||||
|
||||
void test(String[] args) throws Throwable {
|
||||
|
@ -27,6 +27,12 @@
|
||||
* @summary Unit test for Collections.emptyNavigableMap
|
||||
* @run testng EmptyNavigableMap
|
||||
*/
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.Assert.ThrowingRunnable;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -37,13 +43,8 @@ import java.util.NavigableMap;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.Assert.ThrowingRunnable;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.DataProvider;
|
||||
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
public class EmptyNavigableMap {
|
||||
|
||||
@ -124,10 +125,9 @@ public class EmptyNavigableMap {
|
||||
*/
|
||||
@Test(dataProvider = "NavigableMap<?,?>", dataProviderClass = EmptyNavigableMap.class)
|
||||
public void testContainsRequiresComparable(String description, NavigableMap<?,?> navigableMap) {
|
||||
assertThrowsCCE(() -> {
|
||||
navigableMap.containsKey(new Object());
|
||||
},
|
||||
description + ": Compareable should be required");
|
||||
assertThrowsCCE(
|
||||
() -> navigableMap.containsKey(new Object()),
|
||||
description + ": Comparable should be required");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,9 +252,7 @@ public class EmptyNavigableMap {
|
||||
Object last = (BigInteger.ZERO == first) ? BigInteger.TEN : BigInteger.ZERO;
|
||||
|
||||
assertThrowsIAE(
|
||||
() -> {
|
||||
navigableMap.subMap(last, true, first, false);
|
||||
},
|
||||
() -> navigableMap.subMap(last, true, first, false),
|
||||
description + ": Must throw IllegalArgumentException when fromElement is not less than toElement.");
|
||||
|
||||
navigableMap.subMap(first, true, last, false);
|
||||
@ -273,9 +271,8 @@ public class EmptyNavigableMap {
|
||||
// slightly smaller
|
||||
NavigableMap ns = subMap.subMap(first, false, last, false);
|
||||
// slight expansion
|
||||
assertThrowsIAE(() -> {
|
||||
ns.subMap(first, true, last, true);
|
||||
},
|
||||
assertThrowsIAE(
|
||||
() -> ns.subMap(first, true, last, true),
|
||||
description + ": Expansion should not be allowed");
|
||||
|
||||
// much smaller
|
||||
@ -293,9 +290,8 @@ public class EmptyNavigableMap {
|
||||
NavigableMap ns = subMap.headMap(BigInteger.ONE, false);
|
||||
|
||||
// slight expansion
|
||||
assertThrowsIAE(() -> {
|
||||
ns.headMap(BigInteger.ONE, true);
|
||||
},
|
||||
assertThrowsIAE(
|
||||
() -> ns.headMap(BigInteger.ONE, true),
|
||||
description + ": Expansion should not be allowed");
|
||||
|
||||
// much smaller
|
||||
@ -313,9 +309,8 @@ public class EmptyNavigableMap {
|
||||
NavigableMap ns = subMap.tailMap(BigInteger.ONE, false);
|
||||
|
||||
// slight expansion
|
||||
assertThrowsIAE(() -> {
|
||||
ns.tailMap(BigInteger.ONE, true);
|
||||
},
|
||||
assertThrowsIAE(
|
||||
() -> ns.tailMap(BigInteger.ONE, true),
|
||||
description + ": Expansion should not be allowed");
|
||||
|
||||
// much smaller
|
||||
@ -327,14 +322,12 @@ public class EmptyNavigableMap {
|
||||
*/
|
||||
@Test(dataProvider = "NavigableMap<?,?>", dataProviderClass = EmptyNavigableMap.class)
|
||||
public void testTailMap(String description, NavigableMap navigableMap) {
|
||||
assertThrowsNPE(() -> {
|
||||
navigableMap.tailMap(null);
|
||||
},
|
||||
assertThrowsNPE(
|
||||
() -> navigableMap.tailMap(null),
|
||||
description + ": Must throw NullPointerException for null element");
|
||||
|
||||
assertThrowsCCE(() -> {
|
||||
navigableMap.tailMap(new Object());
|
||||
},
|
||||
assertThrowsCCE(
|
||||
() -> navigableMap.tailMap(new Object()),
|
||||
description);
|
||||
|
||||
NavigableMap ss = navigableMap.tailMap("1", true);
|
||||
|
@ -27,22 +27,23 @@
|
||||
* @summary Unit test for Collections.emptyNavigableSet
|
||||
* @run testng EmptyNavigableSet
|
||||
*/
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.Assert.ThrowingRunnable;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.NavigableSet;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.Assert.ThrowingRunnable;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.DataProvider;
|
||||
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertSame;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
@ -130,10 +131,9 @@ public class EmptyNavigableSet {
|
||||
*/
|
||||
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
|
||||
public void testContainsRequiresComparable(String description, NavigableSet<?> navigableSet) {
|
||||
assertThrowsCCE(() -> {
|
||||
navigableSet.contains(new Object());
|
||||
},
|
||||
description + ": Compareable should be required");
|
||||
assertThrowsCCE(
|
||||
() -> navigableSet.contains(new Object()),
|
||||
description + ": Comparable should be required");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,9 +182,7 @@ public class EmptyNavigableSet {
|
||||
*/
|
||||
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
|
||||
public void testFirst(String description, NavigableSet<?> navigableSet) {
|
||||
assertThrowsNSEE(() -> {
|
||||
navigableSet.first();
|
||||
}, description);
|
||||
assertThrowsNSEE(navigableSet::first, description);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,9 +208,7 @@ public class EmptyNavigableSet {
|
||||
*/
|
||||
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
|
||||
public void testLast(String description, NavigableSet<?> navigableSet) {
|
||||
assertThrowsNSEE(() -> {
|
||||
navigableSet.last();
|
||||
}, description);
|
||||
assertThrowsNSEE(navigableSet::last, description);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -277,9 +273,7 @@ public class EmptyNavigableSet {
|
||||
Object last = (BigInteger.ZERO == first) ? BigInteger.TEN : BigInteger.ZERO;
|
||||
|
||||
assertThrowsIAE(
|
||||
() -> {
|
||||
navigableSet.subSet(last, true, first, false);
|
||||
},
|
||||
() -> navigableSet.subSet(last, true, first, false),
|
||||
description
|
||||
+ ": Must throw IllegalArgumentException when fromElement is not less than toElement.");
|
||||
|
||||
@ -299,9 +293,8 @@ public class EmptyNavigableSet {
|
||||
// slightly smaller
|
||||
NavigableSet ns = subSet.subSet(first, false, last, false);
|
||||
// slight expansion
|
||||
assertThrowsIAE(() -> {
|
||||
ns.subSet(first, true, last, true);
|
||||
},
|
||||
assertThrowsIAE(
|
||||
() -> ns.subSet(first, true, last, true),
|
||||
description + ": Expansion should not be allowed");
|
||||
|
||||
// much smaller
|
||||
@ -319,9 +312,8 @@ public class EmptyNavigableSet {
|
||||
NavigableSet ns = subSet.headSet(BigInteger.ONE, false);
|
||||
|
||||
// slight expansion
|
||||
assertThrowsIAE(() -> {
|
||||
ns.headSet(BigInteger.ONE, true);
|
||||
},
|
||||
assertThrowsIAE(
|
||||
() -> ns.headSet(BigInteger.ONE, true),
|
||||
description + ": Expansion should not be allowed");
|
||||
|
||||
// much smaller
|
||||
@ -339,9 +331,8 @@ public class EmptyNavigableSet {
|
||||
NavigableSet ns = subSet.tailSet(BigInteger.ONE, false);
|
||||
|
||||
// slight expansion
|
||||
assertThrowsIAE(() -> {
|
||||
ns.tailSet(BigInteger.ONE, true);
|
||||
},
|
||||
assertThrowsIAE(
|
||||
() -> ns.tailSet(BigInteger.ONE, true),
|
||||
description + ": Expansion should not be allowed");
|
||||
|
||||
// much smaller
|
||||
@ -353,14 +344,13 @@ public class EmptyNavigableSet {
|
||||
*/
|
||||
@Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
|
||||
public void testTailSet(String description, NavigableSet navigableSet) {
|
||||
assertThrowsNPE(() -> {
|
||||
navigableSet.tailSet(null);
|
||||
},
|
||||
assertThrowsNPE(
|
||||
() -> navigableSet.tailSet(null),
|
||||
description + ": Must throw NullPointerException for null element");
|
||||
|
||||
assertThrowsCCE(() -> {
|
||||
navigableSet.tailSet(new Object());
|
||||
}, description);
|
||||
assertThrowsCCE(
|
||||
() -> navigableSet.tailSet(new Object()),
|
||||
description);
|
||||
|
||||
NavigableSet ss = navigableSet.tailSet("1", true);
|
||||
|
||||
|
@ -27,7 +27,9 @@
|
||||
* @summary Basic test for new Enumeration -> List converter
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
public class Enum {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -27,7 +27,12 @@
|
||||
* @summary Basic test for Collections.indexOfSubList/lastIndexOfSubList
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
public class FindSubList {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -28,7 +28,10 @@
|
||||
* @author Josh Bloch
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class Frequency {
|
||||
static final int N = 100;
|
||||
|
@ -29,7 +29,9 @@
|
||||
* @author Josh Bloch
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class MinMax {
|
||||
public static void main(String[] args) {
|
||||
|
@ -28,8 +28,8 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class NCopies {
|
||||
static volatile int passed = 0, failed = 0;
|
||||
|
@ -27,7 +27,10 @@
|
||||
* @summary A null Comparator is now specified to indicate natural ordering.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class NullComparator {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -28,9 +28,46 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.LinkedTransferQueue;
|
||||
|
||||
import static java.util.Collections.asLifoQueue;
|
||||
import static java.util.Collections.checkedList;
|
||||
import static java.util.Collections.checkedMap;
|
||||
import static java.util.Collections.checkedSet;
|
||||
import static java.util.Collections.newSetFromMap;
|
||||
import static java.util.Collections.synchronizedList;
|
||||
import static java.util.Collections.synchronizedMap;
|
||||
import static java.util.Collections.synchronizedSet;
|
||||
import static java.util.Collections.unmodifiableList;
|
||||
import static java.util.Collections.unmodifiableMap;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
public class RacingCollections {
|
||||
/**
|
||||
|
@ -27,7 +27,11 @@
|
||||
* @summary Basic test for new replaceAll algorithm
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
public class ReplaceAll {
|
||||
static final int SIZE = 20;
|
||||
|
@ -28,8 +28,14 @@
|
||||
* @author Josh Bloch
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class ReverseOrder {
|
||||
static byte[] serialBytes(Object o) {
|
||||
|
@ -28,8 +28,17 @@
|
||||
* @author Josh Bloch, Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class ReverseOrder2 {
|
||||
static final int N = 100;
|
||||
|
@ -28,7 +28,12 @@
|
||||
* @key randomness
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
|
||||
public class Rotate {
|
||||
// Should have lots of distinct factors and be > ROTATE_THRESHOLD
|
||||
|
@ -27,7 +27,9 @@
|
||||
* @summary Collections.rotate(...) returns ArithmeticException
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class RotateEmpty {
|
||||
|
||||
|
@ -28,8 +28,13 @@
|
||||
* nCopies and singleton were spec'd to be serializable, but weren't.
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class Ser {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -28,7 +28,10 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class SetFromMap {
|
||||
static volatile int passed = 0, failed = 0;
|
||||
|
@ -28,7 +28,9 @@
|
||||
* @author Josh Bloch
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Swap {
|
||||
static final int SIZE = 100;
|
||||
|
@ -21,7 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 5078378
|
||||
* @summary REGRESSION: Some calls to Collections.binarySearch no longer compile
|
||||
@ -30,7 +30,9 @@
|
||||
* @compile T5078378.java
|
||||
* @compile/fail -Xlint:unchecked -Werror T5078378.java
|
||||
*/
|
||||
import java.util.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
class T5078378 {
|
||||
public static boolean contains(List l, Object o) {
|
||||
|
@ -27,8 +27,16 @@
|
||||
* @summary CheckedCollection.addAll should be all-or-nothing
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import static java.util.Collections.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import static java.util.Collections.checkedCollection;
|
||||
import static java.util.Collections.checkedList;
|
||||
import static java.util.Collections.checkedSet;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class T6433170 {
|
||||
|
@ -29,7 +29,11 @@
|
||||
* (Got that?)
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class ViewSynch {
|
||||
static final Integer ZERO = new Integer(0);
|
||||
|
@ -28,7 +28,16 @@
|
||||
* rather than later
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class WrappedNull {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -28,7 +28,9 @@
|
||||
* false if the Map previously mapped k to null.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class KeySetRemove {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -28,7 +28,8 @@
|
||||
* @author jbloch
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SetValue {
|
||||
static final String key = "key";
|
||||
|
@ -28,7 +28,8 @@
|
||||
* contained null keys or values.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ToString {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -29,8 +29,8 @@
|
||||
* unnecessarily. (java.security.Provider tickled this sensitivity.)
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.security.Provider;
|
||||
import java.util.Map;
|
||||
|
||||
public class EqualsCast {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -28,7 +28,8 @@
|
||||
* @author Josh Bloch
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
public class HashCode {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -26,7 +26,12 @@
|
||||
@summary Test for an illegalargumentexception on loadFactor
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
/**
|
||||
* This class tests to see if creating a hash table with an
|
||||
|
@ -21,18 +21,18 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 4652911
|
||||
* @summary test Hashtable readObject for invocation of overridable put method
|
||||
*/
|
||||
import java.util.Hashtable;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* Class that extends Hashtable to demonstrate bug when
|
||||
@ -52,7 +52,7 @@ public class ReadObject extends Hashtable {
|
||||
Object getValue() {
|
||||
return mValue;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Object get(Object key) {
|
||||
ValueWrapper valueWrapper = (ValueWrapper)super.get(key);
|
||||
|
@ -29,8 +29,11 @@
|
||||
* @author Josh Bloch, Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class SelfRef {
|
||||
public static void main(String[] args) {
|
||||
|
@ -28,7 +28,11 @@
|
||||
* @author Josh Bloch, Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ToArray {
|
||||
public static void main(String[] args) {
|
||||
|
@ -28,7 +28,10 @@
|
||||
* @author Josh Bloch
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ToString {
|
||||
public static void main(String[] args) {
|
||||
|
@ -27,9 +27,21 @@
|
||||
* @summary Basic test for LinkedHashMap. (Based on MapBash)
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class Basic {
|
||||
static final Random rnd = new Random(666);
|
||||
|
@ -27,7 +27,8 @@
|
||||
* @summary Basic test of removeEldestElement method.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Cache {
|
||||
private static final int MAP_SIZE = 10;
|
||||
|
@ -27,12 +27,14 @@
|
||||
* @summary iterators on collection views of empty map weren't fail-fast.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class EmptyMapIterator {
|
||||
public static void main(String[] args) throws Exception {
|
||||
HashMap map = new HashMap();
|
||||
Iterator iter = iter = map.entrySet().iterator();
|
||||
Iterator iter = map.entrySet().iterator();
|
||||
map.put("key", "value");
|
||||
|
||||
try {
|
||||
|
@ -27,8 +27,15 @@
|
||||
* @summary Basic test for LinkedHashSet. (Based on SetBash)
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class Basic {
|
||||
static Random rnd = new Random(666);
|
||||
|
@ -27,7 +27,10 @@
|
||||
* @summary AddAll was prepending instead of appending!
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class AddAll {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -29,7 +29,9 @@
|
||||
* TreeMap.
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.LinkedList;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class Clone {
|
||||
public static void main(String[] args) {
|
||||
|
@ -29,9 +29,10 @@
|
||||
* @author Konstantin Kladko
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ListIterator;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
public class ComodifiedRemove {
|
||||
public static
|
||||
|
@ -29,10 +29,23 @@
|
||||
* @key randomness
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import static java.util.Collections.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class LockStep {
|
||||
|
@ -28,6 +28,11 @@
|
||||
* @author Mike Duigou
|
||||
* @run testng Defaults
|
||||
*/
|
||||
|
||||
import org.testng.Assert.ThrowingRunnable;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.ArrayList;
|
||||
@ -36,36 +41,31 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.testng.Assert.ThrowingRunnable;
|
||||
import org.testng.annotations.Test;
|
||||
import org.testng.annotations.DataProvider;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import static org.testng.Assert.fail;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertSame;
|
||||
import static org.testng.Assert.assertThrows;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
public class Defaults {
|
||||
|
||||
@ -730,7 +730,7 @@ public class Defaults {
|
||||
e90, e91, e92, e93, e94, e95, e96, e97, e98, e99,
|
||||
EXTRA_KEY;
|
||||
public static final int SIZE = values().length;
|
||||
};
|
||||
}
|
||||
private static final int TEST_SIZE = IntegerEnum.SIZE - 1;
|
||||
/**
|
||||
* Realized keys ensure that there is always a hard ref to all test objects.
|
||||
|
@ -28,10 +28,18 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
|
||||
public class Get {
|
||||
|
||||
|
@ -28,8 +28,20 @@
|
||||
* @key randomness
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.TreeMap;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
|
||||
/**
|
||||
* Based on the strange scenario required to reproduce
|
||||
|
@ -32,10 +32,35 @@
|
||||
* @key randomness
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import static java.util.Collections.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.NotSerializableException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
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.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
|
||||
import static java.util.Collections.reverseOrder;
|
||||
import static java.util.Collections.singleton;
|
||||
import static java.util.Collections.singletonMap;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class LockStep {
|
||||
|
@ -27,6 +27,8 @@
|
||||
* @run testng AddNonComparable
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.Queue;
|
||||
import java.util.SortedMap;
|
||||
@ -39,8 +41,8 @@ import java.util.concurrent.PriorityBlockingQueue;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
public class AddNonComparable {
|
||||
|
||||
|
@ -38,8 +38,8 @@
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
@ -42,18 +42,14 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.Queue;
|
||||
|
||||
public class PriorityQueueSort {
|
||||
|
||||
static class MyComparator implements Comparator<Integer> {
|
||||
public int compare(Integer x, Integer y) {
|
||||
int i = x.intValue();
|
||||
int j = y.intValue();
|
||||
if (i < j) return -1;
|
||||
if (i > j) return 1;
|
||||
return 0;
|
||||
return Integer.compare(x.intValue(), y.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,8 @@ import java.util.Queue;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
import java.util.concurrent.LinkedTransferQueue;
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
|
||||
public class RemoveContains {
|
||||
static volatile int passed = 0, failed = 0;
|
||||
|
@ -28,7 +28,8 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
public class NextBytes {
|
||||
private static void realMain(String[] args) throws Throwable {
|
||||
|
@ -21,8 +21,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class SortPerf {
|
||||
private static final int NUM_SETS = 5;
|
||||
private static final int[] lengths = { 10, 100, 1000, 10000, 1000000 };
|
||||
|
@ -27,7 +27,8 @@
|
||||
* @summary TreeMap.containsValue throws NullPointerExc for empty TreeMap
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class ContainsValue {
|
||||
public static void main(String[] args) {
|
||||
|
@ -28,7 +28,10 @@
|
||||
* valid range in the backing array
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.SortedMap;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class HeadTailTypeError {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -28,8 +28,9 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.Comparator;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class NullAtEnd {
|
||||
static volatile int passed = 0, failed = 0;
|
||||
|
@ -28,10 +28,9 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class NullPermissiveComparator {
|
||||
|
@ -27,7 +27,11 @@
|
||||
* @summary The firstKey and lastKey
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.SortedMap;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class SubMap {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -29,7 +29,9 @@
|
||||
* @author Josh Bloch
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
public class SubMapClear {
|
||||
public static void main(String[] args) {
|
||||
|
@ -29,7 +29,9 @@
|
||||
* @author Konstantin Kladko
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
public class ComodifiedRemoveAllElements {
|
||||
public static void main(String[] args) {
|
||||
|
@ -28,10 +28,7 @@
|
||||
* @author Martin Buchholz
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import java.util.Vector;
|
||||
|
||||
public class CopyInto {
|
||||
private static void realMain(String[] args) throws Throwable {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user