RFR: 8287860: Revise usage of volatile in j.u.Locale

2022-06-06 Thread Сергей Цыпанов
- 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()` -

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale

2022-06-06 Thread liach
On Mon, 6 Jun 2022 12:58:39 GMT, Сергей Цыпанов 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()` > -

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale

2022-06-06 Thread Сергей Цыпанов
On Mon, 6 Jun 2022 13:20:31 GMT, liach 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()` >> - `is

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale

2022-06-06 Thread liach
On Mon, 6 Jun 2022 13:32:21 GMT, liach wrote: >> Shouldn't the fields annotated with `@Stable` be `final` as well? > > These fields can only be written once besides the default values, but they > don't have to be written in the static initializer or constructor. So when a > non-zero hash code i

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale

2022-06-06 Thread liach
On Mon, 6 Jun 2022 13:28:44 GMT, Сергей Цыпанов wrote: >> 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

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale [v2]

2022-06-06 Thread Сергей Цыпанов
On Mon, 6 Jun 2022 13:34:27 GMT, liach wrote: >> These fields can only be written once besides the default values, but they >> don't have to be written in the static initializer or constructor. So when a >> non-zero hash code is written, it's cached as if it's a final field. For a >> zero valu

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale [v2]

2022-06-06 Thread Сергей Цыпанов
> - 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 `getISOLang

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale [v3]

2022-06-06 Thread Сергей Цыпанов
> - 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 `getISOLang

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale [v3]

2022-06-06 Thread Naoto Sato
On Mon, 6 Jun 2022 20:19:22 GMT, Сергей Цыпанов 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()`

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale [v2]

2022-06-06 Thread Naoto Sato
On Mon, 6 Jun 2022 14:36:03 GMT, Сергей Цыпанов 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()`

Re: RFR: 8287860: Revise usage of volatile in j.u.Locale [v2]

2022-06-06 Thread Сергей Цыпанов
On Mon, 6 Jun 2022 17:31:15 GMT, Naoto Sato wrote: >> Сергей Цыпанов has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8287860: Mark hash fields with @Stable > > src/java.base/share/classes/java/util/Locale.java line 1084: > >> 1082: