New posts
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import java.lang.reflect.Field;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
/** The classic way every library gets an Unsafe: read the private static field "theUnsafe". */
|
||||
final class UnsafeAccess {
|
||||
private UnsafeAccess() {}
|
||||
|
||||
static Unsafe get() {
|
||||
try {
|
||||
Field f = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
f.setAccessible(true);
|
||||
return (Unsafe) f.get(null);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user