JDK-8064846 : Lazy-init thread safety problems in core reflection
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-11-13
  • Updated: 2015-09-29
  • Resolved: 2014-11-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8 JDK 9
7u80Fixed 8u60Fixed 9 b42Fixed
Related Reports
Relates :  
Relates :  
Description
We need to sprinkle volatile (or in future find some better way of doing lazy-init) over some fields in core reflection that appear to be accessed via a data race.  This adds to the sprinkling of "final" in the same classes in JDK-8062771 and coordinates with related fixes to jdk7u and jdk8u

Webrev: http://cr.openjdk.java.net/~martin/webrevs/openjdk9/core-reflection-volatile/
Comments
There ought to be some official way of having lazy initilalization in core libraries, like C# Lazy, but we don't seem to have that yet, so this change simply makes variables volatile. Ideally we would always CAS from null to ensure true set-once semantics.
14-11-2014