Details
-
Bug
-
Resolution: Fixed
-
P4
-
8, 11, 17
-
b03
-
generic
-
generic
-
Verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8324850 | 17.0.11 | Severin Gehwolf | P4 | Resolved | Fixed | b01 |
JDK-8327792 | 11.0.24 | Severin Gehwolf | P4 | Resolved | Fixed | b01 |
Description
The private method `java.lang.Class.getReflectionFactory()` appears to not be thread-safe.
It lazily initializes the `reflectionFactory` field but there is no happens-before relationship. Therefore it is allowed by the Java Memory Model that the first read of the `reflectionFactory` reads a non-null value and the second read (as part of the `return`) statement returns null, causing a NullPointerException for the caller.
See also https://shipilev.net/blog/2016/close-encounters-of-jmm-kind/#wishful-benign-is-resilient
Attachments
Issue Links
- backported by
-
JDK-8324850 Class.getReflectionFactory() is not thread-safe
- Resolved
-
JDK-8327792 Class.getReflectionFactory() is not thread-safe
- Resolved
- relates to
-
JDK-8261407 ReflectionFactory.checkInitted() is not thread-safe
- Resolved
-
JDK-8183178 Review thread safety of java.lang.reflect.TypeVariable methods
- Closed
- links to
-
Commit openjdk/jdk11u-dev/a26445db
-
Commit openjdk/jdk17u-dev/d7c67fc3
-
Commit openjdk/jdk/905b7639
-
Review openjdk/jdk11u-dev/2554
-
Review openjdk/jdk17u-dev/2153
-
Review openjdk/jdk/6870