Possible subtle memory model error in ClassValue

Andrew Haley aph at redhat.com
Tue Aug 18 15:00:00 UTC 2020

On 17/08/2020 15:24, Peter Levart wrote:
> On 8/16/20 7:35 PM, Andrew Haley wrote:
>> On 15/08/2020 10:13, Peter Levart wrote:
>>> https://github.com/openjdk/jdk/pull/9
>>> Sorry for abusing GitHub pull request mechanism but I don't have
>>> bandwidth currently to clone the mercurial repository ;-)
>> That's a lot of work to avoid a simple fence.
> Two fences, mind you (the read fence is no-op only on Intel). So take
> half of that work for each fence ;-) Still a lot?

OK, but in HotSpot (and GraalVM AFAICR, but I'd need to check) finals
only require a StoreStore fence and the address dependency does the
rest, so if we can get away with using a final field then we can also
get away with just using a StoreStore fence at the end of the
constructor. I understand that this (as Hans pointed out) isn't strict
Java but it depends on how much we care about strict Java inside the
core libraries.

> No, really it was not much work to make the patch. The real work is yet
> to come - checking that it is correct.


Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671

More information about the core-libs-dev mailing list