934 |
|
} |
935 |
|
|
936 |
|
// Unsafe mechanics |
937 |
< |
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe(); |
938 |
< |
private static final long allocationSpinLockOffset = |
939 |
< |
objectFieldOffset(UNSAFE, "allocationSpinLock", |
940 |
< |
PriorityBlockingQueue.class); |
941 |
< |
|
942 |
< |
static long objectFieldOffset(sun.misc.Unsafe UNSAFE, |
943 |
< |
String field, Class<?> klazz) { |
937 |
> |
private static final sun.misc.Unsafe UNSAFE; |
938 |
> |
private static final long allocationSpinLockOffset; |
939 |
> |
static { |
940 |
|
try { |
941 |
< |
return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field)); |
942 |
< |
} catch (NoSuchFieldException e) { |
943 |
< |
// Convert Exception to corresponding Error |
944 |
< |
NoSuchFieldError error = new NoSuchFieldError(field); |
945 |
< |
error.initCause(e); |
946 |
< |
throw error; |
941 |
> |
UNSAFE = sun.misc.Unsafe.getUnsafe(); |
942 |
> |
Class k = PriorityBlockingQueue.class; |
943 |
> |
allocationSpinLockOffset = UNSAFE.objectFieldOffset |
944 |
> |
(k.getDeclaredField("allocationSpinLock")); |
945 |
> |
} catch (Exception e) { |
946 |
> |
throw new Error(e); |
947 |
|
} |
948 |
|
} |
953 |
– |
|
949 |
|
} |