Files
2026-11-06 21:43:48 +05:30

18 lines
510 B
Java

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);
}
}
}