JDK-8064391 : More thread safety problems in core reflection
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 8
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-11-07
  • Updated: 2015-02-02
  • Resolved: 2014-11-14
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
7u80Fixed 8u40 b15Fixed
Related Reports
Relates :  
Relates :  
Description
We have noticed thread safety problems in the JDK sources for core reflection.  We can fix these by:
making effectively final fields truly final, as was done in
JDK-8062771: Core reflection should use final fields whenever possible

and also by using thread-safe constructs on lazy init-once variables in the tree-shaped data structure rooted by Class objects, most obviously by making fields volatile.

Here are changes we made locally at Google:

http://cr.openjdk.java.net/~martin/webrevs/openjdk7/Class-thread-safety/
http://cr.openjdk.java.net/~martin/webrevs/openjdk8/Class-thread-safety/

We think these would be good to include in JDK update releases.

For jdk9, we can and should make similar changes, but we can be more ambitious and try to improve by ensuring that the initialization is truly once, and perhaps take advantage of new core support for volatile fields expected in jdk9.  Or use Unsafe with CAS.
Comments
Not verified. no test
01-12-2014

Joel has volunteered to work on the backports at least.
07-11-2014