public final class UnsafeUtil extends Object
The internal static initializer also detects whether the methods unique to the Unsafe class in JDK8 are present; if not, methods that are compatible with JDK7 are substituted using an internal interface. In order for this to work with jdk7, this library must be compiled using jdk8 and it must be done with both source and target versions of jdk7 specified in pom.xml. The resultant jar will work on jdk7 and jdk8.
This may work with jdk9 but might require the JVM arg -permit-illegal-access, –illegal-access=permit or equivalent. Proper operation with jdk9 or above is not guaranteed and has not been tested.
| Modifier and Type | Field and Description |
|---|---|
static int |
ADDRESS_SIZE |
static long |
ARRAY_BOOLEAN_BASE_OFFSET |
static int |
ARRAY_BOOLEAN_INDEX_SCALE |
static long |
ARRAY_BYTE_BASE_OFFSET |
static int |
ARRAY_BYTE_INDEX_SCALE |
static long |
ARRAY_CHAR_BASE_OFFSET |
static long |
ARRAY_CHAR_INDEX_SCALE |
static long |
ARRAY_DOUBLE_BASE_OFFSET |
static long |
ARRAY_DOUBLE_INDEX_SCALE |
static long |
ARRAY_FLOAT_BASE_OFFSET |
static long |
ARRAY_FLOAT_INDEX_SCALE |
static long |
ARRAY_INT_BASE_OFFSET |
static long |
ARRAY_INT_INDEX_SCALE |
static long |
ARRAY_LONG_BASE_OFFSET |
static long |
ARRAY_LONG_INDEX_SCALE |
static long |
ARRAY_OBJECT_BASE_OFFSET |
static long |
ARRAY_OBJECT_INDEX_SCALE |
static long |
ARRAY_SHORT_BASE_OFFSET |
static long |
ARRAY_SHORT_INDEX_SCALE |
static int |
BOOLEAN_SHIFT |
static int |
BYTE_SHIFT |
static long |
CHAR_SHIFT |
static long |
DOUBLE_SHIFT |
static long |
FLOAT_SHIFT |
static long |
INT_SHIFT |
static String |
JDK |
static long |
LONG_SHIFT |
static String |
LS |
static long |
OBJECT_SHIFT |
static long |
SHORT_SHIFT |
static sun.misc.Unsafe |
unsafe |
| Modifier and Type | Method and Description |
|---|---|
static void |
assertBounds(long reqOff,
long reqLen,
long allocSize)
Assert the requested offset and length against the allocated size.
|
static void |
checkBounds(long reqOff,
long reqLen,
long allocSize)
Check the requested offset and length against the allocated size.
|
public static final sun.misc.Unsafe unsafe
public static final String JDK
public static final int ADDRESS_SIZE
public static final long ARRAY_BOOLEAN_BASE_OFFSET
public static final long ARRAY_BYTE_BASE_OFFSET
public static final long ARRAY_SHORT_BASE_OFFSET
public static final long ARRAY_CHAR_BASE_OFFSET
public static final long ARRAY_INT_BASE_OFFSET
public static final long ARRAY_LONG_BASE_OFFSET
public static final long ARRAY_FLOAT_BASE_OFFSET
public static final long ARRAY_DOUBLE_BASE_OFFSET
public static final long ARRAY_OBJECT_BASE_OFFSET
public static final int ARRAY_BOOLEAN_INDEX_SCALE
public static final int ARRAY_BYTE_INDEX_SCALE
public static final long ARRAY_SHORT_INDEX_SCALE
public static final long ARRAY_CHAR_INDEX_SCALE
public static final long ARRAY_INT_INDEX_SCALE
public static final long ARRAY_LONG_INDEX_SCALE
public static final long ARRAY_FLOAT_INDEX_SCALE
public static final long ARRAY_DOUBLE_INDEX_SCALE
public static final long ARRAY_OBJECT_INDEX_SCALE
public static final int BOOLEAN_SHIFT
public static final int BYTE_SHIFT
public static final long SHORT_SHIFT
public static final long CHAR_SHIFT
public static final long INT_SHIFT
public static final long LONG_SHIFT
public static final long FLOAT_SHIFT
public static final long DOUBLE_SHIFT
public static final long OBJECT_SHIFT
public static final String LS
public static void assertBounds(long reqOff,
long reqLen,
long allocSize)
0 <= reqOff <= reqLen <= reqOff + reqLen <= allocSize.
If this equation is violated and assertions are enabled, an AssertionError will
be thrown.reqOff - the requested offsetreqLen - the requested lengthallocSize - the allocated size.public static void checkBounds(long reqOff,
long reqLen,
long allocSize)
0 <= reqOff <= reqLen <= reqOff + reqLen <= allocSize.
If this equation is violated an IllegalArgumentException will be thrown.reqOff - the requested offsetreqLen - the requested lengthallocSize - the allocated size.Copyright © 2015–2019 Yahoo! Inc.. All rights reserved.