# VarHandle

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# VarHandle

```
abstract class VarHandle
```

|---|----------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                           ||
| ↳ | [java.lang.invoke.VarHandle](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#) |

A VarHandle is a dynamically strongly typed reference to a variable, or to a parametrically-defined family of variables, including static fields, non-static fields, array elements, or components of an off-heap data structure. Access to such variables is supported under various*access modes*, including plain read/write access, volatile read/write access, and compare-and-set.

VarHandles are immutable and have no visible state. VarHandles cannot be subclassed by the user.

A VarHandle has:

- a[variable type](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#varType())T, the type of every variable referenced by this VarHandle; and
- a list of[coordinate types](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#coordinateTypes())`CT1, CT2, ..., CTn`, the types of*coordinate expressions*that jointly locate a variable referenced by this VarHandle.

Variable and coordinate types may be primitive or reference, and are represented by`Class`objects. The list of coordinate types may be empty.

Factory methods that produce or[lookup](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles.Lookup)VarHandle instances document the supported variable type and the list of coordinate types.

Each access mode is associated with one*access mode method* , a[signature polymorphic](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandle#sigpoly)method named for the access mode. When an access mode method is invoked on a VarHandle instance, the initial arguments to the invocation are coordinate expressions that indicate in precisely which object the variable is to be accessed. Trailing arguments to the invocation represent values of importance to the access mode. For example, the various compare-and-set or compare-and-exchange access modes require two trailing arguments for the variable's expected value and new value.

The arity and types of arguments to the invocation of an access mode method are not checked statically. Instead, each access mode method specifies an[access mode type](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#accessModeType(java.lang.invoke.VarHandle.AccessMode)), represented as an instance of[MethodType](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodType), that serves as a kind of method signature against which the arguments are checked dynamically. An access mode type gives formal parameter types in terms of the coordinate types of a VarHandle instance and the types for values of importance to the access mode. An access mode type also gives a return type, often in terms of the variable type of a VarHandle instance. When an access mode method is invoked on a VarHandle instance, the symbolic type descriptor at the call site, the run time types of arguments to the invocation, and the run time type of the return value, must[match](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#invoke)the types given in the access mode type. A runtime exception will be thrown if the match fails. For example, the access mode method[compareAndSet](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#compareAndSet(kotlin.Any))specifies that if its receiver is a VarHandle instance with coordinate types`CT1, ..., CTn`and variable type`T`, then its access mode type is`(CT1 c1, ..., CTn cn, T expectedValue, T newValue)boolean`. Suppose that a VarHandle instance can access array elements, and that its coordinate types are`String[]`and`int`while its variable type is`String`. The access mode type for`compareAndSet`on this VarHandle instance would be`(String[] c1, int c2, String expectedValue, String newValue)boolean`. Such a VarHandle instance may be produced by the[array factory method](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles#arrayElementVarHandle(java.lang.Class))and access array elements as follows:  

```kotlin
<code>String[] sa = ...
  VarHandle avh = MethodHandles.arrayElementVarHandle(String[].class);
  boolean r = avh.compareAndSet(sa, 10, "expected", "new");
  </code>
```

Access modes control atomicity and consistency properties.*Plain* read (`get`) and write (`set`) accesses are guaranteed to be bitwise atomic only for references and for primitive values of at most 32 bits, and impose no observable ordering constraints with respect to threads other than the executing thread.*Opaque* operations are bitwise atomic and coherently ordered with respect to accesses to the same variable. In addition to obeying Opaque properties,*Acquire* mode reads and their subsequent accesses are ordered after matching*Release* mode writes and their previous accesses. In addition to obeying Acquire and Release properties, all*Volatile*operations are totally ordered with respect to each other.

Access modes are grouped into the following categories:

- read access modes that get the value of a variable under specified memory ordering effects. The set of corresponding access mode methods belonging to this group consists of the methods[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)),[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)),[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)),[getOpaque](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getOpaque(kotlin.Any)).
- write access modes that set the value of a variable under specified memory ordering effects. The set of corresponding access mode methods belonging to this group consists of the methods[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any)),[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any)),[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any)),[setOpaque](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setOpaque(kotlin.Any)).
- atomic update access modes that, for example, atomically compare and set the value of a variable under specified memory ordering effects. The set of corresponding access mode methods belonging to this group consists of the methods[compareAndSet](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#compareAndSet(kotlin.Any)),[weakCompareAndSetPlain](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#weakCompareAndSetPlain(kotlin.Any)),[weakCompareAndSet](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#weakCompareAndSet(kotlin.Any)),[weakCompareAndSetAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#weakCompareAndSetAcquire(kotlin.Any)),[weakCompareAndSetRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#weakCompareAndSetRelease(kotlin.Any)),[compareAndExchangeAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#compareAndExchangeAcquire(kotlin.Any)),[compareAndExchange](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#compareAndExchange(kotlin.Any)),[compareAndExchangeRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#compareAndExchangeRelease(kotlin.Any)),[getAndSet](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndSet(kotlin.Any)),[getAndSetAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndSetAcquire(kotlin.Any)),[getAndSetRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndSetRelease(kotlin.Any)).
- numeric atomic update access modes that, for example, atomically get and set with addition the value of a variable under specified memory ordering effects. The set of corresponding access mode methods belonging to this group consists of the methods[getAndAdd](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndAdd(kotlin.Any)),[getAndAddAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndAddAcquire(kotlin.Any)),[getAndAddRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndAddRelease(kotlin.Any)),
- bitwise atomic update access modes that, for example, atomically get and bitwise OR the value of a variable under specified memory ordering effects. The set of corresponding access mode methods belonging to this group consists of the methods[getAndBitwiseOr](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseOr(kotlin.Any)),[getAndBitwiseOrAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseOrAcquire(kotlin.Any)),[getAndBitwiseOrRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseOrRelease(kotlin.Any)),[getAndBitwiseAnd](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseAnd(kotlin.Any)),[getAndBitwiseAndAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseAndAcquire(kotlin.Any)),[getAndBitwiseAndRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseAndRelease(kotlin.Any)),[getAndBitwiseXor](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseXor(kotlin.Any)),[getAndBitwiseXorAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseXorAcquire(kotlin.Any)),[getAndBitwiseXorRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseXorRelease(kotlin.Any)).

Factory methods that produce or[lookup](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles.Lookup)VarHandle instances document the set of access modes that are supported, which may also include documenting restrictions based on the variable type and whether a variable is read-only. If an access mode is not supported then the corresponding access mode method will on invocation throw an`UnsupportedOperationException`. Factory methods should document any additional undeclared exceptions that may be thrown by access mode methods. The[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any))access mode is supported for all VarHandle instances and the corresponding method never throws`UnsupportedOperationException`. If a VarHandle references a read-only variable (for example a`final`field) then write, atomic update, numeric atomic update, and bitwise atomic update access modes are not supported and corresponding methods throw`UnsupportedOperationException`. Read/write access modes (if supported), with the exception of`get`and`set`, provide atomic access for reference types and all primitive types. Unless stated otherwise in the documentation of a factory method, the access modes`get`and`set`(if supported) provide atomic access for reference types and all primitives types, with the exception of`long`and`double`on 32-bit platforms.

