I just tried JDK9
and found out that sun.misc.Unsafe
is now containing not a native method, but delegates them to some jdk.internal.misc.Unsafe
, for example:
@ForceInline
public int getInt(Object o, long offset) {
return theInternalUnsafe.getInt(o, offset);
}
The latest, in turn, looks actually like the old sun.misc.Unsafe
, but now the methods are annotated with some annotation:
@HotSpotIntrinsicCandidate
public native void putObject(Object o, long offset, Object x);
So, is it "safe" to use Unsafe
starting JDK9? Is it a public official API now?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…