--- jsr166/src/test/loops/ListBash.java 2010/09/01 07:20:36 1.10 +++ jsr166/src/test/loops/ListBash.java 2016/10/23 03:03:23 1.17 @@ -1,7 +1,7 @@ /* * Written by Josh Bloch and Doug Lea with assistance from members of * JCP JSR-166 Expert Group and released to the public domain, as - * explained at http://creativecommons.org/licenses/publicdomain + * explained at http://creativecommons.org/publicdomain/zero/1.0/ */ import java.util.*; @@ -12,7 +12,7 @@ public class ListBash { static int numItr; static int listSize; static boolean synch; - static Class cl; + static Class cl; public static void main(String[] args) { numItr = Integer.parseInt(args[1]); @@ -25,7 +25,7 @@ public class ListBash { fail("Class " + args[0] + " not found."); } - synch = (args.length>3); + synch = (args.length > 3); oneRun(); oneRun(); oneRun(); @@ -33,11 +33,11 @@ public class ListBash { static void oneRun() { long startTime = System.nanoTime(); - for (int i=0; i s = newList(cl, synch); - for (int i=0; i s1 = newList(cl, synch); AddRandoms(s1, listSize); @@ -67,10 +65,10 @@ public class ListBash { if (!(s1.equals(s2) && s2.equals(s1))) fail("addAll(int, Collection) doesn't work."); // Reverse List - for (int j=0, n=s1.size(); j itAll = all.listIterator(all.size()); ListIterator itEven = even.listIterator(even.size()); while (itEven.hasPrevious()) { @@ -205,7 +203,7 @@ public class ListBash { Object o = it.next(); if (all.indexOf(o) != all.lastIndexOf(o)) fail("Apparent duplicate detected."); - if (all.subList(i, all.size()).indexOf(o) != 0) { + if (all.subList(i, all.size()).indexOf(o) != 0) { System.out.println("s0: " + all.subList(i, all.size()).indexOf(o)); fail("subList/indexOf is screwy."); } @@ -240,7 +238,7 @@ public class ListBash { } // Done inefficiently so as to exercise toArray - static List clone(List s, Class cl, boolean synch) { + static List clone(List s, Class cl, boolean synch) { List a = Arrays.asList(s.toArray()); if (s.hashCode() != a.hashCode()) fail("Incorrect hashCode computation."); @@ -257,9 +255,9 @@ public class ListBash { return (List) clone; } - static List newList(Class cl, boolean synch) { + static List newList(Class cl, boolean synch) { try { - List s = (List) cl.newInstance(); + List s = (List) cl.getConstructor().newInstance(); if (synch) s = Collections.synchronizedList(s); if (!s.isEmpty()) @@ -272,16 +270,16 @@ public class ListBash { } static void AddRandoms(List s, int n) { - for (int i=0; i