Class CrashExample will cause JVM crashes on JDK6 and JDK7, while Crash does not crash on JDK7, although it hangs forever on JDK6.
public class CrashExample {
public static void main(String[] args) {
new sun.dc.pr.PathDasher(null);
}
}
public class Crash {
public static void main(String[] args) {
try {
startSecondJVM();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Hello crash.");
}
public static void startSecondJVM() throws Exception {
String separator = System.getProperty("file.separator");
String classpath = System.getProperty("java.class.path");
String path = System.getProperty("java.home")
+ separator + "bin" + separator + "java";
System.out.println("path="+path);
ProcessBuilder processBuilder =
new ProcessBuilder(path, "-cp",
classpath,
CrashExample.class.getName());
// processBuilder.inheritIO();
Process process = processBuilder.start();
process.waitFor();
}
}
No comments:
Post a Comment