On Wed, 12 Aug 2026 23:42:54 GMT, Chen Liang <[email protected]> wrote:
> Use the correct version of `compareAndSetReference` from `Unsafe` to ensure > `AtomicReferenceFieldUpdater` works with value objects. > > The new tests stalls on `testWeakCompareAndSet` without the patch and fails > on compareAndSet tests with that stalling test disabled. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). I think this looks okay. I assume Viktor and/or Doug will want to look at this too. test/jdk/java/util/concurrent/atomic/AtomicReferenceFieldUpdaterValueObjectTest.java line 91: > 89: assertSame(new Integer(-4), a.get(this)); > 90: assertFalse(a.compareAndSet(this, new Integer(-5), new > Integer(7))); > 91: assertNotSame(new Integer(7), a.get(this)); You could repeat `assertSame(new Integer(-4), a.get(this))` here to check that a failed CAS did not have any side effect. That keeps it separate from what follows in this test. test/jdk/java/util/concurrent/atomic/AtomicReferenceFieldUpdaterValueObjectTest.java line 112: > 110: > 111: assertTrue(a.compareAndSet(this, new Integer(1), new > Integer(2))); > 112: t.join(Utils.adjustTimeout(1000)); If you use join(Duration) here then it will return a boolean to indicate if the thread terminated, would avoid needing isAlive. That said, I don't think you need a timeout here. It would be simpler to using an untimed-join. ------------- Marked as reviewed by alanb (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/32325#pullrequestreview-4926076707 PR Review Comment: https://git.openjdk.org/jdk/pull/32325#discussion_r3774592432 PR Review Comment: https://git.openjdk.org/jdk/pull/32325#discussion_r3774640929
