diff --git a/test/hotspot/jtreg/gc/TestAllocateHeapAt.java b/test/hotspot/jtreg/gc/TestAllocateHeapAt.java index b228dbff3b3..90d380a1990 100644 --- a/test/hotspot/jtreg/gc/TestAllocateHeapAt.java +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAt.java @@ -40,7 +40,7 @@ import java.util.Collections; public class TestAllocateHeapAt { public static void main(String args[]) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); String testVmOptsStr = System.getProperty("test.java.opts"); if (!testVmOptsStr.isEmpty()) { diff --git a/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java b/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java index d5e5cd57ea4..dd8f724e93f 100644 --- a/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java @@ -42,7 +42,7 @@ import java.util.UUID; public class TestAllocateHeapAtError { public static void main(String args[]) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); String testVmOptsStr = System.getProperty("test.java.opts"); if (!testVmOptsStr.isEmpty()) { diff --git a/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java b/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java index baf8e262561..096ab9684e0 100644 --- a/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java @@ -40,7 +40,7 @@ import java.util.Collections; public class TestAllocateHeapAtMultiple { public static void main(String args[]) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); String[] testVmOpts = null; String test_dir = System.getProperty("test.dir", "."); diff --git a/test/hotspot/jtreg/gc/TestFullGCCount.java b/test/hotspot/jtreg/gc/TestFullGCCount.java index 50663509ce3..fb41b3fe6d4 100644 --- a/test/hotspot/jtreg/gc/TestFullGCCount.java +++ b/test/hotspot/jtreg/gc/TestFullGCCount.java @@ -52,7 +52,7 @@ public class TestFullGCCount { int iterations = 20; boolean failed = false; String errorMessage = ""; - HashMap counts = new HashMap<>(); + HashMap> counts = new HashMap<>(); // Prime the collection of count lists for all collectors. for (int i = 0; i < collectors.size(); i++) { @@ -91,10 +91,10 @@ public class TestFullGCCount { System.out.println("Passed."); } - private static void addCollectionCount(HashMap counts, int iteration) { + private static void addCollectionCount(HashMap> counts, int iteration) { for (int i = 0; i < collectors.size(); i++) { GarbageCollectorMXBean collector = collectors.get(i); - List thisList = counts.get(collector.getName()); + List thisList = counts.get(collector.getName()); thisList.add(collector.getCollectionCount()); } } diff --git a/test/hotspot/jtreg/gc/TestSoftReferencesBehaviorOnOOME.java b/test/hotspot/jtreg/gc/TestSoftReferencesBehaviorOnOOME.java index eb5e5d3b020..b16e961ae23 100644 --- a/test/hotspot/jtreg/gc/TestSoftReferencesBehaviorOnOOME.java +++ b/test/hotspot/jtreg/gc/TestSoftReferencesBehaviorOnOOME.java @@ -71,9 +71,9 @@ public class TestSoftReferencesBehaviorOnOOME { void softReferencesOom(long minSize, long maxSize) { System.out.format( "minSize = %d, maxSize = %d%n", minSize, maxSize ); - LinkedList arrSoftRefs = new LinkedList(); + LinkedList> arrSoftRefs = new LinkedList<>(); staticRef = arrSoftRefs; - LinkedList arrObjects = new LinkedList(); + LinkedList arrObjects = new LinkedList<>(); staticRef = arrObjects; long multiplier = maxSize - minSize; @@ -89,7 +89,7 @@ public class TestSoftReferencesBehaviorOnOOME { while (numSofts-- > 0) { int allocationSize = ((int) (RND_GENERATOR.nextDouble() * multiplier)) + (int)minSize; - arrSoftRefs.add(new SoftReference(new byte[allocationSize])); + arrSoftRefs.add(new SoftReference(new byte[allocationSize])); } System.out.println("free: " + Runtime.getRuntime().freeMemory()); @@ -106,7 +106,7 @@ public class TestSoftReferencesBehaviorOnOOME { arrObjects = null; long oomSoftArraySize = arrSoftRefs.size(); - for (SoftReference sr : arrSoftRefs) { + for (SoftReference sr : arrSoftRefs) { Object o = sr.get(); if (o != null) { diff --git a/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java b/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java index e1553d0a5f7..99a74a96b70 100644 --- a/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java +++ b/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java @@ -41,7 +41,7 @@ import java.util.Collections; public class TestVerifyDuringStartup { public static void main(String args[]) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); String testVmOptsStr = System.getProperty("test.java.opts"); if (!testVmOptsStr.isEmpty()) { diff --git a/test/hotspot/jtreg/gc/TestVerifySilently.java b/test/hotspot/jtreg/gc/TestVerifySilently.java index 24ccc2c08b9..dff4507ccf8 100644 --- a/test/hotspot/jtreg/gc/TestVerifySilently.java +++ b/test/hotspot/jtreg/gc/TestVerifySilently.java @@ -49,7 +49,7 @@ class TestVerifySilentlyRunSystemGC { public class TestVerifySilently { private static OutputAnalyzer runTest(boolean verifySilently) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); Collections.addAll(vmOpts, Utils.getFilteredTestJavaOpts("-Xlog.*")); Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/gc/TestVerifySubSet.java b/test/hotspot/jtreg/gc/TestVerifySubSet.java index baa955da41e..2f6023b68d1 100644 --- a/test/hotspot/jtreg/gc/TestVerifySubSet.java +++ b/test/hotspot/jtreg/gc/TestVerifySubSet.java @@ -47,7 +47,7 @@ class TestVerifySubSetRunSystemGC { public class TestVerifySubSet { private static OutputAnalyzer runTest(String subset) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); Collections.addAll(vmOpts, Utils.getFilteredTestJavaOpts("-Xlog.*")); Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/gc/cms/TestMBeanCMS.java b/test/hotspot/jtreg/gc/cms/TestMBeanCMS.java index eb24c336f12..76c9717830e 100644 --- a/test/hotspot/jtreg/gc/cms/TestMBeanCMS.java +++ b/test/hotspot/jtreg/gc/cms/TestMBeanCMS.java @@ -137,7 +137,7 @@ public class TestMBeanCMS { public void allocationWork(long target) { long sizeAllocated = 0; - List list = new LinkedList(); + List list = new LinkedList<>(); long delay = 50; long count = 0; diff --git a/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java b/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java index a61f61993fb..caad74718e2 100644 --- a/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java +++ b/test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java @@ -52,7 +52,7 @@ public class TestHumongousShrinkHeap { public static final String MIN_FREE_RATIO_FLAG_NAME = "MinHeapFreeRatio"; public static final String MAX_FREE_RATIO_FLAG_NAME = "MaxHeapFreeRatio"; - private static final List> garbage = new ArrayList(); + private static final List> 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 @@ public class TestHumongousShrinkHeap { private void allocate() { for (int i = 0; i < LISTS_COUNT; i++) { - List stuff = new ArrayList(); + List stuff = new ArrayList<>(); allocateList(stuff, HUMON_COUNT, HUMON_SIZE); MemoryUsagePrinter.printMemoryUsage("allocate #" + (i+1)); garbage.add(stuff); @@ -120,12 +120,12 @@ public class TestHumongousShrinkHeap { garbage.subList(0, garbage.size() - 1).clear(); // do not free last one element from last list - List stuff = garbage.get(garbage.size() - 1); + List 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 garbage, int count, int size) { for (int i = 0; i < count; i++) { garbage.add(new byte[size]); } diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java index 4eb41087c49..efb102733f2 100644 --- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java +++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java @@ -66,7 +66,7 @@ public class TestShrinkAuxiliaryData { } protected void test() throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); Collections.addAll(vmOpts, initialOpts); int maxCacheSize = Math.max(0, Math.min(31, getMaxCacheSize())); @@ -82,14 +82,14 @@ public class TestShrinkAuxiliaryData { // for 32 bits ObjectAlignmentInBytes is not a option if (Platform.is32bit()) { - ArrayList vmOptsWithoutAlign = new ArrayList(vmOpts); + ArrayList vmOptsWithoutAlign = new ArrayList<>(vmOpts); vmOptsWithoutAlign.add(ShrinkAuxiliaryDataTest.class.getName()); performTest(vmOptsWithoutAlign); return; } for (int alignment = 3; alignment <= 8; alignment++) { - ArrayList vmOptsWithAlign = new ArrayList(vmOpts); + ArrayList vmOptsWithAlign = new ArrayList<>(vmOpts); vmOptsWithAlign.add("-XX:ObjectAlignmentInBytes=" + (int) Math.pow(2, alignment)); vmOptsWithAlign.add(ShrinkAuxiliaryDataTest.class.getName()); @@ -200,8 +200,8 @@ public class TestShrinkAuxiliaryData { class GarbageObject { - private final List payload = new ArrayList(); - private final List ref = new LinkedList(); + private final List payload = new ArrayList<>(); + private final List ref = new LinkedList<>(); public GarbageObject(int size) { payload.add(new byte[size]); @@ -218,7 +218,7 @@ public class TestShrinkAuxiliaryData { } } - private final List garbage = new ArrayList(); + private final List garbage = new ArrayList<>(); public void test() throws IOException { diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java b/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java index d4167a61aa3..7bdc1ab8a7a 100644 --- a/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java +++ b/test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java @@ -139,7 +139,7 @@ public class TestShrinkDefragmentedHeap { garbage.subList(0, garbage.size() - 1).clear(); // do not free last one element from last list - ArrayList stuff = garbage.get(garbage.size() - 1); + ArrayList stuff = garbage.get(garbage.size() - 1); if (stuff.size() > 1) { stuff.subList(0, stuff.size() - 1).clear(); } @@ -159,7 +159,7 @@ public class TestShrinkDefragmentedHeap { ); } - private static void allocateList(List garbage, int count, int size) { + private static void allocateList(List garbage, int count, int size) { for (int i = 0; i < count; i++) { garbage.add(new byte[size]); } diff --git a/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java b/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java index cb4408081d5..9f5bf8b4141 100644 --- a/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java +++ b/test/hotspot/jtreg/gc/g1/humongousObjects/TestObjectCollected.java @@ -139,7 +139,7 @@ public class TestObjectCollected { System.out.println(String.format("Testing %s reference behavior after %s", ref.name(), gc.name())); - Reference reference = ref.create(); + Reference reference = ref.create(); Asserts.assertNotNull(reference, "Test Bug: failed to allocate reference"); long adr = WHITE_BOX.getObjectAddress(reference.get()); diff --git a/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java b/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java index c35ac67e249..72b36f916cf 100644 --- a/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java +++ b/test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java @@ -70,7 +70,7 @@ import gc.testlibrary.PerfCounters; * @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 gcBeans = ManagementFactoryHelper.getGarbageCollectorMXBeans(); diff --git a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java index 01145fe1a6e..486a9c31090 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java @@ -42,7 +42,7 @@ public class TestAllocateOldGenAt { private static ArrayList 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()) { @@ -62,7 +62,7 @@ public class TestAllocateOldGenAt { } private static void runTest(String... extraFlags) throws Exception { - ArrayList testOpts = new ArrayList(); + ArrayList testOpts = new ArrayList<>(); Collections.addAll(testOpts, commonOpts.toArray(new String[commonOpts.size()])); Collections.addAll(testOpts, extraFlags); diff --git a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java index 6ced99811be..55f60f8607e 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java @@ -44,7 +44,7 @@ public class TestAllocateOldGenAtError { private static ArrayList 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()) { @@ -93,7 +93,7 @@ public class TestAllocateOldGenAtError { } private static OutputAnalyzer runTest(String... extraFlags) throws Exception { - ArrayList testOpts = new ArrayList(); + ArrayList testOpts = new ArrayList<>(); Collections.addAll(testOpts, commonOpts.toArray(new String[commonOpts.size()])); Collections.addAll(testOpts, extraFlags); diff --git a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java index ff8c3a7fa3a..3da53740de7 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java @@ -41,7 +41,7 @@ import java.util.Collections; public class TestAllocateOldGenAtMultiple { public static void main(String args[]) throws Exception { - ArrayList vmOpts = new ArrayList(); + ArrayList vmOpts = new ArrayList<>(); String[] testVmOpts = null; String test_dir = System.getProperty("test.dir", "."); diff --git a/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java b/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java index a8bfe9e4f43..380f8f7093f 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java @@ -52,7 +52,7 @@ public class TestHumongousObjectsOnNvdimm { private static ArrayList testOpts; public static void main(String args[]) throws Exception { - testOpts = new ArrayList(); + testOpts = new ArrayList<>(); String[] common_options = new String[] { "-Xbootclasspath/a:.", diff --git a/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java b/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java index e0191d9d727..dbcfef97538 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java @@ -52,7 +52,7 @@ public class TestOldObjectsOnNvdimm { private static ArrayList testOpts; public static void main(String args[]) throws Exception { - testOpts = new ArrayList(); + testOpts = new ArrayList<>(); String[] common_options = new String[] { "-Xbootclasspath/a:.", diff --git a/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java b/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java index ff294e64391..7927e2a2313 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java @@ -52,7 +52,7 @@ public class TestYoungObjectsOnDram { private static ArrayList testOpts; public static void main(String args[]) throws Exception { - testOpts = new ArrayList(); + testOpts = new ArrayList<>(); String[] common_options = new String[] { "-Xbootclasspath/a:.", diff --git a/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java b/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java index 6ee6a5a5bff..fc8b462c3dc 100644 --- a/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java +++ b/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java @@ -55,12 +55,12 @@ public class TestReclaimStringsLeaksMemory { public static final int ReservedThreshold = 70000; public static void main(String[] args) throws Exception { - ArrayList baseargs = new ArrayList(Arrays.asList( "-Xms256M", - "-Xmx256M", - "-Xlog:gc*", - "-XX:NativeMemoryTracking=summary", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+PrintNMTStatistics" )); + ArrayList 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 =