Skip to content

Commit

Permalink
8217332: JTREG: Clean up, use generics instead of raw types
Browse files Browse the repository at this point in the history
Reviewed-by: mdoerr
Backport-of: f3cb008
  • Loading branch information
GoeLin committed Jun 21, 2022
1 parent 9f059ee commit 9307c8c
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/gc/TestAllocateHeapAt.java
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/gc/TestAllocateHeapAtError.java
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java
Expand Up @@ -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", ".");
Expand Down
6 changes: 3 additions & 3 deletions test/hotspot/jtreg/gc/TestFullGCCount.java
Expand Up @@ -52,7 +52,7 @@ public static void main(String[] args) {
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++) {
Expand Down Expand Up @@ -91,10 +91,10 @@ public static void main(String[] args) {
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());
}
}
Expand Down
8 changes: 4 additions & 4 deletions test/hotspot/jtreg/gc/TestSoftReferencesBehaviorOnOOME.java
Expand Up @@ -71,9 +71,9 @@ public static void main(String[] args) {
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;
Expand All @@ -89,7 +89,7 @@ void softReferencesOom(long minSize, long maxSize) {
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());
Expand All @@ -106,7 +106,7 @@ void softReferencesOom(long minSize, long maxSize) {
arrObjects = null;
long oomSoftArraySize = arrSoftRefs.size();

for (SoftReference sr : arrSoftRefs) {
for (SoftReference<byte[]> sr : arrSoftRefs) {
Object o = sr.get();

if (o != null) {
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/gc/TestVerifyDuringStartup.java
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/gc/TestVerifySilently.java
Expand Up @@ -49,7 +49,7 @@ public static void main(String args[]) throws Exception {
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",
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/gc/TestVerifySubSet.java
Expand Up @@ -47,7 +47,7 @@ public static void main(String args[]) throws Exception {
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",
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/gc/cms/TestMBeanCMS.java
Expand Up @@ -137,7 +137,7 @@ public void run() {
public void allocationWork(long target) {

long sizeAllocated = 0;
List list = new LinkedList();
List<byte[]> list = new LinkedList<>();
long delay = 50;
long count = 0;

Expand Down
8 changes: 4 additions & 4 deletions test/hotspot/jtreg/gc/g1/TestHumongousShrinkHeap.java
Expand Up @@ -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<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);
Expand Down Expand Up @@ -108,7 +108,7 @@ private final void test() {
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);
Expand All @@ -120,12 +120,12 @@ private void free() {
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]);
}
Expand Down
12 changes: 6 additions & 6 deletions test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java
Expand Up @@ -71,7 +71,7 @@ protected TestShrinkAuxiliaryData(int hotCardTableSize) {
}

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()));
Expand All @@ -87,14 +87,14 @@ protected void test() throws Exception {

// 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());
Expand Down Expand Up @@ -205,8 +205,8 @@ protected boolean checkEnvApplicability() {

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]);
Expand All @@ -223,7 +223,7 @@ public void mutate() {
}
}

private final List<GarbageObject> garbage = new ArrayList();
private final List<GarbageObject> garbage = new ArrayList<>();

public void test() throws IOException {

Expand Down
4 changes: 2 additions & 2 deletions test/hotspot/jtreg/gc/g1/TestShrinkDefragmentedHeap.java
Expand Up @@ -140,7 +140,7 @@ private void free() {
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();
}
Expand All @@ -160,7 +160,7 @@ private String prepareMessageCommittedIsNotLess() {
);
}

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]);
}
Expand Down
Expand Up @@ -139,7 +139,7 @@ public static void doTesting(GC gc, REF_FACTORY ref) {

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());

Expand Down
Expand Up @@ -93,7 +93,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();

Expand Down
12 changes: 6 additions & 6 deletions test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java
Expand Up @@ -55,12 +55,12 @@ public class TestReclaimStringsLeaksMemory {
public static final int ReservedThreshold = 70000000;

public static void main(String[] args) throws Exception {
ArrayList<String> baseargs = new ArrayList(Arrays.asList( "-Xms256M",
"-Xmx256M",
"-Xlog:gc*,stringtable*=debug:gc.log",
"-XX:NativeMemoryTracking=summary",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+PrintNMTStatistics" ));
ArrayList<String> baseargs = new ArrayList<>(Arrays.asList("-Xms256M",
"-Xmx256M",
"-Xlog:gc*,stringtable*=debug:gc.log",
"-XX:NativeMemoryTracking=summary",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+PrintNMTStatistics" ));
baseargs.addAll(Arrays.asList(args));
baseargs.add(GCTest.class.getName());
ProcessBuilder pb_default =
Expand Down

1 comment on commit 9307c8c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.