On Mon, 13 Jun 2022 19:55:47 GMT, Сергей Цыпанов <[email protected]> wrote:
>> If there are two threads calling `Executable.hasRealParameterData()` under
>> race and the first one writes into volatile `Executable.parameters` field
>> (doing _releasing store_) and the second thread reads non-null value from
>> the same field (doing acquiring read) then it must read exactly the same
>> value written into `hasRealParameterData` within `privateGetParameters()`.
>> The reason for this is that we assign `hasRealParameterData` before
>> _releasing store_.
>>
>> In the opposite case (_acquiring read_ reads null) the second thread writes
>> the value itself and returns it from the method so there is no change in
>> behavior.
>
> Сергей Цыпанов has updated the pull request incrementally with one additional
> commit since the last revision:
>
> 8288327: Add clarifying comments
src/java.base/share/classes/java/lang/reflect/Executable.java line 453:
> 451:
> 452: private transient boolean hasRealParameterData;
> 453: private transient volatile Parameter[] parameters;
These can probably be annotated with `@Stable` (see also [GH‑8742]):
Suggestion:
private transient @Stable boolean hasRealParameterData;
private transient @Stable volatile Parameter[] parameters;
[GH‑8742]:
https://urldefense.com/v3/__https://github.com/openjdk/jdk/pull/8742__;!!ACWV5N9M2RV99hQ!Pu7IhhN7O8BZ8UFonTLx3XeO8PLqruZTKko5qqtlFfXoeqkvrnO5pNA5lvtjZOVqSVk2yzbMa5S8nkxjwuO1$
-------------
PR: https://git.openjdk.org/jdk/pull/9143