//package com.nowjava;/** 时 代 J a v a - N o w J a v a . c o m 提供 **/
import java.lang.reflect.Field;
import sun.misc.Unsafe;
public class Main {
public static void main(String[] argv) throws Exception {
hardCrash();
}
/**
* Hard-Crash the JVM by accessing memory at location 0x00000000 (or as in 64-Bit: 0x0000000000000000), also called the null-address.
**/
public static final void hardCrash() {
/**
* N o w J a v a . c o m - 时 代 Java 提 供
**/
Unsafe theUnsafe = (Unsafe) getFieldContent(Unsafe.class, null,
"theUnsafe");
theUnsafe.getByte(0);
}
public static final Object getFieldContent(Class<?> objectClass,
Object object, String fieldName) {
System.out.println("Reflection Access: " + objectClass + " @--> "
+ fieldName);
try {
Field field = objectClass.getDeclaredField(fieldName);
field.setAccessible(true);
try {
return field.get(object);
} catch (IllegalArgumentException e) {
e.printStackTrace();
return null;
} catch (IllegalAccessException e) {
e.printStackTrace();
return null;
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。