diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
index 9e2533f071e..e46805538d4 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
@@ -110,6 +110,20 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError;
* boolean r = avh.compareAndSet(sa, 10, "expected", "new");
* }
*
+ *
Access modes control atomicity and consistency properties.
+ * Plain read ({@code get}) and write ({@code 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
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java
index 22850e6dab7..d61f246fec0 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java
@@ -249,7 +249,8 @@ public class AtomicInteger extends Number implements java.io.Serializable {
}
/**
- * Atomically updates the current value with the results of
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the current value with the results of
* applying the given function, returning the previous value. The
* function should be side-effect-free, since it may be re-applied
* when attempted updates fail due to contention among threads.
@@ -270,7 +271,8 @@ public class AtomicInteger extends Number implements java.io.Serializable {
}
/**
- * Atomically updates the current value with the results of
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the current value with the results of
* applying the given function, returning the updated value. The
* function should be side-effect-free, since it may be re-applied
* when attempted updates fail due to contention among threads.
@@ -291,13 +293,14 @@ public class AtomicInteger extends Number implements java.io.Serializable {
}
/**
- * Atomically updates the current value with the results of
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the current value with the results of
* applying the given function to the current and given values,
* returning the previous value. The function should be
* side-effect-free, since it may be re-applied when attempted
- * updates fail due to contention among threads. The function
- * is applied with the current value as its first argument,
- * and the given update as the second argument.
+ * updates fail due to contention among threads. The function is
+ * applied with the current value as its first argument, and the
+ * given update as the second argument.
*
* @param x the update value
* @param accumulatorFunction a side-effect-free function of two arguments
@@ -317,13 +320,14 @@ public class AtomicInteger extends Number implements java.io.Serializable {
}
/**
- * Atomically updates the current value with the results of
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the current value with the results of
* applying the given function to the current and given values,
* returning the updated value. The function should be
* side-effect-free, since it may be re-applied when attempted
- * updates fail due to contention among threads. The function
- * is applied with the current value as its first argument,
- * and the given update as the second argument.
+ * updates fail due to contention among threads. The function is
+ * applied with the current value as its first argument, and the
+ * given update as the second argument.
*
* @param x the update value
* @param accumulatorFunction a side-effect-free function of two arguments
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java
index efddc9fb0f4..f59327da98a 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java
@@ -260,10 +260,12 @@ public class AtomicIntegerArray implements java.io.Serializable {
}
/**
- * Atomically updates the element at index {@code i} with the results
- * of applying the given function, returning the previous value. The
- * function should be side-effect-free, since it may be re-applied
- * when attempted updates fail due to contention among threads.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the element at index {@code i} with
+ * the results of applying the given function, returning the
+ * previous value. The function should be side-effect-free, since
+ * it may be re-applied when attempted updates fail due to
+ * contention among threads.
*
* @param i the index
* @param updateFunction a side-effect-free function
@@ -282,10 +284,12 @@ public class AtomicIntegerArray implements java.io.Serializable {
}
/**
- * Atomically updates the element at index {@code i} with the results
- * of applying the given function, returning the updated value. The
- * function should be side-effect-free, since it may be re-applied
- * when attempted updates fail due to contention among threads.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the element at index {@code i} with
+ * the results of applying the given function, returning the
+ * updated value. The function should be side-effect-free, since it
+ * may be re-applied when attempted updates fail due to contention
+ * among threads.
*
* @param i the index
* @param updateFunction a side-effect-free function
@@ -304,10 +308,11 @@ public class AtomicIntegerArray implements java.io.Serializable {
}
/**
- * Atomically updates the element at index {@code i} with the
- * results of applying the given function to the current and given
- * values, returning the previous value. The function should be
- * side-effect-free, since it may be re-applied when attempted
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the element at index {@code i} with
+ * the results of applying the given function to the current and
+ * given values, returning the previous value. The function should
+ * be side-effect-free, since it may be re-applied when attempted
* updates fail due to contention among threads. The function is
* applied with the current value of the element at index {@code i}
* as its first argument, and the given update as the second
@@ -332,10 +337,11 @@ public class AtomicIntegerArray implements java.io.Serializable {
}
/**
- * Atomically updates the element at index {@code i} with the
- * results of applying the given function to the current and given
- * values, returning the updated value. The function should be
- * side-effect-free, since it may be re-applied when attempted
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the element at index {@code i} with
+ * the results of applying the given function to the current and
+ * given values, returning the updated value. The function should
+ * be side-effect-free, since it may be re-applied when attempted
* updates fail due to contention among threads. The function is
* applied with the current value of the element at index {@code i}
* as its first argument, and the given update as the second
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
index 826a0557b5f..c8a37f30c31 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
@@ -46,6 +46,7 @@ import java.util.function.IntUnaryOperator;
import jdk.internal.misc.Unsafe;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
+import java.lang.invoke.VarHandle;
/**
* A reflection-based utility that enables atomic updates to
@@ -275,10 +276,12 @@ public abstract class AtomicIntegerFieldUpdater {
}
/**
- * Atomically updates the field of the given object managed by this updater
- * with the results of applying the given function, returning the previous
- * value. The function should be side-effect-free, since it may be
- * re-applied when attempted updates fail due to contention among threads.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the field of the given object managed
+ * by this updater with the results of applying the given
+ * function, returning the previous value. The function should be
+ * side-effect-free, since it may be re-applied when attempted
+ * updates fail due to contention among threads.
*
* @param obj An object whose field to get and set
* @param updateFunction a side-effect-free function
@@ -295,10 +298,12 @@ public abstract class AtomicIntegerFieldUpdater {
}
/**
- * Atomically updates the field of the given object managed by this updater
- * with the results of applying the given function, returning the updated
- * value. The function should be side-effect-free, since it may be
- * re-applied when attempted updates fail due to contention among threads.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the field of the given object managed
+ * by this updater with the results of applying the given
+ * function, returning the updated value. The function should be
+ * side-effect-free, since it may be re-applied when attempted
+ * updates fail due to contention among threads.
*
* @param obj An object whose field to get and set
* @param updateFunction a side-effect-free function
@@ -315,13 +320,14 @@ public abstract class AtomicIntegerFieldUpdater {
}
/**
- * Atomically updates the field of the given object managed by this
- * updater with the results of applying the given function to the
- * current and given values, returning the previous value. The
- * function should be side-effect-free, since it may be re-applied
- * when attempted updates fail due to contention among threads. The
- * function is applied with the current value as its first argument,
- * and the given update as the second argument.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the field of the given object managed
+ * by this updater with the results of applying the given function
+ * to the current and given values, returning the previous value.
+ * The function should be side-effect-free, since it may be
+ * re-applied when attempted updates fail due to contention among
+ * threads. The function is applied with the current value as its
+ * first argument, and the given update as the second argument.
*
* @param obj An object whose field to get and set
* @param x the update value
@@ -340,13 +346,14 @@ public abstract class AtomicIntegerFieldUpdater {
}
/**
- * Atomically updates the field of the given object managed by this
- * updater with the results of applying the given function to the
- * current and given values, returning the updated value. The
- * function should be side-effect-free, since it may be re-applied
- * when attempted updates fail due to contention among threads. The
- * function is applied with the current value as its first argument,
- * and the given update as the second argument.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the field of the given object managed
+ * by this updater with the results of applying the given function
+ * to the current and given values, returning the updated value.
+ * The function should be side-effect-free, since it may be
+ * re-applied when attempted updates fail due to contention among
+ * threads. The function is applied with the current value as its
+ * first argument, and the given update as the second argument.
*
* @param obj An object whose field to get and set
* @param x the update value
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java
index 940f67c1bf3..4345ae89f72 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java
@@ -118,8 +118,7 @@ public class AtomicLong extends Number implements java.io.Serializable {
* @param newValue the new value
*/
public final void set(long newValue) {
- // Use putLongVolatile instead of ordinary volatile store when
- // using compareAndSetLong, for sake of some 32bit systems.
+ // See JDK-8180620: Clarify VarHandle mixed-access subtleties
U.putLongVolatile(this, VALUE, newValue);
}
@@ -265,7 +264,8 @@ public class AtomicLong extends Number implements java.io.Serializable {
}
/**
- * Atomically updates the current value with the results of
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the current value with the results of
* applying the given function, returning the previous value. The
* function should be side-effect-free, since it may be re-applied
* when attempted updates fail due to contention among threads.
@@ -286,7 +286,8 @@ public class AtomicLong extends Number implements java.io.Serializable {
}
/**
- * Atomically updates the current value with the results of
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the current value with the results of
* applying the given function, returning the updated value. The
* function should be side-effect-free, since it may be re-applied
* when attempted updates fail due to contention among threads.
@@ -307,13 +308,14 @@ public class AtomicLong extends Number implements java.io.Serializable {
}
/**
- * Atomically updates the current value with the results of
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the current value with the results of
* applying the given function to the current and given values,
* returning the previous value. The function should be
* side-effect-free, since it may be re-applied when attempted
- * updates fail due to contention among threads. The function
- * is applied with the current value as its first argument,
- * and the given update as the second argument.
+ * updates fail due to contention among threads. The function is
+ * applied with the current value as its first argument, and the
+ * given update as the second argument.
*
* @param x the update value
* @param accumulatorFunction a side-effect-free function of two arguments
@@ -333,13 +335,14 @@ public class AtomicLong extends Number implements java.io.Serializable {
}
/**
- * Atomically updates the current value with the results of
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the current value with the results of
* applying the given function to the current and given values,
* returning the updated value. The function should be
* side-effect-free, since it may be re-applied when attempted
- * updates fail due to contention among threads. The function
- * is applied with the current value as its first argument,
- * and the given update as the second argument.
+ * updates fail due to contention among threads. The function is
+ * applied with the current value as its first argument, and the
+ * given update as the second argument.
*
* @param x the update value
* @param accumulatorFunction a side-effect-free function of two arguments
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
index 10aa9deea83..24e42a1ea81 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
@@ -260,10 +260,12 @@ public class AtomicLongArray implements java.io.Serializable {
}
/**
- * Atomically updates the element at index {@code i} with the results
- * of applying the given function, returning the previous value. The
- * function should be side-effect-free, since it may be re-applied
- * when attempted updates fail due to contention among threads.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the element at index {@code i} with
+ * the results of applying the given function, returning the
+ * previous value. The function should be side-effect-free, since
+ * it may be re-applied when attempted updates fail due to
+ * contention among threads.
*
* @param i the index
* @param updateFunction a side-effect-free function
@@ -282,10 +284,12 @@ public class AtomicLongArray implements java.io.Serializable {
}
/**
- * Atomically updates the element at index {@code i} with the results
- * of applying the given function, returning the updated value. The
- * function should be side-effect-free, since it may be re-applied
- * when attempted updates fail due to contention among threads.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the element at index {@code i} with
+ * the results of applying the given function, returning the
+ * updated value. The function should be side-effect-free, since it
+ * may be re-applied when attempted updates fail due to contention
+ * among threads.
*
* @param i the index
* @param updateFunction a side-effect-free function
@@ -304,10 +308,11 @@ public class AtomicLongArray implements java.io.Serializable {
}
/**
- * Atomically updates the element at index {@code i} with the
- * results of applying the given function to the current and given
- * values, returning the previous value. The function should be
- * side-effect-free, since it may be re-applied when attempted
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the element at index {@code i} with
+ * the results of applying the given function to the current and
+ * given values, returning the previous value. The function should
+ * be side-effect-free, since it may be re-applied when attempted
* updates fail due to contention among threads. The function is
* applied with the current value of the element at index {@code i}
* as its first argument, and the given update as the second
@@ -332,10 +337,11 @@ public class AtomicLongArray implements java.io.Serializable {
}
/**
- * Atomically updates the element at index {@code i} with the
- * results of applying the given function to the current and given
- * values, returning the updated value. The function should be
- * side-effect-free, since it may be re-applied when attempted
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the element at index {@code i} with
+ * the results of applying the given function to the current and
+ * given values, returning the updated value. The function should
+ * be side-effect-free, since it may be re-applied when attempted
* updates fail due to contention among threads. The function is
* applied with the current value of the element at index {@code i}
* as its first argument, and the given update as the second
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
index ee0447a8b88..3db7e36fe22 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
@@ -46,6 +46,7 @@ import java.util.function.LongUnaryOperator;
import jdk.internal.misc.Unsafe;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
+import java.lang.invoke.VarHandle;
/**
* A reflection-based utility that enables atomic updates to
@@ -278,10 +279,12 @@ public abstract class AtomicLongFieldUpdater {
}
/**
- * Atomically updates the field of the given object managed by this updater
- * with the results of applying the given function, returning the previous
- * value. The function should be side-effect-free, since it may be
- * re-applied when attempted updates fail due to contention among threads.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the field of the given object managed
+ * by this updater with the results of applying the given
+ * function, returning the previous value. The function should be
+ * side-effect-free, since it may be re-applied when attempted
+ * updates fail due to contention among threads.
*
* @param obj An object whose field to get and set
* @param updateFunction a side-effect-free function
@@ -298,10 +301,12 @@ public abstract class AtomicLongFieldUpdater {
}
/**
- * Atomically updates the field of the given object managed by this updater
- * with the results of applying the given function, returning the updated
- * value. The function should be side-effect-free, since it may be
- * re-applied when attempted updates fail due to contention among threads.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the field of the given object managed
+ * by this updater with the results of applying the given
+ * function, returning the updated value. The function should be
+ * side-effect-free, since it may be re-applied when attempted
+ * updates fail due to contention among threads.
*
* @param obj An object whose field to get and set
* @param updateFunction a side-effect-free function
@@ -318,13 +323,14 @@ public abstract class AtomicLongFieldUpdater {
}
/**
- * Atomically updates the field of the given object managed by this
- * updater with the results of applying the given function to the
- * current and given values, returning the previous value. The
- * function should be side-effect-free, since it may be re-applied
- * when attempted updates fail due to contention among threads. The
- * function is applied with the current value as its first argument,
- * and the given update as the second argument.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the field of the given object managed
+ * by this updater with the results of applying the given function
+ * to the current and given values, returning the previous value.
+ * The function should be side-effect-free, since it may be
+ * re-applied when attempted updates fail due to contention among
+ * threads. The function is applied with the current value as its
+ * first argument, and the given update as the second argument.
*
* @param obj An object whose field to get and set
* @param x the update value
@@ -343,13 +349,14 @@ public abstract class AtomicLongFieldUpdater {
}
/**
- * Atomically updates the field of the given object managed by this
- * updater with the results of applying the given function to the
- * current and given values, returning the updated value. The
- * function should be side-effect-free, since it may be re-applied
- * when attempted updates fail due to contention among threads. The
- * function is applied with the current value as its first argument,
- * and the given update as the second argument.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the field of the given object managed
+ * by this updater with the results of applying the given function
+ * to the current and given values, returning the updated value.
+ * The function should be side-effect-free, since it may be
+ * re-applied when attempted updates fail due to contention among
+ * threads. The function is applied with the current value as its
+ * first argument, and the given update as the second argument.
*
* @param obj An object whose field to get and set
* @param x the update value
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java
index 66b7b6c37a5..db1d483b5ae 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReference.java
@@ -170,7 +170,8 @@ public class AtomicReference implements java.io.Serializable {
}
/**
- * Atomically updates the current value with the results of
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the current value with the results of
* applying the given function, returning the previous value. The
* function should be side-effect-free, since it may be re-applied
* when attempted updates fail due to contention among threads.
@@ -191,7 +192,8 @@ public class AtomicReference implements java.io.Serializable {
}
/**
- * Atomically updates the current value with the results of
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the current value with the results of
* applying the given function, returning the updated value. The
* function should be side-effect-free, since it may be re-applied
* when attempted updates fail due to contention among threads.
@@ -212,13 +214,14 @@ public class AtomicReference implements java.io.Serializable {
}
/**
- * Atomically updates the current value with the results of
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the current value with the results of
* applying the given function to the current and given values,
* returning the previous value. The function should be
* side-effect-free, since it may be re-applied when attempted
- * updates fail due to contention among threads. The function
- * is applied with the current value as its first argument,
- * and the given update as the second argument.
+ * updates fail due to contention among threads. The function is
+ * applied with the current value as its first argument, and the
+ * given update as the second argument.
*
* @param x the update value
* @param accumulatorFunction a side-effect-free function of two arguments
@@ -238,13 +241,14 @@ public class AtomicReference implements java.io.Serializable {
}
/**
- * Atomically updates the current value with the results of
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the current value with the results of
* applying the given function to the current and given values,
* returning the updated value. The function should be
* side-effect-free, since it may be re-applied when attempted
- * updates fail due to contention among threads. The function
- * is applied with the current value as its first argument,
- * and the given update as the second argument.
+ * updates fail due to contention among threads. The function is
+ * applied with the current value as its first argument, and the
+ * given update as the second argument.
*
* @param x the update value
* @param accumulatorFunction a side-effect-free function of two arguments
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
index 2d529bb7ef1..b3193a23b9d 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
@@ -190,10 +190,12 @@ public class AtomicReferenceArray implements java.io.Serializable {
}
/**
- * Atomically updates the element at index {@code i} with the results
- * of applying the given function, returning the previous value. The
- * function should be side-effect-free, since it may be re-applied
- * when attempted updates fail due to contention among threads.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the element at index {@code i} with
+ * the results of applying the given function, returning the
+ * previous value. The function should be side-effect-free, since
+ * it may be re-applied when attempted updates fail due to
+ * contention among threads.
*
* @param i the index
* @param updateFunction a side-effect-free function
@@ -212,10 +214,12 @@ public class AtomicReferenceArray implements java.io.Serializable {
}
/**
- * Atomically updates the element at index {@code i} with the results
- * of applying the given function, returning the updated value. The
- * function should be side-effect-free, since it may be re-applied
- * when attempted updates fail due to contention among threads.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the element at index {@code i} with
+ * the results of applying the given function, returning the
+ * updated value. The function should be side-effect-free, since it
+ * may be re-applied when attempted updates fail due to contention
+ * among threads.
*
* @param i the index
* @param updateFunction a side-effect-free function
@@ -234,10 +238,11 @@ public class AtomicReferenceArray implements java.io.Serializable {
}
/**
- * Atomically updates the element at index {@code i} with the
- * results of applying the given function to the current and given
- * values, returning the previous value. The function should be
- * side-effect-free, since it may be re-applied when attempted
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the element at index {@code i} with
+ * the results of applying the given function to the current and
+ * given values, returning the previous value. The function should
+ * be side-effect-free, since it may be re-applied when attempted
* updates fail due to contention among threads. The function is
* applied with the current value of the element at index {@code i}
* as its first argument, and the given update as the second
@@ -262,10 +267,11 @@ public class AtomicReferenceArray implements java.io.Serializable {
}
/**
- * Atomically updates the element at index {@code i} with the
- * results of applying the given function to the current and given
- * values, returning the updated value. The function should be
- * side-effect-free, since it may be re-applied when attempted
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the element at index {@code i} with
+ * the results of applying the given function to the current and
+ * given values, returning the updated value. The function should
+ * be side-effect-free, since it may be re-applied when attempted
* updates fail due to contention among threads. The function is
* applied with the current value of the element at index {@code i}
* as its first argument, and the given update as the second
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
index a469abb98cc..062e797c496 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
@@ -46,6 +46,7 @@ import java.util.function.UnaryOperator;
import jdk.internal.misc.Unsafe;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
+import java.lang.invoke.VarHandle;
/**
* A reflection-based utility that enables atomic updates to
@@ -199,10 +200,12 @@ public abstract class AtomicReferenceFieldUpdater {
}
/**
- * Atomically updates the field of the given object managed by this updater
- * with the results of applying the given function, returning the previous
- * value. The function should be side-effect-free, since it may be
- * re-applied when attempted updates fail due to contention among threads.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the field of the given object managed
+ * by this updater with the results of applying the given
+ * function, returning the previous value. The function should be
+ * side-effect-free, since it may be re-applied when attempted
+ * updates fail due to contention among threads.
*
* @param obj An object whose field to get and set
* @param updateFunction a side-effect-free function
@@ -219,10 +222,12 @@ public abstract class AtomicReferenceFieldUpdater {
}
/**
- * Atomically updates the field of the given object managed by this updater
- * with the results of applying the given function, returning the updated
- * value. The function should be side-effect-free, since it may be
- * re-applied when attempted updates fail due to contention among threads.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the field of the given object managed
+ * by this updater with the results of applying the given
+ * function, returning the updated value. The function should be
+ * side-effect-free, since it may be re-applied when attempted
+ * updates fail due to contention among threads.
*
* @param obj An object whose field to get and set
* @param updateFunction a side-effect-free function
@@ -239,13 +244,14 @@ public abstract class AtomicReferenceFieldUpdater {
}
/**
- * Atomically updates the field of the given object managed by this
- * updater with the results of applying the given function to the
- * current and given values, returning the previous value. The
- * function should be side-effect-free, since it may be re-applied
- * when attempted updates fail due to contention among threads. The
- * function is applied with the current value as its first argument,
- * and the given update as the second argument.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the field of the given object managed
+ * by this updater with the results of applying the given function
+ * to the current and given values, returning the previous value.
+ * The function should be side-effect-free, since it may be
+ * re-applied when attempted updates fail due to contention among
+ * threads. The function is applied with the current value as its
+ * first argument, and the given update as the second argument.
*
* @param obj An object whose field to get and set
* @param x the update value
@@ -264,13 +270,14 @@ public abstract class AtomicReferenceFieldUpdater {
}
/**
- * Atomically updates the field of the given object managed by this
- * updater with the results of applying the given function to the
- * current and given values, returning the updated value. The
- * function should be side-effect-free, since it may be re-applied
- * when attempted updates fail due to contention among threads. The
- * function is applied with the current value as its first argument,
- * and the given update as the second argument.
+ * Atomically updates (with memory effects as specified by {@link
+ * VarHandle#compareAndSet}) the field of the given object managed
+ * by this updater with the results of applying the given function
+ * to the current and given values, returning the updated value.
+ * The function should be side-effect-free, since it may be
+ * re-applied when attempted updates fail due to contention among
+ * threads. The function is applied with the current value as its
+ * first argument, and the given update as the second argument.
*
* @param obj An object whose field to get and set
* @param x the update value