RFR: 8359119: Change Charset to use StableValue

Alan Bateman alanb at openjdk.org
Tue Jun 10 15:07:28 UTC 2025


On Tue, 10 Jun 2025 14:09:03 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> Fields and methods can better leverage the Stable Value API compared to using DCL and holder classes. There are also some fields that can be marked `@Stable`.
> 
> This PR passes tier1, tier2, and tier3 tests on multiple platforms.

src/java.base/share/classes/java/nio/charset/Charset.java line 384:

> 382: 
> 383:     private static final Supplier<ThreadTracker> TRACKER = StableValue.supplier(
> 384:             new Supplier<>() { public ThreadTracker get() { return new ThreadTracker(); }});

ThreadTracker pre-dates ScopedValue. We could potentially use a  ScopedValue<Boolean> IN_USE here, or StableValue<ScopedValue<Boolean>> if there are issues running the class initializer in early VM startup. Separate discussion but we don't need ThreadTracker now.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25727#discussion_r2138150754


More information about the nio-dev mailing list