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

Chen Liang liach at openjdk.org
Tue Mar 21 13:57:24 UTC 2023


On Tue, 21 Mar 2023 07:25:38 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> src/java.base/share/classes/java/time/ZoneOffset.java line 430:
>> 
>>> 428:     public static ZoneOffset ofTotalSeconds(int totalSeconds) {
>>> 429:         final class Holder {
>>> 430:             private static final IntFunction<ZoneOffset> ZONE_OFFSET_MAPPER = new ZoneOffsetMapper();
>> 
>> Can't the ZoneOffsetMapper itself serve as a holder class? so we move this singleton into ZoneOffsetMapper itself.
>
> It is possible but this keeps the mapper more local and only accessible where it is supposed to be used. For testing purposed, it might be better to have the class as you propose.

If we want it local, I suppose we can convert the whole `ZoneOffsetMapper` local with this singleton in `ofTotalSeconds` static method as well.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/12346#discussion_r1143415419


More information about the i18n-dev mailing list