|
31 | 31 | * @bug 8306583
|
32 | 32 | */
|
33 | 33 |
|
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; |
37 | 37 |
|
38 |
| - public class TestCDSVMCrash { |
| 38 | +public class TestCDSVMCrash { |
39 | 39 |
|
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 { |
57 | 58 | CDSTestUtils.executeAndLog(pb, "cds_vm_crash");
|
58 | 59 | throw new Error("Expected VM to crash");
|
59 |
| - } catch(RuntimeException e) { |
| 60 | + } catch(RuntimeException e) { |
60 | 61 | if (!e.getMessage().equals("Hotspot crashed")) {
|
61 |
| - throw new Error("Expected message: Hotspot crashed"); |
| 62 | + throw new Error("Expected message: Hotspot crashed"); |
62 | 63 | }
|
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 | + } |
70 | 65 | System.out.println("PASSED");
|
71 |
| - } |
72 |
| - } |
| 66 | + } |
| 67 | +} |
1 commit comments
openjdk-notifier[bot] commentedon Jun 23, 2024
Review
Issues