OpenJDK / jdk / jdk
changeset 53694:a0a327cae58f
8217332: JTREG: Clean up, use generics instead of raw types
Reviewed-by: tschatzl, sangheki
line wrap: on
line diff
--- a/test/hotspot/jtreg/gc/TestAllocateHeapAt.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAt.java Fri Feb 08 12:09:41 2019 +0100 @@ -40,7 +40,7 @@ public class TestAllocateHeapAt { public static void main(String args[]) throws Exception { - ArrayList<String> vmOpts = new ArrayList(); + ArrayList<String> vmOpts = new ArrayList<>(); String testVmOptsStr = System.getProperty("test.java.opts"); if (!testVmOptsStr.isEmpty()) {
--- a/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java Fri Feb 08 12:09:41 2019 +0100 @@ -42,7 +42,7 @@ public class TestAllocateHeapAtError { public static void main(String args[]) throws Exception { - ArrayList<String> vmOpts = new ArrayList(); + ArrayList<String> vmOpts = new ArrayList<>(); String testVmOptsStr = System.getProperty("test.java.opts"); if (!testVmOptsStr.isEmpty()) {
--- a/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java Fri Feb 08 12:09:41 2019 +0100 @@ -40,7 +40,7 @@ public class TestAllocateHeapAtMultiple { public static void main(String args[]) throws Exception { - ArrayList<String> vmOpts = new ArrayList(); + ArrayList<String> vmOpts = new ArrayList<>(); String[] testVmOpts = null; String test_dir = System.getProperty("test.dir", ".");
--- a/test/hotspot/jtreg/gc/TestFullGCCount.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/TestFullGCCount.java Fri Feb 08 12:09:41 2019 +0100 @@ -52,7 +52,7 @@ int iterations = 20; boolean failed = false; String errorMessage = ""; - HashMap<String, List> counts = new HashMap<>(); + HashMap<String, List<Long>> counts = new HashMap<>(); // Prime the collection of count lists for all collectors. for (int i = 0; i < collectors.size(); i++) { @@ -91,10 +91,10 @@ System.out.println("Passed."); } - private static void addCollectionCount(HashMap<String, List> counts, int iteration) { + private static void addCollectionCount(HashMap<String, List<Long>> counts, int iteration) { for (int i = 0; i < collectors.size(); i++) { GarbageCollectorMXBean collector = collectors.get(i); - List thisList = counts.get(collector.getName()); + List<Long> thisList = counts.get(collector.getName()); thisList.add(collector.getCollectionCount()); } }
--- a/test/hotspot/jtreg/gc/TestSoftReferencesBehaviorOnOOME.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/TestSoftReferencesBehaviorOnOOME.java Fri Feb 08 12:09:41 2019 +0100 @@ -71,9 +71,9 @@ void softReferencesOom(long minSize, long maxSize) { System.out.format( "minSize = %d, maxSize = %d%n", minSize, maxSize ); - LinkedList<SoftReference> arrSoftRefs = new LinkedList(); + LinkedList<SoftReference<byte[]>> arrSoftRefs = new LinkedList<>(); staticRef = arrSoftRefs; - LinkedList arrObjects = new LinkedList(); + LinkedList<byte[]> arrObjects = new LinkedList<>(); staticRef = arrObjects; long multiplier = maxSize - minSize; @@ -89,7 +89,7 @@ while (numSofts-- > 0) { int allocationSize = ((int) (RND_GENERATOR.nextDouble() * multiplier)) + (int)minSize; - arrSoftRefs.add(new SoftReference(new byte[allocationSize])); + arrSoftRefs.add(new SoftReference<byte[]>(new byte[allocationSize])); } System.out.println("free: " + Runtime.getRuntime().freeMemory()); @@ -106,7 +106,7 @@ arrObjects = null; long oomSoftArraySize = arrSoftRefs.size(); - for (SoftReference sr : arrSoftRefs) { + for (SoftReference<byte[]> sr : arrSoftRefs) { Object o = sr.get(); if (o != null) {
--- a/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java Fri Feb 08 12:09:41 2019 +0100 @@ -41,7 +41,7 @@ public class TestVerifyDuringStartup { public static void main(String args[]) throws Exception { - ArrayList<String> vmOpts = new ArrayList(); + ArrayList<String> vmOpts = new ArrayList<>(); String testVmOptsStr = System.getProperty("test.java.opts"); if (!testVmOptsStr.isEmpty()) {
--- a/test/hotspot/jtreg/gc/TestVerifySilently.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/TestVerifySilently.java Fri Feb 08 12:09:41 2019 +0100 @@ -49,7 +49,7 @@ public class TestVerifySilently { private static OutputAnalyzer runTest(boolean verifySilently) throws Exception { - ArrayList<String> vmOpts = new ArrayList(); + ArrayList<String> vmOpts = new ArrayList<>(); Collections.addAll(vmOpts, Utils.getFilteredTestJavaOpts("-Xlog.*")); Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
--- a/test/hotspot/jtreg/gc/TestVerifySubSet.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/TestVerifySubSet.java Fri Feb 08 12:09:41 2019 +0100 @@ -47,7 +47,7 @@ public class TestVerifySubSet { private static OutputAnalyzer runTest(String subset) throws Exception { - ArrayList<String> vmOpts = new ArrayList(); + ArrayList<String> vmOpts = new ArrayList<>(); Collections.addAll(vmOpts, Utils.getFilteredTestJavaOpts("-Xlog.*")); Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
--- a/test/hotspot/jtreg/gc/cms/TestMBeanCMS.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/cms/TestMBeanCMS.java Fri Feb 08 12:09:41 2019 +0100 @@ -137,7 +137,7 @@ public void allocationWork(long target) { long sizeAllocated = 0; - List list = new LinkedList(); + List<byte[]> list = new LinkedList<>(); long delay = 50; long count = 0;
--- a/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java Fri Feb 08 12:09:41 2019 +0100 @@ -52,7 +52,7 @@ public static final String MIN_FREE_RATIO_FLAG_NAME = "MinHeapFreeRatio"; public static final String MAX_FREE_RATIO_FLAG_NAME = "MaxHeapFreeRatio"; - private static final List<List<byte[]>> garbage = new ArrayList(); + private static final List<List<byte[]>> garbage = new ArrayList<>(); private static final int REGION_SIZE = 1024 * 1024; // 1M private static final int LISTS_COUNT = 10; private static final int HUMON_SIZE = Math.round(.9f * REGION_SIZE); @@ -108,7 +108,7 @@ private void allocate() { for (int i = 0; i < LISTS_COUNT; i++) { - List<byte[]> stuff = new ArrayList(); + List<byte[]> stuff = new ArrayList<>(); allocateList(stuff, HUMON_COUNT, HUMON_SIZE); MemoryUsagePrinter.printMemoryUsage("allocate #" + (i+1)); garbage.add(stuff); @@ -120,12 +120,12 @@ garbage.subList(0, garbage.size() - 1).clear(); // do not free last one element from last list - List stuff = garbage.get(garbage.size() - 1); + List<byte[]> stuff = garbage.get(garbage.size() - 1); stuff.subList(0, stuff.size() - 1).clear(); System.gc(); } - private static void allocateList(List garbage, int count, int size) { + private static void allocateList(List<byte[]> garbage, int count, int size) { for (int i = 0; i < count; i++) { garbage.add(new byte[size]); }
--- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java Fri Feb 08 12:09:41 2019 +0100 @@ -66,7 +66,7 @@ } protected void test() throws Exception { - ArrayList<String> vmOpts = new ArrayList(); + ArrayList<String> vmOpts = new ArrayList<>(); Collections.addAll(vmOpts, initialOpts); int maxCacheSize = Math.max(0, Math.min(31, getMaxCacheSize())); @@ -82,14 +82,14 @@ // for 32 bits ObjectAlignmentInBytes is not a option if (Platform.is32bit()) { - ArrayList<String> vmOptsWithoutAlign = new ArrayList(vmOpts); + ArrayList<String> vmOptsWithoutAlign = new ArrayList<>(vmOpts); vmOptsWithoutAlign.add(ShrinkAuxiliaryDataTest.class.getName()); performTest(vmOptsWithoutAlign); return; } for (int alignment = 3; alignment <= 8; alignment++) { - ArrayList<String> vmOptsWithAlign = new ArrayList(vmOpts); + ArrayList<String> vmOptsWithAlign = new ArrayList<>(vmOpts); vmOptsWithAlign.add("-XX:ObjectAlignmentInBytes=" + (int) Math.pow(2, alignment)); vmOptsWithAlign.add(ShrinkAuxiliaryDataTest.class.getName()); @@ -200,8 +200,8 @@ class GarbageObject { - private final List<byte[]> payload = new ArrayList(); - private final List<GarbageObject> ref = new LinkedList(); + private final List<byte[]> payload = new ArrayList<>(); + private final List<GarbageObject> ref = new LinkedList<>(); public GarbageObject(int size) { payload.add(new byte[size]); @@ -218,7 +218,7 @@ } } - private final List<GarbageObject> garbage = new ArrayList(); + private final List<GarbageObject> garbage = new ArrayList<>(); public void test() throws IOException {
--- a/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java Fri Feb 08 12:09:41 2019 +0100 @@ -139,7 +139,7 @@ garbage.subList(0, garbage.size() - 1).clear(); // do not free last one element from last list - ArrayList stuff = garbage.get(garbage.size() - 1); + ArrayList<byte[]> stuff = garbage.get(garbage.size() - 1); if (stuff.size() > 1) { stuff.subList(0, stuff.size() - 1).clear(); } @@ -159,7 +159,7 @@ ); } - private static void allocateList(List garbage, int count, int size) { + private static void allocateList(List<byte[]> garbage, int count, int size) { for (int i = 0; i < count; i++) { garbage.add(new byte[size]); }
--- a/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java Fri Feb 08 12:09:41 2019 +0100 @@ -139,7 +139,7 @@ System.out.println(String.format("Testing %s reference behavior after %s", ref.name(), gc.name())); - Reference reference = ref.create(); + Reference<byte[]> reference = ref.create(); Asserts.assertNotNull(reference, "Test Bug: failed to allocate reference"); long adr = WHITE_BOX.getObjectAddress(reference.get());
--- a/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java Fri Feb 08 12:09:41 2019 +0100 @@ -70,7 +70,7 @@ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+UsePerfData -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC gc.metaspace.TestMetaspacePerfCounters */ public class TestMetaspacePerfCounters { - public static Class fooClass = null; + public static Class<?> fooClass = null; private static final String[] counterNames = {"minCapacity", "maxCapacity", "capacity", "used"}; private static final List<GarbageCollectorMXBean> gcBeans = ManagementFactoryHelper.getGarbageCollectorMXBeans();
--- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java Fri Feb 08 12:09:41 2019 +0100 @@ -43,7 +43,7 @@ private static ArrayList<String> commonOpts; public static void main(String args[]) throws Exception { - commonOpts = new ArrayList(); + commonOpts = new ArrayList<>(); String testVmOptsStr = System.getProperty("test.java.opts"); if (!testVmOptsStr.isEmpty()) { @@ -63,7 +63,7 @@ } private static void runTest(String... extraFlags) throws Exception { - ArrayList<String> testOpts = new ArrayList(); + ArrayList<String> testOpts = new ArrayList<>(); Collections.addAll(testOpts, commonOpts.toArray(new String[commonOpts.size()])); Collections.addAll(testOpts, extraFlags);
--- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java Fri Feb 08 12:09:41 2019 +0100 @@ -45,7 +45,7 @@ private static ArrayList<String> commonOpts; public static void main(String args[]) throws Exception { - commonOpts = new ArrayList(); + commonOpts = new ArrayList<>(); String testVmOptsStr = System.getProperty("test.java.opts"); if (!testVmOptsStr.isEmpty()) { @@ -94,7 +94,7 @@ } private static OutputAnalyzer runTest(String... extraFlags) throws Exception { - ArrayList<String> testOpts = new ArrayList(); + ArrayList<String> testOpts = new ArrayList<>(); Collections.addAll(testOpts, commonOpts.toArray(new String[commonOpts.size()])); Collections.addAll(testOpts, extraFlags);
--- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java Fri Feb 08 12:09:41 2019 +0100 @@ -42,7 +42,7 @@ public class TestAllocateOldGenAtMultiple { public static void main(String args[]) throws Exception { - ArrayList<String> vmOpts = new ArrayList(); + ArrayList<String> vmOpts = new ArrayList<>(); String[] testVmOpts = null; String test_dir = System.getProperty("test.dir", ".");
--- a/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java Fri Feb 08 12:09:41 2019 +0100 @@ -53,7 +53,7 @@ private static ArrayList<String> testOpts; public static void main(String args[]) throws Exception { - testOpts = new ArrayList(); + testOpts = new ArrayList<>(); String[] common_options = new String[] { "-Xbootclasspath/a:.",
--- a/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java Fri Feb 08 12:09:41 2019 +0100 @@ -53,7 +53,7 @@ private static ArrayList<String> testOpts; public static void main(String args[]) throws Exception { - testOpts = new ArrayList(); + testOpts = new ArrayList<>(); String[] common_options = new String[] { "-Xbootclasspath/a:.",
--- a/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java Fri Feb 08 12:09:41 2019 +0100 @@ -53,7 +53,7 @@ private static ArrayList<String> testOpts; public static void main(String args[]) throws Exception { - testOpts = new ArrayList(); + testOpts = new ArrayList<>(); String[] common_options = new String[] { "-Xbootclasspath/a:.",
--- a/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java Fri Feb 08 11:52:33 2019 +0100 +++ b/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java Fri Feb 08 12:09:41 2019 +0100 @@ -55,12 +55,12 @@ public static final int ReservedThreshold = 70000; public static void main(String[] args) throws Exception { - ArrayList<String> baseargs = new ArrayList(Arrays.asList( "-Xms256M", - "-Xmx256M", - "-Xlog:gc*", - "-XX:NativeMemoryTracking=summary", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+PrintNMTStatistics" )); + ArrayList<String> baseargs = new ArrayList<>(Arrays.asList("-Xms256M", + "-Xmx256M", + "-Xlog:gc*", + "-XX:NativeMemoryTracking=summary", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+PrintNMTStatistics" )); baseargs.addAll(Arrays.asList(args)); baseargs.add(GCTest.class.getName()); ProcessBuilder pb_default =