8217389: JTREG: Clean up, remove unused variable warnings
Reviewed-by: lmesnik, tschatzl
--- a/test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java Mon Feb 18 12:08:08 2019 +0100
@@ -120,19 +120,16 @@
public static void main(String args[]) throws Exception {
String gcName = args[0];
- final int M32 = 32 * 1024 * 1024;
- final int M64 = 64 * 1024 * 1024;
- final int M96 = 96 * 1024 * 1024;
- final int M128 = 128 * 1024 * 1024;
- checkMaxNewSize(new String[] { gcName, "-Xmx128M" }, M128);
- checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewRatio=5" }, M128);
- checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewSize=32M" }, M128);
- checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:OldSize=96M" }, M128);
- checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:MaxNewSize=32M" }, M32);
- checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewSize=32M", "-XX:MaxNewSize=32M" }, M32);
- checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewRatio=6", "-XX:MaxNewSize=32M" }, M32);
- checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-Xms96M" }, M128);
- checkMaxNewSize(new String[] { gcName, "-Xmx96M", "-Xms96M" }, M96);
- checkMaxNewSize(new String[] { gcName, "-XX:NewSize=128M", "-XX:MaxNewSize=50M"}, M128);
+ final int M = 1024 * 1024;
+ checkMaxNewSize(new String[] { gcName, "-Xmx128M" }, 128 * M);
+ checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewRatio=5" }, 128 * M);
+ checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewSize=32M" }, 128 * M);
+ checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:OldSize=96M" }, 128 * M);
+ checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:MaxNewSize=32M" }, 32 * M);
+ checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewSize=32M", "-XX:MaxNewSize=32M" }, 32 * M);
+ checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-XX:NewRatio=6", "-XX:MaxNewSize=32M" }, 32 * M);
+ checkMaxNewSize(new String[] { gcName, "-Xmx128M", "-Xms96M" }, 128 * M);
+ checkMaxNewSize(new String[] { gcName, "-Xmx96M", "-Xms96M" }, 96 * M);
+ checkMaxNewSize(new String[] { gcName, "-XX:NewSize=128M", "-XX:MaxNewSize=50M"}, 128 * M);
}
}
--- a/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java Mon Feb 18 12:08:08 2019 +0100
@@ -23,6 +23,8 @@
package gc.arguments;
+import static java.lang.ref.Reference.reachabilityFence;
+
/*
* @test TestTargetSurvivorRatioFlag
* @key gc
@@ -297,7 +299,7 @@
// force minor GC
while (youngGCBean.getCollectionCount() <= initialGcId + MAX_TENURING_THRESHOLD * 2) {
- byte b[] = new byte[ARRAY_LENGTH];
+ reachabilityFence(new byte[ARRAY_LENGTH]);
}
allocator.release();
--- a/test/hotspot/jtreg/gc/cms/DisableResizePLAB.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/cms/DisableResizePLAB.java Mon Feb 18 12:08:08 2019 +0100
@@ -23,6 +23,8 @@
package gc.cms;
+import static java.lang.ref.Reference.reachabilityFence;
+
/*
* @test DisableResizePLAB
* @key gc
@@ -41,7 +43,7 @@
}
long startTime = System.currentTimeMillis();
while (System.currentTimeMillis() - startTime < 10_000) {
- Object o = new byte[1024];
+ reachabilityFence(new byte[1024]);
}
}
}
--- a/test/hotspot/jtreg/gc/cslocker/TestCSLocker.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/cslocker/TestCSLocker.java Mon Feb 18 12:08:08 2019 +0100
@@ -23,6 +23,8 @@
package gc.cslocker;
+import static java.lang.ref.Reference.reachabilityFence;
+
/*
* @test TestCSLocker
* @key gc
@@ -73,8 +75,7 @@
while (isRunning) {
try {
- int[] arr = null;
- arr = new int[size];
+ reachabilityFence(new int[size]);
sleep(sleepTime);
} catch (InterruptedException e) {
isRunning = false;
--- a/test/hotspot/jtreg/gc/epsilon/TestMemoryMXBeans.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/epsilon/TestMemoryMXBeans.java Mon Feb 18 12:08:08 2019 +0100
@@ -57,8 +57,8 @@
MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
long heapInit = memoryMXBean.getHeapMemoryUsage().getInit();
long heapMax = memoryMXBean.getHeapMemoryUsage().getMax();
- long nonHeapInit = memoryMXBean.getNonHeapMemoryUsage().getInit();
- long nonHeapMax = memoryMXBean.getNonHeapMemoryUsage().getMax();
+ memoryMXBean.getNonHeapMemoryUsage().getInit(); // value not used
+ memoryMXBean.getNonHeapMemoryUsage().getMax(); // value not used
if (initSize > 0 && heapInit != initSize) {
throw new IllegalStateException("Init heap size is wrong: " + heapInit + " vs " + initSize);
--- a/test/hotspot/jtreg/gc/g1/TestFromCardCacheIndex.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/g1/TestFromCardCacheIndex.java Mon Feb 18 12:08:08 2019 +0100
@@ -130,7 +130,7 @@
if (target == null) {
continue;
}
- final long startAddress = WB.getObjectAddress(target);
+ WB.getObjectAddress(target); // startAddress not used
final long lastAddress = getObjectLastAddress(target);
final int card = getCardIndex32bit(lastAddress);
if (card == -1) {
--- a/test/hotspot/jtreg/gc/g1/TestHumongousAllocNearlyFullRegion.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/g1/TestHumongousAllocNearlyFullRegion.java Mon Feb 18 12:08:08 2019 +0100
@@ -23,6 +23,8 @@
package gc.g1;
+import static java.lang.ref.Reference.reachabilityFence;
+
/*
* @test TestHumongousAllocNearlyFullRegion
* @bug 8143587
@@ -62,7 +64,7 @@
for (int i = 0; i < heapSize; i++) {
// 131069 is the number of longs it takes to fill a heapRegion except
// for 8 bytes on 64 bit.
- long[] largeObect = new long[131069];
+ reachabilityFence(new long[131069]);
}
}
}
--- a/test/hotspot/jtreg/gc/g1/TestRemsetLoggingThreads.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/g1/TestRemsetLoggingThreads.java Mon Feb 18 12:08:08 2019 +0100
@@ -54,10 +54,6 @@
OutputAnalyzer output = new OutputAnalyzer(pb.start());
- // a zero in refinement thread numbers indicates that the value in ParallelGCThreads should be used.
- // Additionally use at least one thread.
- int expectedNumRefinementThreads = refinementThreads;
-
String pattern = "Concurrent RS threads times \\(s\\)$";
Matcher m = Pattern.compile(pattern, Pattern.MULTILINE).matcher(output.getStdout());
--- a/test/hotspot/jtreg/gc/g1/humongousObjects/TestNoAllocationsInHRegions.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/g1/humongousObjects/TestNoAllocationsInHRegions.java Mon Feb 18 12:08:08 2019 +0100
@@ -26,6 +26,8 @@
import jdk.test.lib.Utils;
import sun.hotspot.WhiteBox;
+import static java.lang.ref.Reference.reachabilityFence;
+
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
@@ -139,7 +141,7 @@
// Dead object allocation
() -> {
int size = RND.nextInt(DEAD_OBJECT_MAX_SIZE);
- byte[] deadObject = new byte[size];
+ reachabilityFence(new byte[size]);
},
// Check
--- a/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java Mon Feb 18 12:08:08 2019 +0100
@@ -27,7 +27,6 @@
import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
-import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
@@ -67,8 +66,6 @@
}
private static void verifyContainsMetaSpaceUpdate(OutputAnalyzer output) {
- Predicate<String> collectedMetaSpace = line -> check(line);
-
// At least one metaspace line from GC should show GC being collected.
boolean foundCollectedMetaSpace = output.asLines().stream()
.filter(s -> s.contains("[gc,metaspace"))
--- a/test/hotspot/jtreg/gc/logging/TestPrintReferences.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/logging/TestPrintReferences.java Mon Feb 18 12:08:08 2019 +0100
@@ -131,7 +131,6 @@
// Find the first Reference Processing log and check its format.
private static void checkLogFormat(OutputAnalyzer output, boolean parallelRefProcEnabled) {
- String countRegex = "[0-9]+";
String timeRegex = doubleRegex + "ms";
/* Total Reference processing time */
--- a/test/hotspot/jtreg/gc/logging/TestUnifiedLoggingSwitchStress.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/logging/TestUnifiedLoggingSwitchStress.java Mon Feb 18 12:08:08 2019 +0100
@@ -31,6 +31,9 @@
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.ReflectionException;
+
+import static java.lang.ref.Reference.reachabilityFence;
+
import java.lang.management.ManagementFactory;
import java.util.LinkedList;
import java.util.List;
@@ -128,7 +131,7 @@
// Dead object allocation
() -> {
int size = RND.nextInt(DEAD_OBJECT_MAX_SIZE);
- byte[] deadObject = new byte[size];
+ reachabilityFence(new byte[size]);
}
};
--- a/test/hotspot/jtreg/gc/metaspace/G1AddMetaspaceDependency.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/metaspace/G1AddMetaspaceDependency.java Mon Feb 18 12:08:08 2019 +0100
@@ -111,13 +111,12 @@
Loader f_loader = new Loader(b_name, b_bytes, a_name, a_loader);
Loader g_loader = new Loader(b_name, b_bytes, a_name, a_loader);
- Class<?> c;
- c = b_loader.loadClass(b_name);
- c = c_loader.loadClass(b_name);
- c = d_loader.loadClass(b_name);
- c = e_loader.loadClass(b_name);
- c = f_loader.loadClass(b_name);
- c = g_loader.loadClass(b_name);
+ b_loader.loadClass(b_name);
+ c_loader.loadClass(b_name);
+ d_loader.loadClass(b_name);
+ e_loader.loadClass(b_name);
+ f_loader.loadClass(b_name);
+ g_loader.loadClass(b_name);
}
public class A {
}
--- a/test/hotspot/jtreg/gc/metaspace/TestMetaspaceInitialization.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/metaspace/TestMetaspaceInitialization.java Mon Feb 18 12:08:08 2019 +0100
@@ -33,6 +33,7 @@
*/
public class TestMetaspaceInitialization {
private class Internal {
+ @SuppressWarnings("unused")
public int x;
public Internal(int x) {
this.x = x;
--- a/test/hotspot/jtreg/gc/stress/gcbasher/Decompiler.java Mon Feb 18 10:48:48 2019 +0100
+++ b/test/hotspot/jtreg/gc/stress/gcbasher/Decompiler.java Mon Feb 18 12:08:08 2019 +0100
@@ -132,7 +132,7 @@
byteCodeIndex++;
}
- int def = cursor.readIntAt(byteCodeIndex);
+ cursor.readIntAt(byteCodeIndex); // def
byteCodeIndex +=4;
int npairs = cursor.readIntAt(byteCodeIndex);
@@ -149,7 +149,7 @@
byteCodeIndex++;
}
- int def = cursor.readIntAt(byteCodeIndex);
+ cursor.readIntAt(byteCodeIndex); // def
byteCodeIndex +=4;
int low = cursor.readIntAt(byteCodeIndex);
@@ -245,7 +245,7 @@
private ConstantPoolEntry[] decodeConstantPool() {
final int CONSTANT_Utf8 = 1;
- final int CONSTANT_Unicode = 2;
+ // final int CONSTANT_Unicode = 2;
final int CONSTANT_Integer = 3;
final int CONSTANT_Float = 4;
final int CONSTANT_Long = 5;