Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // (c) 2013 http://twitter.com/mihi42 //
- import java.lang.reflect.Field;
- import java.lang.reflect.Method;
- import sun.misc.Unsafe;
- public class CrashWhenDebugged {
- public static void main(String[] args) throws Exception {
- Field ff = Unsafe.class.getDeclaredField("theUnsafe");
- ff.setAccessible(true);
- Unsafe u = (Unsafe) ff.get(null);
- final Field g = Thread.class.getDeclaredField("group");
- g.setAccessible(true);
- Thread t = new Thread("Killer") {
- public void run() {
- try {
- Thread.sleep(200);
- g.set(this, null);
- } catch (Exception ex) {
- }
- }
- };
- u.putInt(t, u.objectFieldOffset(g), 3);
- Method m = Thread.class.getDeclaredMethod("start0");
- m.setAccessible(true);
- m.invoke(t);
- t.join();
- System.out.println("I survived!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment