JDK-8367013 : Add Atomic to package/replace idiom of volatile var plus AtomicAccess:: operations
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2025-09-05
  • Updated: 2025-09-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 26
26Unresolved
Related Reports
Blocks :  
Relates :  
Description
Lock-free code in HotSpot uses an idiom of declaring variables `volatile` and using operations from the `AtomicAccess` class (formerly `Atomic`) to access and modify those variables.  It would be better to package that idiom, preventing accidental misuse such as using non-atomic read-modify-write arithmetic operations on such variables.

The proposal is to add `Atomic<T>`, where `T` is a supported atomic type as before. Then incrementally replace (most) uses of that idiom with uses of this new type. "Most" because it is expected there will be some small residue where use of the `Atomic<T>` class isn't appropriate. One example is BitMap, which provides some atomic operations but where it would not be appropriate to change the underlying data to be an array of `Atomic<bm_word_t>`. Another example is the atomic functions in the `Copy` class.