Details
Description
A DESCRIPTION OF THE PROBLEM :
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
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
- relates to
-
JDK-8183178 Review thread safety of java.lang.reflect.TypeVariable methods
-
- Open
-
-
JDK-8261407 ReflectionFactory.checkInitted() is not thread-safe
-
- Resolved
-