Access modes will override any memory ordering effects specified at the declaration site of a variable. For example, a VarHandle accessing a field using the`get`access mode will access the field as specified*by its access mode* even if that field is declared`volatile`. When mixed access is performed extreme care should be taken since the Java Memory Model may permit surprising results.

In addition to supporting access to variables under various access modes, a set of static methods, referred to as memory fence methods, is also provided for fine-grained control of memory ordering. The Java Language Specification permits other threads to observe operations as if they were executed in orders different than are apparent in program source code, subject to constraints arising, for example, from the use of locks,`volatile`fields or VarHandles. The static methods,[fullFence](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#fullFence()),[acquireFence](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#acquireFence()),[releaseFence](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#releaseFence()),[loadLoadFence](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#loadLoadFence())and[storeStoreFence](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#storeStoreFence()), can also be used to impose constraints. Their specifications, as is the case for certain access modes, are phrased in terms of the lack of "reorderings" -- observable ordering effects that might otherwise occur if the fence was not present. More precise phrasing of the specification of access mode methods and memory fence methods may accompany future updates of the Java Language Specification.

# Compiling invocation of access mode methods

A Java method call expression naming an access mode method can invoke a VarHandle from Java source code. From the viewpoint of source code, these methods can take any arguments and their polymorphic result (if expressed) can be cast to any return type. Formally this is accomplished by giving the access mode methods variable arity`Object`arguments and`Object`return types (if the return type is polymorphic), but they have an additional quality called*signature polymorphism* which connects this freedom of invocation directly to the JVM execution stack.

As is usual with virtual methods, source-level calls to access mode methods compile to an`invokevirtual`instruction. More unusually, the compiler must record the actual argument types, and may not perform method invocation conversions on the arguments. Instead, it must generate instructions to push them on the stack according to their own unconverted types. The VarHandle object itself will be pushed on the stack before the arguments. The compiler then generates an`invokevirtual`instruction that invokes the access mode method with a symbolic type descriptor which describes the argument and return types.

To issue a complete symbolic type descriptor, the compiler must also determine the return type (if polymorphic). This is based on a cast on the method invocation expression, if there is one, or else`Object`if the invocation is an expression, or else`void`if the invocation is a statement. The cast may be to a primitive type (but not`void`).

As a corner case, an uncasted`null`argument is given a symbolic type descriptor of`java.lang.Void`. The ambiguity with the type`Void`is harmless, since there are no references of type`Void`except the null reference.

# Performing invocation of access mode methods

The first time an`invokevirtual`instruction is executed it is linked by symbolically resolving the names in the instruction and verifying that the method call is statically legal. This also holds for calls to access mode methods. In this case, the symbolic type descriptor emitted by the compiler is checked for correct syntax, and names it contains are resolved. Thus, an`invokevirtual`instruction which invokes an access mode method will always link, as long as the symbolic type descriptor is syntactically well-formed and the types exist.

When the`invokevirtual`is executed after linking, the receiving VarHandle's access mode type is first checked by the JVM to ensure that it matches the symbolic type descriptor. If the type match fails, it means that the access mode method which the caller is invoking is not present on the individual VarHandle being invoked.

Invocation of an access mode method behaves as if an invocation of[MethodHandle.invoke](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandle#invoke(kotlin.Any)), where the receiving method handle accepts the VarHandle instance as the leading argument. More specifically, the following, where`{access-mode}`corresponds to the access mode method name:  

```kotlin
<code>VarHandle vh = ..
  R r = (R) vh.{access-mode}(p1, p2, ..., pN);
  </code>
```
behaves as if:  

```kotlin
<code>VarHandle vh = ..
  VarHandle.AccessMode am = VarHandle.AccessMode.valueFromMethodName("{access-mode}");
  MethodHandle mh = MethodHandles.varHandleExactInvoker(
                        am,
                        vh.accessModeType(am));
 
  R r = (R) mh.invoke(vh, p1, p2, ..., pN)
  </code>
```
(modulo access mode methods do not declare throwing of`Throwable`). This is equivalent to:  

```kotlin
<code>MethodHandle mh = MethodHandles.lookup().findVirtual(
                        VarHandle.class,
                        "{access-mode}",
                        MethodType.methodType(R, p1, p2, ..., pN));
 
  R r = (R) mh.invokeExact(vh, p1, p2, ..., pN)
  </code>
```
where the desired method type is the symbolic type descriptor and a[MethodHandle.invokeExact](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandle#invokeExact(kotlin.Any))is performed, since before invocation of the target, the handle will apply reference casts as necessary and box, unbox, or widen primitive values, as if by[asType](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandle#asType(java.lang.invoke.MethodType))(see also[MethodHandles.varHandleInvoker](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles#varHandleInvoker(java.lang.invoke.VarHandle.AccessMode,%20java.lang.invoke.MethodType))). More concisely, such behaviour is equivalent to:  

```kotlin
<code>VarHandle vh = ..
  VarHandle.AccessMode am = VarHandle.AccessMode.valueFromMethodName("{access-mode}");
  MethodHandle mh = vh.toMethodHandle(am);
 
  R r = (R) mh.invoke(p1, p2, ..., pN)
  </code>
```
Where, in this case, the method handle is bound to the VarHandle instance.

# Invocation checking

In typical programs, VarHandle access mode type matching will usually succeed. But if a match fails, the JVM will throw a[WrongMethodTypeException](https://developer.android.com/reference/kotlin/java/lang/invoke/WrongMethodTypeException).

Thus, an access mode type mismatch which might show up as a linkage error in a statically typed program can show up as a dynamic`WrongMethodTypeException`in a program which uses VarHandles.

Because access mode types contain "live"`Class`objects, method type matching takes into account both type names and class loaders. Thus, even if a VarHandle`VH`is created in one class loader`L1`and used in another`L2`, VarHandle access mode method calls are type-safe, because the caller's symbolic type descriptor, as resolved in`L2`, is matched against the original callee method's symbolic type descriptor, as resolved in`L1`. The resolution in`L1`happens when`VH`is created and its access mode types are assigned, while the resolution in`L2`happens when the`invokevirtual`instruction is linked.

Apart from type descriptor checks, a VarHandles's capability to access it's variables is unrestricted. If a VarHandle is formed on a non-public variable by a class that has access to that variable, the resulting VarHandle can be used in any place by any caller who receives a reference to it.

Unlike with the Core Reflection API, where access is checked every time a reflective method is invoked, VarHandle access checking is performed[when the VarHandle is created](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles.Lookup#access). Thus, VarHandles to non-public variables, or to variables in non-public classes, should generally be kept secret. They should not be passed to untrusted code unless their use from the untrusted code would be harmless.

# VarHandle creation

Java code can create a VarHandle that directly accesses any field that is accessible to that code. This is done via a reflective, capability-based API called[MethodHandles.Lookup](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles.Lookup). For example, a VarHandle for a non-static field can be obtained from[Lookup.findVarHandle](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles.Lookup#findVarHandle(java.lang.Class,%20kotlin.String,%20java.lang.Class)). There is also a conversion method from Core Reflection API objects,[Lookup.unreflectVarHandle](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles.Lookup#unreflectVarHandle(java.lang.reflect.Field)).

Access to protected field members is restricted to receivers only of the accessing class, or one of its subclasses, and the accessing class must in turn be a subclass (or package sibling) of the protected member's defining class. If a VarHandle refers to a protected non-static field of a declaring class outside the current package, the receiver argument will be narrowed to the type of the accessing class.

# Interoperation between VarHandles and the Core Reflection API

Using factory methods in the[Lookup](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles.Lookup)API, any field represented by a Core Reflection API object can be converted to a behaviorally equivalent VarHandle. For example, a reflective[Field](https://developer.android.com/reference/kotlin/java/lang/reflect/Field.html#)can be converted to a VarHandle using[Lookup.unreflectVarHandle](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles.Lookup#unreflectVarHandle(java.lang.reflect.Field)). The resulting VarHandles generally provide more direct and efficient access to the underlying fields.

As a special case, when the Core Reflection API is used to view the signature polymorphic access mode methods in this class, they appear as ordinary non-polymorphic methods. Their reflective appearance, as viewed by[Class.getDeclaredMethod](https://developer.android.com/reference/kotlin/java/lang/Class.html#getDeclaredMethod(kotlin.String,%20java.lang.Class)), is unaffected by their special status in this API. For example, java.lang.reflect.Method#getModifiers will report exactly those modifier bits required for any similarly declared method, including in this case`native`and`varargs`bits.

As with any reflected method, these methods (when reflected) may be invoked directly via[java.lang.reflect.Method.invoke](https://developer.android.com/reference/kotlin/java/lang/reflect/Method.html#invoke(kotlin.Any,%20kotlin.Any)), via JNI, or indirectly via[Lookup.unreflect](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles.Lookup#unreflect(java.lang.reflect.Method)). However, such reflective calls do not result in access mode method invocations. Such a call, if passed the required argument (a single one, of type`Object[]`), will ignore the argument and will throw an`UnsupportedOperationException`.

Since`invokevirtual`instructions can natively invoke VarHandle access mode methods under any symbolic type descriptor, this reflective view conflicts with the normal presentation of these methods via bytecodes. Thus, these native methods, when reflectively viewed by`Class.getDeclaredMethod`, may be regarded as placeholders only.

In order to obtain an invoker method for a particular access mode type, use[java.lang.invoke.MethodHandles#varHandleExactInvoker](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles#varHandleExactInvoker(java.lang.invoke.VarHandle.AccessMode,%20java.lang.invoke.MethodType))or[java.lang.invoke.MethodHandles#varHandleInvoker](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles#varHandleInvoker(java.lang.invoke.VarHandle.AccessMode,%20java.lang.invoke.MethodType)). The[Lookup.findVirtual](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles.Lookup#findVirtual(java.lang.Class,%20kotlin.String,%20java.lang.invoke.MethodType))API is also able to return a method handle to call an access mode method for any specified access mode type and is equivalent in behaviour to[java.lang.invoke.MethodHandles#varHandleInvoker](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandles#varHandleInvoker(java.lang.invoke.VarHandle.AccessMode,%20java.lang.invoke.MethodType)).

# Interoperation between VarHandles and Java generics

A VarHandle can be obtained for a variable, such as a field, which is declared with Java generic types. As with the Core Reflection API, the VarHandle's variable type will be constructed from the erasure of the source-level type. When a VarHandle access mode method is invoked, the types of its arguments or the return value cast type may be generic types or type instances. If this occurs, the compiler will replace those types by their erasures when it constructs the symbolic type descriptor for the`invokevirtual`instruction.

## Summary

|                                                                                           Nested classes                                                                                           ||
|---|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|   | [AccessMode](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle.AccessMode) The set of access modes that specify how a variable, referenced by a VarHandle, is accessed. |

|                                                                                                                                                                                                                                                                                                                                                                                                                                             Public methods                                                                                                                                                                                                                                                                                                                                                                                                                                             ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [MethodType](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodType)!                                                                                                        | [accessModeType](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#accessModeType(java.lang.invoke.VarHandle.AccessMode))`(`accessMode:` `[VarHandle.AccessMode](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle.AccessMode)!`)` Obtains the access mode type for this VarHandle and a given access mode.                                                                                                                                                                                                                                                                                                                                          |
| openstatic[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                                                                           | [acquireFence](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#acquireFence())`()` Ensures that loads before the fence will not be reordered with loads and stores after the fence.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [compareAndExchange](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#compareAndExchange(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the`newValue`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).           |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [compareAndExchangeAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#compareAndExchangeAcquire(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the`newValue`with the memory semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).               |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [compareAndExchangeRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#compareAndExchangeRelease(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the`newValue`with the memory semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).               |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                                                               | [compareAndSet](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#compareAndSet(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the`newValue`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).                     |
| [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[Class](https://developer.android.com/reference/kotlin/java/lang/Class.html#)\<\*\>!\>! | [coordinateTypes](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#coordinateTypes())`()` Returns the coordinate types for this VarHandle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| openstatic[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                                                                           | [fullFence](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#fullFence())`()` Ensures that loads and stores before the fence will not be reordered with loads and stores after the fence.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Returns the value of a variable, with memory semantics of reading as if the variable was declared non-`volatile`.                                                                                                                                                                                                                                                                                                                                                                                 |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Returns the value of a variable, and ensures that subsequent loads and stores are not reordered before this access.                                                                                                                                                                                                                                                                                                                                                                 |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndAdd](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndAdd(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically adds the`value`to the current value of a variable with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any)), and returns the variable's previous value, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).                                                                       |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndAddAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndAddAcquire(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically adds the`value`to the current value of a variable with the memory semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any)), and returns the variable's previous value, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).                                                                           |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndAddRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndAddRelease(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically adds the`value`to the current value of a variable with the memory semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any)), and returns the variable's previous value, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).                                                                           |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndBitwiseAnd](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseAnd(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the result of bitwise AND between the variable's current value and the`mask`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)). |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndBitwiseAndAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseAndAcquire(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the result of bitwise AND between the variable's current value and the`mask`with the memory semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).     |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndBitwiseAndRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseAndRelease(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the result of bitwise AND between the variable's current value and the`mask`with the memory semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).     |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndBitwiseOr](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseOr(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the result of bitwise OR between the variable's current value and the`mask`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).    |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndBitwiseOrAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseOrAcquire(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the result of bitwise OR between the variable's current value and the`mask`with the memory semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).        |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndBitwiseOrRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseOrRelease(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the result of bitwise OR between the variable's current value and the`mask`with the memory semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).        |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndBitwiseXor](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseXor(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the result of bitwise XOR between the variable's current value and the`mask`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)). |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndBitwiseXorAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseXorAcquire(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the result of bitwise XOR between the variable's current value and the`mask`with the memory semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).     |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndBitwiseXorRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndBitwiseXorRelease(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the result of bitwise XOR between the variable's current value and the`mask`with the memory semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).     |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndSet](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndSet(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the`newValue`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).                                                                              |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndSetAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndSetAcquire(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the`newValue`with the memory semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).                                                                                  |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getAndSetRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAndSetRelease(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Atomically sets the value of a variable to the`newValue`with the memory semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).                                                                                  |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getOpaque](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getOpaque(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Returns the value of a variable, accessed in program order, but with no assurance of memory ordering effects with respect to other threads.                                                                                                                                                                                                                                                                                                                                           |
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!                                                                                                                      | [getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Returns the value of a variable, with memory semantics of reading as if the variable was declared`volatile`.                                                                                                                                                                                                                                                                                                                                                                      |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                                                               | [isAccessModeSupported](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#isAccessModeSupported(java.lang.invoke.VarHandle.AccessMode))`(`accessMode:` `[VarHandle.AccessMode](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle.AccessMode)!`)` Returns`true`if the given access mode is supported, otherwise`false`.                                                                                                                                                                                                                                                                                                                               |
| openstatic[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                                                                           | [loadLoadFence](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#loadLoadFence())`()` Ensures that loads before the fence will not be reordered with loads after the fence.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| openstatic[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                                                                           | [releaseFence](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#releaseFence())`()` Ensures that loads and stores before the fence will not be reordered with stores after the fence.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                                                                                     | [set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Sets the value of a variable to the`newValue`, with memory semantics of setting as if the variable was declared non-`volatile`and non-`final`.                                                                                                                                                                                                                                                                                                                                                    |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                                                                                     | [setOpaque](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setOpaque(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Sets the value of a variable to the`newValue`, in program order, but with no assurance of memory ordering effects with respect to other threads.                                                                                                                                                                                                                                                                                                                                      |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                                                                                     | [setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Sets the value of a variable to the`newValue`, and ensures that prior loads and stores are not reordered after this access.                                                                                                                                                                                                                                                                                                                                                         |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                                                                                     | [setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Sets the value of a variable to the`newValue`, with memory semantics of setting as if the variable was declared`volatile`.                                                                                                                                                                                                                                                                                                                                                        |
| openstatic[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                                                                           | [storeStoreFence](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#storeStoreFence())`()` Ensures that stores before the fence will not be reordered with stores after the fence.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [MethodHandle](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandle)!                                                                                                    | [toMethodHandle](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#toMethodHandle(java.lang.invoke.VarHandle.AccessMode))`(`accessMode:` `[VarHandle.AccessMode](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle.AccessMode)!`)` Obtains a method handle bound to this VarHandle and the given access mode.                                                                                                                                                                                                                                                                                                                                        |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)                                                                                                                 | [toString](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#toString())`()` Returns a compact textual description of this[VarHandle](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#), including the type of variable described, and a description of its coordinates.                                                                                                                                                                                                                                                                                                                                                                           |
| [Class](https://developer.android.com/reference/kotlin/java/lang/Class.html#)\<\*\>!                                                                                                             | [varType](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#varType())`()` Returns the variable type of variables referenced by this VarHandle.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                                                               | [weakCompareAndSet](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#weakCompareAndSet(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Possibly atomically sets the value of a variable to the`newValue`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).    |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                                                               | [weakCompareAndSetAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#weakCompareAndSetAcquire(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Possibly atomically sets the value of a variable to the`newValue`with the semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).               |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                                                               | [weakCompareAndSetPlain](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#weakCompareAndSetPlain(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Possibly atomically sets the value of a variable to the`newValue`with the semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).                                 |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                                                               | [weakCompareAndSetRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#weakCompareAndSetRelease(kotlin.Any))`(`vararg` `args:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!`)` Possibly atomically sets the value of a variable to the`newValue`with the semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).               |

## Public methods

### accessModeType

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun accessModeType(accessMode: VarHandle.AccessMode!): MethodType!
```

Obtains the access mode type for this VarHandle and a given access mode.

The access mode type's parameter types will consist of a prefix that is the coordinate types of this VarHandle followed by further types as defined by the access mode method. The access mode type's return type is defined by the return type of the access mode method.

|                                                                                                   Parameters                                                                                                    ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `accessMode` | [VarHandle.AccessMode](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle.AccessMode)!:the access mode, corresponding to the signature-polymorphic method of the same name |

|                                                                  Return                                                                   ||
|-------------------------------------------------------------------------------------------|------------------------------------------------|
| [MethodType](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodType)! | the access mode type for the given access mode |

### acquireFence

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun acquireFence(): Unit
```

Ensures that loads before the fence will not be reordered with loads and stores after the fence.  

### compareAndExchange

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun compareAndExchange(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the`newValue`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)T`.

The symbolic type descriptor at the call site of`compareAndExchange`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE)`on this VarHandle.

|                                                                                                              Parameters                                                                                                               ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)`, statically represented using varargs. |

|                                                                                                                   Return                                                                                                                   ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the witness value, which will be the same as the`expectedValue`if successful , statically represented using`Object`. |

|                                                                         Exceptions                                                                         ||
|---------------------------------------------|---------------------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                                         |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type is not compatible with the caller's symbolic type descriptor.                         |
| `java.lang.ClassCastException`              | if the access mode type is compatible with the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))
- [#getVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any))  

### compareAndExchangeAcquire

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun compareAndExchangeAcquire(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the`newValue`with the memory semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)T`.

The symbolic type descriptor at the call site of`compareAndExchangeAcquire`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)`on this VarHandle.

|                                                                                                              Parameters                                                                                                               ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)`, statically represented using varargs. |

|                                                                                                                   Return                                                                                                                   ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the witness value, which will be the same as the`expectedValue`if successful , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#set(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))
- [#getAcquire(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any))  

### compareAndExchangeRelease

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun compareAndExchangeRelease(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the`newValue`with the memory semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)T`.

The symbolic type descriptor at the call site of`compareAndExchangeRelease`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)`on this VarHandle.

|                                                                                                              Parameters                                                                                                               ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)`, statically represented using varargs. |

|                                                                                                                   Return                                                                                                                   ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the witness value, which will be the same as the`expectedValue`if successful , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setRelease(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))
- [#get(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any))  

### compareAndSet

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun compareAndSet(vararg args: Any!): Boolean
```

Atomically sets the value of a variable to the`newValue`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean`.

The symbolic type descriptor at the call site of`compareAndSet`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.COMPARE_AND_SET)`on this VarHandle.

|                                                                                                              Parameters                                                                                                               ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)`, statically represented using varargs. |

|                                                                                        Return                                                                                         ||
|------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if successful, otherwise`false`if the witness value was not the same as the`expectedValue`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))
- [#getVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any))  

### coordinateTypes

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun coordinateTypes(): MutableList<Class<*>!>!
```

Returns the coordinate types for this VarHandle.

|                                                                                                                                 Return                                                                                                                                  ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[Class](https://developer.android.com/reference/kotlin/java/lang/Class.html#)<*>!>! | the coordinate types for this VarHandle. The returned list is unmodifiable |

### fullFence

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun fullFence(): Unit
```

Ensures that loads and stores before the fence will not be reordered with loads and stores after the fence.  

### get

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun get(vararg args: Any!): Any!
```

Returns the value of a variable, with memory semantics of reading as if the variable was declared non-`volatile`. Commonly referred to as plain read access.

The method signature is of the form`(CT1 ct1, ..., CTn ctn)T`.

The symbolic type descriptor at the call site of`get`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET)`on this VarHandle.

This access mode is supported by all VarHandle instances and never throws`UnsupportedOperationException`.

|                                                                                              Parameters                                                                                              ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn)`, statically represented using varargs. |

|                                                                                         Return                                                                                          ||
|-----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

### getAcquire

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAcquire(vararg args: Any!): Any!
```

Returns the value of a variable, and ensures that subsequent loads and stores are not reordered before this access.

The method signature is of the form`(CT1 ct1, ..., CTn ctn)T`.

The symbolic type descriptor at the call site of`getAcquire`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_ACQUIRE)`on this VarHandle.

|                                                                                                Parameters                                                                                                ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn)`, statically represented using varargs. |

|                                                                                         Return                                                                                          ||
|-----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

### getAndAdd

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndAdd(vararg args: Any!): Any!
```

Atomically adds the`value`to the current value of a variable with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any)), and returns the variable's previous value, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T value)T`.

The symbolic type descriptor at the call site of`getAndAdd`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_ADD)`on this VarHandle.

|                                                                                                    Parameters                                                                                                     ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T value)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))
- [#getVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any))  

### getAndAddAcquire

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndAddAcquire(vararg args: Any!): Any!
```

Atomically adds the`value`to the current value of a variable with the memory semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any)), and returns the variable's previous value, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T value)T`.

The symbolic type descriptor at the call site of`getAndAddAcquire`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_ADD_ACQUIRE)`on this VarHandle.

|                                                                                                    Parameters                                                                                                     ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T value)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))
- [#getVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any))  

### getAndAddRelease

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndAddRelease(vararg args: Any!): Any!
```

Atomically adds the`value`to the current value of a variable with the memory semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any)), and returns the variable's previous value, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T value)T`.

The symbolic type descriptor at the call site of`getAndAddRelease`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_ADD_RELEASE)`on this VarHandle.

|                                                                                                    Parameters                                                                                                     ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T value)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))
- [#getVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any))  

### getAndBitwiseAnd

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndBitwiseAnd(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the result of bitwise AND between the variable's current value and the`mask`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).

If the variable type is the non-integral`boolean`type then a logical AND is performed instead of a bitwise AND.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T mask)T`.

The symbolic type descriptor at the call site of`getAndBitwiseAnd`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_AND)`on this VarHandle.

|                                                                                                    Parameters                                                                                                    ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T mask)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))
- [#getVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any))  

### getAndBitwiseAndAcquire

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndBitwiseAndAcquire(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the result of bitwise AND between the variable's current value and the`mask`with the memory semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).

If the variable type is the non-integral`boolean`type then a logical AND is performed instead of a bitwise AND.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T mask)T`.

The symbolic type descriptor at the call site of`getAndBitwiseAndAcquire`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_AND_ACQUIRE)`on this VarHandle.

|                                                                                                    Parameters                                                                                                    ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T mask)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#set(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))
- [#getAcquire(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any))  

### getAndBitwiseAndRelease

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndBitwiseAndRelease(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the result of bitwise AND between the variable's current value and the`mask`with the memory semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).

If the variable type is the non-integral`boolean`type then a logical AND is performed instead of a bitwise AND.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T mask)T`.

The symbolic type descriptor at the call site of`getAndBitwiseAndRelease`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_AND_RELEASE)`on this VarHandle.

|                                                                                                    Parameters                                                                                                    ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T mask)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setRelease(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))
- [#get(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any))  

### getAndBitwiseOr

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndBitwiseOr(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the result of bitwise OR between the variable's current value and the`mask`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).

If the variable type is the non-integral`boolean`type then a logical OR is performed instead of a bitwise OR.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T mask)T`.

The symbolic type descriptor at the call site of`getAndBitwiseOr`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_OR)`on this VarHandle.

|                                                                                                    Parameters                                                                                                    ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T mask)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))
- [#getVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any))  

### getAndBitwiseOrAcquire

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndBitwiseOrAcquire(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the result of bitwise OR between the variable's current value and the`mask`with the memory semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).

If the variable type is the non-integral`boolean`type then a logical OR is performed instead of a bitwise OR.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T mask)T`.

The symbolic type descriptor at the call site of`getAndBitwiseOrAcquire`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_OR_ACQUIRE)`on this VarHandle.

|                                                                                                    Parameters                                                                                                    ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T mask)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#set(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))
- [#getAcquire(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any))  

### getAndBitwiseOrRelease

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndBitwiseOrRelease(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the result of bitwise OR between the variable's current value and the`mask`with the memory semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).

If the variable type is the non-integral`boolean`type then a logical OR is performed instead of a bitwise OR.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T mask)T`.

The symbolic type descriptor at the call site of`getAndBitwiseOrRelease`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_OR_RELEASE)`on this VarHandle.

|                                                                                                    Parameters                                                                                                    ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T mask)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setRelease(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))
- [#get(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any))  

### getAndBitwiseXor

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndBitwiseXor(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the result of bitwise XOR between the variable's current value and the`mask`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).

If the variable type is the non-integral`boolean`type then a logical XOR is performed instead of a bitwise XOR.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T mask)T`.

The symbolic type descriptor at the call site of`getAndBitwiseXor`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_XOR)`on this VarHandle.

|                                                                                                    Parameters                                                                                                    ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T mask)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))
- [#getVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any))  

### getAndBitwiseXorAcquire

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndBitwiseXorAcquire(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the result of bitwise XOR between the variable's current value and the`mask`with the memory semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).

If the variable type is the non-integral`boolean`type then a logical XOR is performed instead of a bitwise XOR.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T mask)T`.

The symbolic type descriptor at the call site of`getAndBitwiseXorAcquire`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_XOR_ACQUIRE)`on this VarHandle.

|                                                                                                    Parameters                                                                                                    ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T mask)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#set(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))
- [#getAcquire(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any))  

### getAndBitwiseXorRelease

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndBitwiseXorRelease(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the result of bitwise XOR between the variable's current value and the`mask`with the memory semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).

If the variable type is the non-integral`boolean`type then a logical XOR is performed instead of a bitwise XOR.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T mask)T`.

The symbolic type descriptor at the call site of`getAndBitwiseXorRelease`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_BITWISE_XOR_RELEASE)`on this VarHandle.

|                                                                                                    Parameters                                                                                                    ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T mask)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setRelease(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))
- [#get(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any))  

### getAndSet

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndSet(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the`newValue`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T newValue)T`.

