1 package com.cliffc.aa.util;
3 import java.lang.reflect.Field;
5 import sun.misc.Unsafe;
21 if(
UtilUnsafe.class.getClassLoader() ==
null )
22 return Unsafe.getUnsafe();
24 final Field fld = Unsafe.class.getDeclaredField(
"theUnsafe");
25 fld.setAccessible(
true);
27 }
catch (Exception e) {
28 throw new RuntimeException(
"Could not obtain access to sun.misc.Unsafe", e);
34 try { f = clz.getDeclaredField(field); }
35 catch( java.lang.NoSuchFieldException e ) {
throw new RuntimeException(e); }
36 return UNSAFE.objectFieldOffset(f);