public static Unsafe getUnsafe() {
try {
return Unsafe.getUnsafe();
} catch (SecurityException se) {
try {
return java.security.AccessController.doPrivileged(new java.security.PrivilegedExceptionAction<Unsafe>() {
@Override
public Unsafe run() throws Exception {
final Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class;
if (true) {
final Field f = k.getDeclaredField("theUnsafe");
f.setAccessible(true);
final Object x = f.get(null);
return k.cast(x);
} else {
for (Field f : k.getDeclaredFields()) {
f.setAccessible(true);
final Object x = f.get(null);
if (k.isInstance(x))
return k.cast(x);
}
throw new NoSuchFieldError("the Unsafe");
}
}
});
} catch (java.security.PrivilegedActionException e) {
throw new RuntimeException("Could not initialize intrinsics", e.getCause());
}
}
}
why would you use "if(true) .... else ..." in this method? do you forget to fill the expression of if?
why would you use "if(true) .... else ..." in this method? do you forget to fill the expression of if?