The symbolic type descriptor at the call site of`getAndSet`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_SET)`on this VarHandle.

|                                                                                                      Parameters                                                                                                      ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T newValue)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))
- [#getVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any))  

### getAndSetAcquire

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndSetAcquire(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the`newValue`with the memory semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T newValue)T`.

The symbolic type descriptor at the call site of`getAndSetAcquire`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_SET_ACQUIRE)`on this VarHandle.

|                                                                                                      Parameters                                                                                                      ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T newValue)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))
- [#getVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any))  

### getAndSetRelease

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getAndSetRelease(vararg args: Any!): Any!
```

Atomically sets the value of a variable to the`newValue`with the memory semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))and returns the variable's previous value, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T newValue)T`.

The symbolic type descriptor at the call site of`getAndSetRelease`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_AND_SET_RELEASE)`on this VarHandle.

|                                                                                                      Parameters                                                                                                      ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T newValue)`, statically represented using varargs. |

|                                                                                              Return                                                                                              ||
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the previous value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))
- [#getVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any))  

### getOpaque

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getOpaque(vararg args: Any!): Any!
```

Returns the value of a variable, accessed in program order, but with no assurance of memory ordering effects with respect to other threads.

The method signature is of the form`(CT1 ct1, ..., CTn ctn)T`.

The symbolic type descriptor at the call site of`getOpaque`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_OPAQUE)`on this VarHandle.

|                                                                                                Parameters                                                                                                ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn)`, statically represented using varargs. |

|                                                                                         Return                                                                                          ||
|-----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

### getVolatile

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getVolatile(vararg args: Any!): Any!
```

