Code example for Field

Methods: get, setAccessible

0
    // Not on bootclasspath 
    if( UtilUnsafe.class.getClassLoader() == null )
      return Unsafe.getUnsafe(); 
    try { 
      final Field fld = Unsafe.class.getDeclaredField("theUnsafe");
      fld.setAccessible(true);
      return (Unsafe) fld.get(UtilUnsafe.class);
    } catch (Exception e) {
      throw new RuntimeException("Could not obtain access to sun.misc.Unsafe", e);
    } 
  } 
}