<i18n dev> RFR: 8301552: Use AtomicReferenceArray for caching instead of CHM in ZoneOffset [v4]

j3graham duke at openjdk.org
Thu Feb 2 09:29:59 UTC 2023


On Wed, 1 Feb 2023 11:37:16 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> src/java.base/share/classes/java/time/ZoneOffset.java line 147:
>> 
>>> 145: 
>>> 146:     /** Cache of time-zone offset by offset in seconds [-18h, +18h] for each even quarter of an hour. */
>>> 147:     private static final AtomicReferenceArray<ZoneOffset> SECONDS_CACHE = new AtomicReferenceArray<>(MAX_SECONDS_CACHE_SLOT * 2 + 1);
>> 
>> Can we use regular array instead?
>
> We can but that entails special handling to ensure thread-safety. I will provide such a solution. Thanks.

If you need the thread-safety, perhaps sticking with `AtomicReferenceArray` is a simpler solution than the regular array one.

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

PR: https://git.openjdk.org/jdk/pull/12346


More information about the i18n-dev mailing list