Returns the value of a variable, with memory semantics of reading as if the variable was declared`volatile`.

The method signature is of the form`(CT1 ct1, ..., CTn ctn)T`.

The symbolic type descriptor at the call site of`getVolatile`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.GET_VOLATILE)`on this VarHandle.

|                                                                                                Parameters                                                                                                ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn)`, statically represented using varargs. |

|                                                                                         Return                                                                                          ||
|-----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the signature-polymorphic result that is the value of the variable , statically represented using`Object`. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

### isAccessModeSupported

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun isAccessModeSupported(accessMode: VarHandle.AccessMode!): Boolean
```

Returns`true`if the given access mode is supported, otherwise`false`.

The return of a`false`value for a given access mode indicates that an`UnsupportedOperationException`is thrown on invocation of the corresponding access mode method.

|                                                                                                   Parameters                                                                                                    ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `accessMode` | [VarHandle.AccessMode](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle.AccessMode)!:the access mode, corresponding to the signature-polymorphic method of the same name |

|                                                                       Return                                                                       ||
|------------------------------------------------------------------------------------|----------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if the given access mode is supported, otherwise`false`. |

### loadLoadFence

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun loadLoadFence(): Unit
```

Ensures that loads before the fence will not be reordered with loads after the fence.  

### releaseFence

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun releaseFence(): Unit
```

Ensures that loads and stores before the fence will not be reordered with stores after the fence.  

### set

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun set(vararg args: Any!): Unit
```

