public final class UnsafeAccess extends Object
| Modifier and Type | Field and Description |
|---|---|
static sun |
UNSAFE
|
| Modifier and Type | Method and Description |
|---|---|
static long |
addressOf(Class
Returns the address of the specific field on the class and wraps a NoSuchFieldException into an internal error.
|
static boolean |
compareAndSwapInt(Object
|
static int |
getAndAddInt(Object
|
static int |
getAndIncrementInt(Object
|
static int |
getAndSetInt(Object
|
static boolean |
isUnsafeAvailable()
|
public static final boolean isUnsafeAvailable()
public static int getAndIncrementInt(Objectobj, long offset)
public static int getAndAddInt(Objectobj, long offset, int n)
public static int getAndSetInt(Objectobj, long offset, int newValue)
public static boolean compareAndSwapInt(Objectobj, long offset, int expected, int newValue)
public static long addressOf(Class<?> clazz, String fieldName)
One can avoid using static initializers this way and just assign the address directly to the target static field.
clazz - the target class
fieldName - the target field name