--- jsr166/src/test/loops/MapWordLoops.java 2011/12/05 04:08:46 1.8 +++ jsr166/src/test/loops/MapWordLoops.java 2016/10/23 03:03:23 1.13 @@ -3,8 +3,8 @@ * Expert Group and released to the public domain, as explained at * http://creativecommons.org/publicdomain/zero/1.0/ */ -import java.util.*; import java.io.*; +import java.util.*; public class MapWordLoops { @@ -25,7 +25,7 @@ public class MapWordLoops { static final int numTests = 3; public static void main(String[] args) { - Class mapClass = null; + Class mapClass = null; try { mapClass = Class.forName(args[0]); } catch (ClassNotFoundException e) { @@ -39,10 +39,9 @@ public class MapWordLoops { for (int s = WORDS_FILES.length-1; s >= 0; --s) tests(mapClass, numTests, s); - } - static void tests(Class mapClass, int numTests, int sizeIndex) { + static void tests(Class mapClass, int numTests, int sizeIndex) { try { String[] key = readWords(sizeIndex); int size = key.length; @@ -65,11 +64,9 @@ public class MapWordLoops { } } - - static Map newMap(Class cl) { + static Map newMap(Class cl) { try { - Map m = (Map)cl.newInstance(); - return m; + return (Map) cl.getConstructor().newInstance(); } catch (Exception e) { throw new RuntimeException("Can't instantiate " + cl + ": " + e); } @@ -127,7 +124,6 @@ public class MapWordLoops { return runTime; } - static class Runner implements Runnable { final Map map; final String[] key; @@ -148,7 +144,6 @@ public class MapWordLoops { rng = new LoopHelpers.SimpleRandom((id + 1) * 8862213513L); } - int oneStep(int j) { int n = key.length; int r = rng.next() & 0x7FFFFFFF;