Sets the value of a variable to the`newValue`, with memory semantics of setting as if the variable was declared non-`volatile`and non-`final`. Commonly referred to as plain write access.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T newValue)void`

The symbolic type descriptor at the call site of`set`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.SET)`on this VarHandle.

|                                                                                                      Parameters                                                                                                      ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T newValue)`, statically represented using varargs. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

### setOpaque

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setOpaque(vararg args: Any!): Unit
```

Sets the value of a variable to the`newValue`, in program order, but with no assurance of memory ordering effects with respect to other threads.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T newValue)void`.

The symbolic type descriptor at the call site of`setOpaque`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.SET_OPAQUE)`on this VarHandle.

|                                                                                                      Parameters                                                                                                      ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T newValue)`, statically represented using varargs. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

### setRelease

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setRelease(vararg args: Any!): Unit
```

Sets the value of a variable to the`newValue`, and ensures that prior loads and stores are not reordered after this access.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T newValue)void`.

The symbolic type descriptor at the call site of`setRelease`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.SET_RELEASE)`on this VarHandle.

|                                                                                                      Parameters                                                                                                      ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T newValue)`, statically represented using varargs. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

### setVolatile

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setVolatile(vararg args: Any!): Unit
```

Sets the value of a variable to the`newValue`, with memory semantics of setting as if the variable was declared`volatile`.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T newValue)void`.

The symbolic type descriptor at the call site of`setVolatile`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.SET_VOLATILE)`on this VarHandle.

