RFR: 8064846: Lazy-init thread safety problems in core reflection
martinrb at google.com
Fri Nov 14 21:48:04 UTC 2014
On Fri, Nov 14, 2014 at 9:32 AM, Peter Levart <peter.levart at gmail.com> wrote:
> Hi Martin,
> I dont know if you saw https://bugs.openjdk.java.net/browse/JDK-8064517 (a
> followup to your fix for final fields). It would be best to merge those
> fixes, what do you think?
I've deliberately ignored those changes for now, so that this when
this change goes in, all the jdk releases will have the same fixes
I agree there is more work to do.
> Otherwise I think that making all lazily initialized fields volatile is not
> necessary. Since you have made the Type implementations
> unsafe-publication-tolerable (by making their fields final), the only fields
> that need to be volatile are those that are used to lazily publish arrays.
> Am I right?
You may be right, but it's risky - it's hard to tell whether every
single Type implementation has exclusively final fields. We'd have to
write yet another test that examines every single Class in the
bootclasspath to be sure. (How does one do this in a jigsaw'ed
For safety's sake, I'd also like us to use CAS with our lazy-init
fields. Perhaps use Atomic field updaters throughout the reflection
codebase, for jdk9.
I'm not (yet) claiming to be an OWNER of java/reflect. Who is the real OWNER?
More information about the core-libs-dev