在staitc块中给static final赋值,若有异常,会有编译期异常Variable ‘UNSAFE’ might not have been initialized。why?
private static final sun.misc.Unsafe UNSAFE;
static {
try {
Field field = Unsafe.class.getDeclaredField("theUnsafe");
field.setAccessible(true);
UNSAFE = (Unsafe) field.get(null);
} catch (Exception e) {
}
}