Skip to content

Commit 2d89cc2

Browse files
author
Amos Shi
committedJun 23, 2024
8321933: TestCDSVMCrash.java spawns two processes
Backport-of: 1fde8b868a0e40fb79de505106ef07e3dccbd1de
1 parent d0e54e9 commit 2d89cc2

File tree

1 file changed

+27
-32
lines changed

1 file changed

+27
-32
lines changed
 

‎test/hotspot/jtreg/runtime/cds/TestCDSVMCrash.java

+27-32
Original file line numberDiff line numberDiff line change
@@ -31,42 +31,37 @@
3131
* @bug 8306583
3232
*/
3333

34-
import jdk.test.lib.cds.CDSTestUtils;
35-
import jdk.test.lib.process.OutputAnalyzer;
36-
import jdk.test.lib.process.ProcessTools;
34+
import jdk.test.lib.cds.CDSTestUtils;
35+
import jdk.test.lib.process.OutputAnalyzer;
36+
import jdk.test.lib.process.ProcessTools;
3737

38-
public class TestCDSVMCrash {
38+
public class TestCDSVMCrash {
3939

40-
public static void main(String[] args) throws Exception {
41-
if (args.length == 1) {
42-
// This should guarantee to throw:
43-
// java.lang.OutOfMemoryError: Requested array size exceeds VM limit
44-
try {
45-
Object[] oa = new Object[Integer.MAX_VALUE];
46-
throw new Error("OOME not triggered");
47-
} catch (OutOfMemoryError err) {
48-
throw new Error("OOME didn't abort JVM!");
49-
}
50-
}
51-
// else this is the main test
52-
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+CrashOnOutOfMemoryError",
53-
"-XX:-CreateCoredumpOnCrash", "-Xmx128m", "-Xshare:on", TestCDSVMCrash.class.getName(),"throwOOME");
54-
OutputAnalyzer output = new OutputAnalyzer(pb.start());
55-
// executeAndLog should throw an exception in the VM crashed
56-
try {
40+
public static void main(String[] args) throws Exception {
41+
if (args.length == 1) {
42+
// This should guarantee to throw:
43+
// java.lang.OutOfMemoryError: Requested array size exceeds VM limit
44+
try {
45+
Object[] oa = new Object[Integer.MAX_VALUE];
46+
throw new Error("OOME not triggered");
47+
} catch (OutOfMemoryError err) {
48+
throw new Error("OOME didn't abort JVM!");
49+
}
50+
}
51+
// else this is the main test
52+
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+CrashOnOutOfMemoryError",
53+
"-XX:-CreateCoredumpOnCrash", "-Xmx128m",
54+
"-Xshare:on", TestCDSVMCrash.class.getName(),
55+
"throwOOME");
56+
// executeAndLog should throw an exception in the VM crashed
57+
try {
5758
CDSTestUtils.executeAndLog(pb, "cds_vm_crash");
5859
throw new Error("Expected VM to crash");
59-
} catch(RuntimeException e) {
60+
} catch(RuntimeException e) {
6061
if (!e.getMessage().equals("Hotspot crashed")) {
61-
throw new Error("Expected message: Hotspot crashed");
62+
throw new Error("Expected message: Hotspot crashed");
6263
}
63-
}
64-
int exitValue = output.getExitValue();
65-
if (0 == exitValue) {
66-
//expecting a non zero value
67-
throw new Error("Expected to get non zero exit value");
68-
}
69-
output.shouldContain("A fatal error has been detected by the Java Runtime Environment");
64+
}
7065
System.out.println("PASSED");
71-
}
72-
}
66+
}
67+
}

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Jun 23, 2024

@openjdk-notifier[bot]
Please sign in to comment.