|                                                                                                      Parameters                                                                                                      ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T newValue)`, statically represented using varargs. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

### storeStoreFence

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun storeStoreFence(): Unit
```

Ensures that stores before the fence will not be reordered with stores after the fence.  

### toMethodHandle

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun toMethodHandle(accessMode: VarHandle.AccessMode!): MethodHandle!
```

Obtains a method handle bound to this VarHandle and the given access mode.

|                                                                                                   Parameters                                                                                                    ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `accessMode` | [VarHandle.AccessMode](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle.AccessMode)!:the access mode, corresponding to the signature-polymorphic method of the same name |

|                                                                              Return                                                                              ||
|-----------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [MethodHandle](https://developer.android.com/reference/kotlin/java/lang/invoke/MethodHandle)! | a method handle bound to this VarHandle and the given access mode |

### toString

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun toString(): String
```

Returns a compact textual description of this[VarHandle](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#), including the type of variable described, and a description of its coordinates.

|                                                                                                     Return                                                                                                     ||
|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | A compact textual description of this[VarHandle](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#) |

### varType

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun varType(): Class<*>!
```

Returns the variable type of variables referenced by this VarHandle.

|                                                                     Return                                                                     ||
|-----------------------------------------------------------------------------------|-------------------------------------------------------------|
| [Class](https://developer.android.com/reference/kotlin/java/lang/Class.html#)<*>! | the variable type of variables referenced by this VarHandle |

### weakCompareAndSet

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun weakCompareAndSet(vararg args: Any!): Boolean
```

Possibly atomically sets the value of a variable to the`newValue`with the memory semantics of[setVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[getVolatile](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any)).

This operation may fail spuriously (typically, due to memory contention) even if the witness value does match the expected value.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean`.

The symbolic type descriptor at the call site of`weakCompareAndSet`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)`on this VarHandle.

|                                                                                                              Parameters                                                                                                               ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)`, statically represented using varargs. |

|                                                                                                           Return                                                                                                            ||
|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if successful, otherwise`false`if the witness value was not the same as the`expectedValue`or if this operation spuriously failed. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setVolatile(kotlin.Any))
- [#getVolatile(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getVolatile(kotlin.Any))  

### weakCompareAndSetAcquire

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun weakCompareAndSetAcquire(vararg args: Any!): Boolean
```

Possibly atomically sets the value of a variable to the`newValue`with the semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[getAcquire](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any)).

