RFR: 8367013: Add Atomic<T> to package/replace idiom of volatile var plus AtomicAccess:: operations

Kim Barrett kbarrett at openjdk.org
Thu Sep 25 07:29:39 UTC 2025


On Wed, 24 Sep 2025 14:36:25 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

>> Please review this change that adds the type `Atomic<T>`, to use as the type
>> of a variable that is accessed (including writes) concurrently by multiple
>> threads. This is intended to replace (most) uses of the current HotSpot idiom
>> of declaring a variable `volatile` and accessing that variable using functions
>> from the AtomicAccess class.
>> https://github.com/openjdk/jdk/blame/528f93f8cb9f1fb9c19f31ab80c8a546f47beed2/doc/hotspot-style.md#L138-L147
>> 
>> Testing: mach5 tier1-6, GHA sanity tests
>
> I tested this in my editor (Eclipse) and it doesn't seem to give any code completion because of this: 
> 
> // The Atomic<T> type.
> template<typename T>
> using Atomic = AtomicImpl::Selected<T>;
> 
> If I explicitly use AtomicImpl::AtomicInteger<size_t> then I get the expected code completion.
> 
> I wonder if this is going to be problematic with other editors or if this is just a problem with Eclipse.

@stefank and I are discussing some changes that make the code more IDE friendly, which seems like a laudible goal.
So I'm withdrawing this PR to avoid wasting reviewer time when there's going to be some non-trivial changes.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/27462#issuecomment-3332538858


More information about the hotspot-dev mailing list