This commit is contained in:
Alexey Kudravtsev
2015-11-10 14:43:47 +03:00
parent 669cb8444c
commit 39df36d294
@@ -35,14 +35,16 @@ import java.lang.reflect.Modifier;
* - new methods "forFieldXXX" added that search by field type instead of field name, which is useful in scrambled classes
*/
public class AtomicFieldUpdater<T,V> {
private static final Unsafe unsafe = getUnsafe();
@NotNull
public static Unsafe getUnsafe() {
Unsafe unsafe = ReflectionUtil.getStaticFieldValue(Unsafe.class, Unsafe.class, "theUnsafe");
private static final Unsafe unsafe;
static {
unsafe = ReflectionUtil.getStaticFieldValue(Unsafe.class, Unsafe.class, "theUnsafe");
if (unsafe == null) {
throw new RuntimeException("Could not find 'theUnsafe' field in the " + Unsafe.class);
}
}
@NotNull
public static Unsafe getUnsafe() {
return unsafe;
}