public final class UnsafeUtil extends Object
Unsafe access.| 限定符和类型 | 类和说明 |
|---|---|
static class |
UnsafeUtil.UnsafeAccessor |
| 限定符和类型 | 方法和说明 |
|---|---|
static long |
addressOffset(ByteBuffer buffer)
Gets the offset of the
address field of the given
direct ByteBuffer. |
static int |
arrayBaseOffset(Class<?> clazz)
Reports the offset of the first element in the storage allocation of a
given array class.
|
static int |
arrayIndexScale(Class<?> clazz)
Reports the scale factor for addressing elements in the storage
allocation of a given array class.
|
static boolean |
getBoolean(boolean[] target,
long index) |
static boolean |
getBoolean(Object target,
long offset) |
static boolean |
getBooleanVolatile(boolean[] target,
long index) |
static byte |
getByte(byte[] target,
long index) |
static byte |
getByte(long address) |
static byte |
getByte(Object target,
long offset) |
static byte |
getByteVolatile(byte[] target,
long index) |
static double |
getDouble(double[] target,
long index) |
static double |
getDouble(Object target,
long offset) |
static double |
getDoubleVolatile(double[] target,
long index) |
static float |
getFloat(float[] target,
long index) |
static float |
getFloat(Object target,
long offset) |
static float |
getFloatVolatile(float[] target,
long index) |
static int |
getInt(int[] target,
long index) |
static int |
getInt(long address) |
static int |
getInt(Object target,
long offset) |
static int |
getIntVolatile(int[] target,
long index) |
static long |
getLong(long address) |
static long |
getLong(long[] target,
long index) |
static long |
getLong(Object target,
long offset) |
static long |
getLongVolatile(long[] target,
long index) |
static Object |
getObject(Object[] target,
long index) |
static Object |
getObject(Object target,
long offset) |
static Object |
getObjectVolatile(Object[] target,
long index) |
static ClassLoader |
getSystemClassLoader()
Returns the system
ClassLoader. |
static UnsafeUtil.UnsafeAccessor |
getUnsafeAccessor()
Get a
UnsafeUtil.UnsafeAccessor appropriate for the platform. |
static boolean |
hasUnsafe()
Whether or not can use the unsafe api.
|
static String |
moveToString(char[] chars)
Returns a new
String backed by the given chars. |
static long |
objectFieldOffset(Class<?> clazz,
String fieldName)
Returns the offset of the provided class and fieldName, or
-1 if sun.misc.Unsafe is not
available. |
static long |
objectFieldOffset(Field field)
Returns the offset of the provided field, or
-1 if sun.misc.Unsafe is not
available. |
static void |
putBoolean(boolean[] target,
long index,
boolean value) |
static void |
putBoolean(Object target,
long offset,
boolean value) |
static void |
putBooleanVolatile(boolean[] target,
long index,
boolean value) |
static void |
putByte(byte[] target,
long index,
byte value) |
static void |
putByte(long address,
byte value) |
static void |
putByte(Object target,
long offset,
byte value) |
static void |
putByteVolatile(byte[] target,
long index,
byte value) |
static void |
putDouble(double[] target,
long index,
double value) |
static void |
putDouble(Object target,
long offset,
double value) |
static void |
putDoubleVolatile(double[] target,
long index,
double value) |
static void |
putFloat(float[] target,
long index,
float value) |
static void |
putFloat(Object target,
long offset,
float value) |
static void |
putFloatVolatile(float[] target,
long index,
float value) |
static void |
putInt(int[] target,
long index,
int value) |
static void |
putInt(long address,
int value) |
static void |
putInt(Object target,
long offset,
int value) |
static void |
putIntVolatile(int[] target,
long index,
int value) |
static void |
putLong(long[] target,
long index,
long value) |
static void |
putLong(long address,
long value) |
static void |
putLong(Object target,
long offset,
long value) |
static void |
putLongVolatile(long[] target,
long index,
long value) |
static void |
putObject(Object[] target,
long index,
Object value) |
static void |
putObject(Object target,
long offset,
Object value) |
static void |
putObjectVolatile(Object[] target,
long index,
Object value) |
static void |
throwException(Throwable t) |
public static boolean hasUnsafe()
public static UnsafeUtil.UnsafeAccessor getUnsafeAccessor()
UnsafeUtil.UnsafeAccessor appropriate for the platform.public static byte getByte(Object target, long offset)
public static void putByte(Object target, long offset, byte value)
public static int getInt(Object target, long offset)
public static void putInt(Object target, long offset, int value)
public static long getLong(Object target, long offset)
public static void putLong(Object target, long offset, long value)
public static boolean getBoolean(Object target, long offset)
public static void putBoolean(Object target, long offset, boolean value)
public static float getFloat(Object target, long offset)
public static void putFloat(Object target, long offset, float value)
public static double getDouble(Object target, long offset)
public static void putDouble(Object target, long offset, double value)
public static byte getByte(byte[] target,
long index)
public static void putByte(byte[] target,
long index,
byte value)
public static int getInt(int[] target,
long index)
public static void putInt(int[] target,
long index,
int value)
public static long getLong(long[] target,
long index)
public static void putLong(long[] target,
long index,
long value)
public static boolean getBoolean(boolean[] target,
long index)
public static void putBoolean(boolean[] target,
long index,
boolean value)
public static float getFloat(float[] target,
long index)
public static void putFloat(float[] target,
long index,
float value)
public static double getDouble(double[] target,
long index)
public static void putDouble(double[] target,
long index,
double value)
public static byte getByte(long address)
public static void putByte(long address,
byte value)
public static int getInt(long address)
public static void putInt(long address,
int value)
public static long getLong(long address)
public static void putLong(long address,
long value)
public static byte getByteVolatile(byte[] target,
long index)
public static void putByteVolatile(byte[] target,
long index,
byte value)
public static int getIntVolatile(int[] target,
long index)
public static void putIntVolatile(int[] target,
long index,
int value)
public static long getLongVolatile(long[] target,
long index)
public static void putLongVolatile(long[] target,
long index,
long value)
public static boolean getBooleanVolatile(boolean[] target,
long index)
public static void putBooleanVolatile(boolean[] target,
long index,
boolean value)
public static float getFloatVolatile(float[] target,
long index)
public static void putFloatVolatile(float[] target,
long index,
float value)
public static double getDoubleVolatile(double[] target,
long index)
public static void putDoubleVolatile(double[] target,
long index,
double value)
public static int arrayBaseOffset(Class<?> clazz)
public static int arrayIndexScale(Class<?> clazz)
public static long objectFieldOffset(Field field)
-1 if sun.misc.Unsafe is not
available.public static long objectFieldOffset(Class<?> clazz, String fieldName)
-1 if sun.misc.Unsafe is not
available.public static long addressOffset(ByteBuffer buffer)
address field of the given
direct ByteBuffer.public static void throwException(Throwable t)
public static String moveToString(char[] chars)
String backed by the given chars.
The char array should not be mutated any more after calling
this function.public static ClassLoader getSystemClassLoader()
ClassLoader.Copyright © 2021. All rights reserved.