--- jsr166/src/test/loops/NavigableMapCheck.java 2014/12/31 17:00:58 1.13 +++ jsr166/src/test/loops/NavigableMapCheck.java 2016/10/23 03:03:23 1.16 @@ -37,7 +37,6 @@ public class NavigableMapCheck { } } - if (args.length > 1) numTests = Integer.parseInt(args[1]); @@ -46,7 +45,6 @@ public class NavigableMapCheck { System.out.println("Testing " + mapClass.getName() + " trials: " + numTests + " size: " + size); - absentSize = 8; while (absentSize < size) absentSize <<= 1; absentMask = absentSize - 1; @@ -59,25 +57,21 @@ public class NavigableMapCheck { for (int i = 0; i < size; ++i) key[i] = new Integer(i * 2 + 1); - for (int rep = 0; rep < numTests; ++rep) { runTest(newMap(mapClass), key); } TestTimer.printStats(); - } static NavigableMap newMap(Class cl) { try { - NavigableMap m = (NavigableMap) cl.newInstance(); - return m; + return (NavigableMap) cl.getConstructor().newInstance(); } catch (Exception e) { throw new RuntimeException("Can't instantiate " + cl + ": " + e); } } - static void runTest(NavigableMap s, Integer[] key) { shuffle(key); int size = key.length; @@ -171,7 +165,6 @@ public class NavigableMapCheck { reallyAssert(sum == expect); } - static void t9(NavigableMap s) { int sum = 0; int iters = 20; @@ -237,7 +230,6 @@ public class NavigableMapCheck { reallyAssert(sum == iters-1); } - static void ktest(NavigableMap s, int size, Integer[] key) { timer.start("ContainsKey ", size); Set ks = s.keySet(); @@ -249,7 +241,6 @@ public class NavigableMapCheck { reallyAssert(sum == size); } - static void ittest1(NavigableMap s, int size) { int sum = 0; timer.start("Iter Key ", size); @@ -299,13 +290,11 @@ public class NavigableMapCheck { reallyAssert(sum == size); } - static void rittest(NavigableMap s, int size) { rittest1(s, size); // rittest2(s, size); } - static void rtest(NavigableMap s, int size) { timer.start("Remove (iterator) ", size); for (Iterator it = s.keySet().iterator(); it.hasNext(); ) { @@ -324,12 +313,11 @@ public class NavigableMapCheck { timer.finish(); } - static void dtest(NavigableMap s, int size, Integer[] key) { timer.start("Put (putAll) ", size * 2); - NavigableMap s2 = null; + final NavigableMap s2; try { - s2 = (NavigableMap) (s.getClass().newInstance()); + s2 = (NavigableMap) s.getClass().getConstructor().newInstance(); s2.putAll(s); } catch (Exception e) { e.printStackTrace(); return; } @@ -391,8 +379,6 @@ public class NavigableMapCheck { reallyAssert(s2.isEmpty() && s.isEmpty()); } - - static void test(NavigableMap s, Integer[] key) { int size = key.length; @@ -454,7 +440,6 @@ public class NavigableMapCheck { startTime = System.currentTimeMillis(); } - String classify() { if (name.startsWith("Get")) return "Get "; @@ -494,9 +479,7 @@ public class NavigableMapCheck { if (timePerOp < stats.least) stats.least = timePerOp; } } - } - } static class Stats {