--- 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;