Package org.jctools.util
Class UnsafeAccess
- java.lang.Object
-
- org.jctools.util.UnsafeAccess
-
public class UnsafeAccess extends java.lang.ObjectWhy should we resort to using Unsafe?
- To construct class fields which allow volatile/ordered/plain access: This requirement is covered by
AtomicReferenceFieldUpdaterand 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.
- To construct class fields which allow volatile/ordered/plain access: This requirement is covered by
-
-
Field Summary
Fields Modifier and Type Field Description static booleanSUPPORTS_GET_AND_ADD_LONGstatic booleanSUPPORTS_GET_AND_SET_REFstatic sun.misc.UnsafeUNSAFE
-
Constructor Summary
Constructors Constructor Description UnsafeAccess()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longfieldOffset(java.lang.Class clz, java.lang.String fieldName)private static sun.misc.UnsafegetUnsafe()private static booleanhasGetAndAddLongSupport()private static booleanhasGetAndSetSupport()
-
-
-
Method Detail
-
getUnsafe
private static sun.misc.Unsafe getUnsafe()
-
hasGetAndSetSupport
private static boolean hasGetAndSetSupport()
-
hasGetAndAddLongSupport
private static boolean hasGetAndAddLongSupport()
-
fieldOffset
public static long fieldOffset(java.lang.Class clz, java.lang.String fieldName) throws java.lang.RuntimeException- Throws:
java.lang.RuntimeException
-
-