@SuppressAnimalSniffer public final class UnsafeAccess extends Object
Note that you can force RxJava to not use Unsafe API by setting any value to System Property
rx.unsafe-disable
.
Modifier and Type | Field and Description |
---|---|
static sun.misc.Unsafe |
UNSAFE |
Modifier and Type | Method and Description |
---|---|
static long |
addressOf(Class<?> clazz,
String fieldName)
Returns the address of the specific field on the class and
wraps a NoSuchFieldException into an internal error.
|
static boolean |
compareAndSwapInt(Object obj,
long offset,
int expected,
int newValue) |
static int |
getAndAddInt(Object obj,
long offset,
int n) |
static int |
getAndIncrementInt(Object obj,
long offset) |
static int |
getAndSetInt(Object obj,
long offset,
int newValue) |
static boolean |
isUnsafeAvailable() |
public static boolean isUnsafeAvailable()
public static int getAndIncrementInt(Object obj, long offset)
public static int getAndAddInt(Object obj, long offset, int n)
public static int getAndSetInt(Object obj, long offset, int newValue)
public static boolean compareAndSwapInt(Object obj, 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 classfieldName
- the target field nameCopyright © 2017. All rights reserved.