Package org.jctools.util
Class UnsafeAccess
- java.lang.Object
-
- org.jctools.util.UnsafeAccess
-
public class UnsafeAccess extends Object
Why should we resort to using Unsafe?
- To construct class fields which allow volatile/ordered/plain access: This requirement is covered by
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. - To construct flavors of
AtomicReferenceArray
. - Other use cases exist but are not present in this library yet.
- Author:
- nitsanw
- To construct class fields which allow volatile/ordered/plain access: This requirement is covered by
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
SUPPORTS_GET_AND_ADD_LONG
static boolean
SUPPORTS_GET_AND_SET_REF
static sun.misc.Unsafe
UNSAFE
-
Constructor Summary
Constructors Constructor Description UnsafeAccess()
-
-
-
Method Detail
-
fieldOffset
public static long fieldOffset(Class clz, String fieldName) throws RuntimeException
- Throws:
RuntimeException
-
-