Skip to content

Instantly share code, notes, and snippets.

@yasuflatland-lf
Last active December 29, 2015 07:49
Show Gist options
  • Select an option

  • Save yasuflatland-lf/7638555 to your computer and use it in GitHub Desktop.

Select an option

Save yasuflatland-lf/7638555 to your computer and use it in GitHub Desktop.
This code will crash JVM to invoke with following parameter.java -Xbootclasspath/p:. Crash
import sun.misc.Unsafe;
import java.lang.reflect.Field;
public class Crash {
public static void main(String... args) throws Exception {
getUnsafe().getByte(0);
}
private static Unsafe getUnsafe() throws NoSuchFieldException, IllegalAccessException {
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
theUnsafe.setAccessible(true);
return (Unsafe) theUnsafe.get(null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment