Skip to content

Commit

Permalink
8217389: JTREG: Clean up, remove unused variable warnings
Browse files Browse the repository at this point in the history
Reviewed-by: lmesnik, tschatzl
  • Loading branch information
lkorinth committed Feb 18, 2019
1 parent 3d13ab6 commit b09dfdb
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 42 deletions.
25 changes: 11 additions & 14 deletions test/hotspot/jtreg/gc/arguments/TestMaxNewSize.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,16 @@ private static String getFlagValue(String flag, String where) {

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

package gc.arguments;

import static java.lang.ref.Reference.reachabilityFence;

/*
* @test TestTargetSurvivorRatioFlag
* @key gc
Expand Down Expand Up @@ -297,7 +299,7 @@ public static void allocateMemory(double ratio, long maxSize) throws Exception {

// force minor GC
while (youngGCBean.getCollectionCount() <= initialGcId + MAX_TENURING_THRESHOLD * 2) {
byte b[] = new byte[ARRAY_LENGTH];
reachabilityFence(new byte[ARRAY_LENGTH]);
}

allocator.release();
Expand Down
4 changes: 3 additions & 1 deletion test/hotspot/jtreg/gc/cms/DisableResizePLAB.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

package gc.cms;

import static java.lang.ref.Reference.reachabilityFence;

/*
* @test DisableResizePLAB
* @key gc
Expand All @@ -41,7 +43,7 @@ public static void main(String args[]) throws Exception {
}
long startTime = System.currentTimeMillis();
while (System.currentTimeMillis() - startTime < 10_000) {
Object o = new byte[1024];
reachabilityFence(new byte[1024]);
}
}
}
5 changes: 3 additions & 2 deletions test/hotspot/jtreg/gc/cslocker/TestCSLocker.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

package gc.cslocker;

import static java.lang.ref.Reference.reachabilityFence;

/*
* @test TestCSLocker
* @key gc
Expand Down Expand Up @@ -73,8 +75,7 @@ public void run() {

while (isRunning) {
try {
int[] arr = null;
arr = new int[size];
reachabilityFence(new int[size]);
sleep(sleepTime);
} catch (InterruptedException e) {
isRunning = false;
Expand Down
4 changes: 2 additions & 2 deletions test/hotspot/jtreg/gc/epsilon/TestMemoryMXBeans.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public static void testMemoryBean(long initSize, long maxSize) {
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);
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/gc/g1/TestFromCardCacheIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static Object[] findArray(Object[][] arrays) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

package gc.g1;

import static java.lang.ref.Reference.reachabilityFence;

/*
* @test TestHumongousAllocNearlyFullRegion
* @bug 8143587
Expand Down Expand Up @@ -62,7 +64,7 @@ public static void main(String [] args) {
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]);
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions test/hotspot/jtreg/gc/g1/TestRemsetLoggingThreads.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ private static void runTest(int refinementThreads, int workerThreads) throws Exc

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -139,7 +141,7 @@ public Allocator(int maxAllocationMemory) {
// Dead object allocation
() -> {
int size = RND.nextInt(DEAD_OBJECT_MAX_SIZE);
byte[] deadObject = new byte[size];
reachabilityFence(new byte[size]);
},

// Check
Expand Down
3 changes: 0 additions & 3 deletions test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -67,8 +66,6 @@ public static void main(String[] args) throws Exception {
}

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"))
Expand Down
1 change: 0 additions & 1 deletion test/hotspot/jtreg/gc/logging/TestPrintReferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ private static String subphaseRegex(String subphaseName, boolean parallelRefProc

// 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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -128,7 +131,7 @@ public MemoryStresser(int maxMemory) {
// Dead object allocation
() -> {
int size = RND.nextInt(DEAD_OBJECT_MAX_SIZE);
byte[] deadObject = new byte[size];
reachabilityFence(new byte[size]);
}
};

Expand Down
13 changes: 6 additions & 7 deletions test/hotspot/jtreg/gc/metaspace/G1AddMetaspaceDependency.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,12 @@ private static void runTest(final byte[] a_bytes, final byte[] b_bytes) throws E
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 {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*/
public class TestMetaspaceInitialization {
private class Internal {
@SuppressWarnings("unused")
public int x;
public Internal(int x) {
this.x = x;
Expand Down
6 changes: 3 additions & 3 deletions test/hotspot/jtreg/gc/stress/gcbasher/Decompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private void decodeMethodDependencies(MethodInfo[] methods, ConstantPoolEntry[]
byteCodeIndex++;
}

int def = cursor.readIntAt(byteCodeIndex);
cursor.readIntAt(byteCodeIndex); // def
byteCodeIndex +=4;

int npairs = cursor.readIntAt(byteCodeIndex);
Expand All @@ -149,7 +149,7 @@ private void decodeMethodDependencies(MethodInfo[] methods, ConstantPoolEntry[]
byteCodeIndex++;
}

int def = cursor.readIntAt(byteCodeIndex);
cursor.readIntAt(byteCodeIndex); // def
byteCodeIndex +=4;

int low = cursor.readIntAt(byteCodeIndex);
Expand Down Expand Up @@ -245,7 +245,7 @@ private void decodeFields() {

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;
Expand Down

0 comments on commit b09dfdb

Please sign in to comment.