模块 mxlib.api

类 Unsafe


  • public abstract class Unsafe
    extends Object
    A collection of methods for performing low-level, unsafe operations. Although the class and all methods are public, use of this class is limited because only trusted code can obtain instances of it. Note: It is the resposibility of the caller to make sure arguments are checked before methods of this class are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!
    从以下版本开始:
    2.7
    作者:
    John R. Rose
    另请参阅:
    getUnsafe(), Unsafe, Unsafe.getUnsafe(), Unsafe, Unsafe.getUnsafe()
    • 字段详细资料

      • ARRAY_BOOLEAN_BASE_OFFSET

        public static final int ARRAY_BOOLEAN_BASE_OFFSET
        The value of arrayBaseOffset(boolean[].class)
      • ARRAY_BYTE_BASE_OFFSET

        public static final int ARRAY_BYTE_BASE_OFFSET
        The value of arrayBaseOffset(byte[].class)
      • ARRAY_SHORT_BASE_OFFSET

        public static final int ARRAY_SHORT_BASE_OFFSET
        The value of arrayBaseOffset(short[].class)
      • ARRAY_CHAR_BASE_OFFSET

        public static final int ARRAY_CHAR_BASE_OFFSET
        The value of arrayBaseOffset(char[].class)
      • ARRAY_INT_BASE_OFFSET

        public static final int ARRAY_INT_BASE_OFFSET
        The value of arrayBaseOffset(int[].class)
      • ARRAY_LONG_BASE_OFFSET

        public static final int ARRAY_LONG_BASE_OFFSET
        The value of arrayBaseOffset(long[].class)
      • ARRAY_FLOAT_BASE_OFFSET

        public static final int ARRAY_FLOAT_BASE_OFFSET
        The value of arrayBaseOffset(float[].class)
      • ARRAY_DOUBLE_BASE_OFFSET

        public static final int ARRAY_DOUBLE_BASE_OFFSET
        The value of arrayBaseOffset(double[].class)
      • ARRAY_OBJECT_BASE_OFFSET

        public static final int ARRAY_OBJECT_BASE_OFFSET
        The value of arrayBaseOffset(Object[].class)
      • ARRAY_BOOLEAN_INDEX_SCALE

        public static final int ARRAY_BOOLEAN_INDEX_SCALE
        The value of arrayIndexScale(boolean[].class)
      • ARRAY_BYTE_INDEX_SCALE

        public static final int ARRAY_BYTE_INDEX_SCALE
        The value of arrayIndexScale(byte[].class)
      • ARRAY_SHORT_INDEX_SCALE

        public static final int ARRAY_SHORT_INDEX_SCALE
        The value of arrayIndexScale(short[].class)
      • ARRAY_CHAR_INDEX_SCALE

        public static final int ARRAY_CHAR_INDEX_SCALE
        The value of arrayIndexScale(char[].class)
      • ARRAY_INT_INDEX_SCALE

        public static final int ARRAY_INT_INDEX_SCALE
        The value of arrayIndexScale(int[].class)
      • ARRAY_LONG_INDEX_SCALE

        public static final int ARRAY_LONG_INDEX_SCALE
        The value of arrayIndexScale(long[].class)
      • ARRAY_FLOAT_INDEX_SCALE

        public static final int ARRAY_FLOAT_INDEX_SCALE
        The value of arrayIndexScale(float[].class)
      • ARRAY_DOUBLE_INDEX_SCALE

        public static final int ARRAY_DOUBLE_INDEX_SCALE
        The value of arrayIndexScale(double[].class)
      • ARRAY_OBJECT_INDEX_SCALE

        public static final int ARRAY_OBJECT_INDEX_SCALE
        The value of arrayIndexScale(Object[].class)
      • ADDRESS_SIZE

        public static final int ADDRESS_SIZE
        The value of addressSize()
    • 构造器详细资料

      • Unsafe

        public Unsafe()
    • 方法详细资料

      • $finishUnsafeInit

        public static void $finishUnsafeInit()
        Call by MXLib Internal Code
      • getUnsafe

        @Contract(pure=true)
        public static Unsafe getUnsafe()
        Provides the caller with the capability of performing unsafe operations.

        The returned Unsafe object should be carefully guarded by the caller, since it can be used to read and write data at arbitrary memory addresses. It must never be passed to untrusted code.

        Most methods in this class are very low-level, and correspond to a small number of hardware instructions (on typical machines). Compilers are encouraged to optimize these methods accordingly.

        Here is a suggested idiom for using unsafe operations:

         
         class MyTrustedClass {
           private static final Unsafe unsafe = Unsafe.getUnsafe();
           ...
           private long myCountAddress = ...;
           public int getCount() { return unsafe.getByte(myCountAddress); }
         }

        (It may assist compilers to make the local variable final.)

      • getInt

        @Contract(pure=true)
        public abstract int getInt​(Object o,
                                   long offset)
        Fetches a value from a given Java variable. More specifically, fetches a field or array element within the given object o at the given offset, or (if o is null) from the memory address whose numerical value is the given offset.

        The results are undefined unless one of the following cases is true:

        If one of the above cases is true, the call references a specific Java variable (field or array element). However, the results are undefined if that variable is not in fact of the type returned by this method.

        This method refers to a variable by means of two parameters, and so it provides (in effect) a double-register addressing mode for Java variables. When the object reference is null, this method uses its offset as an absolute address. This is similar in operation to methods such as getInt(long), which provide (in effect) a single-register addressing mode for non-Java variables. However, because Java variables may have a different layout in memory from non-Java variables, programmers should not assume that these two addressing modes are ever equivalent. Also, programmers should remember that offsets from the double-register addressing mode cannot be portably confused with longs used in the single-register addressing mode.

        参数:
        o - Java heap object in which the variable resides, if any, else null
        offset - indication of where the variable resides in a Java heap object, if any, else a memory address locating the variable statically
        返回:
        the value fetched from the indicated Java variable
        抛出:
        RuntimeException - No defined exceptions are thrown, not even NullPointerException
      • putInt

        public abstract void putInt​(Object o,
                                    long offset,
                                    int x)
        Stores a value into a given Java variable.

        The first two parameters are interpreted exactly as with getInt(Object, long) to refer to a specific Java variable (field or array element). The given value is stored into that variable.

        The variable must be of the same type as the method parameter x.

        参数:
        o - Java heap object in which the variable resides, if any, else null
        offset - indication of where the variable resides in a Java heap object, if any, else a memory address locating the variable statically
        x - the value to store into the indicated Java variable
        抛出:
        RuntimeException - No defined exceptions are thrown, not even NullPointerException
      • getReference

        @Contract(pure=true)
        public abstract Object getReference​(Object o,
                                            long offset)
        Fetches a reference value from a given Java variable.
        另请参阅:
        getInt(Object, long)
      • putReference

        public abstract void putReference​(Object o,
                                          long offset,
                                          Object x)
        Stores a reference value into a given Java variable.

        Unless the reference x being stored is either null or matches the field type, the results are undefined. If the reference o is non-null, card marks or other store barriers for that object (if the VM requires them) are updated.

        另请参阅:
        putInt(Object, long, int)
      • getBoolean

        @Contract(pure=true)
        public abstract boolean getBoolean​(Object o,
                                           long offset)
        另请参阅:
        getInt(Object, long)
      • getDouble

        @Contract(pure=true)
        public abstract double getDouble​(Object o,
                                         long offset)
        另请参阅:
        getInt(Object, long)
      • getAddress

        @Contract(pure=true)
        public abstract long getAddress​(Object o,
                                        long offset)
        Fetches a abstract pointer from a given memory address. If the address is zero, or does not point into a block obtained from allocateMemory(long), the results are undefined.

        If the abstract pointer is less than 64 bits wide, it is extended as an unsigned number to a Java long. The pointer may be indexed by any given byte offset, simply by adding that offset (as a simple integer) to the long representing the pointer. The number of bytes actually read from the target address may be determined by consulting addressSize().

        另请参阅:
        allocateMemory(long), getInt(Object, long)
      • putAddress

        public abstract void putAddress​(Object o,
                                        long offset,
                                        long x)
        Stores a abstract pointer into a given memory address. If the address is zero, or does not point into a block obtained from allocateMemory(long), the results are undefined.

        The number of bytes actually written at the target address may be determined by consulting addressSize().

        另请参阅:
        allocateMemory(long), putInt(Object, long, int)
      • getUncompressedObject

        @Contract(pure=true)
        public abstract Object getUncompressedObject​(long address)
        Fetches an uncompressed reference value from a given abstract variable ignoring the VM's compressed references mode.
        参数:
        address - a memory address locating the variable
        返回:
        the value fetched from the indicated abstract variable
      • getByte

        @Contract(pure=true)
        public abstract byte getByte​(long address)
        Fetches a value from a given memory address. If the address is zero, or does not point into a block obtained from allocateMemory(long), the results are undefined.
        另请参阅:
        allocateMemory(long)
      • putByte

        public void putByte​(long address,
                            byte x)
        Stores a value into a given memory address. If the address is zero, or does not point into a block obtained from allocateMemory(long), the results are undefined.
        另请参阅:
        getByte(long)
      • getShort

        @Contract(pure=true)
        public short getShort​(long address)
        另请参阅:
        getByte(long)
      • putShort

        public void putShort​(long address,
                             short x)
        另请参阅:
        putByte(long, byte)
      • getChar

        @Contract(pure=true)
        public char getChar​(long address)
        另请参阅:
        getByte(long)
      • getInt

        @Contract(pure=true)
        public int getInt​(long address)
        另请参阅:
        getByte(long)
      • getLong

        @Contract(pure=true)
        public long getLong​(long address)
        另请参阅:
        getByte(long)
      • getFloat

        @Contract(pure=true)
        public float getFloat​(long address)
        另请参阅:
        getByte(long)
      • putFloat

        public void putFloat​(long address,
                             float x)
        另请参阅:
        putByte(long, byte)
      • getDouble

        @Contract(pure=true)
        public double getDouble​(long address)
        另请参阅:
        getByte(long)
      • putDouble

        public void putDouble​(long address,
                              double x)
        另请参阅:
        putByte(long, byte)
      • allocateMemory

        @Contract(pure=true)
        public abstract long allocateMemory​(long bytes)
        Allocates a new block of abstract memory, of the given size in bytes. The contents of the memory are uninitialized; they will generally be garbage. The resulting abstract pointer will never be zero, and will be aligned for all value types. Dispose of this memory by calling freeMemory(long), or resize it with reallocateMemory(long, long). Note: It is the resposibility of the caller to make sure arguments are checked before the methods are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!
        抛出:
        RuntimeException - if the size is negative or too large for the abstract size_t type
        OutOfMemoryError - if the allocation is refused by the system
        另请参阅:
        getByte(long), putByte(long, byte)
      • reallocateMemory

        public abstract long reallocateMemory​(long address,
                                              long bytes)
        Resizes a new block of abstract memory, to the given size in bytes. The contents of the new block past the size of the old block are uninitialized; they will generally be garbage. The resulting abstract pointer will be zero if and only if the requested size is zero. The resulting abstract pointer will be aligned for all value types. Dispose of this memory by calling freeMemory(long), or resize it with reallocateMemory(long, long). The address passed to this method may be null, in which case an allocation will be performed. Note: It is the resposibility of the caller to make sure arguments are checked before the methods are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!
        抛出:
        RuntimeException - if the size is negative or too large for the abstract size_t type
        OutOfMemoryError - if the allocation is refused by the system
        另请参阅:
        allocateMemory(long)
      • setMemory

        public abstract void setMemory​(Object o,
                                       long offset,
                                       long bytes,
                                       byte value)
        Sets all bytes in a given block of memory to a fixed value (usually zero).

        This method determines a block's base address by means of two parameters, and so it provides (in effect) a double-register addressing mode, as discussed in getInt(Object, long). When the object reference is null, the offset supplies an absolute base address.

        The stores are in coherent (atomic) units of a size determined by the address and length parameters. If the effective address and length are all even modulo 8, the stores take place in 'long' units. If the effective address and length are (resp.) even modulo 4 or 2, the stores take place in units of 'int' or 'short'. Note: It is the resposibility of the caller to make sure arguments are checked before the methods are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!

        抛出:
        RuntimeException - if any of the arguments is invalid
        从以下版本开始:
        1.7
      • setMemory

        public void setMemory​(long address,
                              long bytes,
                              byte value)
        Sets all bytes in a given block of memory to a fixed value (usually zero). This provides a single-register addressing mode, as discussed in getInt(Object, long).

        Equivalent to setMemory(null, address, bytes, value).

      • copyMemory

        public abstract void copyMemory​(Object srcBase,
                                        long srcOffset,
                                        Object destBase,
                                        long destOffset,
                                        long bytes)
        Sets all bytes in a given block of memory to a copy of another block.

        This method determines each block's base address by means of two parameters, and so it provides (in effect) a double-register addressing mode, as discussed in getInt(Object, long). When the object reference is null, the offset supplies an absolute base address.

        The transfers are in coherent (atomic) units of a size determined by the address and length parameters. If the effective addresses and length are all even modulo 8, the transfer takes place in 'long' units. If the effective addresses and length are (resp.) even modulo 4 or 2, the transfer takes place in units of 'int' or 'short'. Note: It is the resposibility of the caller to make sure arguments are checked before the methods are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!

        抛出:
        RuntimeException - if any of the arguments is invalid
        从以下版本开始:
        1.7
      • copyMemory

        public void copyMemory​(long srcAddress,
                               long destAddress,
                               long bytes)
        Sets all bytes in a given block of memory to a copy of another block. This provides a single-register addressing mode, as discussed in getInt(Object, long).

        Equivalent to copyMemory(null, srcAddress, null, destAddress, bytes).

      • copySwapMemory

        public abstract void copySwapMemory​(Object srcBase,
                                            long srcOffset,
                                            Object destBase,
                                            long destOffset,
                                            long bytes,
                                            long elemSize)
        Copies all elements from one block of memory to another block, *unconditionally* byte swapping the elements on the fly.

        This method determines each block's base address by means of two parameters, and so it provides (in effect) a double-register addressing mode, as discussed in getInt(Object, long). When the object reference is null, the offset supplies an absolute base address. Note: It is the resposibility of the caller to make sure arguments are checked before the methods are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!

        抛出:
        RuntimeException - if any of the arguments is invalid
        从以下版本开始:
        9
      • copySwapMemory

        public void copySwapMemory​(long srcAddress,
                                   long destAddress,
                                   long bytes,
                                   long elemSize)
        Copies all elements from one block of memory to another block, byte swapping the elements on the fly.

        This provides a single-register addressing mode, as discussed in getInt(Object, long).

        Equivalent to copySwapMemory(null, srcAddress, null, destAddress, bytes, elemSize).

      • freeMemory

        public abstract void freeMemory​(long address)
        Disposes of a block of abstract memory, as obtained from allocateMemory(long) or reallocateMemory(long, long). The address passed to this method may be null, in which case no action is taken. Note: It is the resposibility of the caller to make sure arguments are checked before the methods are called. While some rudimentary checks are performed on the input, the checks are best effort and when performance is an overriding priority, as when methods of this class are optimized by the runtime compiler, some or all checks (if any) may be elided. Hence, the caller must not rely on the checks and corresponding exceptions!
        抛出:
        RuntimeException - if any of the arguments is invalid
        另请参阅:
        allocateMemory(long)
      • objectFieldOffset

        @Contract(pure=true)
        public abstract long objectFieldOffset​(@NotNull
                                               @NotNull Field f)
        Reports the location of a given field in the storage allocation of its class. Do not expect to perform any sort of arithmetic on this offset; it is just a cookie which is passed to the unsafe heap memory accessors.

        Any given field will always have the same offset and base, and no two distinct fields of the same class will ever have the same offset and base.

        As of 1.4.1, offsets for fields are represented as long values, although the Sun JVM does not use the most significant 32 bits. However, JVM implementations which store static fields at absolute addresses can use long offsets and null base pointers to express the field locations in a form usable by getInt(Object, long). Therefore, code which will be ported to such JVMs on 64-bit platforms must preserve all bits of static field offsets.

        另请参阅:
        getInt(Object, long)
      • objectFieldOffset

        @Contract(pure=true)
        public abstract long objectFieldOffset​(Class<?> c,
                                               String name)
        Reports the location of the field with a given name in the storage allocation of its class.
        抛出:
        NullPointerException - if any parameter is null.
        InternalError - if there is no field named name declared in class c, i.e., if c.getDeclaredField(name) would throw java.lang.NoSuchFieldException.
        另请参阅:
        objectFieldOffset(Field)
      • staticFieldOffset

        @Contract(pure=true)
        public abstract long staticFieldOffset​(@NotNull
                                               @NotNull Field f)
        Reports the location of a given static field, in conjunction with staticFieldBase(java.lang.reflect.Field).

        Do not expect to perform any sort of arithmetic on this offset; it is just a cookie which is passed to the unsafe heap memory accessors.

        Any given field will always have the same offset, and no two distinct fields of the same class will ever have the same offset.

        As of 1.4.1, offsets for fields are represented as long values, although the Sun JVM does not use the most significant 32 bits. It is hard to imagine a JVM technology which needs more than a few bits to encode an offset within a non-array object, However, for consistency with other methods in this class, this method reports its result as a long value.

        另请参阅:
        getInt(Object, long)
      • staticFieldBase

        @Contract(pure=true)
        public abstract Object staticFieldBase​(@NotNull
                                               @NotNull Field f)
        Reports the location of a given static field, in conjunction with staticFieldOffset(java.lang.reflect.Field).

        Fetch the base "Object", if any, with which static fields of the given class can be accessed via methods like getInt(Object, long). This value may be null. This value may refer to an object which is a "cookie", not guaranteed to be a real Object, and it should not be used in any way except as argument to the get and put routines in this class.

      • shouldBeInitialized

        @Contract(pure=true)
        public abstract boolean shouldBeInitialized​(@NotNull
                                                    @NotNull Class<?> c)
        Detects if the given class may need to be initialized. This is often needed in conjunction with obtaining the static field base of a class.
        返回:
        false only if a call to ensureClassInitialized would have no effect
      • ensureClassInitialized

        public abstract void ensureClassInitialized​(@NotNull
                                                    @NotNull Class<?> c)
        Ensures the given class has been initialized. This is often needed in conjunction with obtaining the static field base of a class.
      • arrayBaseOffset

        @Contract(pure=true)
        public abstract int arrayBaseOffset​(@NotNull
                                            @NotNull Class<?> arrayClass)
        Reports the offset of the first element in the storage allocation of a given array class. If arrayIndexScale(java.lang.Class<?>) returns a non-zero value for the same class, you may use that scale factor, together with this base offset, to form new offsets to access elements of arrays of the given class.
        另请参阅:
        getInt(Object, long), putInt(Object, long, int)
      • addressSize

        @Contract(pure=true)
        public abstract int addressSize()
        Reports the size in bytes of a abstract pointer, as stored via putAddress(java.lang.Object, long, long). This value will be either 4 or 8. Note that the sizes of other primitive types (as stored in abstract memory blocks) is determined fully by their information content.
      • pageSize

        @Contract(pure=true)
        public abstract int pageSize()
        Reports the size in bytes of a abstract memory page (whatever that is). This value will always be a power of two.
      • defineClass

        public abstract Class<?> defineClass​(String name,
                                             @NotNull
                                             @org.jetbrains.annotations.NotNull byte[] b,
                                             int off,
                                             int len,
                                             ClassLoader loader,
                                             ProtectionDomain protectionDomain)
        Tells the VM to define a class, without security checks. By default, the class loader and protection domain come from the caller's class.
      • defineClass0

        public abstract Class<?> defineClass0​(String name,
                                              @NotNull
                                              @org.jetbrains.annotations.NotNull byte[] b,
                                              int off,
                                              int len,
                                              ClassLoader loader,
                                              ProtectionDomain protectionDomain)
      • defineAnonymousClass

        public abstract Class<?> defineAnonymousClass​(@NotNull
                                                      @NotNull Class<?> hostClass,
                                                      @NotNull
                                                      @org.jetbrains.annotations.NotNull byte[] data,
                                                      Object[] cpPatches)
        Defines a class but does not make it known to the class loader or system dictionary.

        For each CP entry, the corresponding CP patch must either be null or have the a format that matches its tag:

        • Integer, Long, Float, Double: the corresponding wrapper object type from java.lang
        • Utf8: a string (must have suitable syntax if used as signature or name)
        • Class: any java.lang.Class object
        • String: any object (not just a java.lang.String)
        • InterfaceMethodRef: (NYI) a method handle to invoke on that call site's arguments
        参数:
        hostClass - context for linkage, access control, protection domain, and class loader
        data - bytes of a class file
        cpPatches - where non-null entries exist, they replace corresponding CP entries in data
      • allocateInstance

        @NotNull
        @Contract(pure=true)
        public abstract <T> T allocateInstance​(@NotNull
                                               @NotNull Class<T> cls)
                                        throws InstantiationException
        Allocates an instance but does not run any constructor. Initializes the class if it has not yet been.
        抛出:
        InstantiationException
      • allocateUninitializedArray

        @Contract(pure=true)
        public abstract Object allocateUninitializedArray​(@NotNull
                                                          @NotNull Class<?> componentType,
                                                          int length)
        Allocates an array of a given type, but does not do zeroing.

        This method should only be used in the very rare cases where a high-performance code overwrites the destination array completely, and compilers cannot assist in zeroing elimination. In an overwhelming majority of cases, a normal Java allocation should be used instead.

        Users of this method are required to overwrite the initial (garbage) array contents before allowing untrusted code, or code in other threads, to observe the reference to the newly allocated array. In addition, the publication of the array reference must be safe according to the Java Memory Model requirements.

        The safest approach to deal with an uninitialized array is to keep the reference to it in local variable at least until the initialization is complete, and then publish it once, either by writing it to a volatile field, or storing it into a final field in constructor, or issuing a storeFence() before publishing the reference.

        参数:
        componentType - array component type to allocate
        length - array size to allocate
        抛出:
        IllegalArgumentException - if component type is null, or not a primitive class; or the length is negative
      • throwException

        public abstract void throwException​(Throwable ee)
        Throws the exception without telling the verifier.
      • compareAndSetReference

        public abstract boolean compareAndSetReference​(Object o,
                                                       long offset,
                                                       Object expected,
                                                       Object x)
        Atomically updates Java variable to x if it is currently holding expected.

        This operation has memory semantics of a volatile read and write. Corresponds to C11 atomic_compare_exchange_strong.

        返回:
        true if successful
      • compareAndExchangeReference

        public abstract Object compareAndExchangeReference​(Object o,
                                                           long offset,
                                                           Object expected,
                                                           Object x)
      • compareAndExchangeReferenceAcquire

        public abstract Object compareAndExchangeReferenceAcquire​(Object o,
                                                                  long offset,
                                                                  Object expected,
                                                                  Object x)
      • compareAndExchangeReferenceRelease

        public abstract Object compareAndExchangeReferenceRelease​(Object o,
                                                                  long offset,
                                                                  Object expected,
                                                                  Object x)
      • weakCompareAndSetReferencePlain

        public abstract boolean weakCompareAndSetReferencePlain​(Object o,
                                                                long offset,
                                                                Object expected,
                                                                Object x)
      • weakCompareAndSetReferenceAcquire

        public abstract boolean weakCompareAndSetReferenceAcquire​(Object o,
                                                                  long offset,
                                                                  Object expected,
                                                                  Object x)
      • weakCompareAndSetReferenceRelease

        public abstract boolean weakCompareAndSetReferenceRelease​(Object o,
                                                                  long offset,
                                                                  Object expected,
                                                                  Object x)
      • weakCompareAndSetReference

        public abstract boolean weakCompareAndSetReference​(Object o,
                                                           long offset,
                                                           Object expected,
                                                           Object x)
      • compareAndSetInt

        public abstract boolean compareAndSetInt​(Object o,
                                                 long offset,
                                                 int expected,
                                                 int x)
        Atomically updates Java variable to x if it is currently holding expected.

        This operation has memory semantics of a volatile read and write. Corresponds to C11 atomic_compare_exchange_strong.

        返回:
        true if successful
      • compareAndExchangeInt

        public abstract int compareAndExchangeInt​(Object o,
                                                  long offset,
                                                  int expected,
                                                  int x)
      • compareAndExchangeIntAcquire

        public abstract int compareAndExchangeIntAcquire​(Object o,
                                                         long offset,
                                                         int expected,
                                                         int x)
      • compareAndExchangeIntRelease

        public abstract int compareAndExchangeIntRelease​(Object o,
                                                         long offset,
                                                         int expected,
                                                         int x)
      • weakCompareAndSetIntPlain

        public abstract boolean weakCompareAndSetIntPlain​(Object o,
                                                          long offset,
                                                          int expected,
                                                          int x)
      • weakCompareAndSetIntAcquire

        public abstract boolean weakCompareAndSetIntAcquire​(Object o,
                                                            long offset,
                                                            int expected,
                                                            int x)
      • weakCompareAndSetIntRelease

        public abstract boolean weakCompareAndSetIntRelease​(Object o,
                                                            long offset,
                                                            int expected,
                                                            int x)
      • weakCompareAndSetInt

        public abstract boolean weakCompareAndSetInt​(Object o,
                                                     long offset,
                                                     int expected,
                                                     int x)
      • compareAndExchangeByte

        public abstract byte compareAndExchangeByte​(Object o,
                                                    long offset,
                                                    byte expected,
                                                    byte x)
      • compareAndSetByte

        public abstract boolean compareAndSetByte​(Object o,
                                                  long offset,
                                                  byte expected,
                                                  byte x)
      • weakCompareAndSetByte

        public abstract boolean weakCompareAndSetByte​(Object o,
                                                      long offset,
                                                      byte expected,
                                                      byte x)
      • weakCompareAndSetByteAcquire

        public abstract boolean weakCompareAndSetByteAcquire​(Object o,
                                                             long offset,
                                                             byte expected,
                                                             byte x)
      • weakCompareAndSetByteRelease

        public abstract boolean weakCompareAndSetByteRelease​(Object o,
                                                             long offset,
                                                             byte expected,
                                                             byte x)
      • weakCompareAndSetBytePlain

        public abstract boolean weakCompareAndSetBytePlain​(Object o,
                                                           long offset,
                                                           byte expected,
                                                           byte x)
      • compareAndExchangeByteAcquire

        public abstract byte compareAndExchangeByteAcquire​(Object o,
                                                           long offset,
                                                           byte expected,
                                                           byte x)
      • compareAndExchangeByteRelease

        public abstract byte compareAndExchangeByteRelease​(Object o,
                                                           long offset,
                                                           byte expected,
                                                           byte x)
      • compareAndExchangeShort

        public abstract short compareAndExchangeShort​(Object o,
                                                      long offset,
                                                      short expected,
                                                      short x)
      • compareAndSetShort

        public abstract boolean compareAndSetShort​(Object o,
                                                   long offset,
                                                   short expected,
                                                   short x)
      • weakCompareAndSetShort

        public abstract boolean weakCompareAndSetShort​(Object o,
                                                       long offset,
                                                       short expected,
                                                       short x)
      • weakCompareAndSetShortAcquire

        public abstract boolean weakCompareAndSetShortAcquire​(Object o,
                                                              long offset,
                                                              short expected,
                                                              short x)
      • weakCompareAndSetShortRelease

        public abstract boolean weakCompareAndSetShortRelease​(Object o,
                                                              long offset,
                                                              short expected,
                                                              short x)
      • weakCompareAndSetShortPlain

        public abstract boolean weakCompareAndSetShortPlain​(Object o,
                                                            long offset,
                                                            short expected,
                                                            short x)
      • compareAndExchangeShortAcquire

        public abstract short compareAndExchangeShortAcquire​(Object o,
                                                             long offset,
                                                             short expected,
                                                             short x)
      • compareAndExchangeShortRelease

        public abstract short compareAndExchangeShortRelease​(Object o,
                                                             long offset,
                                                             short expected,
                                                             short x)
      • compareAndSetChar

        public abstract boolean compareAndSetChar​(Object o,
                                                  long offset,
                                                  char expected,
                                                  char x)
      • compareAndExchangeChar

        public abstract char compareAndExchangeChar​(Object o,
                                                    long offset,
                                                    char expected,
                                                    char x)
      • compareAndExchangeCharAcquire

        public abstract char compareAndExchangeCharAcquire​(Object o,
                                                           long offset,
                                                           char expected,
                                                           char x)
      • compareAndExchangeCharRelease

        public abstract char compareAndExchangeCharRelease​(Object o,
                                                           long offset,
                                                           char expected,
                                                           char x)
      • weakCompareAndSetChar

        public abstract boolean weakCompareAndSetChar​(Object o,
                                                      long offset,
                                                      char expected,
                                                      char x)
      • weakCompareAndSetCharAcquire

        public abstract boolean weakCompareAndSetCharAcquire​(Object o,
                                                             long offset,
                                                             char expected,
                                                             char x)
      • weakCompareAndSetCharRelease

        public abstract boolean weakCompareAndSetCharRelease​(Object o,
                                                             long offset,
                                                             char expected,
                                                             char x)
      • weakCompareAndSetCharPlain

        public abstract boolean weakCompareAndSetCharPlain​(Object o,
                                                           long offset,
                                                           char expected,
                                                           char x)
      • compareAndSetBoolean

        public abstract boolean compareAndSetBoolean​(Object o,
                                                     long offset,
                                                     boolean expected,
                                                     boolean x)
      • compareAndExchangeBoolean

        public abstract boolean compareAndExchangeBoolean​(Object o,
                                                          long offset,
                                                          boolean expected,
                                                          boolean x)
      • compareAndExchangeBooleanAcquire

        public abstract boolean compareAndExchangeBooleanAcquire​(Object o,
                                                                 long offset,
                                                                 boolean expected,
                                                                 boolean x)
      • compareAndExchangeBooleanRelease

        public abstract boolean compareAndExchangeBooleanRelease​(Object o,
                                                                 long offset,
                                                                 boolean expected,
                                                                 boolean x)
      • weakCompareAndSetBoolean

        public abstract boolean weakCompareAndSetBoolean​(Object o,
                                                         long offset,
                                                         boolean expected,
                                                         boolean x)
      • weakCompareAndSetBooleanAcquire

        public abstract boolean weakCompareAndSetBooleanAcquire​(Object o,
                                                                long offset,
                                                                boolean expected,
                                                                boolean x)
      • weakCompareAndSetBooleanRelease

        public abstract boolean weakCompareAndSetBooleanRelease​(Object o,
                                                                long offset,
                                                                boolean expected,
                                                                boolean x)
      • weakCompareAndSetBooleanPlain

        public abstract boolean weakCompareAndSetBooleanPlain​(Object o,
                                                              long offset,
                                                              boolean expected,
                                                              boolean x)
      • compareAndSetFloat

        public abstract boolean compareAndSetFloat​(Object o,
                                                   long offset,
                                                   float expected,
                                                   float x)
        Atomically updates Java variable to x if it is currently holding expected.

        This operation has memory semantics of a volatile read and write. Corresponds to C11 atomic_compare_exchange_strong.

        返回:
        true if successful
      • compareAndExchangeFloat

        public abstract float compareAndExchangeFloat​(Object o,
                                                      long offset,
                                                      float expected,
                                                      float x)
      • compareAndExchangeFloatAcquire

        public abstract float compareAndExchangeFloatAcquire​(Object o,
                                                             long offset,
                                                             float expected,
                                                             float x)
      • compareAndExchangeFloatRelease

        public abstract float compareAndExchangeFloatRelease​(Object o,
                                                             long offset,
                                                             float expected,
                                                             float x)
      • weakCompareAndSetFloatPlain

        public abstract boolean weakCompareAndSetFloatPlain​(Object o,
                                                            long offset,
                                                            float expected,
                                                            float x)
      • weakCompareAndSetFloatAcquire

        public abstract boolean weakCompareAndSetFloatAcquire​(Object o,
                                                              long offset,
                                                              float expected,
                                                              float x)
      • weakCompareAndSetFloatRelease

        public abstract boolean weakCompareAndSetFloatRelease​(Object o,
                                                              long offset,
                                                              float expected,
                                                              float x)
      • weakCompareAndSetFloat

        public abstract boolean weakCompareAndSetFloat​(Object o,
                                                       long offset,
                                                       float expected,
                                                       float x)
      • compareAndSetDouble

        public abstract boolean compareAndSetDouble​(Object o,
                                                    long offset,
                                                    double expected,
                                                    double x)
        Atomically updates Java variable to x if it is currently holding expected.

        This operation has memory semantics of a volatile read and write. Corresponds to C11 atomic_compare_exchange_strong.

        返回:
        true if successful
      • compareAndExchangeDouble

        public abstract double compareAndExchangeDouble​(Object o,
                                                        long offset,
                                                        double expected,
                                                        double x)
      • compareAndExchangeDoubleAcquire

        public abstract double compareAndExchangeDoubleAcquire​(Object o,
                                                               long offset,
                                                               double expected,
                                                               double x)
      • compareAndExchangeDoubleRelease

        public abstract double compareAndExchangeDoubleRelease​(Object o,
                                                               long offset,
                                                               double expected,
                                                               double x)
      • weakCompareAndSetDoublePlain

        public abstract boolean weakCompareAndSetDoublePlain​(Object o,
                                                             long offset,
                                                             double expected,
                                                             double x)
      • weakCompareAndSetDoubleAcquire

        public abstract boolean weakCompareAndSetDoubleAcquire​(Object o,
                                                               long offset,
                                                               double expected,
                                                               double x)
      • weakCompareAndSetDoubleRelease

        public abstract boolean weakCompareAndSetDoubleRelease​(Object o,
                                                               long offset,
                                                               double expected,
                                                               double x)
      • weakCompareAndSetDouble

        public abstract boolean weakCompareAndSetDouble​(Object o,
                                                        long offset,
                                                        double expected,
                                                        double x)
      • compareAndSetLong

        public abstract boolean compareAndSetLong​(Object o,
                                                  long offset,
                                                  long expected,
                                                  long x)
        Atomically updates Java variable to x if it is currently holding expected.

        This operation has memory semantics of a volatile read and write. Corresponds to C11 atomic_compare_exchange_strong.

        返回:
        true if successful
      • compareAndExchangeLong

        public abstract long compareAndExchangeLong​(Object o,
                                                    long offset,
                                                    long expected,
                                                    long x)
      • compareAndExchangeLongAcquire

        public abstract long compareAndExchangeLongAcquire​(Object o,
                                                           long offset,
                                                           long expected,
                                                           long x)
      • compareAndExchangeLongRelease

        public abstract long compareAndExchangeLongRelease​(Object o,
                                                           long offset,
                                                           long expected,
                                                           long x)
      • weakCompareAndSetLongPlain

        public abstract boolean weakCompareAndSetLongPlain​(Object o,
                                                           long offset,
                                                           long expected,
                                                           long x)
      • weakCompareAndSetLongAcquire

        public abstract boolean weakCompareAndSetLongAcquire​(Object o,
                                                             long offset,
                                                             long expected,
                                                             long x)
      • weakCompareAndSetLongRelease

        public abstract boolean weakCompareAndSetLongRelease​(Object o,
                                                             long offset,
                                                             long expected,
                                                             long x)
      • weakCompareAndSetLong

        public abstract boolean weakCompareAndSetLong​(Object o,
                                                      long offset,
                                                      long expected,
                                                      long x)
      • getReferenceVolatile

        @Contract(pure=true)
        public abstract Object getReferenceVolatile​(Object o,
                                                    long offset)
        Fetches a reference value from a given Java variable, with volatile load semantics. Otherwise identical to getReference(Object, long)
      • putReferenceVolatile

        public abstract void putReferenceVolatile​(Object o,
                                                  long offset,
                                                  Object x)
        Stores a reference value into a given Java variable, with volatile store semantics. Otherwise identical to putReference(Object, long, Object)
      • getIntVolatile

        @Contract(pure=true)
        public abstract int getIntVolatile​(Object o,
                                           long offset)
        Volatile version of getInt(Object, long)
      • getBooleanVolatile

        @Contract(pure=true)
        public abstract boolean getBooleanVolatile​(Object o,
                                                   long offset)
        Volatile version of getBoolean(Object, long)
      • getByteVolatile

        @Contract(pure=true)
        public abstract byte getByteVolatile​(Object o,
                                             long offset)
        Volatile version of getByte(Object, long)
      • getShortVolatile

        @Contract(pure=true)
        public abstract short getShortVolatile​(Object o,
                                               long offset)
        Volatile version of getShort(Object, long)
      • getCharVolatile

        @Contract(pure=true)
        public abstract char getCharVolatile​(Object o,
                                             long offset)
        Volatile version of getChar(Object, long)
      • getLongVolatile

        @Contract(pure=true)
        public abstract long getLongVolatile​(Object o,
                                             long offset)
        Volatile version of getLong(Object, long)
      • getFloatVolatile

        @Contract(pure=true)
        public abstract float getFloatVolatile​(Object o,
                                               long offset)
        Volatile version of getFloat(Object, long)
      • getDoubleVolatile

        @Contract(pure=true)
        public abstract double getDoubleVolatile​(Object o,
                                                 long offset)
        Volatile version of getDouble(Object, long)
      • unpark

        public abstract void unpark​(Object thread)
        Unblocks the given thread blocked on park, or, if it is not blocked, causes the subsequent call to park not to block. Note: this operation is "unsafe" solely because the caller must somehow ensure that the thread has not been destroyed. Nothing special is usually required to ensure this when called from Java (in which there will ordinarily be a live reference to the thread) but this is not nearly-automatically so when calling from abstract code.
        参数:
        thread - the thread to unpark.
      • park

        public abstract void park​(boolean isAbsolute,
                                  long time)
        Blocks current thread, returning when a balancing unpark occurs, or a balancing unpark has already occurred, or the thread is interrupted, or, if not absolute and time is not zero, the given time nanoseconds have elapsed, or if absolute, the given deadline in milliseconds since Epoch has passed, or spuriously (i.e., returning for no "reason"). Note: This operation is in the Unsafe class only because unpark is, so it would be strange to place it elsewhere.
      • getLoadAverage

        public abstract int getLoadAverage​(double[] loadavg,
                                           int nelems)
        Gets the load average in the system run queue assigned to the available processors averaged over various periods of time. This method retrieves the given nelem samples and assigns to the elements of the given loadavg array. The system imposes a maximum of 3 samples, representing averages over the last 1, 5, and 15 minutes, respectively.
        参数:
        loadavg - an array of double of size nelems
        nelems - the number of samples to be retrieved and must be 1 to 3.
        返回:
        the number of samples actually retrieved; or -1 if the load average is unobtainable.
      • getAndAddInt

        public abstract int getAndAddInt​(Object o,
                                         long offset,
                                         int delta)
        Atomically adds the given value to the current value of a field or array element within the given object o at the given offset.
        参数:
        o - object/array to update the field/element in
        offset - field/element offset
        delta - the value to add
        返回:
        the previous value
        从以下版本开始:
        1.8
      • getAndAddIntRelease

        public abstract int getAndAddIntRelease​(Object o,
                                                long offset,
                                                int delta)
      • getAndAddIntAcquire

        public abstract int getAndAddIntAcquire​(Object o,
                                                long offset,
                                                int delta)
      • getAndAddLong

        public abstract long getAndAddLong​(Object o,
                                           long offset,
                                           long delta)
        Atomically adds the given value to the current value of a field or array element within the given object o at the given offset.
        参数:
        o - object/array to update the field/element in
        offset - field/element offset
        delta - the value to add
        返回:
        the previous value
        从以下版本开始:
        1.8
      • getAndAddLongRelease

        public abstract long getAndAddLongRelease​(Object o,
                                                  long offset,
                                                  long delta)
      • getAndAddLongAcquire

        public abstract long getAndAddLongAcquire​(Object o,
                                                  long offset,
                                                  long delta)
      • getAndAddByte

        public abstract byte getAndAddByte​(Object o,
                                           long offset,
                                           byte delta)
      • getAndAddByteRelease

        public abstract byte getAndAddByteRelease​(Object o,
                                                  long offset,
                                                  byte delta)
      • getAndAddByteAcquire

        public abstract byte getAndAddByteAcquire​(Object o,
                                                  long offset,
                                                  byte delta)
      • getAndAddShort

        public abstract short getAndAddShort​(Object o,
                                             long offset,
                                             short delta)
      • getAndAddShortRelease

        public abstract short getAndAddShortRelease​(Object o,
                                                    long offset,
                                                    short delta)
      • getAndAddShortAcquire

        public abstract short getAndAddShortAcquire​(Object o,
                                                    long offset,
                                                    short delta)
      • getAndAddChar

        public abstract char getAndAddChar​(Object o,
                                           long offset,
                                           char delta)
      • getAndAddCharRelease

        public abstract char getAndAddCharRelease​(Object o,
                                                  long offset,
                                                  char delta)
      • getAndAddCharAcquire

        public abstract char getAndAddCharAcquire​(Object o,
                                                  long offset,
                                                  char delta)
      • getAndAddFloat

        public abstract float getAndAddFloat​(Object o,
                                             long offset,
                                             float delta)
      • getAndAddFloatRelease

        public abstract float getAndAddFloatRelease​(Object o,
                                                    long offset,
                                                    float delta)
      • getAndAddFloatAcquire

        public abstract float getAndAddFloatAcquire​(Object o,
                                                    long offset,
                                                    float delta)
      • getAndAddDouble

        public abstract double getAndAddDouble​(Object o,
                                               long offset,
                                               double delta)
      • getAndAddDoubleRelease

        public abstract double getAndAddDoubleRelease​(Object o,
                                                      long offset,
                                                      double delta)
      • getAndAddDoubleAcquire

        public abstract double getAndAddDoubleAcquire​(Object o,
                                                      long offset,
                                                      double delta)
      • getAndSetInt

        public abstract int getAndSetInt​(Object o,
                                         long offset,
                                         int newValue)
        Atomically exchanges the given value with the current value of a field or array element within the given object o at the given offset.
        参数:
        o - object/array to update the field/element in
        offset - field/element offset
        newValue - new value
        返回:
        the previous value
        从以下版本开始:
        1.8
      • getAndSetIntRelease

        public abstract int getAndSetIntRelease​(Object o,
                                                long offset,
                                                int newValue)
      • getAndSetIntAcquire

        public abstract int getAndSetIntAcquire​(Object o,
                                                long offset,
                                                int newValue)
      • getAndSetLong

        public abstract long getAndSetLong​(Object o,
                                           long offset,
                                           long newValue)
        Atomically exchanges the given value with the current value of a field or array element within the given object o at the given offset.
        参数:
        o - object/array to update the field/element in
        offset - field/element offset
        newValue - new value
        返回:
        the previous value
        从以下版本开始:
        1.8
      • getAndSetLongRelease

        public abstract long getAndSetLongRelease​(Object o,
                                                  long offset,
                                                  long newValue)
      • getAndSetLongAcquire

        public abstract long getAndSetLongAcquire​(Object o,
                                                  long offset,
                                                  long newValue)
      • getAndSetReference

        public abstract Object getAndSetReference​(Object o,
                                                  long offset,
                                                  Object newValue)
        Atomically exchanges the given reference value with the current reference value of a field or array element within the given object o at the given offset.
        参数:
        o - object/array to update the field/element in
        offset - field/element offset
        newValue - new value
        返回:
        the previous value
        从以下版本开始:
        1.8
      • getAndSetReferenceRelease

        public abstract Object getAndSetReferenceRelease​(Object o,
                                                         long offset,
                                                         Object newValue)
      • getAndSetReferenceAcquire

        public abstract Object getAndSetReferenceAcquire​(Object o,
                                                         long offset,
                                                         Object newValue)
      • getAndSetByte

        public abstract byte getAndSetByte​(Object o,
                                           long offset,
                                           byte newValue)
      • getAndSetByteRelease

        public abstract byte getAndSetByteRelease​(Object o,
                                                  long offset,
                                                  byte newValue)
      • getAndSetByteAcquire

        public abstract byte getAndSetByteAcquire​(Object o,
                                                  long offset,
                                                  byte newValue)
      • getAndSetBoolean

        public abstract boolean getAndSetBoolean​(Object o,
                                                 long offset,
                                                 boolean newValue)
      • getAndSetBooleanRelease

        public abstract boolean getAndSetBooleanRelease​(Object o,
                                                        long offset,
                                                        boolean newValue)
      • getAndSetBooleanAcquire

        public abstract boolean getAndSetBooleanAcquire​(Object o,
                                                        long offset,
                                                        boolean newValue)
      • getAndSetShort

        public abstract short getAndSetShort​(Object o,
                                             long offset,
                                             short newValue)
      • getAndSetShortRelease

        public abstract short getAndSetShortRelease​(Object o,
                                                    long offset,
                                                    short newValue)
      • getAndSetShortAcquire

        public abstract short getAndSetShortAcquire​(Object o,
                                                    long offset,
                                                    short newValue)
      • getAndSetChar

        public abstract char getAndSetChar​(Object o,
                                           long offset,
                                           char newValue)
      • getAndSetCharRelease

        public abstract char getAndSetCharRelease​(Object o,
                                                  long offset,
                                                  char newValue)
      • getAndSetCharAcquire

        public abstract char getAndSetCharAcquire​(Object o,
                                                  long offset,
                                                  char newValue)
      • getAndSetFloat

        public abstract float getAndSetFloat​(Object o,
                                             long offset,
                                             float newValue)
      • getAndSetFloatRelease

        public abstract float getAndSetFloatRelease​(Object o,
                                                    long offset,
                                                    float newValue)
      • getAndSetFloatAcquire

        public abstract float getAndSetFloatAcquire​(Object o,
                                                    long offset,
                                                    float newValue)
      • getAndSetDouble

        public abstract double getAndSetDouble​(Object o,
                                               long offset,
                                               double newValue)
      • getAndSetDoubleRelease

        public abstract double getAndSetDoubleRelease​(Object o,
                                                      long offset,
                                                      double newValue)
      • getAndSetDoubleAcquire

        public abstract double getAndSetDoubleAcquire​(Object o,
                                                      long offset,
                                                      double newValue)
      • getAndBitwiseOrBoolean

        public abstract boolean getAndBitwiseOrBoolean​(Object o,
                                                       long offset,
                                                       boolean mask)
      • getAndBitwiseOrBooleanRelease

        public abstract boolean getAndBitwiseOrBooleanRelease​(Object o,
                                                              long offset,
                                                              boolean mask)
      • getAndBitwiseOrBooleanAcquire

        public abstract boolean getAndBitwiseOrBooleanAcquire​(Object o,
                                                              long offset,
                                                              boolean mask)
      • getAndBitwiseAndBoolean

        public abstract boolean getAndBitwiseAndBoolean​(Object o,
                                                        long offset,
                                                        boolean mask)
      • getAndBitwiseAndBooleanRelease

        public abstract boolean getAndBitwiseAndBooleanRelease​(Object o,
                                                               long offset,
                                                               boolean mask)
      • getAndBitwiseAndBooleanAcquire

        public abstract boolean getAndBitwiseAndBooleanAcquire​(Object o,
                                                               long offset,
                                                               boolean mask)
      • getAndBitwiseXorBoolean

        public abstract boolean getAndBitwiseXorBoolean​(Object o,
                                                        long offset,
                                                        boolean mask)
      • getAndBitwiseXorBooleanRelease

        public abstract boolean getAndBitwiseXorBooleanRelease​(Object o,
                                                               long offset,
                                                               boolean mask)
      • getAndBitwiseXorBooleanAcquire

        public abstract boolean getAndBitwiseXorBooleanAcquire​(Object o,
                                                               long offset,
                                                               boolean mask)
      • getAndBitwiseOrByte

        public abstract byte getAndBitwiseOrByte​(Object o,
                                                 long offset,
                                                 byte mask)
      • getAndBitwiseOrByteRelease

        public abstract byte getAndBitwiseOrByteRelease​(Object o,
                                                        long offset,
                                                        byte mask)
      • getAndBitwiseOrByteAcquire

        public abstract byte getAndBitwiseOrByteAcquire​(Object o,
                                                        long offset,
                                                        byte mask)
      • getAndBitwiseAndByte

        public abstract byte getAndBitwiseAndByte​(Object o,
                                                  long offset,
                                                  byte mask)
      • getAndBitwiseAndByteRelease

        public abstract byte getAndBitwiseAndByteRelease​(Object o,
                                                         long offset,
                                                         byte mask)
      • getAndBitwiseAndByteAcquire

        public abstract byte getAndBitwiseAndByteAcquire​(Object o,
                                                         long offset,
                                                         byte mask)
      • getAndBitwiseXorByte

        public abstract byte getAndBitwiseXorByte​(Object o,
                                                  long offset,
                                                  byte mask)
      • getAndBitwiseXorByteRelease

        public abstract byte getAndBitwiseXorByteRelease​(Object o,
                                                         long offset,
                                                         byte mask)
      • getAndBitwiseXorByteAcquire

        public abstract byte getAndBitwiseXorByteAcquire​(Object o,
                                                         long offset,
                                                         byte mask)
      • getAndBitwiseOrChar

        public abstract char getAndBitwiseOrChar​(Object o,
                                                 long offset,
                                                 char mask)
      • getAndBitwiseOrCharRelease

        public abstract char getAndBitwiseOrCharRelease​(Object o,
                                                        long offset,
                                                        char mask)
      • getAndBitwiseOrCharAcquire

        public abstract char getAndBitwiseOrCharAcquire​(Object o,
                                                        long offset,
                                                        char mask)
      • getAndBitwiseAndChar

        public abstract char getAndBitwiseAndChar​(Object o,
                                                  long offset,
                                                  char mask)
      • getAndBitwiseAndCharRelease

        public abstract char getAndBitwiseAndCharRelease​(Object o,
                                                         long offset,
                                                         char mask)
      • getAndBitwiseAndCharAcquire

        public abstract char getAndBitwiseAndCharAcquire​(Object o,
                                                         long offset,
                                                         char mask)
      • getAndBitwiseXorChar

        public abstract char getAndBitwiseXorChar​(Object o,
                                                  long offset,
                                                  char mask)
      • getAndBitwiseXorCharRelease

        public abstract char getAndBitwiseXorCharRelease​(Object o,
                                                         long offset,
                                                         char mask)
      • getAndBitwiseXorCharAcquire

        public abstract char getAndBitwiseXorCharAcquire​(Object o,
                                                         long offset,
                                                         char mask)
      • getAndBitwiseOrShort

        public abstract short getAndBitwiseOrShort​(Object o,
                                                   long offset,
                                                   short mask)
      • getAndBitwiseOrShortRelease

        public abstract short getAndBitwiseOrShortRelease​(Object o,
                                                          long offset,
                                                          short mask)
      • getAndBitwiseOrShortAcquire

        public abstract short getAndBitwiseOrShortAcquire​(Object o,
                                                          long offset,
                                                          short mask)
      • getAndBitwiseAndShort

        public abstract short getAndBitwiseAndShort​(Object o,
                                                    long offset,
                                                    short mask)
      • getAndBitwiseAndShortRelease

        public abstract short getAndBitwiseAndShortRelease​(Object o,
                                                           long offset,
                                                           short mask)
      • getAndBitwiseAndShortAcquire

        public abstract short getAndBitwiseAndShortAcquire​(Object o,
                                                           long offset,
                                                           short mask)
      • getAndBitwiseXorShort

        public abstract short getAndBitwiseXorShort​(Object o,
                                                    long offset,
                                                    short mask)
      • getAndBitwiseXorShortRelease

        public abstract short getAndBitwiseXorShortRelease​(Object o,
                                                           long offset,
                                                           short mask)
      • getAndBitwiseXorShortAcquire

        public abstract short getAndBitwiseXorShortAcquire​(Object o,
                                                           long offset,
                                                           short mask)
      • getAndBitwiseOrInt

        public abstract int getAndBitwiseOrInt​(Object o,
                                               long offset,
                                               int mask)
      • getAndBitwiseOrIntRelease

        public abstract int getAndBitwiseOrIntRelease​(Object o,
                                                      long offset,
                                                      int mask)
      • getAndBitwiseOrIntAcquire

        public abstract int getAndBitwiseOrIntAcquire​(Object o,
                                                      long offset,
                                                      int mask)
      • getAndBitwiseAndInt

        public abstract int getAndBitwiseAndInt​(Object o,
                                                long offset,
                                                int mask)
        Atomically replaces the current value of a field or array element within the given object with the result of bitwise AND between the current value and mask.
        参数:
        o - object/array to update the field/element in
        offset - field/element offset
        mask - the mask value
        返回:
        the previous value
        从以下版本开始:
        9
      • getAndBitwiseAndIntRelease

        public abstract int getAndBitwiseAndIntRelease​(Object o,
                                                       long offset,
                                                       int mask)
      • getAndBitwiseAndIntAcquire

        public abstract int getAndBitwiseAndIntAcquire​(Object o,
                                                       long offset,
                                                       int mask)
      • getAndBitwiseXorInt

        public abstract int getAndBitwiseXorInt​(Object o,
                                                long offset,
                                                int mask)
      • getAndBitwiseXorIntRelease

        public abstract int getAndBitwiseXorIntRelease​(Object o,
                                                       long offset,
                                                       int mask)
      • getAndBitwiseXorIntAcquire

        public abstract int getAndBitwiseXorIntAcquire​(Object o,
                                                       long offset,
                                                       int mask)
      • getAndBitwiseOrLong

        public abstract long getAndBitwiseOrLong​(Object o,
                                                 long offset,
                                                 long mask)
      • getAndBitwiseOrLongRelease

        public abstract long getAndBitwiseOrLongRelease​(Object o,
                                                        long offset,
                                                        long mask)
      • getAndBitwiseOrLongAcquire

        public abstract long getAndBitwiseOrLongAcquire​(Object o,
                                                        long offset,
                                                        long mask)
      • getAndBitwiseAndLong

        public abstract long getAndBitwiseAndLong​(Object o,
                                                  long offset,
                                                  long mask)
      • getAndBitwiseAndLongRelease

        public abstract long getAndBitwiseAndLongRelease​(Object o,
                                                         long offset,
                                                         long mask)
      • getAndBitwiseAndLongAcquire

        public abstract long getAndBitwiseAndLongAcquire​(Object o,
                                                         long offset,
                                                         long mask)
      • getAndBitwiseXorLong

        public abstract long getAndBitwiseXorLong​(Object o,
                                                  long offset,
                                                  long mask)
      • getAndBitwiseXorLongRelease

        public abstract long getAndBitwiseXorLongRelease​(Object o,
                                                         long offset,
                                                         long mask)
      • getAndBitwiseXorLongAcquire

        public abstract long getAndBitwiseXorLongAcquire​(Object o,
                                                         long offset,
                                                         long mask)
      • loadFence

        public abstract void loadFence()
        Ensures that loads before the fence will not be reordered with loads and stores after the fence; a "LoadLoad plus LoadStore barrier".

        Corresponds to C11 atomic_thread_fence(memory_order_acquire) (an "acquire fence").

        A pure LoadLoad fence is not provided, since the addition of LoadStore is almost always desired, and most current hardware instructions that provide a LoadLoad barrier also provide a LoadStore barrier for free.

        从以下版本开始:
        1.8
      • storeFence

        public abstract void storeFence()
        Ensures that loads and stores before the fence will not be reordered with stores after the fence; a "StoreStore plus LoadStore barrier".

        Corresponds to C11 atomic_thread_fence(memory_order_release) (a "release fence").

        A pure StoreStore fence is not provided, since the addition of LoadStore is almost always desired, and most current hardware instructions that provide a StoreStore barrier also provide a LoadStore barrier for free.

        从以下版本开始:
        1.8
      • fullFence

        public abstract void fullFence()
        Ensures that loads and stores before the fence will not be reordered with loads and stores after the fence. Implies the effects of both loadFence() and storeFence(), and in addition, the effect of a StoreLoad barrier.

        Corresponds to C11 atomic_thread_fence(memory_order_seq_cst).

        从以下版本开始:
        1.8
      • loadLoadFence

        public abstract void loadLoadFence()
        Ensures that loads before the fence will not be reordered with loads after the fence.
      • storeStoreFence

        public abstract void storeStoreFence()
        Ensures that stores before the fence will not be reordered with stores after the fence.
      • isBigEndian

        public abstract boolean isBigEndian()
        返回:
        Returns true if the abstract byte ordering of this platform is big-endian, false if it is little-endian.
      • unalignedAccess

        public abstract boolean unalignedAccess()
        返回:
        Returns true if this platform is capable of performing accesses at addresses which are not aligned for the type of the primitive type being accessed, false otherwise.
      • getLongUnaligned

        @Contract(pure=true)
        public abstract long getLongUnaligned​(Object o,
                                              long offset)
        Fetches a value at some byte offset into a given Java object. More specifically, fetches a value within the given object o at the given offset, or (if o is null) from the memory address whose numerical value is the given offset.

        The specification of this method is the same as getLong(Object, long) except that the offset does not need to have been obtained from objectFieldOffset(java.lang.reflect.Field) on the Field of some Java field. The value in memory is raw data, and need not correspond to any Java variable. Unless o is null, the value accessed must be entirely within the allocated object. The endianness of the value in memory is the endianness of the abstract platform.

        The read will be atomic with respect to the largest power of two that divides the GCD of the offset and the storage size. For example, getLongUnaligned will make atomic reads of 2-, 4-, or 8-byte storage units if the offset is zero mod 2, 4, or 8, respectively. There are no other guarantees of atomicity.

        8-byte atomicity is only guaranteed on platforms on which support atomic accesses to longs.

        参数:
        o - Java heap object in which the value resides, if any, else null
        offset - The offset in bytes from the start of the object
        返回:
        the value fetched from the indicated object
        抛出:
        RuntimeException - No defined exceptions are thrown, not even NullPointerException
        从以下版本开始:
        9
      • getLongUnaligned

        @Contract(pure=true)
        public abstract long getLongUnaligned​(Object o,
                                              long offset,
                                              boolean bigEndian)
        As getLongUnaligned(Object, long) but with an additional argument which specifies the endianness of the value as stored in memory.
        参数:
        o - Java heap object in which the variable resides
        offset - The offset in bytes from the start of the object
        bigEndian - The endianness of the value
        返回:
        the value fetched from the indicated object
        从以下版本开始:
        9
      • putLongUnaligned

        public abstract void putLongUnaligned​(Object o,
                                              long offset,
                                              long x)
        Stores a value at some byte offset into a given Java object.

        The specification of this method is the same as getLong(Object, long) except that the offset does not need to have been obtained from objectFieldOffset(java.lang.reflect.Field) on the Field of some Java field. The value in memory is raw data, and need not correspond to any Java variable. The endianness of the value in memory is the endianness of the abstract platform.

        The write will be atomic with respect to the largest power of two that divides the GCD of the offset and the storage size. For example, putLongUnaligned will make atomic writes of 2-, 4-, or 8-byte storage units if the offset is zero mod 2, 4, or 8, respectively. There are no other guarantees of atomicity.

        8-byte atomicity is only guaranteed on platforms on which support atomic accesses to longs.

        参数:
        o - Java heap object in which the value resides, if any, else null
        offset - The offset in bytes from the start of the object
        x - the value to store
        抛出:
        RuntimeException - No defined exceptions are thrown, not even NullPointerException
        从以下版本开始:
        9
      • putLongUnaligned

        public abstract void putLongUnaligned​(Object o,
                                              long offset,
                                              long x,
                                              boolean bigEndian)
        As putLongUnaligned(Object, long, long) but with an additional argument which specifies the endianness of the value as stored in memory.
        参数:
        o - Java heap object in which the value resides
        offset - The offset in bytes from the start of the object
        x - the value to store
        bigEndian - The endianness of the value
        抛出:
        RuntimeException - No defined exceptions are thrown, not even NullPointerException
        从以下版本开始:
        9