JDK-8004919 : AnnotationSupport uses possibly half-constructed AnnotationType instances
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2012-12-12
  • Updated: 2013-08-06
  • Resolved: 2013-01-31
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 8
8 b77Fixed
Related Reports
Relates :  
Description
In the sun.reflect.annotation.AnnotationSupport class the AnnotationType for a particular annotation class is not obtained via the synchronized getInstance() method, but incorrectly via direct unsynchronized read of Class.annotationType field. The code in AnnotationSupport can therefore dereference a half-constructed AnnotationType instance before it's constructor, executing in another thread, is finished and before final fields in object are frozen.

Class.[get,set]AnnotationType should only be called from within the synchronized AnnotationType.getInstance method.
Comments
Verified in jdk8/b101 with the test mentioned in comment.
06-08-2013

Thanks to Peter for finding this, initial bugreport via mail here: http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-December/012629.html
12-12-2012