static Exchanger() { int s; try { U = sun.misc.Unsafe.Unsafe; Class ek = typeof(Exchanger); Class nk = typeof(Node); Class ak = typeof(Node[]); Class tk = typeof(Thread); BOUND = U.objectFieldOffset(ek.GetDeclaredField("bound")); SLOT = U.objectFieldOffset(ek.GetDeclaredField("slot")); MATCH = U.objectFieldOffset(nk.GetDeclaredField("match")); BLOCKER = U.objectFieldOffset(tk.GetDeclaredField("parkBlocker")); s = U.arrayIndexScale(ak); // ABASE absorbs padding in front of element 0 ABASE = U.arrayBaseOffset(ak) + (1 << ASHIFT); } catch (Exception e) { throw new Error(e); } if ((s & (s - 1)) != 0 || s > (1 << ASHIFT)) { throw new Error("Unsupported array scale"); } }
static InetSocketAddress() { try { sun.misc.Unsafe @unsafe = sun.misc.Unsafe.Unsafe; FIELDS_OFFSET = @unsafe.objectFieldOffset(typeof(InetSocketAddress).getDeclaredField("holder")); UNSAFE = @unsafe; } catch (ReflectiveOperationException e) { throw new Error(e); } }
static Cell() { try { UNSAFE = sun.misc.Unsafe.Unsafe; Class ak = typeof(Cell); ValueOffset = UNSAFE.objectFieldOffset(ak.GetDeclaredField("value")); } catch (Exception e) { throw new Error(e); } }
internal static long ObjectFieldOffset(sun.misc.Unsafe UNSAFE, String field, Class klazz) { try { return(UNSAFE.objectFieldOffset(klazz.GetDeclaredField(field))); } catch (NoSuchFieldException e) { // Convert Exception to corresponding Error NoSuchFieldError error = new NoSuchFieldError(field); error.InitCause(e); throw error; } }
static Node() { try { UNSAFE = sun.misc.Unsafe.Unsafe; Class k = typeof(Node); ItemOffset = UNSAFE.objectFieldOffset(k.GetDeclaredField("item")); NextOffset = UNSAFE.objectFieldOffset(k.GetDeclaredField("next")); } catch (Exception e) { throw new Error(e); } }
static ForkJoinWorkerThread() { try { U = sun.misc.Unsafe.Unsafe; Class tk = typeof(Thread); THREADLOCALS = U.objectFieldOffset(tk.GetDeclaredField("threadLocals")); INHERITABLETHREADLOCALS = U.objectFieldOffset(tk.GetDeclaredField("inheritableThreadLocals")); INHERITEDACCESSCONTROLCONTEXT = U.objectFieldOffset(tk.GetDeclaredField("inheritedAccessControlContext")); } catch (Exception e) { throw new Error(e); } }
static FutureTask() { try { UNSAFE = sun.misc.Unsafe.Unsafe; Class k = typeof(FutureTask); StateOffset = UNSAFE.objectFieldOffset(k.GetDeclaredField("state")); RunnerOffset = UNSAFE.objectFieldOffset(k.GetDeclaredField("runner")); WaitersOffset = UNSAFE.objectFieldOffset(k.GetDeclaredField("waiters")); } catch (Exception e) { throw new Error(e); } }
static Striped64() { try { UNSAFE = sun.misc.Unsafe.Unsafe; Class sk = typeof(Striped64); BASE = UNSAFE.objectFieldOffset(sk.GetDeclaredField("base")); CELLSBUSY = UNSAFE.objectFieldOffset(sk.GetDeclaredField("cellsBusy")); Class tk = typeof(Thread); PROBE = UNSAFE.objectFieldOffset(tk.GetDeclaredField("threadLocalRandomProbe")); } catch (Exception e) { throw new Error(e); } }