This operation may fail spuriously (typically, due to memory contention) even if the witness value does match the expected value.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean`.

The symbolic type descriptor at the call site of`weakCompareAndSetAcquire`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)`on this VarHandle.

|                                                                                                              Parameters                                                                                                               ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)`, statically represented using varargs. |

|                                                                                                           Return                                                                                                            ||
|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if successful, otherwise`false`if the witness value was not the same as the`expectedValue`or if this operation spuriously failed. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#set(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))
- [#getAcquire(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#getAcquire(kotlin.Any))  

### weakCompareAndSetPlain

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun weakCompareAndSetPlain(vararg args: Any!): Boolean
```

Possibly atomically sets the value of a variable to the`newValue`with the semantics of[set](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).

This operation may fail spuriously (typically, due to memory contention) even if the witness value does match the expected value.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean`.

The symbolic type descriptor at the call site of`weakCompareAndSetPlain`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_PLAIN)`on this VarHandle.

|                                                                                                              Parameters                                                                                                               ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)`, statically represented using varargs. |

|                                                                                                           Return                                                                                                            ||
|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if successful, otherwise`false`if the witness value was not the same as the`expectedValue`or if this operation spuriously failed. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#set(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#set(kotlin.Any))
- [#get(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any))  

### weakCompareAndSetRelease

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun weakCompareAndSetRelease(vararg args: Any!): Boolean
```

