8193300: Miscellaneous changes imported from jsr166 CVS 2018-01
Reviewed-by: martin
--- a/src/java.base/share/classes/java/util/ArrayList.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/ArrayList.java Tue Jan 16 18:28:39 2018 -0800
@@ -1550,7 +1550,6 @@
setBit(deathRow, i - beg);
if (modCount != expectedModCount)
throw new ConcurrentModificationException();
- expectedModCount++;
modCount++;
int w = beg;
for (i = beg; i < end; i++)
--- a/src/java.base/share/classes/java/util/Vector.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/Vector.java Tue Jan 16 18:28:39 2018 -0800
@@ -1023,7 +1023,6 @@
setBit(deathRow, i - beg);
if (modCount != expectedModCount)
throw new ConcurrentModificationException();
- expectedModCount++;
modCount++;
int w = beg;
for (i = beg; i < end; i++)
--- a/src/java.base/share/classes/java/util/concurrent/AbstractExecutorService.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/AbstractExecutorService.java Tue Jan 16 18:28:39 2018 -0800
@@ -245,8 +245,7 @@
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 @@
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;
}
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java Tue Jan 16 18:28:39 2018 -0800
@@ -717,12 +717,12 @@
*/
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 @@
* @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 @@
}
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 @@
}
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 @@
}
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 @@
}
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;
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java Tue Jan 16 18:28:39 2018 -0800
@@ -2204,9 +2204,7 @@
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 @@
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 @@
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);
}
/**
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java Tue Jan 16 18:28:39 2018 -0800
@@ -309,9 +309,7 @@
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;
}
}
--- a/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java Tue Jan 16 18:28:39 2018 -0800
@@ -508,7 +508,7 @@
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 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 @@
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();
}
/**
--- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java Tue Jan 16 18:28:39 2018 -0800
@@ -1353,17 +1353,16 @@
@SuppressWarnings("unchecked")
private boolean bulkRemove(Predicate<? super E> filter) {
boolean removed = false;
+ final ReentrantLock lock = this.lock;
Node<E> p = null;
- final ReentrantLock lock = this.lock;
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 @@
}
// 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 @@
unlink(q);
removed = true;
}
+ nodes[i] = null; // help GC
}
} finally {
lock.unlock();
--- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java Tue Jan 16 18:28:39 2018 -0800
@@ -1060,11 +1060,10 @@
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 @@
}
// 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 @@
unlink(q, ancestor);
removed = true;
}
+ nodes[i] = null; // help GC
}
} finally {
fullyUnlock();
--- a/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java Tue Jan 16 18:28:39 2018 -0800
@@ -772,9 +772,8 @@
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 @@
// 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
--- a/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java Tue Jan 16 18:28:39 2018 -0800
@@ -269,8 +269,8 @@
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;
--- a/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java Tue Jan 16 18:28:39 2018 -0800
@@ -753,8 +753,10 @@
else
pred.next = next;
}
- else
+ else {
subs.add(b.subscriber);
+ pred = b;
+ }
}
}
return subs;
--- a/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java Tue Jan 16 18:28:39 2018 -0800
@@ -67,7 +67,7 @@
* {@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.
--- a/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java Tue Jan 16 18:24:32 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java Tue Jan 16 18:28:39 2018 -0800
@@ -264,13 +264,12 @@
* 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 @@
* 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 @@
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 @@
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;
@@ -1470,33 +1463,6 @@
}
/**
- * 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.
*
* @param threadFactory the new thread factory
--- a/test/jdk/java/util/AbstractCollection/ToString.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/AbstractCollection/ToString.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/AbstractList/CheckForComodification.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/AbstractList/CheckForComodification.java Tue Jan 16 18:28:39 2018 -0800
@@ -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;
--- a/test/jdk/java/util/AbstractList/FailFastIterator.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/AbstractList/FailFastIterator.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/AbstractList/HasNextAfterException.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/AbstractList/HasNextAfterException.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/AbstractMap/AbstractMapClone.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/AbstractMap/AbstractMapClone.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/AbstractMap/Equals.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/AbstractMap/Equals.java Tue Jan 16 18:28:39 2018 -0800
@@ -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
--- a/test/jdk/java/util/AbstractMap/SimpleEntries.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/AbstractMap/SimpleEntries.java Tue Jan 16 18:28:39 2018 -0800
@@ -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";
--- a/test/jdk/java/util/AbstractMap/ToString.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/AbstractMap/ToString.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/AbstractSequentialList/AddAll.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/AbstractSequentialList/AddAll.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/ArrayList/AddAll.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/ArrayList/AddAll.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/ArrayList/Bug6533203.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/ArrayList/Bug6533203.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/ArrayList/IteratorMicroBenchmark.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/ArrayList/IteratorMicroBenchmark.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 @@
}
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) {
--- a/test/jdk/java/util/ArrayList/RangeCheckMicroBenchmark.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/ArrayList/RangeCheckMicroBenchmark.java Tue Jan 16 18:28:39 2018 -0800
@@ -32,9 +32,14 @@
* @author Martin Buchholz
*/
-import java.util.*;
+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 java.util.concurrent.CountDownLatch;
+
+import static java.util.stream.Collectors.toList;
public class RangeCheckMicroBenchmark {
abstract static class Job {
@@ -133,16 +138,11 @@
}
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) {
--- a/test/jdk/java/util/Collection/BiggernYours.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collection/BiggernYours.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 @@
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 @@
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");}
--- a/test/jdk/java/util/Collection/HotPotatoes.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collection/HotPotatoes.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Collection/IteratorAtEnd.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collection/IteratorAtEnd.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Collection/IteratorMicroBenchmark.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collection/IteratorMicroBenchmark.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 @@
}
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 @@
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);
--- a/test/jdk/java/util/Collection/RemoveMicroBenchmark.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collection/RemoveMicroBenchmark.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 @@
}
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 @@
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));
--- a/test/jdk/java/util/Collections/AddAll.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/AddAll.java Tue Jan 16 18:28:39 2018 -0800
@@ -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;
--- a/test/jdk/java/util/Collections/BigBinarySearch.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/BigBinarySearch.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Collections/BinarySearchNullComparator.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/BinarySearchNullComparator.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Collections/CheckedIdentityMap.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/CheckedIdentityMap.java Tue Jan 16 18:28:39 2018 -0800
@@ -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
--- a/test/jdk/java/util/Collections/CheckedListBash.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/CheckedListBash.java Tue Jan 16 18:28:39 2018 -0800
@@ -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();
--- a/test/jdk/java/util/Collections/CheckedMapBash.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/CheckedMapBash.java Tue Jan 16 18:28:39 2018 -0800
@@ -30,10 +30,20 @@
* @key randomness
*/
-import java.util.*;
+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 org.testng.annotations.Test;
-import org.testng.annotations.DataProvider;
import static org.testng.Assert.fail;
--- a/test/jdk/java/util/Collections/CheckedNull.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/CheckedNull.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Collections/CheckedSetBash.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/CheckedSetBash.java Tue Jan 16 18:28:39 2018 -0800
@@ -30,13 +30,23 @@
* @key randomness
*/
-import java.util.*;
-import java.util.function.Supplier;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import org.testng.annotations.DataProvider;
+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.assertTrue;
import static org.testng.Assert.fail;
-import static org.testng.Assert.assertTrue;
public class CheckedSetBash {
static final int numItr = 100;
--- a/test/jdk/java/util/Collections/Disjoint.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/Disjoint.java Tue Jan 16 18:28:39 2018 -0800
@@ -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;
--- a/test/jdk/java/util/Collections/EmptyCollectionSerialization.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/EmptyCollectionSerialization.java Tue Jan 16 18:28:39 2018 -0800
@@ -29,14 +29,22 @@
* @run testng EmptyCollectionSerialization
*/
-import java.util.*;
-import java.util.function.Supplier;
-import java.io.*;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import org.testng.annotations.DataProvider;
+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.assertSame;
import static org.testng.Assert.fail;
-import static org.testng.Assert.assertSame;
public class EmptyCollectionSerialization {
private static Object patheticDeepCopy(Object o) throws Exception {
--- a/test/jdk/java/util/Collections/EmptyIterator.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/EmptyIterator.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Collections/EmptyNavigableMap.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/EmptyNavigableMap.java Tue Jan 16 18:28:39 2018 -0800
@@ -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.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.assertFalse;
import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.assertFalse;
public class EmptyNavigableMap {
@@ -124,10 +125,9 @@
*/
@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 @@
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 @@
// 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 @@
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 @@
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 @@
*/
@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);
--- a/test/jdk/java/util/Collections/EmptyNavigableSet.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/EmptyNavigableSet.java Tue Jan 16 18:28:39 2018 -0800
@@ -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.NavigableSet;
import java.util.NoSuchElementException;
-import java.util.NavigableSet;
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 @@
*/
@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 @@
*/
@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 @@
*/
@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 @@
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 @@
// 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 @@
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 @@
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 @@
*/
@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);
--- a/test/jdk/java/util/Collections/Enum.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/Enum.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Collections/FindSubList.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/FindSubList.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Collections/Frequency.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/Frequency.java Tue Jan 16 18:28:39 2018 -0800
@@ -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;
--- a/test/jdk/java/util/Collections/MinMax.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/MinMax.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/Collections/NCopies.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/NCopies.java Tue Jan 16 18:28:39 2018 -0800
@@ -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;
--- a/test/jdk/java/util/Collections/NullComparator.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/NullComparator.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Collections/RacingCollections.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/RacingCollections.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
/**
--- a/test/jdk/java/util/Collections/ReplaceAll.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/ReplaceAll.java Tue Jan 16 18:28:39 2018 -0800
@@ -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;
--- a/test/jdk/java/util/Collections/ReverseOrder.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/ReverseOrder.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/Collections/ReverseOrder2.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/ReverseOrder2.java Tue Jan 16 18:28:39 2018 -0800
@@ -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;
--- a/test/jdk/java/util/Collections/Rotate.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/Rotate.java Tue Jan 16 18:28:39 2018 -0800
@@ -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
--- a/test/jdk/java/util/Collections/RotateEmpty.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/RotateEmpty.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Collections/Ser.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/Ser.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Collections/SetFromMap.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/SetFromMap.java Tue Jan 16 18:28:39 2018 -0800
@@ -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;
--- a/test/jdk/java/util/Collections/Swap.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/Swap.java Tue Jan 16 18:28:39 2018 -0800
@@ -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;
--- a/test/jdk/java/util/Collections/T5078378.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/T5078378.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/Collections/T6433170.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/T6433170.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Collections/ViewSynch.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/ViewSynch.java Tue Jan 16 18:28:39 2018 -0800
@@ -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);
--- a/test/jdk/java/util/Collections/WrappedNull.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Collections/WrappedNull.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/HashMap/KeySetRemove.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/HashMap/KeySetRemove.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/HashMap/SetValue.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/HashMap/SetValue.java Tue Jan 16 18:28:39 2018 -0800
@@ -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";
--- a/test/jdk/java/util/HashMap/ToString.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/HashMap/ToString.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Hashtable/EqualsCast.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Hashtable/EqualsCast.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Hashtable/HashCode.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Hashtable/HashCode.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Hashtable/IllegalLoadFactor.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Hashtable/IllegalLoadFactor.java Tue Jan 16 18:28:39 2018 -0800
@@ -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
--- a/test/jdk/java/util/Hashtable/ReadObject.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Hashtable/ReadObject.java Tue Jan 16 18:28:39 2018 -0800
@@ -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.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInputStream;
import java.io.Serializable;
+import java.util.Hashtable;
/**
* Class that extends Hashtable to demonstrate bug when
@@ -52,7 +52,7 @@
Object getValue() {
return mValue;
}
- };
+ }
public Object get(Object key) {
ValueWrapper valueWrapper = (ValueWrapper)super.get(key);
--- a/test/jdk/java/util/Hashtable/SelfRef.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Hashtable/SelfRef.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/IdentityHashMap/ToArray.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/IdentityHashMap/ToArray.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/IdentityHashMap/ToString.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/IdentityHashMap/ToString.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/LinkedHashMap/Basic.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/LinkedHashMap/Basic.java Tue Jan 16 18:28:39 2018 -0800
@@ -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);
--- a/test/jdk/java/util/LinkedHashMap/Cache.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/LinkedHashMap/Cache.java Tue Jan 16 18:28:39 2018 -0800
@@ -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;
--- a/test/jdk/java/util/LinkedHashMap/EmptyMapIterator.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/LinkedHashMap/EmptyMapIterator.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/LinkedHashSet/Basic.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/LinkedHashSet/Basic.java Tue Jan 16 18:28:39 2018 -0800
@@ -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);
--- a/test/jdk/java/util/LinkedList/AddAll.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/LinkedList/AddAll.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/LinkedList/Clone.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/LinkedList/Clone.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/LinkedList/ComodifiedRemove.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/LinkedList/ComodifiedRemove.java Tue Jan 16 18:28:39 2018 -0800
@@ -29,9 +29,10 @@
* @author Konstantin Kladko
*/
-import java.util.*;
+import java.util.ConcurrentModificationException;
+import java.util.LinkedList;
+import java.util.List;
import java.util.ListIterator;
-import java.util.ConcurrentModificationException;
public class ComodifiedRemove {
public static
--- a/test/jdk/java/util/List/LockStep.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/List/LockStep.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Map/Defaults.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Map/Defaults.java Tue Jan 16 18:28:39 2018 -0800
@@ -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.Collections;
import java.util.EnumMap;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
-import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Set;
import java.util.TreeMap;
-import java.util.Set;
import java.util.WeakHashMap;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentHashMap;
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 @@
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.
--- a/test/jdk/java/util/Map/Get.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Map/Get.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Map/LockStep.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Map/LockStep.java Tue Jan 16 18:28:39 2018 -0800
@@ -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
--- a/test/jdk/java/util/NavigableMap/LockStep.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/NavigableMap/LockStep.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/PriorityQueue/AddNonComparable.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/PriorityQueue/AddNonComparable.java Tue Jan 16 18:28:39 2018 -0800
@@ -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.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 {
--- a/test/jdk/java/util/PriorityQueue/NoNulls.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/PriorityQueue/NoNulls.java Tue Jan 16 18:28:39 2018 -0800
@@ -38,8 +38,8 @@
*/
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Comparator;
-import java.util.Collection;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.TreeSet;
--- a/test/jdk/java/util/PriorityQueue/PriorityQueueSort.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/PriorityQueue/PriorityQueueSort.java Tue Jan 16 18:28:39 2018 -0800
@@ -42,18 +42,14 @@
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
+import java.util.PriorityQueue;
import java.util.Queue;
-import java.util.PriorityQueue;
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());
}
}
--- a/test/jdk/java/util/PriorityQueue/RemoveContains.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/PriorityQueue/RemoveContains.java Tue Jan 16 18:28:39 2018 -0800
@@ -37,8 +37,8 @@
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.PriorityBlockingQueue;
-import java.util.concurrent.LinkedTransferQueue;
public class RemoveContains {
static volatile int passed = 0, failed = 0;
--- a/test/jdk/java/util/Random/NextBytes.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Random/NextBytes.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/TimSort/SortPerf.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/TimSort/SortPerf.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 };
--- a/test/jdk/java/util/TreeMap/ContainsValue.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/TreeMap/ContainsValue.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/TreeMap/HeadTailTypeError.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/TreeMap/HeadTailTypeError.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/TreeMap/NullAtEnd.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/TreeMap/NullAtEnd.java Tue Jan 16 18:28:39 2018 -0800
@@ -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;
--- a/test/jdk/java/util/TreeMap/NullPermissiveComparator.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/TreeMap/NullPermissiveComparator.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/TreeMap/SubMap.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/TreeMap/SubMap.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/TreeMap/SubMapClear.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/TreeMap/SubMapClear.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/Vector/ComodifiedRemoveAllElements.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Vector/ComodifiedRemoveAllElements.java Tue Jan 16 18:28:39 2018 -0800
@@ -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) {
--- a/test/jdk/java/util/Vector/CopyInto.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Vector/CopyInto.java Tue Jan 16 18:28:39 2018 -0800
@@ -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 {
--- a/test/jdk/java/util/Vector/IllegalConstructorArgs.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Vector/IllegalConstructorArgs.java Tue Jan 16 18:28:39 2018 -0800
@@ -27,7 +27,7 @@
* @summary Test for illegal argument exception
*/
-import java.util.*;
+import java.util.Vector;
/**
* This is a simple test class created to check for
--- a/test/jdk/java/util/Vector/LastIndexOf.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Vector/LastIndexOf.java Tue Jan 16 18:28:39 2018 -0800
@@ -28,7 +28,7 @@
* valid range in the backing array
*/
-import java.util.*;
+import java.util.Vector;
public class LastIndexOf {
public static void main(String[] args) throws Exception {
--- a/test/jdk/java/util/Vector/SyncLastIndexOf.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/Vector/SyncLastIndexOf.java Tue Jan 16 18:28:39 2018 -0800
@@ -27,7 +27,8 @@
* @summary Vector's lastIndexOf(Object) was lacking synchronization
* @author Konstantin Kladko
*/
-import java.util.*;
+
+import java.util.Vector;
public class SyncLastIndexOf {
--- a/test/jdk/java/util/WeakHashMap/GCDuringIteration.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/WeakHashMap/GCDuringIteration.java Tue Jan 16 18:28:39 2018 -0800
@@ -32,7 +32,7 @@
* @key randomness
*/
-import static java.util.concurrent.TimeUnit.SECONDS;
+import jdk.test.lib.RandomFactory;
import java.lang.ref.WeakReference;
import java.util.Arrays;
@@ -43,7 +43,8 @@
import java.util.WeakHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.function.BooleanSupplier;
-import jdk.test.lib.RandomFactory;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
public class GCDuringIteration {
--- a/test/jdk/java/util/WeakHashMap/Iteration.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/WeakHashMap/Iteration.java Tue Jan 16 18:28:39 2018 -0800
@@ -28,7 +28,9 @@
* @author Josh Bloch
*/
-import java.util.*;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.WeakHashMap;
public class Iteration {
public static void main(String[] args) {
--- a/test/jdk/java/util/WeakHashMap/ZeroInitCap.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/WeakHashMap/ZeroInitCap.java Tue Jan 16 18:28:39 2018 -0800
@@ -21,7 +21,8 @@
* questions.
*/
-import java.util.*;
+import java.util.Map;
+import java.util.WeakHashMap;
/*
* @test
--- a/test/jdk/java/util/concurrent/ArrayBlockingQueue/WhiteBox.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/ArrayBlockingQueue/WhiteBox.java Tue Jan 16 18:28:39 2018 -0800
@@ -39,7 +39,7 @@
*/
import static org.testng.Assert.*;
-import org.testng.annotations.DataProvider;
+
import org.testng.annotations.Test;
import java.lang.ref.WeakReference;
--- a/test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java Tue Jan 16 18:28:39 2018 -0800
@@ -78,9 +78,7 @@
pseudodelay = i;
}
public int compareTo(PDelay other) {
- int a = this.pseudodelay;
- int b = other.pseudodelay;
- return (a < b) ? -1 : (a > b) ? 1 : 0;
+ return Integer.compare(this.pseudodelay, other.pseudodelay);
}
public int compareTo(Delayed y) {
return compareTo((PDelay)y);
--- a/test/jdk/java/util/concurrent/BlockingQueue/LoopHelpers.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/BlockingQueue/LoopHelpers.java Tue Jan 16 18:28:39 2018 -0800
@@ -95,7 +95,7 @@
String num = Long.toString(n);
if (num.length() >= field.length())
return num;
- StringBuffer b = new StringBuffer(field);
+ StringBuilder b = new StringBuilder(field);
b.replace(b.length()-num.length(), b.length(), num);
return b.toString();
}
--- a/test/jdk/java/util/concurrent/BlockingQueue/OfferDrainToLoops.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/BlockingQueue/OfferDrainToLoops.java Tue Jan 16 18:28:39 2018 -0800
@@ -79,7 +79,7 @@
final long timeoutMillis = 10L * 1000L;
final SplittableRandom rnd = new SplittableRandom();
- /** Poor man's bounded buffer. */
+ // Poor man's bounded buffer.
final AtomicLong approximateCount = new AtomicLong(0L);
abstract class CheckedThread extends Thread {
--- a/test/jdk/java/util/concurrent/CompletableFuture/Basic.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/CompletableFuture/Basic.java Tue Jan 16 18:28:39 2018 -0800
@@ -151,11 +151,11 @@
// runAsync tests
//----------------------------------------------------------------
try {
- CompletableFuture<Void> cf = runAsync(() -> { });
+ CompletableFuture<Void> cf = runAsync(() -> {});
checkCompletedNormally(cf, cf.join());
- cf = runAsync(() -> { }, commonPool());
+ cf = runAsync(() -> {}, commonPool());
checkCompletedNormally(cf, cf.join());
- cf = runAsync(() -> { }, executor);
+ cf = runAsync(() -> {}, executor);
checkCompletedNormally(cf, cf.join());
cf = runAsync(() -> { throw new RuntimeException(); });
checkCompletedExceptionally(cf);
@@ -200,32 +200,32 @@
try {
CompletableFuture<Integer> cf2;
CompletableFuture<String> cf1 = supplyAsync(() -> "a test string");
- cf2 = cf1.thenApply((x) -> { if (x.equals("a test string")) return 1; else return 0; });
+ cf2 = cf1.thenApply(x -> x.equals("a test string") ? 1 : 0);
checkCompletedNormally(cf1, "a test string");
checkCompletedNormally(cf2, 1);
cf1 = supplyAsync(() -> "a test string");
- cf2 = cf1.thenApplyAsync((x) -> { if (x.equals("a test string")) return 1; else return 0; });
+ cf2 = cf1.thenApplyAsync(x -> x.equals("a test string") ? 1 : 0);
checkCompletedNormally(cf1, "a test string");
checkCompletedNormally(cf2, 1);
cf1 = supplyAsync(() -> "a test string");
- cf2 = cf1.thenApplyAsync((x) -> { if (x.equals("a test string")) return 1; else return 0; }, executor);
+ cf2 = cf1.thenApplyAsync(x -> x.equals("a test string") ? 1 : 0, executor);
checkCompletedNormally(cf1, "a test string");
checkCompletedNormally(cf2, 1);
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
- cf2 = cf1.thenApply((x) -> { return 0; } );
+ cf2 = cf1.thenApply(x -> 0);
checkCompletedExceptionally(cf1);
checkCompletedExceptionally(cf2);
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
- cf2 = cf1.thenApplyAsync((x) -> { return 0; } );
+ cf2 = cf1.thenApplyAsync(x -> 0);
checkCompletedExceptionally(cf1);
checkCompletedExceptionally(cf2);
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
- cf2 = cf1.thenApplyAsync((x) -> { return 0; }, executor);
+ cf2 = cf1.thenApplyAsync(x -> 0, executor);
checkCompletedExceptionally(cf1);
checkCompletedExceptionally(cf2);
} catch (Throwable t) { unexpected(t); }
@@ -237,40 +237,40 @@
CompletableFuture<Void> cf2;
int before = atomicInt.get();
CompletableFuture<String> cf1 = supplyAsync(() -> "a test string");
- cf2 = cf1.thenAccept((x) -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); });
+ cf2 = cf1.thenAccept(x -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); });
checkCompletedNormally(cf1, "a test string");
checkCompletedNormally(cf2, null);
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
cf1 = supplyAsync(() -> "a test string");
- cf2 = cf1.thenAcceptAsync((x) -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); });
+ cf2 = cf1.thenAcceptAsync(x -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); });
checkCompletedNormally(cf1, "a test string");
checkCompletedNormally(cf2, null);
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
cf1 = supplyAsync(() -> "a test string");
- cf2 = cf1.thenAcceptAsync((x) -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); }, executor);
+ cf2 = cf1.thenAcceptAsync(x -> { if (x.equals("a test string")) { atomicInt.incrementAndGet(); return; } throw new RuntimeException(); }, executor);
checkCompletedNormally(cf1, "a test string");
checkCompletedNormally(cf2, null);
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
- cf2 = cf1.thenAccept((x) -> { atomicInt.incrementAndGet(); } );
+ cf2 = cf1.thenAccept(x -> atomicInt.incrementAndGet());
checkCompletedExceptionally(cf1);
checkCompletedExceptionally(cf2);
check(atomicInt.get() == before);
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
- cf2 = cf1.thenAcceptAsync((x) -> { atomicInt.incrementAndGet(); } );
+ cf2 = cf1.thenAcceptAsync(x -> atomicInt.incrementAndGet());
checkCompletedExceptionally(cf1);
checkCompletedExceptionally(cf2);
check(atomicInt.get() == before);
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
- cf2 = cf1.thenAcceptAsync((x) -> { atomicInt.incrementAndGet(); }, executor );
+ cf2 = cf1.thenAcceptAsync(x -> atomicInt.incrementAndGet(), executor );
checkCompletedExceptionally(cf1);
checkCompletedExceptionally(cf2);
check(atomicInt.get() == before);
@@ -283,40 +283,40 @@
CompletableFuture<Void> cf2;
int before = atomicInt.get();
CompletableFuture<String> cf1 = supplyAsync(() -> "a test string");
- cf2 = cf1.thenRun(() -> { atomicInt.incrementAndGet(); });
+ cf2 = cf1.thenRun(() -> atomicInt.incrementAndGet());
checkCompletedNormally(cf1, "a test string");
checkCompletedNormally(cf2, null);
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
cf1 = supplyAsync(() -> "a test string");
- cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); });
+ cf2 = cf1.thenRunAsync(() -> atomicInt.incrementAndGet());
checkCompletedNormally(cf1, "a test string");
checkCompletedNormally(cf2, null);
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
cf1 = supplyAsync(() -> "a test string");
- cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); }, executor);
+ cf2 = cf1.thenRunAsync(() -> atomicInt.incrementAndGet(), executor);
checkCompletedNormally(cf1, "a test string");
checkCompletedNormally(cf2, null);
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
- cf2 = cf1.thenRun(() -> { atomicInt.incrementAndGet(); });
+ cf2 = cf1.thenRun(() -> atomicInt.incrementAndGet());
checkCompletedExceptionally(cf1);
checkCompletedExceptionally(cf2);
check(atomicInt.get() == before);
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
- cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); });
+ cf2 = cf1.thenRunAsync(() -> atomicInt.incrementAndGet());
checkCompletedExceptionally(cf1);
checkCompletedExceptionally(cf2);
check(atomicInt.get() == before);
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
- cf2 = cf1.thenRunAsync(() -> { atomicInt.incrementAndGet(); }, executor);
+ cf2 = cf1.thenRunAsync(() -> atomicInt.incrementAndGet(), executor);
checkCompletedExceptionally(cf1);
checkCompletedExceptionally(cf2);
check(atomicInt.get() == before);
@@ -329,42 +329,42 @@
CompletableFuture<Integer> cf3;
CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
CompletableFuture<Integer> cf2 = supplyAsync(() -> 1);
- cf3 = cf1.thenCombine(cf2, (x, y) -> { return x + y; });
+ cf3 = cf1.thenCombine(cf2, (x, y) -> x + y);
checkCompletedNormally(cf1, 1);
checkCompletedNormally(cf2, 1);
checkCompletedNormally(cf3, 2);
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> 1);
- cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return x + y; });
+ cf3 = cf1.thenCombineAsync(cf2, (x, y) -> x + y);
checkCompletedNormally(cf1, 1);
checkCompletedNormally(cf2, 1);
checkCompletedNormally(cf3, 2);
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> 1);
- cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return x + y; }, executor);
+ cf3 = cf1.thenCombineAsync(cf2, (x, y) -> x + y, executor);
checkCompletedNormally(cf1, 1);
checkCompletedNormally(cf2, 1);
checkCompletedNormally(cf3, 2);
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
cf2 = supplyAsync(() -> 1);
- cf3 = cf1.thenCombine(cf2, (x, y) -> { return 0; });
+ cf3 = cf1.thenCombine(cf2, (x, y) -> 0);
checkCompletedExceptionally(cf1);
checkCompletedNormally(cf2, 1);
checkCompletedExceptionally(cf3);
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> { throw new RuntimeException(); });
- cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return 0; });
+ cf3 = cf1.thenCombineAsync(cf2, (x, y) -> 0);
checkCompletedNormally(cf1, 1);
checkCompletedExceptionally(cf2);
checkCompletedExceptionally(cf3);
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
cf2 = supplyAsync(() -> { throw new RuntimeException(); });
- cf3 = cf1.thenCombineAsync(cf2, (x, y) -> { return 0; }, executor);
+ cf3 = cf1.thenCombineAsync(cf2, (x, y) -> 0, executor);
checkCompletedExceptionally(cf1);
checkCompletedExceptionally(cf2);
checkCompletedExceptionally(cf3);
@@ -405,7 +405,7 @@
before = atomicInt.get();
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
cf2 = supplyAsync(() -> 1);
- cf3 = cf1.thenAcceptBoth(cf2, (x, y) -> { atomicInt.incrementAndGet(); });
+ cf3 = cf1.thenAcceptBoth(cf2, (x, y) -> atomicInt.incrementAndGet());
checkCompletedExceptionally(cf1);
checkCompletedNormally(cf2, 1);
checkCompletedExceptionally(cf3);
@@ -413,7 +413,7 @@
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> { throw new RuntimeException(); });
- cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { atomicInt.incrementAndGet(); });
+ cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> atomicInt.incrementAndGet());
checkCompletedNormally(cf1, 1);
checkCompletedExceptionally(cf2);
checkCompletedExceptionally(cf3);
@@ -421,7 +421,7 @@
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
cf2 = supplyAsync(() -> { throw new RuntimeException(); });
- cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> { atomicInt.incrementAndGet(); }, executor);
+ cf3 = cf1.thenAcceptBothAsync(cf2, (x, y) -> atomicInt.incrementAndGet(), executor);
checkCompletedExceptionally(cf1);
checkCompletedExceptionally(cf2);
checkCompletedExceptionally(cf3);
@@ -463,7 +463,7 @@
before = atomicInt.get();
CompletableFuture<Integer> cf4 = supplyAsync(() -> { throw new RuntimeException(); });
CompletableFuture<Integer> cf5 = supplyAsync(() -> 1);
- cf3 = cf5.runAfterBothAsync(cf4, () -> { atomicInt.incrementAndGet(); }, executor);
+ cf3 = cf5.runAfterBothAsync(cf4, () -> atomicInt.incrementAndGet(), executor);
checkCompletedExceptionally(cf4);
checkCompletedNormally(cf5, 1);
checkCompletedExceptionally(cf3);
@@ -472,7 +472,7 @@
before = atomicInt.get();
cf4 = supplyAsync(() -> 1);
cf5 = supplyAsync(() -> { throw new RuntimeException(); });
- cf3 = cf5.runAfterBothAsync(cf4, () -> { atomicInt.incrementAndGet(); });
+ cf3 = cf5.runAfterBothAsync(cf4, () -> atomicInt.incrementAndGet());
checkCompletedNormally(cf4, 1);
checkCompletedExceptionally(cf5);
checkCompletedExceptionally(cf3);
@@ -481,7 +481,7 @@
before = atomicInt.get();
cf4 = supplyAsync(() -> { throw new RuntimeException(); });
cf5 = supplyAsync(() -> { throw new RuntimeException(); });
- cf3 = cf5.runAfterBoth(cf4, () -> { atomicInt.incrementAndGet(); });
+ cf3 = cf5.runAfterBoth(cf4, () -> atomicInt.incrementAndGet());
checkCompletedExceptionally(cf4);
checkCompletedExceptionally(cf5);
checkCompletedExceptionally(cf3);
@@ -495,46 +495,46 @@
CompletableFuture<Integer> cf3;
CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
- cf3 = cf1.applyToEither(cf2, (x) -> { check(x == 1 || x == 2); return x; });
+ cf3 = cf1.applyToEither(cf2, x -> { check(x == 1 || x == 2); return x; });
checkCompletedNormally(cf3, new Object[] {1, 2});
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> 2);
- cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); return x; });
+ cf3 = cf1.applyToEitherAsync(cf2, x -> { check(x == 1 || x == 2); return x; });
checkCompletedNormally(cf3, new Object[] {1, 2});
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> 2);
- cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); return x; }, executor);
+ cf3 = cf1.applyToEitherAsync(cf2, x -> { check(x == 1 || x == 2); return x; }, executor);
checkCompletedNormally(cf3, new Object[] {1, 2});
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
cf2 = supplyAsync(() -> 2);
- cf3 = cf1.applyToEither(cf2, (x) -> { check(x == 2); return x; });
+ cf3 = cf1.applyToEither(cf2, x -> { check(x == 2); return x; });
try { check(cf3.join() == 2); } catch (CompletionException x) { pass(); }
check(cf3.isDone());
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> { throw new RuntimeException(); });
- cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1); return x; });
+ cf3 = cf1.applyToEitherAsync(cf2, x -> { check(x == 1); return x; });
try { check(cf3.join() == 1); } catch (CompletionException x) { pass(); }
check(cf3.isDone());
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
cf2 = supplyAsync(() -> { throw new RuntimeException(); });
- cf3 = cf1.applyToEitherAsync(cf2, (x) -> { fail(); return x; });
+ cf3 = cf1.applyToEitherAsync(cf2, x -> { fail(); return x; });
checkCompletedExceptionally(cf3);
check(cf1.isDone() || cf2.isDone());
final Phaser cf3Done = new Phaser(2);
cf1 = supplyAsync(() -> { cf3Done.arriveAndAwaitAdvance(); return 1; });
cf2 = supplyAsync(() -> 2);
- cf3 = cf1.applyToEither(cf2, (x) -> { check(x == 2); return x; });
+ cf3 = cf1.applyToEither(cf2, x -> { check(x == 2); return x; });
checkCompletedNormally(cf3, 2);
checkCompletedNormally(cf2, 2);
check(!cf1.isDone());
@@ -544,7 +544,7 @@
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> { cf3Done.arriveAndAwaitAdvance(); return 2; });
- cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1); return x; });
+ cf3 = cf1.applyToEitherAsync(cf2, x -> { check(x == 1); return x; });
checkCompletedNormally(cf3, 1);
checkCompletedNormally(cf1, 1);
check(!cf2.isDone());
@@ -561,7 +561,7 @@
int before = atomicInt.get();
CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
- cf3 = cf1.acceptEither(cf2, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); });
+ cf3 = cf1.acceptEither(cf2, x -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); });
checkCompletedNormally(cf3, null);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1));
@@ -569,7 +569,7 @@
before = atomicInt.get();
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> 2);
- cf3 = cf1.acceptEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); });
+ cf3 = cf1.acceptEitherAsync(cf2, x -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); });
checkCompletedNormally(cf3, null);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1));
@@ -577,35 +577,35 @@
before = atomicInt.get();
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> 2);
- cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); }, executor);
+ cf3 = cf2.acceptEitherAsync(cf1, x -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); }, executor);
checkCompletedNormally(cf3, null);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1));
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
cf2 = supplyAsync(() -> 2);
- cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 2); }, executor);
+ cf3 = cf2.acceptEitherAsync(cf1, x -> { check(x == 2); }, executor);
try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
check(cf3.isDone());
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> { throw new RuntimeException(); });
- cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 1); });
+ cf3 = cf2.acceptEitherAsync(cf1, x -> { check(x == 1); });
try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
check(cf3.isDone());
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
cf2 = supplyAsync(() -> { throw new RuntimeException(); });
- cf3 = cf2.acceptEitherAsync(cf1, (x) -> { fail(); });
+ cf3 = cf2.acceptEitherAsync(cf1, x -> { fail(); });
checkCompletedExceptionally(cf3);
check(cf1.isDone() || cf2.isDone());
final Phaser cf3Done = new Phaser(2);
cf1 = supplyAsync(() -> { cf3Done.arriveAndAwaitAdvance(); return 1; });
cf2 = supplyAsync(() -> 2);
- cf3 = cf1.acceptEither(cf2, (x) -> { check(x == 2); });
+ cf3 = cf1.acceptEither(cf2, x -> { check(x == 2); });
checkCompletedNormally(cf3, null);
checkCompletedNormally(cf2, 2);
check(!cf1.isDone());
@@ -615,7 +615,7 @@
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> { cf3Done.arriveAndAwaitAdvance(); return 2; });
- cf3 = cf1.acceptEitherAsync(cf2, (x) -> { check(x == 1); });
+ cf3 = cf1.acceptEitherAsync(cf2, x -> { check(x == 1); });
checkCompletedNormally(cf3, null);
checkCompletedNormally(cf1, 1);
check(!cf2.isDone());
@@ -630,33 +630,33 @@
try {
CompletableFuture<Void> cf3;
int before = atomicInt.get();
- CompletableFuture<Void> cf1 = runAsync(() -> { });
- CompletableFuture<Void> cf2 = runAsync(() -> { });
- cf3 = cf1.runAfterEither(cf2, () -> { atomicInt.incrementAndGet(); });
+ CompletableFuture<Void> cf1 = runAsync(() -> {});
+ CompletableFuture<Void> cf2 = runAsync(() -> {});
+ cf3 = cf1.runAfterEither(cf2, () -> atomicInt.incrementAndGet());
checkCompletedNormally(cf3, null);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
- cf1 = runAsync(() -> { });
- cf2 = runAsync(() -> { });
- cf3 = cf1.runAfterEitherAsync(cf2, () -> { atomicInt.incrementAndGet(); });
+ cf1 = runAsync(() -> {});
+ cf2 = runAsync(() -> {});
+ cf3 = cf1.runAfterEitherAsync(cf2, () -> atomicInt.incrementAndGet());
checkCompletedNormally(cf3, null);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
- cf1 = runAsync(() -> { });
- cf2 = runAsync(() -> { });
- cf3 = cf2.runAfterEitherAsync(cf1, () -> { atomicInt.incrementAndGet(); }, executor);
+ cf1 = runAsync(() -> {});
+ cf2 = runAsync(() -> {});
+ cf3 = cf2.runAfterEitherAsync(cf1, () -> atomicInt.incrementAndGet(), executor);
checkCompletedNormally(cf3, null);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
cf1 = runAsync(() -> { throw new RuntimeException(); });
- cf2 = runAsync(() -> { });
- cf3 = cf2.runAfterEither(cf1, () -> { atomicInt.incrementAndGet(); });
+ cf2 = runAsync(() -> {});
+ cf3 = cf2.runAfterEither(cf1, () -> atomicInt.incrementAndGet());
try {
check(cf3.join() == null);
check(atomicInt.get() == (before + 1));
@@ -665,9 +665,9 @@
check(cf1.isDone() || cf2.isDone());
before = atomicInt.get();
- cf1 = runAsync(() -> { });
+ cf1 = runAsync(() -> {});
cf2 = runAsync(() -> { throw new RuntimeException(); });
- cf3 = cf1.runAfterEitherAsync(cf2, () -> { atomicInt.incrementAndGet(); });
+ cf3 = cf1.runAfterEitherAsync(cf2, () -> atomicInt.incrementAndGet());
try {
check(cf3.join() == null);
check(atomicInt.get() == (before + 1));
@@ -678,16 +678,16 @@
before = atomicInt.get();
cf1 = runAsync(() -> { throw new RuntimeException(); });
cf2 = runAsync(() -> { throw new RuntimeException(); });
- cf3 = cf2.runAfterEitherAsync(cf1, () -> { atomicInt.incrementAndGet(); }, executor);
+ cf3 = cf2.runAfterEitherAsync(cf1, () -> atomicInt.incrementAndGet(), executor);
checkCompletedExceptionally(cf3);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == before);
final Phaser cf3Done = new Phaser(2);
before = atomicInt.get();
- cf1 = runAsync(() -> { cf3Done.arriveAndAwaitAdvance(); });
- cf2 = runAsync(() -> { });
- cf3 = cf1.runAfterEither(cf2, () -> { atomicInt.incrementAndGet(); });
+ cf1 = runAsync(() -> cf3Done.arriveAndAwaitAdvance());
+ cf2 = runAsync(() -> {});
+ cf3 = cf1.runAfterEither(cf2, () -> atomicInt.incrementAndGet());
checkCompletedNormally(cf3, null);
checkCompletedNormally(cf2, null);
check(!cf1.isDone());
@@ -697,9 +697,9 @@
checkCompletedNormally(cf3, null);
before = atomicInt.get();
- cf1 = runAsync(() -> { });
- cf2 = runAsync(() -> { cf3Done.arriveAndAwaitAdvance(); });
- cf3 = cf1.runAfterEitherAsync(cf2, () -> { atomicInt.incrementAndGet(); });
+ cf1 = runAsync(() -> {});
+ cf2 = runAsync(() -> cf3Done.arriveAndAwaitAdvance());
+ cf3 = cf1.runAfterEitherAsync(cf2, () -> atomicInt.incrementAndGet());
checkCompletedNormally(cf3, null);
checkCompletedNormally(cf1, null);
check(!cf2.isDone());
@@ -715,35 +715,35 @@
try {
CompletableFuture<Integer> cf2;
CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
- cf2 = cf1.thenCompose((x) -> { check(x ==1); return CompletableFuture.completedFuture(2); });
+ cf2 = cf1.thenCompose(x -> { check(x == 1); return CompletableFuture.completedFuture(2); });
checkCompletedNormally(cf1, 1);
checkCompletedNormally(cf2, 2);
cf1 = supplyAsync(() -> 1);
- cf2 = cf1.thenComposeAsync((x) -> { check(x ==1); return CompletableFuture.completedFuture(2); });
+ cf2 = cf1.thenComposeAsync(x -> { check(x == 1); return CompletableFuture.completedFuture(2); });
checkCompletedNormally(cf1, 1);
checkCompletedNormally(cf2, 2);
cf1 = supplyAsync(() -> 1);
- cf2 = cf1.thenComposeAsync((x) -> { check(x ==1); return CompletableFuture.completedFuture(2); }, executor);
+ cf2 = cf1.thenComposeAsync(x -> { check(x == 1); return CompletableFuture.completedFuture(2); }, executor);
checkCompletedNormally(cf1, 1);
checkCompletedNormally(cf2, 2);
int before = atomicInt.get();
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
- cf2 = cf1.thenCompose((x) -> { atomicInt.incrementAndGet(); return CompletableFuture.completedFuture(2); });
+ cf2 = cf1.thenCompose(x -> { atomicInt.incrementAndGet(); return CompletableFuture.completedFuture(2); });
checkCompletedExceptionally(cf1);
checkCompletedExceptionally(cf2);
check(atomicInt.get() == before);
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
- cf2 = cf1.thenComposeAsync((x) -> { atomicInt.incrementAndGet(); return CompletableFuture.completedFuture(2); });
+ cf2 = cf1.thenComposeAsync(x -> { atomicInt.incrementAndGet(); return CompletableFuture.completedFuture(2); });
checkCompletedExceptionally(cf1);
checkCompletedExceptionally(cf2);
check(atomicInt.get() == before);
cf1 = supplyAsync(() -> 1);
- cf2 = cf1.thenComposeAsync((x) -> { throw new RuntimeException(); }, executor);
+ cf2 = cf1.thenComposeAsync(x -> { throw new RuntimeException(); }, executor);
checkCompletedNormally(cf1, 1);
checkCompletedExceptionally(cf2);
} catch (Throwable t) { unexpected(t); }
@@ -787,13 +787,13 @@
try {
CompletableFuture<Integer> cf2;
CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
- cf2 = cf1.exceptionally((t) -> { fail("function should never be called"); return 2;});
+ cf2 = cf1.exceptionally(t -> { fail("function should never be called"); return 2;});
checkCompletedNormally(cf1, 1);
checkCompletedNormally(cf2, 1);
final RuntimeException t = new RuntimeException();
cf1 = supplyAsync(() -> { throw t; });
- cf2 = cf1.exceptionally((x) -> { check(x.getCause() == t); return 2;});
+ cf2 = cf1.exceptionally(x -> { check(x.getCause() == t); return 2;});
checkCompletedExceptionally(cf1);
checkCompletedNormally(cf2, 2);
} catch (Throwable t) { unexpected(t); }
--- a/test/jdk/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/ConcurrentHashMap/LoopHelpers.java Tue Jan 16 18:28:39 2018 -0800
@@ -95,7 +95,7 @@
String num = Long.toString(n);
if (num.length() >= field.length())
return num;
- StringBuffer b = new StringBuffer(field);
+ StringBuilder b = new StringBuilder(field);
b.replace(b.length()-num.length(), b.length(), num);
return b.toString();
}
--- a/test/jdk/java/util/concurrent/ConcurrentHashMap/MapCheck.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/ConcurrentHashMap/MapCheck.java Tue Jan 16 18:28:39 2018 -0800
@@ -109,14 +109,12 @@
static Map newMap(Class cl) {
try {
- Map m = (Map)cl.newInstance();
- return m;
+ return (Map)cl.newInstance();
} catch (Exception e) {
throw new RuntimeException("Can't instantiate " + cl + ": " + e);
}
}
-
static void runTest(Map s, Object[] key) {
shuffle(key);
int size = key.length;
@@ -137,7 +135,6 @@
// System.gc();
}
-
static void t1(String nm, int n, Map s, Object[] key, int expect) {
int sum = 0;
int iters = 4;
--- a/test/jdk/java/util/concurrent/ConcurrentLinkedQueue/WhiteBox.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/ConcurrentLinkedQueue/WhiteBox.java Tue Jan 16 18:28:39 2018 -0800
@@ -55,7 +55,6 @@
import java.util.concurrent.ThreadLocalRandom;
import static java.util.stream.Collectors.toList;
import java.util.function.Consumer;
-import java.util.function.Function;
@Test
public class WhiteBox {
--- a/test/jdk/java/util/concurrent/ConcurrentQueues/LoopHelpers.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/ConcurrentQueues/LoopHelpers.java Tue Jan 16 18:28:39 2018 -0800
@@ -95,7 +95,7 @@
String num = Long.toString(n);
if (num.length() >= field.length())
return num;
- StringBuffer b = new StringBuffer(field);
+ StringBuilder b = new StringBuilder(field);
b.replace(b.length()-num.length(), b.length(), num);
return b.toString();
}
--- a/test/jdk/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java Tue Jan 16 18:28:39 2018 -0800
@@ -81,7 +81,7 @@
final CountDownLatch done = new CountDownLatch(3);
final SplittableRandom rnd = new SplittableRandom();
- /** Poor man's bounded buffer; prevents unbounded queue expansion. */
+ // Poor man's bounded buffer; prevents unbounded queue expansion.
final Semaphore offers = new Semaphore(maxQueueSize);
abstract class CheckedThread extends Thread {
--- a/test/jdk/java/util/concurrent/Exchanger/LoopHelpers.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/Exchanger/LoopHelpers.java Tue Jan 16 18:28:39 2018 -0800
@@ -95,7 +95,7 @@
String num = Long.toString(n);
if (num.length() >= field.length())
return num;
- StringBuffer b = new StringBuffer(field);
+ StringBuilder b = new StringBuilder(field);
b.replace(b.length()-num.length(), b.length(), num);
return b.toString();
}
--- a/test/jdk/java/util/concurrent/ExecutorCompletionService/ExecutorCompletionServiceLoops.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/ExecutorCompletionService/ExecutorCompletionServiceLoops.java Tue Jan 16 18:28:39 2018 -0800
@@ -52,7 +52,7 @@
static final ExecutorService pool =
Executors.newFixedThreadPool(POOLSIZE);
static final ExecutorCompletionService<Integer> ecs =
- new ExecutorCompletionService<Integer>(pool);
+ new ExecutorCompletionService<>(pool);
static boolean print = false;
public static void main(String[] args) throws Exception {
--- a/test/jdk/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/ExecutorCompletionService/LoopHelpers.java Tue Jan 16 18:28:39 2018 -0800
@@ -95,7 +95,7 @@
String num = Long.toString(n);
if (num.length() >= field.length())
return num;
- StringBuffer b = new StringBuffer(field);
+ StringBuilder b = new StringBuilder(field);
b.replace(b.length()-num.length(), b.length(), num);
return b.toString();
}
--- a/test/jdk/java/util/concurrent/FutureTask/BlockingTaskExecutor.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/FutureTask/BlockingTaskExecutor.java Tue Jan 16 18:28:39 2018 -0800
@@ -26,21 +26,25 @@
* @bug 6431315
* @summary ExecutorService.invokeAll might hang
* @author Martin Buchholz
+ * @library /lib/testlibrary/
*/
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.TimeUnit;
+import jdk.testlibrary.Utils;
/**
* Adapted from Doug Lea, which was...
* adapted from a posting by Tom Sugden tom at epcc.ed.ac.uk
*/
public class BlockingTaskExecutor {
+ static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
static void realMain(String[] args) throws Throwable {
for (int i = 1; i <= 100; i++) {
@@ -75,15 +79,19 @@
// are blocked. This should cause the tasks to be
// interrupted.
executor.shutdownNow();
- if (! executor.awaitTermination(5L, TimeUnit.SECONDS))
- throw new Error("Executor stuck");
+ if (! executor.awaitTermination(LONG_DELAY_MS, MILLISECONDS))
+ throw new Error(
+ String.format("Executor termination timed out after %d ms",
+ LONG_DELAY_MS));
// Wait for the invocation thread to complete.
- thread.join(5000);
+ thread.join(LONG_DELAY_MS);
if (thread.isAlive()) {
thread.interrupt();
- thread.join(5000);
- throw new Error("invokeAll stuck");
+ thread.join(LONG_DELAY_MS);
+ throw new Error(
+ String.format("invokeAll timed out after %d ms",
+ LONG_DELAY_MS));
}
}
--- a/test/jdk/java/util/concurrent/FutureTask/ExplicitSet.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/FutureTask/ExplicitSet.java Tue Jan 16 18:28:39 2018 -0800
@@ -60,7 +60,7 @@
public Boolean call() {
fail("The task should never be run!");
return null;
- };
+ }
});
}
--- a/test/jdk/java/util/concurrent/FutureTask/LoopHelpers.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/FutureTask/LoopHelpers.java Tue Jan 16 18:28:39 2018 -0800
@@ -95,7 +95,7 @@
String num = Long.toString(n);
if (num.length() >= field.length())
return num;
- StringBuffer b = new StringBuffer(field);
+ StringBuilder b = new StringBuilder(field);
b.replace(b.length()-num.length(), b.length(), num);
return b.toString();
}
--- a/test/jdk/java/util/concurrent/FutureTask/NegativeTimeout.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/FutureTask/NegativeTimeout.java Tue Jan 16 18:28:39 2018 -0800
@@ -38,7 +38,7 @@
public class NegativeTimeout {
public static void main(String[] args) throws Exception {
- FutureTask<Void> task = new FutureTask<>( () -> { return null; } );
+ FutureTask<Void> task = new FutureTask<>(() -> null);
try {
task.get(Long.MIN_VALUE, TimeUnit.NANOSECONDS);
} catch (TimeoutException success) {}
--- a/test/jdk/java/util/concurrent/LinkedTransferQueue/WhiteBox.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/LinkedTransferQueue/WhiteBox.java Tue Jan 16 18:28:39 2018 -0800
@@ -56,7 +56,6 @@
import java.util.concurrent.TimeUnit;
import static java.util.stream.Collectors.toList;
import java.util.function.Consumer;
-import java.util.function.Function;
@Test
public class WhiteBox {
--- a/test/jdk/java/util/concurrent/atomic/AtomicUpdaters.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/atomic/AtomicUpdaters.java Tue Jan 16 18:28:39 2018 -0800
@@ -89,9 +89,9 @@
// Would like to test a public volatile in a class in another
// package - but of course there aren't any
- new Config(AtomicInteger.class, "value", "private", hasSM ? false : true, false, "private int field of class in different package", TYPE.INT),
- new Config(AtomicLong.class, "value", "private", hasSM ? false : true, false, "private long field of class in different package", TYPE.LONG),
- new Config(AtomicReference.class, "value", "private", hasSM ? false : true, false, "private reference field of class in different package", TYPE.REF),
+ new Config(AtomicInteger.class, "value", "private", !hasSM, false, "private int field of class in different package", TYPE.INT),
+ new Config(AtomicLong.class, "value", "private", !hasSM, false, "private long field of class in different package", TYPE.LONG),
+ new Config(AtomicReference.class, "value", "private", !hasSM, false, "private reference field of class in different package", TYPE.REF),
};
}
--- a/test/jdk/java/util/concurrent/locks/Lock/LoopHelpers.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/locks/Lock/LoopHelpers.java Tue Jan 16 18:28:39 2018 -0800
@@ -95,7 +95,7 @@
String num = Long.toString(n);
if (num.length() >= field.length())
return num;
- StringBuffer b = new StringBuffer(field);
+ StringBuilder b = new StringBuilder(field);
b.replace(b.length()-num.length(), b.length(), num);
return b.toString();
}
--- a/test/jdk/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/locks/ReentrantLock/LoopHelpers.java Tue Jan 16 18:28:39 2018 -0800
@@ -95,7 +95,7 @@
String num = Long.toString(n);
if (num.length() >= field.length())
return num;
- StringBuffer b = new StringBuffer(field);
+ StringBuilder b = new StringBuilder(field);
b.replace(b.length()-num.length(), b.length(), num);
return b.toString();
}
--- a/test/jdk/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/locks/ReentrantReadWriteLock/LoopHelpers.java Tue Jan 16 18:28:39 2018 -0800
@@ -95,7 +95,7 @@
String num = Long.toString(n);
if (num.length() >= field.length())
return num;
- StringBuffer b = new StringBuffer(field);
+ StringBuilder b = new StringBuilder(field);
b.replace(b.length()-num.length(), b.length(), num);
return b.toString();
}
--- a/test/jdk/java/util/concurrent/tck/AbstractQueueTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/AbstractQueueTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -80,7 +80,7 @@
}
/**
- * add throws IllegalStateException true if offer fails
+ * add throws IllegalStateException if offer fails
*/
public void testAddF() {
Fail q = new Fail();
@@ -106,7 +106,7 @@
*/
public void testRemoveS() {
Succeed q = new Succeed();
- q.remove();
+ assertSame(one, q.remove());
}
/**
@@ -125,7 +125,7 @@
*/
public void testElementS() {
Succeed q = new Succeed();
- q.element();
+ assertSame(one, q.element());
}
/**
--- a/test/jdk/java/util/concurrent/tck/ArrayDeque8Test.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/ArrayDeque8Test.java Tue Jan 16 18:28:39 2018 -0800
@@ -110,14 +110,13 @@
assertEquals((Integer) 1, q.peekLast());
assertEquals(maxArraySize - 1, q.size());
- ArrayDeque qq = q;
ArrayDeque smallish = new ArrayDeque(
Collections.nCopies(Integer.MAX_VALUE - q.size() + 1, e));
assertThrows(
IllegalStateException.class,
- () -> qq.addAll(qq),
- () -> qq.addAll(smallish),
- () -> smallish.addAll(qq));
+ () -> q.addAll(q),
+ () -> q.addAll(smallish),
+ () -> smallish.addAll(q));
}
}
--- a/test/jdk/java/util/concurrent/tck/AtomicReferenceArrayTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/AtomicReferenceArrayTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -84,7 +84,7 @@
*/
public void testConstructorSubClassArray() {
Integer[] a = { two, one, three, four, seven };
- AtomicReferenceArray<Number> aa = new AtomicReferenceArray<Number>(a);
+ AtomicReferenceArray<Number> aa = new AtomicReferenceArray<>(a);
assertEquals(a.length, aa.length());
for (int i = 0; i < a.length; i++) {
assertSame(a[i], aa.get(i));
--- a/test/jdk/java/util/concurrent/tck/BlockingQueueTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/BlockingQueueTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -216,18 +216,20 @@
public void testDrainToNonPositiveMaxElements() {
final BlockingQueue q = emptyCollection();
final int[] ns = { 0, -1, -42, Integer.MIN_VALUE };
- for (int n : ns)
- assertEquals(0, q.drainTo(new ArrayList(), n));
+ final ArrayList sink = new ArrayList();
+ for (int n : ns) {
+ assertEquals(0, q.drainTo(sink, n));
+ assertTrue(sink.isEmpty());
+ }
if (q.remainingCapacity() > 0) {
// Not SynchronousQueue, that is
Object one = makeElement(1);
q.add(one);
- ArrayList c = new ArrayList();
for (int n : ns)
- assertEquals(0, q.drainTo(new ArrayList(), n));
+ assertEquals(0, q.drainTo(sink, n));
assertEquals(1, q.size());
assertSame(one, q.poll());
- assertTrue(c.isEmpty());
+ assertTrue(sink.isEmpty());
}
}
--- a/test/jdk/java/util/concurrent/tck/CompletableFutureTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/CompletableFutureTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -357,7 +357,7 @@
* toString indicates current completion state
*/
public void testToString_incomplete() {
- CompletableFuture<String> f = new CompletableFuture<String>();
+ CompletableFuture<String> f = new CompletableFuture<>();
assertTrue(f.toString().matches(".*\\[.*Not completed.*\\]"));
if (testImplementationDetails)
assertEquals(identityString(f) + "[Not completed]",
@@ -365,7 +365,7 @@
}
public void testToString_normal() {
- CompletableFuture<String> f = new CompletableFuture<String>();
+ CompletableFuture<String> f = new CompletableFuture<>();
assertTrue(f.complete("foo"));
assertTrue(f.toString().matches(".*\\[.*Completed normally.*\\]"));
if (testImplementationDetails)
@@ -374,7 +374,7 @@
}
public void testToString_exception() {
- CompletableFuture<String> f = new CompletableFuture<String>();
+ CompletableFuture<String> f = new CompletableFuture<>();
assertTrue(f.completeExceptionally(new IndexOutOfBoundsException()));
assertTrue(f.toString().matches(".*\\[.*Completed exceptionally.*\\]"));
if (testImplementationDetails)
@@ -384,7 +384,7 @@
public void testToString_cancelled() {
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) {
- CompletableFuture<String> f = new CompletableFuture<String>();
+ CompletableFuture<String> f = new CompletableFuture<>();
assertTrue(f.cancel(mayInterruptIfRunning));
assertTrue(f.toString().matches(".*\\[.*Completed exceptionally.*\\]"));
if (testImplementationDetails)
--- a/test/jdk/java/util/concurrent/tck/ConcurrentHashMap8Test.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/ConcurrentHashMap8Test.java Tue Jan 16 18:28:39 2018 -0800
@@ -212,7 +212,7 @@
*/
public void testReplaceAll() {
ConcurrentHashMap<Integer, String> map = map5();
- map.replaceAll((x, y) -> { return x > 3 ? "Z" : y; });
+ map.replaceAll((x, y) -> (x > 3) ? "Z" : y);
assertEquals("A", map.get(one));
assertEquals("B", map.get(two));
assertEquals("C", map.get(three));
--- a/test/jdk/java/util/concurrent/tck/ConcurrentHashMapTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/ConcurrentHashMapTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -83,17 +83,12 @@
return map;
}
- /** Re-implement Integer.compare for old java versions */
- static int compare(int x, int y) {
- return (x < y) ? -1 : (x > y) ? 1 : 0;
- }
-
// classes for testing Comparable fallbacks
static class BI implements Comparable<BI> {
private final int value;
BI(int value) { this.value = value; }
public int compareTo(BI other) {
- return compare(value, other.value);
+ return Integer.compare(value, other.value);
}
public boolean equals(Object x) {
return (x instanceof BI) && ((BI)x).value == value;
@@ -127,7 +122,7 @@
break;
}
if (r == 0)
- r = compare(size(), other.size());
+ r = Integer.compare(size(), other.size());
return r;
}
private static final long serialVersionUID = 0;
@@ -155,8 +150,7 @@
*/
public void testComparableFamily() {
int size = 500; // makes measured test run time -> 60ms
- ConcurrentHashMap<BI, Boolean> m =
- new ConcurrentHashMap<BI, Boolean>();
+ ConcurrentHashMap<BI, Boolean> m = new ConcurrentHashMap<>();
for (int i = 0; i < size; i++) {
assertNull(m.put(new CI(i), true));
}
@@ -172,13 +166,12 @@
*/
public void testGenericComparable() {
int size = 120; // makes measured test run time -> 60ms
- ConcurrentHashMap<Object, Boolean> m =
- new ConcurrentHashMap<Object, Boolean>();
+ ConcurrentHashMap<Object, Boolean> m = new ConcurrentHashMap<>();
for (int i = 0; i < size; i++) {
BI bi = new BI(i);
BS bs = new BS(String.valueOf(i));
- LexicographicList<BI> bis = new LexicographicList<BI>(bi);
- LexicographicList<BS> bss = new LexicographicList<BS>(bs);
+ LexicographicList<BI> bis = new LexicographicList<>(bi);
+ LexicographicList<BS> bss = new LexicographicList<>(bs);
assertNull(m.putIfAbsent(bis, true));
assertTrue(m.containsKey(bis));
if (m.putIfAbsent(bss, true) == null)
@@ -197,14 +190,13 @@
*/
public void testGenericComparable2() {
int size = 500; // makes measured test run time -> 60ms
- ConcurrentHashMap<Object, Boolean> m =
- new ConcurrentHashMap<Object, Boolean>();
+ ConcurrentHashMap<Object, Boolean> m = new ConcurrentHashMap<>();
for (int i = 0; i < size; i++) {
m.put(Collections.singletonList(new BI(i)), true);
}
for (int i = 0; i < size; i++) {
- LexicographicList<BI> bis = new LexicographicList<BI>(new BI(i));
+ LexicographicList<BI> bis = new LexicographicList<>(new BI(i));
assertTrue(m.containsKey(bis));
}
}
@@ -215,8 +207,7 @@
*/
public void testMixedComparable() {
int size = 1200; // makes measured test run time -> 35ms
- ConcurrentHashMap<Object, Object> map =
- new ConcurrentHashMap<Object, Object>();
+ ConcurrentHashMap<Object, Object> map = new ConcurrentHashMap<>();
Random rng = new Random();
for (int i = 0; i < size; i++) {
Object x;
--- a/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSetTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSetTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -65,8 +65,7 @@
* Integers 0 ... n - 1.
*/
private static ConcurrentSkipListSet<Integer> populatedSet(int n) {
- ConcurrentSkipListSet<Integer> q =
- new ConcurrentSkipListSet<Integer>();
+ ConcurrentSkipListSet<Integer> q = new ConcurrentSkipListSet<>();
assertTrue(q.isEmpty());
for (int i = n - 1; i >= 0; i -= 2)
assertTrue(q.add(new Integer(i)));
--- a/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -60,8 +60,7 @@
* Integers 0 ... n - 1.
*/
private static NavigableSet<Integer> populatedSet(int n) {
- ConcurrentSkipListSet<Integer> q =
- new ConcurrentSkipListSet<Integer>();
+ ConcurrentSkipListSet<Integer> q = new ConcurrentSkipListSet<>();
assertTrue(q.isEmpty());
for (int i = n - 1; i >= 0; i -= 2)
--- a/test/jdk/java/util/concurrent/tck/CopyOnWriteArrayListTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/CopyOnWriteArrayListTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -83,8 +83,8 @@
static CopyOnWriteArrayList<Integer> populatedArray(Integer[] elements) {
CopyOnWriteArrayList<Integer> a = new CopyOnWriteArrayList<>();
assertTrue(a.isEmpty());
- for (int i = 0; i < elements.length; i++)
- a.add(elements[i]);
+ for (Integer element : elements)
+ a.add(element);
assertFalse(a.isEmpty());
assertEquals(elements.length, a.size());
return a;
--- a/test/jdk/java/util/concurrent/tck/CyclicBarrierTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/CyclicBarrierTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -335,8 +335,7 @@
c.await();
shouldThrow();
}
- catch (BrokenBarrierException ok) {}
- catch (InterruptedException ok) {}
+ catch (BrokenBarrierException | InterruptedException ok) {}
}}});
for (int i = 0; i < 4; i++) {
--- a/test/jdk/java/util/concurrent/tck/ForkJoinPool8Test.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/ForkJoinPool8Test.java Tue Jan 16 18:28:39 2018 -0800
@@ -1557,7 +1557,7 @@
* timeout elapsed
*/
public void testAwaitQuiescence2() throws Exception {
- /**
+ /*
* """It is possible to disable or limit the use of threads in the
* common pool by setting the parallelism property to zero. However
* doing so may cause unjoined tasks to never be executed."""
--- a/test/jdk/java/util/concurrent/tck/FutureTaskTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/FutureTaskTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -865,7 +865,7 @@
* toString indicates current completion state
*/
public void testToString_incomplete() {
- FutureTask<String> f = new FutureTask<String>(() -> "");
+ FutureTask<String> f = new FutureTask<>(() -> "");
assertTrue(f.toString().matches(".*\\[.*Not completed.*\\]"));
if (testImplementationDetails)
assertTrue(f.toString().startsWith(
@@ -873,7 +873,7 @@
}
public void testToString_normal() {
- FutureTask<String> f = new FutureTask<String>(() -> "");
+ FutureTask<String> f = new FutureTask<>(() -> "");
f.run();
assertTrue(f.toString().matches(".*\\[.*Completed normally.*\\]"));
if (testImplementationDetails)
@@ -882,7 +882,7 @@
}
public void testToString_exception() {
- FutureTask<String> f = new FutureTask<String>(
+ FutureTask<String> f = new FutureTask<>(
() -> { throw new ArithmeticException(); });
f.run();
assertTrue(f.toString().matches(".*\\[.*Completed exceptionally.*\\]"));
@@ -893,7 +893,7 @@
public void testToString_cancelled() {
for (boolean mayInterruptIfRunning : new boolean[] { true, false }) {
- FutureTask<String> f = new FutureTask<String>(() -> "");
+ FutureTask<String> f = new FutureTask<>(() -> "");
assertTrue(f.cancel(mayInterruptIfRunning));
assertTrue(f.toString().matches(".*\\[.*Cancelled.*\\]"));
if (testImplementationDetails)
--- a/test/jdk/java/util/concurrent/tck/JSR166TestCase.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/JSR166TestCase.java Tue Jan 16 18:28:39 2018 -0800
@@ -472,18 +472,11 @@
}
}
- public static boolean atLeastJava6() { return JAVA_CLASS_VERSION >= 50.0; }
- public static boolean atLeastJava7() { return JAVA_CLASS_VERSION >= 51.0; }
- public static boolean atLeastJava8() { return JAVA_CLASS_VERSION >= 52.0; }
- public static boolean atLeastJava9() {
- return JAVA_CLASS_VERSION >= 53.0
- // As of 2015-09, java9 still uses 52.0 class file version
- || JAVA_SPECIFICATION_VERSION.matches("^(1\\.)?(9|[0-9][0-9])$");
- }
- public static boolean atLeastJava10() {
- return JAVA_CLASS_VERSION >= 54.0
- || JAVA_SPECIFICATION_VERSION.matches("^(1\\.)?[0-9][0-9]$");
- }
+ public static boolean atLeastJava6() { return JAVA_CLASS_VERSION >= 50.0; }
+ public static boolean atLeastJava7() { return JAVA_CLASS_VERSION >= 51.0; }
+ public static boolean atLeastJava8() { return JAVA_CLASS_VERSION >= 52.0; }
+ public static boolean atLeastJava9() { return JAVA_CLASS_VERSION >= 53.0; }
+ public static boolean atLeastJava10() { return JAVA_CLASS_VERSION >= 54.0; }
/**
* Collects all JSR166 unit tests as one suite.
--- a/test/jdk/java/util/concurrent/tck/LinkedBlockingQueueTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/LinkedBlockingQueueTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -86,8 +86,7 @@
* Integers 0 ... n - 1.
*/
private static LinkedBlockingQueue<Integer> populatedQueue(int n) {
- LinkedBlockingQueue<Integer> q =
- new LinkedBlockingQueue<Integer>(n);
+ LinkedBlockingQueue<Integer> q = new LinkedBlockingQueue<>(n);
assertTrue(q.isEmpty());
for (int i = 0; i < n; i++)
assertTrue(q.offer(new Integer(i)));
--- a/test/jdk/java/util/concurrent/tck/MapTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/MapTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -129,7 +129,7 @@
final Object v2 = (permitsNullValues && rnd.nextBoolean() && v1 != null)
? null : impl.makeValue(2);
- /** If true, always lands in first bucket in hash tables. */
+ // If true, always lands in first bucket in hash tables.
final boolean poorHash = rnd.nextBoolean();
class Key implements Comparable<Key> {
final int i;
--- a/test/jdk/java/util/concurrent/tck/RecursiveActionTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/RecursiveActionTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -352,8 +352,7 @@
* succeeds in the presence of interrupts
*/
public void testJoinIgnoresInterruptsOutsideForkJoinPool() {
- final SynchronousQueue<FibAction[]> sq =
- new SynchronousQueue<FibAction[]>();
+ final SynchronousQueue<FibAction[]> sq = new SynchronousQueue<>();
RecursiveAction a = new CheckedRecursiveAction() {
protected void realCompute() throws InterruptedException {
FibAction[] fibActions = new FibAction[6];
--- a/test/jdk/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/ScheduledExecutorSubclassTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -872,7 +872,7 @@
immediates.forEach(
f -> assertTrue(((ScheduledFuture)f).getDelay(NANOSECONDS) <= 0L));
- Stream.of(immediates, delayeds, periodics).flatMap(c -> c.stream())
+ Stream.of(immediates, delayeds, periodics).flatMap(Collection::stream)
.forEach(f -> assertFalse(f.isDone()));
try { p.shutdown(); } catch (SecurityException ok) { return; }
@@ -926,7 +926,7 @@
assertTrue(q.isEmpty());
- Stream.of(immediates, delayeds, periodics).flatMap(c -> c.stream())
+ Stream.of(immediates, delayeds, periodics).flatMap(Collection::stream)
.forEach(f -> assertTrue(f.isDone()));
for (Future<?> f : immediates) assertNull(f.get());
--- a/test/jdk/java/util/concurrent/tck/ScheduledExecutorTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/ScheduledExecutorTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -831,7 +831,7 @@
immediates.forEach(
f -> assertTrue(((ScheduledFuture)f).getDelay(NANOSECONDS) <= 0L));
- Stream.of(immediates, delayeds, periodics).flatMap(c -> c.stream())
+ Stream.of(immediates, delayeds, periodics).flatMap(Collection::stream)
.forEach(f -> assertFalse(f.isDone()));
try { p.shutdown(); } catch (SecurityException ok) { return; }
@@ -885,7 +885,7 @@
assertTrue(q.isEmpty());
- Stream.of(immediates, delayeds, periodics).flatMap(c -> c.stream())
+ Stream.of(immediates, delayeds, periodics).flatMap(Collection::stream)
.forEach(f -> assertTrue(f.isDone()));
for (Future<?> f : immediates) assertNull(f.get());
--- a/test/jdk/java/util/concurrent/tck/SubmissionPublisherTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/SubmissionPublisherTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -431,7 +431,7 @@
*/
public void testCancel() {
SubmissionPublisher<Integer> p =
- new SubmissionPublisher<Integer>(basicExecutor, 4); // must be < 20
+ new SubmissionPublisher<>(basicExecutor, 4); // must be < 20
TestSubscriber s1 = new TestSubscriber();
TestSubscriber s2 = new TestSubscriber();
p.subscribe(s1);
@@ -1012,6 +1012,7 @@
* cvs update -D '2017-11-25' src/main/java/util/concurrent/SubmissionPublisher.java && ant -Djsr166.expensiveTests=true -Djsr166.tckTestClass=SubmissionPublisherTest -Djsr166.methodFilter=testMissedSignal tck; cvs update -A src/main/java/util/concurrent/SubmissionPublisher.java
*/
public void testMissedSignal_8187947() throws Exception {
+ if (!atLeastJava9()) return; // backport to jdk8 too hard
final int N = expensiveTests ? (1 << 20) : (1 << 10);
final CountDownLatch finished = new CountDownLatch(1);
final SubmissionPublisher<Boolean> pub = new SubmissionPublisher<>();
--- a/test/jdk/java/util/concurrent/tck/ThreadLocalRandomTest.java Tue Jan 16 18:24:32 2018 -0800
+++ b/test/jdk/java/util/concurrent/tck/ThreadLocalRandomTest.java Tue Jan 16 18:28:39 2018 -0800
@@ -382,7 +382,7 @@
// Don't use main thread's ThreadLocalRandom - it is likely to
// be polluted by previous tests.
final AtomicReference<ThreadLocalRandom> threadLocalRandom =
- new AtomicReference<ThreadLocalRandom>();
+ new AtomicReference<>();
final AtomicLong rand = new AtomicLong();
long firstRand = 0;