Unable to initialize PlatformDependent when sun.misc.Unsafe is unavailable
Motivation: PlatformDependent0 should not be referenced directly when sun.misc.Unsafe is unavailable. Modifications: Guard byteArrayBaseOffset with hasUnsafe check. Result: PlatformDependent can be initialized when sun.misc.Unsafe is unavailable.
This commit is contained in:
parent
f0f0edbf78
commit
895a92cb22
@ -98,7 +98,7 @@ public final class PlatformDependent {
|
|||||||
private static final int DEFAULT_MAX_MPSC_CAPACITY = MPSC_CHUNK_SIZE * MPSC_CHUNK_SIZE;
|
private static final int DEFAULT_MAX_MPSC_CAPACITY = MPSC_CHUNK_SIZE * MPSC_CHUNK_SIZE;
|
||||||
private static final int MAX_ALLOWED_MPSC_CAPACITY = Pow2.MAX_POW2;
|
private static final int MAX_ALLOWED_MPSC_CAPACITY = Pow2.MAX_POW2;
|
||||||
|
|
||||||
private static final long BYTE_ARRAY_BASE_OFFSET = PlatformDependent0.byteArrayBaseOffset();
|
private static final long BYTE_ARRAY_BASE_OFFSET = byteArrayBaseOffset0();
|
||||||
|
|
||||||
private static final boolean HAS_JAVASSIST = hasJavassist0();
|
private static final boolean HAS_JAVASSIST = hasJavassist0();
|
||||||
|
|
||||||
@ -1378,6 +1378,13 @@ public final class PlatformDependent {
|
|||||||
return PlatformDependent0.addressSize();
|
return PlatformDependent0.addressSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static long byteArrayBaseOffset0() {
|
||||||
|
if (!hasUnsafe()) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return PlatformDependent0.byteArrayBaseOffset();
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean equalsSafe(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length) {
|
private static boolean equalsSafe(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length) {
|
||||||
final int end = startPos1 + length;
|
final int end = startPos1 + length;
|
||||||
for (int i = startPos1, j = startPos2; i < end; ++i, ++j) {
|
for (int i = startPos1, j = startPos2; i < end; ++i, ++j) {
|
||||||
|
Loading…
Reference in New Issue
Block a user