Skip to content

Commit d84e4f1

Browse files
committedApr 27, 2020
8243565: some gc tests use 'test.java.opts' and not 'test.vm.opts'
Reviewed-by: stefank
1 parent e0f46d0 commit d84e4f1

14 files changed

+142
-308
lines changed
 

‎test/hotspot/jtreg/gc/TestAllocateHeapAt.java

+9-22
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* @requires vm.gc != "Z" & os.family != "aix"
3030
* @library /test/lib
3131
* @modules java.base/jdk.internal.misc
32-
* @run main gc.TestAllocateHeapAt
32+
* @run driver gc.TestAllocateHeapAt
3333
*/
3434

3535
import jdk.test.lib.JDKToolFinder;
@@ -40,28 +40,15 @@
4040

4141
public class TestAllocateHeapAt {
4242
public static void main(String args[]) throws Exception {
43-
ArrayList<String> vmOpts = new ArrayList<>();
44-
45-
String testVmOptsStr = System.getProperty("test.java.opts");
46-
if (!testVmOptsStr.isEmpty()) {
47-
String[] testVmOpts = testVmOptsStr.split(" ");
48-
Collections.addAll(vmOpts, testVmOpts);
49-
}
5043
String test_dir = System.getProperty("test.dir", ".");
51-
Collections.addAll(vmOpts, new String[] {"-XX:AllocateHeapAt=" + test_dir,
52-
"-Xlog:gc+heap=info",
53-
"-Xmx32m",
54-
"-Xms32m",
55-
"-version"});
56-
57-
System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
58-
for (int i = 0; i < vmOpts.size(); i += 1) {
59-
System.out.print(" " + vmOpts.get(i));
60-
}
61-
System.out.println();
62-
63-
ProcessBuilder pb =
64-
ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
44+
String[] flags = {
45+
"-XX:AllocateHeapAt=" + test_dir,
46+
"-Xlog:gc+heap=info",
47+
"-Xmx32m",
48+
"-Xms32m",
49+
"-version"};
50+
51+
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, flags);
6552
OutputAnalyzer output = new OutputAnalyzer(pb.start());
6653

6754
System.out.println("Output:\n" + output.getOutput());

‎test/hotspot/jtreg/gc/TestAllocateHeapAtError.java

+8-24
Original file line numberDiff line numberDiff line change
@@ -29,47 +29,31 @@
2929
* @requires vm.gc != "Z" & os.family != "aix"
3030
* @library /test/lib
3131
* @modules java.base/jdk.internal.misc
32-
* @run main gc.TestAllocateHeapAtError
32+
* @run driver gc.TestAllocateHeapAtError
3333
*/
3434

3535
import java.io.File;
36-
import jdk.test.lib.JDKToolFinder;
3736
import jdk.test.lib.process.ProcessTools;
3837
import jdk.test.lib.process.OutputAnalyzer;
39-
import java.util.ArrayList;
40-
import java.util.Collections;
4138
import java.util.UUID;
4239

4340
public class TestAllocateHeapAtError {
4441
public static void main(String args[]) throws Exception {
45-
ArrayList<String> vmOpts = new ArrayList<>();
46-
47-
String testVmOptsStr = System.getProperty("test.java.opts");
48-
if (!testVmOptsStr.isEmpty()) {
49-
String[] testVmOpts = testVmOptsStr.split(" ");
50-
Collections.addAll(vmOpts, testVmOpts);
51-
}
5242
String test_dir = System.getProperty("test.dir", ".");
5343

5444
File f = null;
5545
do {
5646
f = new File(test_dir, UUID.randomUUID().toString());
5747
} while(f.exists());
5848

59-
Collections.addAll(vmOpts, new String[] {"-XX:AllocateHeapAt=" + f.getName(),
60-
"-Xlog:gc+heap=info",
61-
"-Xmx32m",
62-
"-Xms32m",
63-
"-version"});
64-
65-
System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
66-
for (int i = 0; i < vmOpts.size(); i += 1) {
67-
System.out.print(" " + vmOpts.get(i));
68-
}
69-
System.out.println();
49+
String[] flags = {
50+
"-XX:AllocateHeapAt=" + f.getName(),
51+
"-Xlog:gc+heap=info",
52+
"-Xmx32m",
53+
"-Xms32m",
54+
"-version"};
7055

71-
ProcessBuilder pb =
72-
ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
56+
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, flags);
7357
OutputAnalyzer output = new OutputAnalyzer(pb.start());
7458

7559
System.out.println("Output:\n" + output.getOutput());

‎test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java

+18-36
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* @library /test/lib
3030
* @modules java.base/jdk.internal.misc
3131
* @requires vm.bits == "64" & vm.gc != "Z" & os.family != "aix"
32-
* @run main/timeout=360 gc.TestAllocateHeapAtMultiple
32+
* @run driver/timeout=360 gc.TestAllocateHeapAtMultiple
3333
*/
3434

3535
import jdk.test.lib.JDKToolFinder;
@@ -40,48 +40,30 @@
4040

4141
public class TestAllocateHeapAtMultiple {
4242
public static void main(String args[]) throws Exception {
43-
ArrayList<String> vmOpts = new ArrayList<>();
44-
String[] testVmOpts = null;
43+
ArrayList<String> flags = new ArrayList<>();
4544

4645
String test_dir = System.getProperty("test.dir", ".");
4746

48-
String testVmOptsStr = System.getProperty("test.java.opts");
49-
if (!testVmOptsStr.isEmpty()) {
50-
testVmOpts = testVmOptsStr.split(" ");
51-
}
52-
53-
// Extra options for each of the sub-tests
54-
String[] extraOptsList = new String[] {
55-
"-Xmx32m -Xms32m -XX:+UseCompressedOops", // 1. With compressedoops enabled.
56-
"-Xmx32m -Xms32m -XX:-UseCompressedOops", // 2. With compressedoops disabled.
57-
"-Xmx32m -Xms32m -XX:HeapBaseMinAddress=3g", // 3. With user specified HeapBaseMinAddress.
58-
"-Xmx32m -Xms32m -XX:+UseLargePages", // 4. Set UseLargePages.
59-
"-Xmx32m -Xms32m -XX:+UseNUMA" // 5. Set UseNUMA.
47+
// Extra flags for each of the sub-tests
48+
String[][] extraFlagsList = new String[][] {
49+
{"-Xmx32m", "-Xms32m", "-XX:+UseCompressedOops"}, // 1. With compressedoops enabled.
50+
{"-Xmx32m", "-Xms32m", "-XX:-UseCompressedOops"}, // 2. With compressedoops disabled.
51+
{"-Xmx32m", "-Xms32m", "-XX:HeapBaseMinAddress=3g"}, // 3. With user specified HeapBaseMinAddress.
52+
{"-Xmx32m", "-Xms32m", "-XX:+UseLargePages"}, // 4. Set UseLargePages.
53+
{"-Xmx32m", "-Xms32m", "-XX:+UseNUMA"} // 5. Set UseNUMA.
6054
};
6155

62-
for(String extraOpts : extraOptsList) {
63-
vmOpts.clear();
64-
if(testVmOpts != null) {
65-
Collections.addAll(vmOpts, testVmOpts);
66-
}
67-
// Add extra options specific to the sub-test.
68-
String[] extraOptsArray = extraOpts.split(" ");
69-
if(extraOptsArray != null) {
70-
Collections.addAll(vmOpts, extraOptsArray);
71-
}
72-
// Add common options
73-
Collections.addAll(vmOpts, new String[] {"-XX:AllocateHeapAt=" + test_dir,
74-
"-Xlog:gc+heap=info",
75-
"-version"});
76-
77-
System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
78-
for (int i = 0; i < vmOpts.size(); i += 1) {
79-
System.out.print(" " + vmOpts.get(i));
80-
}
81-
System.out.println();
56+
for (String[] extraFlags : extraFlagsList) {
57+
flags.clear();
58+
// Add extra flags specific to the sub-test.
59+
Collections.addAll(flags, extraFlags);
60+
// Add common flags
61+
Collections.addAll(flags, new String[] {"-XX:AllocateHeapAt=" + test_dir,
62+
"-Xlog:gc+heap=info",
63+
"-version"});
8264

8365
ProcessBuilder pb =
84-
ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
66+
ProcessTools.createJavaProcessBuilder(true, flags.toArray(String[]::new));
8567
OutputAnalyzer output = new OutputAnalyzer(pb.start());
8668

8769
System.out.println("Output:\n" + output.getOutput());

‎test/hotspot/jtreg/gc/TestVerifyDuringStartup.java

+9-25
Original file line numberDiff line numberDiff line change
@@ -30,38 +30,22 @@
3030
* @requires vm.gc != "Z"
3131
* @library /test/lib
3232
* @modules java.base/jdk.internal.misc
33-
* @run main gc.TestVerifyDuringStartup
33+
* @run driver gc.TestVerifyDuringStartup
3434
*/
3535

36-
import jdk.test.lib.JDKToolFinder;
3736
import jdk.test.lib.process.ProcessTools;
3837
import jdk.test.lib.process.OutputAnalyzer;
39-
import java.util.ArrayList;
40-
import java.util.Collections;
4138

4239
public class TestVerifyDuringStartup {
4340
public static void main(String args[]) throws Exception {
44-
ArrayList<String> vmOpts = new ArrayList<>();
45-
46-
String testVmOptsStr = System.getProperty("test.java.opts");
47-
if (!testVmOptsStr.isEmpty()) {
48-
String[] testVmOpts = testVmOptsStr.split(" ");
49-
Collections.addAll(vmOpts, testVmOpts);
50-
}
51-
Collections.addAll(vmOpts, new String[] {"-XX:-UseTLAB",
52-
"-XX:+UnlockDiagnosticVMOptions",
53-
"-XX:+VerifyDuringStartup",
54-
"-Xlog:gc+verify=debug",
55-
"-version"});
56-
57-
System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
58-
for (int i = 0; i < vmOpts.size(); i += 1) {
59-
System.out.print(" " + vmOpts.get(i));
60-
}
61-
System.out.println();
62-
63-
ProcessBuilder pb =
64-
ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
41+
String[] flags = {
42+
"-XX:-UseTLAB",
43+
"-XX:+UnlockDiagnosticVMOptions",
44+
"-XX:+VerifyDuringStartup",
45+
"-Xlog:gc+verify=debug",
46+
"-version"};
47+
48+
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, flags);
6549
OutputAnalyzer output = new OutputAnalyzer(pb.start());
6650

6751
System.out.println("Output:\n" + output.getOutput());

‎test/hotspot/jtreg/gc/arguments/TestMaxHeapSizeTools.java

+3-14
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,9 @@ private static long valueAfter(String source, String match) {
193193
* @param vmargs Arguments to the VM to run
194194
* @param classname Name of the class to run
195195
* @param arguments Arguments to the class
196-
* @param useTestDotJavaDotOpts Use test.java.opts as part of the VM argument string
197196
* @return The OutputAnalyzer with the results for the invocation.
198197
*/
199-
public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname, String[] arguments, boolean useTestDotJavaDotOpts) throws Exception {
198+
public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname, String[] arguments) throws Exception {
200199
ArrayList<String> finalargs = new ArrayList<String>();
201200

202201
String[] whiteboxOpts = new String[] {
@@ -205,30 +204,20 @@ public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname,
205204
"-cp", System.getProperty("java.class.path"),
206205
};
207206

208-
if (useTestDotJavaDotOpts) {
209-
// System.getProperty("test.java.opts") is '' if no options is set,
210-
// we need to skip such a result
211-
String[] externalVMOpts = new String[0];
212-
if (System.getProperty("test.java.opts") != null && System.getProperty("test.java.opts").length() != 0) {
213-
externalVMOpts = System.getProperty("test.java.opts").split(" ");
214-
}
215-
finalargs.addAll(Arrays.asList(externalVMOpts));
216-
}
217-
218207
finalargs.addAll(Arrays.asList(vmargs));
219208
finalargs.addAll(Arrays.asList(whiteboxOpts));
220209
finalargs.add(classname);
221210
finalargs.addAll(Arrays.asList(arguments));
222211

223-
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs.toArray(new String[0]));
212+
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs.toArray(String[]::new));
224213
OutputAnalyzer output = new OutputAnalyzer(pb.start());
225214
output.shouldHaveExitValue(0);
226215

227216
return output;
228217
}
229218

230219
private static void getMinInitialMaxHeap(String[] args, MinInitialMaxValues val) throws Exception {
231-
OutputAnalyzer output = runWhiteBoxTest(args, ErgoArgsPrinter.class.getName(), new String[] {}, false);
220+
OutputAnalyzer output = runWhiteBoxTest(args, ErgoArgsPrinter.class.getName(), new String[] {});
232221

233222
// the output we watch for has the following format:
234223
//

‎test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsErgo.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
* java.management/sun.management
3636
* @build sun.hotspot.WhiteBox
3737
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
38-
* sun.hotspot.WhiteBox$WhiteBoxPermission
39-
* @run main/othervm gc.arguments.TestUseCompressedOopsErgo -XX:+UseSerialGC
38+
* sun.hotspot.WhiteBox$WhiteBoxPermission
39+
* @run driver gc.arguments.TestUseCompressedOopsErgo -XX:+UseSerialGC
4040
*/
4141

4242
/*
@@ -51,8 +51,8 @@
5151
* java.management/sun.management
5252
* @build sun.hotspot.WhiteBox
5353
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
54-
* sun.hotspot.WhiteBox$WhiteBoxPermission
55-
* @run main/othervm gc.arguments.TestUseCompressedOopsErgo -XX:+UseParallelGC
54+
* sun.hotspot.WhiteBox$WhiteBoxPermission
55+
* @run driver gc.arguments.TestUseCompressedOopsErgo -XX:+UseParallelGC
5656
*/
5757

5858
/*
@@ -67,8 +67,8 @@
6767
* java.management/sun.management
6868
* @build sun.hotspot.WhiteBox
6969
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
70-
* sun.hotspot.WhiteBox$WhiteBoxPermission
71-
* @run main/othervm gc.arguments.TestUseCompressedOopsErgo -XX:+UseG1GC
70+
* sun.hotspot.WhiteBox$WhiteBoxPermission
71+
* @run driver gc.arguments.TestUseCompressedOopsErgo -XX:+UseG1GC
7272
*/
7373

7474
/*
@@ -83,8 +83,8 @@
8383
* java.management/sun.management
8484
* @build sun.hotspot.WhiteBox
8585
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
86-
* sun.hotspot.WhiteBox$WhiteBoxPermission
87-
* @run main/othervm gc.arguments.TestUseCompressedOopsErgo -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC
86+
* sun.hotspot.WhiteBox$WhiteBoxPermission
87+
* @run driver gc.arguments.TestUseCompressedOopsErgo -XX:+UnlockExperimentalVMOptions -XX:+UseShenandoahGC
8888
*/
8989

9090
public class TestUseCompressedOopsErgo {

‎test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsErgoTools.java

+4-15
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private static long getCompressedClassSpaceSize() {
5656

5757

5858
public static long getMaxHeapForCompressedOops(String[] vmargs) throws Exception {
59-
OutputAnalyzer output = runWhiteBoxTest(vmargs, DetermineMaxHeapForCompressedOops.class.getName(), new String[] {}, false);
59+
OutputAnalyzer output = runWhiteBoxTest(vmargs, DetermineMaxHeapForCompressedOops.class.getName(), new String[] {});
6060
return Long.parseLong(output.getStdout());
6161
}
6262

@@ -78,10 +78,9 @@ public static boolean is64bitVM() {
7878
* @param vmargs Arguments to the VM to run
7979
* @param classname Name of the class to run
8080
* @param arguments Arguments to the class
81-
* @param useTestDotJavaDotOpts Use test.java.opts as part of the VM argument string
8281
* @return The OutputAnalyzer with the results for the invocation.
8382
*/
84-
public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname, String[] arguments, boolean useTestDotJavaDotOpts) throws Exception {
83+
public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname, String[] arguments) throws Exception {
8584
ArrayList<String> finalargs = new ArrayList<String>();
8685

8786
String[] whiteboxOpts = new String[] {
@@ -90,22 +89,12 @@ public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname,
9089
"-cp", System.getProperty("java.class.path"),
9190
};
9291

93-
if (useTestDotJavaDotOpts) {
94-
// System.getProperty("test.java.opts") is '' if no options is set,
95-
// we need to skip such a result
96-
String[] externalVMOpts = new String[0];
97-
if (System.getProperty("test.java.opts") != null && System.getProperty("test.java.opts").length() != 0) {
98-
externalVMOpts = System.getProperty("test.java.opts").split(" ");
99-
}
100-
finalargs.addAll(Arrays.asList(externalVMOpts));
101-
}
102-
10392
finalargs.addAll(Arrays.asList(vmargs));
10493
finalargs.addAll(Arrays.asList(whiteboxOpts));
10594
finalargs.add(classname);
10695
finalargs.addAll(Arrays.asList(arguments));
10796

108-
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs.toArray(new String[0]));
97+
ProcessBuilder pb = GCArguments.createJavaProcessBuilder(finalargs.toArray(String[]::new));
10998
OutputAnalyzer output = new OutputAnalyzer(pb.start());
11099
output.shouldHaveExitValue(0);
111100
return output;
@@ -115,7 +104,7 @@ private static String[] join(String[] part1, String part2) {
115104
ArrayList<String> result = new ArrayList<String>();
116105
result.addAll(Arrays.asList(part1));
117106
result.add(part2);
118-
return result.toArray(new String[0]);
107+
return result.toArray(String[]::new);
119108
}
120109

121110
public static void checkCompressedOopsErgo(String[] gcflags) throws Exception {

‎test/hotspot/jtreg/gc/g1/TestHumongousCodeCacheRoots.java

+6-18
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
* java.management
3434
* @build sun.hotspot.WhiteBox
3535
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
36-
* sun.hotspot.WhiteBox$WhiteBoxPermission
36+
* sun.hotspot.WhiteBox$WhiteBoxPermission
3737
* @summary Humongous objects may have references from the code cache
38-
* @run main gc.g1.TestHumongousCodeCacheRoots
39-
*/
38+
* @run driver gc.g1.TestHumongousCodeCacheRoots
39+
*/
4040

4141
import jdk.test.lib.process.OutputAnalyzer;
4242
import jdk.test.lib.process.ProcessTools;
@@ -92,10 +92,9 @@ public class TestHumongousCodeCacheRoots {
9292
* @param vmargs Arguments to the VM to run
9393
* @param classname Name of the class to run
9494
* @param arguments Arguments to the class
95-
* @param useTestDotJavaDotOpts Use test.java.opts as part of the VM argument string
9695
* @return The OutputAnalyzer with the results for the invocation.
9796
*/
98-
public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname, String[] arguments, boolean useTestDotJavaDotOpts) throws Exception {
97+
public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname, String[] arguments) throws Exception {
9998
ArrayList<String> finalargs = new ArrayList<String>();
10099

101100
String[] whiteboxOpts = new String[] {
@@ -104,22 +103,12 @@ public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname,
104103
"-cp", System.getProperty("java.class.path"),
105104
};
106105

107-
if (useTestDotJavaDotOpts) {
108-
// System.getProperty("test.java.opts") is '' if no options is set,
109-
// we need to skip such a result
110-
String[] externalVMOpts = new String[0];
111-
if (System.getProperty("test.java.opts") != null && System.getProperty("test.java.opts").length() != 0) {
112-
externalVMOpts = System.getProperty("test.java.opts").split(" ");
113-
}
114-
finalargs.addAll(Arrays.asList(externalVMOpts));
115-
}
116-
117106
finalargs.addAll(Arrays.asList(vmargs));
118107
finalargs.addAll(Arrays.asList(whiteboxOpts));
119108
finalargs.add(classname);
120109
finalargs.addAll(Arrays.asList(arguments));
121110

122-
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(new String[0]));
111+
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(String[]::new));
123112
OutputAnalyzer output = new OutputAnalyzer(pb.start());
124113
output.shouldHaveExitValue(0);
125114
return output;
@@ -133,8 +122,7 @@ public static void main(String[] args) throws Exception {
133122
"-XX:+G1VerifyHeapRegionCodeRoots", "-XX:+VerifyAfterGC", // make sure that verification is run
134123
};
135124

136-
runWhiteBoxTest(baseArguments, TestHumongousCodeCacheRootsHelper.class.getName(),
137-
new String[] {}, false);
125+
runWhiteBoxTest(baseArguments, TestHumongousCodeCacheRootsHelper.class.getName(), new String[] { });
138126
}
139127
}
140128

‎test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java

+12-25
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @requires test.vm.gc.nvdimm
3131
* @library /test/lib
3232
* @modules java.base/jdk.internal.misc
33-
* @run main gc.nvdimm.TestAllocateOldGenAt
33+
* @run driver gc.nvdimm.TestAllocateOldGenAt
3434
*/
3535

3636
import jdk.test.lib.JDKToolFinder;
@@ -40,40 +40,27 @@
4040
import java.util.Collections;
4141

4242
public class TestAllocateOldGenAt {
43-
private static ArrayList<String> commonOpts;
43+
private static String[] commonFlags;
4444

4545
public static void main(String args[]) throws Exception {
46-
commonOpts = new ArrayList<>();
47-
48-
String testVmOptsStr = System.getProperty("test.java.opts");
49-
if (!testVmOptsStr.isEmpty()) {
50-
String[] testVmOpts = testVmOptsStr.split(" ");
51-
Collections.addAll(commonOpts, testVmOpts);
52-
}
5346
String test_dir = System.getProperty("test.dir", ".");
54-
Collections.addAll(commonOpts, new String[] {"-XX:+UnlockExperimentalVMOptions",
55-
"-XX:AllocateOldGenAt=" + test_dir,
56-
"-Xmx32m",
57-
"-Xms32m",
58-
"-version"});
47+
commonFlags = new String[] {
48+
"-XX:+UnlockExperimentalVMOptions",
49+
"-XX:AllocateOldGenAt=" + test_dir,
50+
"-Xmx32m",
51+
"-Xms32m",
52+
"-version"};
5953

6054
runTest("-XX:+UseG1GC");
6155
runTest("-XX:+UseParallelGC");
6256
}
6357

6458
private static void runTest(String... extraFlags) throws Exception {
65-
ArrayList<String> testOpts = new ArrayList<>();
66-
Collections.addAll(testOpts, commonOpts.toArray(new String[commonOpts.size()]));
67-
Collections.addAll(testOpts, extraFlags);
68-
69-
System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
70-
for (int i = 0; i < testOpts.size(); i += 1) {
71-
System.out.print(" " + testOpts.get(i));
72-
}
73-
System.out.println();
74-
59+
ArrayList<String> flags = new ArrayList<>();
60+
Collections.addAll(flags, commonFlags);
61+
Collections.addAll(flags, extraFlags);
7562
ProcessBuilder pb =
76-
ProcessTools.createJavaProcessBuilder(testOpts.toArray(new String[testOpts.size()]));
63+
ProcessTools.createJavaProcessBuilder(true, flags.toArray(String[]::new));
7764
OutputAnalyzer output = new OutputAnalyzer(pb.start());
7865

7966
output.shouldHaveExitValue(0);

‎test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java

+15-25
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @requires test.vm.gc.nvdimm
3131
* @library /test/lib
3232
* @modules java.base/jdk.internal.misc
33-
* @run main gc.nvdimm.TestAllocateOldGenAtError
33+
* @run driver gc.nvdimm.TestAllocateOldGenAtError
3434
*/
3535

3636
import java.io.File;
@@ -42,29 +42,23 @@
4242
import java.util.UUID;
4343

4444
public class TestAllocateOldGenAtError {
45-
private static ArrayList<String> commonOpts;
45+
private static String[] commonFlags;
4646

4747
public static void main(String args[]) throws Exception {
48-
commonOpts = new ArrayList<>();
49-
50-
String testVmOptsStr = System.getProperty("test.java.opts");
51-
if (!testVmOptsStr.isEmpty()) {
52-
String[] testVmOpts = testVmOptsStr.split(" ");
53-
Collections.addAll(commonOpts, testVmOpts);
54-
}
5548
String test_dir = System.getProperty("test.dir", ".");
5649

5750
File f = null;
5851
do {
5952
f = new File(test_dir, UUID.randomUUID().toString());
6053
} while(f.exists());
6154

62-
Collections.addAll(commonOpts, new String[] {"-XX:+UnlockExperimentalVMOptions",
63-
"-XX:AllocateOldGenAt=" + f.getName(),
64-
"-Xlog:gc+heap=info",
65-
"-Xmx32m",
66-
"-Xms32m",
67-
"-version"});
55+
commonFlags = new String[] {
56+
"-XX:+UnlockExperimentalVMOptions",
57+
"-XX:AllocateOldGenAt=" + f.getName(),
58+
"-Xlog:gc+heap=info",
59+
"-Xmx32m",
60+
"-Xms32m",
61+
"-version"};
6862

6963
testG1();
7064
testParallelOld();
@@ -83,24 +77,20 @@ private static void testG1() throws Exception {
8377

8478
private static void testParallelOld() throws Exception {
8579
System.out.println("Testing Parallel GC");
80+
8681
OutputAnalyzer output = runTest("-XX:+UseParallelGC");
82+
8783
output.shouldContain("Error occurred during initialization of VM");
8884
output.shouldNotHaveExitValue(0);
8985
}
9086

9187
private static OutputAnalyzer runTest(String... extraFlags) throws Exception {
92-
ArrayList<String> testOpts = new ArrayList<>();
93-
Collections.addAll(testOpts, commonOpts.toArray(new String[commonOpts.size()]));
94-
Collections.addAll(testOpts, extraFlags);
95-
96-
System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
97-
for (int i = 0; i < testOpts.size(); i += 1) {
98-
System.out.print(" " + testOpts.get(i));
99-
}
100-
System.out.println();
88+
ArrayList<String> flags = new ArrayList<>();
89+
Collections.addAll(flags, commonFlags);
90+
Collections.addAll(flags, extraFlags);
10191

10292
ProcessBuilder pb =
103-
ProcessTools.createJavaProcessBuilder(testOpts.toArray(new String[testOpts.size()]));
93+
ProcessTools.createJavaProcessBuilder(true, flags.toArray(String[]::new));
10494
OutputAnalyzer output = new OutputAnalyzer(pb.start());
10595
return output;
10696
}

‎test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java

+17-37
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @library /test/lib
3232
* @modules java.base/jdk.internal.misc
3333
* @requires vm.bits == "64"
34-
* @run main gc.nvdimm.TestAllocateOldGenAtMultiple -XX:+UseG1GC
34+
* @run driver gc.nvdimm.TestAllocateOldGenAtMultiple
3535
*/
3636

3737
import jdk.test.lib.JDKToolFinder;
@@ -42,49 +42,29 @@
4242

4343
public class TestAllocateOldGenAtMultiple {
4444
public static void main(String args[]) throws Exception {
45-
ArrayList<String> vmOpts = new ArrayList<>();
46-
String[] testVmOpts = null;
47-
45+
ArrayList<String> flags = new ArrayList<>();
4846
String test_dir = System.getProperty("test.dir", ".");
4947

50-
String testVmOptsStr = System.getProperty("test.java.opts");
51-
if (!testVmOptsStr.isEmpty()) {
52-
testVmOpts = testVmOptsStr.split(" ");
53-
}
54-
55-
// Extra options for each of the sub-tests
56-
String[] extraOptsList = new String[] {
57-
"-Xmx32m -Xms32m -XX:+UseCompressedOops", // 1. With compressedoops enabled.
58-
"-Xmx32m -Xms32m -XX:-UseCompressedOops", // 2. With compressedoops disabled.
59-
"-Xmx32m -Xms32m -XX:HeapBaseMinAddress=3g", // 3. With user specified HeapBaseMinAddress.
60-
"-Xmx4g -Xms4g", // 4. With larger heap size (UnscaledNarrowOop not possible).
61-
"-Xmx4g -Xms4g -XX:+UseLargePages", // 5. Set UseLargePages.
62-
"-Xmx4g -Xms4g -XX:+UseNUMA" // 6. Set UseNUMA.
48+
// Extra flags for each of the sub-tests
49+
String[][] extraFlagsList = {
50+
{"-Xmx32m", "-Xms32m", "-XX:+UseCompressedOops"}, // 1. With compressedoops enabled.
51+
{"-Xmx32m", "-Xms32m", "-XX:-UseCompressedOops"}, // 2. With compressedoops disabled.
52+
{"-Xmx32m", "-Xms32m", "-XX:HeapBaseMinAddress=3g"}, // 3. With user specified HeapBaseMinAddress.
53+
{"-Xmx4g", "-Xms4g"}, // 4. With larger heap size (UnscaledNarrowOop not possible).
54+
{"-Xmx4g", "-Xms4g", "-XX:+UseLargePages"}, // 5. Set UseLargePages.
55+
{"-Xmx4g", "-Xms4g", "-XX:+UseNUMA"} // 6. Set UseNUMA.
6356
};
6457

65-
for(String extraOpts : extraOptsList) {
66-
vmOpts.clear();
67-
if(testVmOpts != null) {
68-
Collections.addAll(vmOpts, testVmOpts);
69-
}
70-
// Add extra options specific to the sub-test.
71-
String[] extraOptsArray = extraOpts.split(" ");
72-
if(extraOptsArray != null) {
73-
Collections.addAll(vmOpts, extraOptsArray);
74-
}
75-
// Add common options
76-
Collections.addAll(vmOpts, new String[] {"-XX:+UnlockExperimentalVMOptions",
58+
for (String[] extraFlags : extraFlagsList) {
59+
flags.clear();
60+
// Add extra flags specific to the sub-test.
61+
Collections.addAll(flags, extraFlags);
62+
// Add common flags
63+
Collections.addAll(flags, new String[] {"-XX:+UnlockExperimentalVMOptions",
7764
"-XX:AllocateOldGenAt=" + test_dir,
7865
"-version"});
79-
80-
System.out.print("Testing:\n" + JDKToolFinder.getJDKTool("java"));
81-
for (int i = 0; i < vmOpts.size(); i += 1) {
82-
System.out.print(" " + vmOpts.get(i));
83-
}
84-
System.out.println();
85-
8666
ProcessBuilder pb =
87-
ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
67+
ProcessTools.createJavaProcessBuilder(true, flags.toArray(String[]::new));
8868
OutputAnalyzer output = new OutputAnalyzer(pb.start());
8969

9070
System.out.println("Output:\n" + output.getOutput());

‎test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java

+11-19
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
* @requires test.vm.gc.nvdimm
3232
* @build sun.hotspot.WhiteBox
3333
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
34-
* @run main gc.nvdimm.TestHumongousObjectsOnNvdimm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
35-
* -XX:+WhiteBoxAPI
34+
* sun.hotspot.WhiteBox$WhiteBoxPermission
35+
* @run driver gc.nvdimm.TestHumongousObjectsOnNvdimm
3636
*/
3737

3838
import jdk.test.lib.process.OutputAnalyzer;
@@ -50,39 +50,31 @@
5050
*/
5151
public class TestHumongousObjectsOnNvdimm {
5252

53-
private static ArrayList<String> testOpts;
53+
private static String[] commonFlags;
5454

5555
public static void main(String args[]) throws Exception {
56-
testOpts = new ArrayList<>();
57-
58-
String[] common_options = new String[] {
56+
commonFlags = new String[] {
5957
"-Xbootclasspath/a:.",
6058
"-XX:+UnlockExperimentalVMOptions",
6159
"-XX:+UnlockDiagnosticVMOptions",
6260
"-XX:+WhiteBoxAPI",
63-
"-XX:AllocateOldGenAt="+System.getProperty("test.dir", "."),
61+
"-XX:AllocateOldGenAt=" + System.getProperty("test.dir", "."),
6462
"-Xms10M", "-Xmx10M",
6563
"-XX:G1HeapRegionSize=1m"
6664
};
6765

68-
String testVmOptsStr = System.getProperty("test.java.opts");
69-
if (!testVmOptsStr.isEmpty()) {
70-
String[] testVmOpts = testVmOptsStr.split(" ");
71-
Collections.addAll(testOpts, testVmOpts);
72-
}
73-
Collections.addAll(testOpts, common_options);
74-
7566
// Test with G1 GC
7667
runTest("-XX:+UseG1GC");
7768
}
7869

7970
private static void runTest(String... extraFlags) throws Exception {
80-
Collections.addAll(testOpts, extraFlags);
81-
testOpts.add(HumongousObjectTest.class.getName());
82-
System.out.println(testOpts);
71+
ArrayList<String> flags = new ArrayList<>();
72+
Collections.addAll(flags, commonFlags);
73+
Collections.addAll(flags, extraFlags);
74+
flags.add(HumongousObjectTest.class.getName());
8375

84-
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false,
85-
testOpts.toArray(new String[testOpts.size()]));
76+
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
77+
flags.toArray(String[]::new));
8678

8779
OutputAnalyzer output = new OutputAnalyzer(pb.start());
8880
output.shouldHaveExitValue(0);

‎test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java

+11-20
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
* @library /test/lib
3232
* @build sun.hotspot.WhiteBox
3333
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
34-
* @run main gc.nvdimm.TestOldObjectsOnNvdimm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
35-
* -XX:+WhiteBoxAPI
34+
* sun.hotspot.WhiteBox$WhiteBoxPermission
35+
* @run driver gc.nvdimm.TestOldObjectsOnNvdimm
3636
*/
3737

3838
import jdk.test.lib.process.OutputAnalyzer;
@@ -50,39 +50,30 @@
5050
public class TestOldObjectsOnNvdimm {
5151

5252
public static final int ALLOCATION_SIZE = 100;
53-
private static ArrayList<String> testOpts;
53+
private static String[] commonFlags;
5454

5555
public static void main(String args[]) throws Exception {
56-
testOpts = new ArrayList<>();
57-
58-
String[] common_options = new String[] {
56+
commonFlags = new String[] {
5957
"-Xbootclasspath/a:.",
6058
"-XX:+UnlockExperimentalVMOptions",
6159
"-XX:+UnlockDiagnosticVMOptions",
6260
"-XX:+WhiteBoxAPI",
63-
"-XX:AllocateOldGenAt="+System.getProperty("test.dir", "."),
61+
"-XX:AllocateOldGenAt=" + System.getProperty("test.dir", "."),
6462
"-Xms10M", "-Xmx10M",
6563
"-XX:MaxTenuringThreshold=1" // Promote objects to Old Gen
6664
};
67-
68-
String testVmOptsStr = System.getProperty("test.java.opts");
69-
if (!testVmOptsStr.isEmpty()) {
70-
String[] testVmOpts = testVmOptsStr.split(" ");
71-
Collections.addAll(testOpts, testVmOpts);
72-
}
73-
Collections.addAll(testOpts, common_options);
74-
7565
runTest("-XX:+UseG1GC");
7666
runTest("-XX:+UseParallelGC");
7767
}
7868

7969
private static void runTest(String... extraFlags) throws Exception {
80-
Collections.addAll(testOpts, extraFlags);
81-
testOpts.add(OldObjectTest.class.getName());
82-
System.out.println(testOpts);
70+
ArrayList<String> flags = new ArrayList<>();
71+
Collections.addAll(flags, commonFlags);
72+
Collections.addAll(flags, extraFlags);
73+
flags.add(OldObjectTest.class.getName());
8374

84-
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false,
85-
testOpts.toArray(new String[testOpts.size()]));
75+
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
76+
flags.toArray(String[]::new));
8677

8778
OutputAnalyzer output = new OutputAnalyzer(pb.start());
8879
System.out.println(output.getStdout());

‎test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java

+11-20
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
* @library /test/lib
3232
* @build sun.hotspot.WhiteBox
3333
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
34-
* @run main gc.nvdimm.TestYoungObjectsOnDram -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
35-
* -XX:+WhiteBoxAPI
34+
* sun.hotspot.WhiteBox$WhiteBoxPermission
35+
* @run driver gc.nvdimm.TestYoungObjectsOnDram
3636
*/
3737

3838
import jdk.test.lib.process.OutputAnalyzer;
@@ -50,40 +50,31 @@
5050
public class TestYoungObjectsOnDram {
5151

5252
public static final int ALLOCATION_SIZE = 100;
53-
private static ArrayList<String> testOpts;
53+
private static String[] commonFlags;
5454

5555
public static void main(String args[]) throws Exception {
56-
testOpts = new ArrayList<>();
57-
58-
String[] common_options = new String[] {
56+
commonFlags = new String[] {
5957
"-Xbootclasspath/a:.",
6058
"-XX:+UnlockExperimentalVMOptions",
6159
"-XX:+UnlockDiagnosticVMOptions",
6260
"-XX:+WhiteBoxAPI",
63-
"-XX:AllocateOldGenAt="+System.getProperty("test.dir", "."),
61+
"-XX:AllocateOldGenAt=" + System.getProperty("test.dir", "."),
6462
"-XX:SurvivorRatio=1", // Survivor-to-eden ratio is 1:1
6563
"-Xms10M", "-Xmx10M",
6664
"-XX:InitialTenuringThreshold=15" // avoid promotion of objects to Old Gen
6765
};
68-
69-
String testVmOptsStr = System.getProperty("test.java.opts");
70-
if (!testVmOptsStr.isEmpty()) {
71-
String[] testVmOpts = testVmOptsStr.split(" ");
72-
Collections.addAll(testOpts, testVmOpts);
73-
}
74-
Collections.addAll(testOpts, common_options);
75-
7666
runTest("-XX:+UseG1GC");
7767
runTest("-XX:+UseParallelGC");
7868
}
7969

8070
private static void runTest(String... extraFlags) throws Exception {
81-
Collections.addAll(testOpts, extraFlags);
82-
testOpts.add(YoungObjectTest.class.getName());
83-
System.out.println(testOpts);
71+
ArrayList<String> flags = new ArrayList<>();
72+
Collections.addAll(flags, commonFlags);
73+
Collections.addAll(flags, extraFlags);
74+
flags.add(YoungObjectTest.class.getName());
8475

85-
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false,
86-
testOpts.toArray(new String[testOpts.size()]));
76+
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
77+
flags.toArray(String[]::new));
8778

8879
OutputAnalyzer output = new OutputAnalyzer(pb.start());
8980
System.out.println(output.getStdout());

0 commit comments

Comments
 (0)
Please sign in to comment.