public class UnsafeAccess
extends java.lang.Object
AtomicReferenceFieldUpdater
and similar but their performance is arguably worse than the DIY approach
(depending on JVM version) while Unsafe intrinsification is a far lesser challenge for JIT compilers.
AtomicReferenceArray
.
Modifier and Type | Field and Description |
---|---|
static boolean |
SUPPORTS_GET_AND_ADD_LONG |
static boolean |
SUPPORTS_GET_AND_SET_REF |
static sun.misc.Unsafe |
UNSAFE |
Constructor and Description |
---|
UnsafeAccess() |
Modifier and Type | Method and Description |
---|---|
static long |
fieldOffset(java.lang.Class clz,
java.lang.String fieldName) |
private static sun.misc.Unsafe |
getUnsafe() |
private static boolean |
hasGetAndAddLongSupport() |
private static boolean |
hasGetAndSetSupport() |
public static final boolean SUPPORTS_GET_AND_SET_REF
public static final boolean SUPPORTS_GET_AND_ADD_LONG
public static final sun.misc.Unsafe UNSAFE
private static sun.misc.Unsafe getUnsafe()
private static boolean hasGetAndSetSupport()
private static boolean hasGetAndAddLongSupport()
public static long fieldOffset(java.lang.Class clz, java.lang.String fieldName) throws java.lang.RuntimeException
java.lang.RuntimeException