Possible subtle memory model error in ClassValue

John Rose john.r.rose at oracle.com
Sat Aug 8 00:41:59 UTC 2020


On Aug 7, 2020, at 2:35 PM, John Rose <john.r.rose at oracle.com> wrote:
> 
> (Here’s a tidbit of JMM politics:  I once heard Doug Lea
> considering whether maybe all fields should be treated
> more like final fields.  I don’t know if this is still a live
> idea, but it would make this bug go way, since nearly all
> constructors would then get fences of some sort.)

Paul helpfully pointed me at Aleksey’s excellent description
and investigation of this proposal, which I had forgotten about:

https://shipilev.net/blog/2014/all-fields-are-final/
https://bugs.openjdk.java.net/browse/JDK-8031818

The JVM flag -XX:+AlwaysSafeConstructors might be
useful to enable this proposed feature and see if it suppresses
the bug.  (Don’t forget to unlock.)

Looks like the conversation is stalled, pending further
insights and problem fixes.  I had an idea for fixing one
of the problems with chained constructors, commented
on JDK-8032218.

— John


More information about the core-libs-dev mailing list