On Mon, 6 Jun 2022 12:58:39 GMT, Сергей Цыпанов <d...@openjdk.java.net> wrote:
> - cached hash code of `Locale` and `Locale$LanguageRange` shouldn't be > volatile, even in case of race in the worst case it is recalculated at most > once per thread > - `defaultLocale` field is read multiple times in `initDefault()` > - `isoLanguages` is accessed multiple times in `getISOLanguages()` > - `languageTag` is read twice in `toLanguageTag()` src/java.base/share/classes/java/util/Locale.java line 2260: > 2258: * Calculated hashcode > 2259: */ > 2260: private transient volatile int hashCodeValue; We can additionally annotate such cache fields with `@Stable` so as to enable constant-folding optimizations from the hotspot JIT. ------------- PR: https://git.openjdk.java.net/jdk/pull/9041