Where does the unsafe variable been set

89 views Asked by At

When studying the jdk source code (jdk 1.8.0_111), i found a piece of strange code as follow:

public class AtmicBoolean implements Serializable {

    private static final long serialVersionUID = 4654671469794556979L;
    private static final Unsafe unsafe = ;
    private static final long valueOffset;
    private volatile int value;

    static {
        try {
            valueOffset = unsafe.objectFieldOffset(AtomicBoolean.class.getDeclaredField("value"));
        } catch (Exception localException) {
            throw new Error(localException);
        }
    }
  // .... other codes
}

Question: where does the unsafe variable was set ?

0

There are 0 answers