Possibly atomically sets the value of a variable to the`newValue`with the semantics of[setRelease](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))if the variable's current value, referred to as the*witness value* ,`==`the`expectedValue`, as accessed with the memory semantics of[get](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any)).

This operation may fail spuriously (typically, due to memory contention) even if the witness value does match the expected value.

The method signature is of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)boolean`.

The symbolic type descriptor at the call site of`weakCompareAndSetRelease`must match the access mode type that is the result of calling`accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)`on this VarHandle.

|                                                                                                              Parameters                                                                                                               ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `args` | [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!:the signature-polymorphic parameter list of the form`(CT1 ct1, ..., CTn ctn, T expectedValue, T newValue)`, statically represented using varargs. |

|                                                                                                           Return                                                                                                            ||
|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if successful, otherwise`false`if the witness value was not the same as the`expectedValue`or if this operation spuriously failed. |

|                                                                   Exceptions                                                                    ||
|---------------------------------------------|----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException`   | if the access mode is unsupported for this VarHandle.                                              |
| `java.lang.invoke.WrongMethodTypeException` | if the access mode type does not match the caller's symbolic type descriptor.                      |
| `java.lang.ClassCastException`              | if the access mode type matches the caller's symbolic type descriptor, but a reference cast fails. |

**See Also**

- [#setRelease(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#setRelease(kotlin.Any))
- [#get(Object...)](https://developer.android.com/reference/kotlin/java/lang/invoke/VarHandle#get(kotlin.Any))