< prev index next >

test/runtime/ErrorHandling/CreateCoredumpOnCrash.java

Print this page




  39     private static class Crasher {
  40         public static void main(String[] args) {
  41             Utils.getUnsafe().putInt(0L, 0);
  42         }
  43     }
  44 
  45     public static void main(String[] args) throws Exception {
  46         runTest("-XX:-CreateCoredumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped");
  47 
  48         if (Platform.isWindows()) {
  49             // The old CreateMinidumpOnCrash option should still work
  50             runTest("-XX:-CreateMinidumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped");
  51         } else {
  52             runTest("-XX:+CreateCoredumpOnCrash").shouldNotContain("CreateCoredumpOnCrash turned off, no core file dumped");
  53         }
  54 
  55     }
  56     public static OutputAnalyzer runTest(String option) throws Exception {
  57         return new OutputAnalyzer(
  58             ProcessTools.createJavaProcessBuilder(
  59             "-Xmx64m", "-XX:-TransmitErrorReport", "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName())
  60             .start());
  61     }
  62 }


  39     private static class Crasher {
  40         public static void main(String[] args) {
  41             Utils.getUnsafe().putInt(0L, 0);
  42         }
  43     }
  44 
  45     public static void main(String[] args) throws Exception {
  46         runTest("-XX:-CreateCoredumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped");
  47 
  48         if (Platform.isWindows()) {
  49             // The old CreateMinidumpOnCrash option should still work
  50             runTest("-XX:-CreateMinidumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped");
  51         } else {
  52             runTest("-XX:+CreateCoredumpOnCrash").shouldNotContain("CreateCoredumpOnCrash turned off, no core file dumped");
  53         }
  54 
  55     }
  56     public static OutputAnalyzer runTest(String option) throws Exception {
  57         return new OutputAnalyzer(
  58             ProcessTools.createJavaProcessBuilder(
  59             "-Xmx64m", "-XX:-TransmitErrorReport", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName())
  60             .start());
  61     }
  62 }
< prev index next >