-
Bug
-
Resolution: Fixed
-
P4
-
None
-
6
-
generic
-
generic
A DESCRIPTION OF THE FIX :
Bug Description : NullPointerException and inconsistent results in generic reflection methods.
If multiple threads seek generic reflection information about the same class, only the first
is guaranteed to get valid results. The others may get incorrect results, or get NullPointerException
exceptions.
Subset of Releases affected : 1.5.0, Mustang b74
Platforms affected : Windows XP 64 bit
Evaluation: The lack of the volatile qualifier on the genericInfo field means that access to
this field is not data race free.
Diff baseline : Mustang b74
Diff :
Class.java.old Wed Mar 8 11:40:24 2006
+++ Class.java Wed Mar 8 11:42:01 2006
@@ -553,6 +553,8 @@
}
// cache the name to reduce the number of calls into the VM
+ // Note: Does not need to be volatile, because String is safe for
+ // reference via data races.
private transient String name;
private native String getName0();
@@ -2211,7 +2213,7 @@
private native String getGenericSignature();
// Generic info repository; lazily initialized
- private transient ClassRepository genericInfo;
+ private volatile transient ClassRepository genericInfo;
// accessor for factory
private GenericsFactory getFactory() {
JUnit TESTCASE :
This would be amost impossible to show in a test case.
Bug Description : NullPointerException and inconsistent results in generic reflection methods.
If multiple threads seek generic reflection information about the same class, only the first
is guaranteed to get valid results. The others may get incorrect results, or get NullPointerException
exceptions.
Subset of Releases affected : 1.5.0, Mustang b74
Platforms affected : Windows XP 64 bit
Evaluation: The lack of the volatile qualifier on the genericInfo field means that access to
this field is not data race free.
Diff baseline : Mustang b74
Diff :
Class.java.old Wed Mar 8 11:40:24 2006
+++ Class.java Wed Mar 8 11:42:01 2006
@@ -553,6 +553,8 @@
}
// cache the name to reduce the number of calls into the VM
+ // Note: Does not need to be volatile, because String is safe for
+ // reference via data races.
private transient String name;
private native String getName0();
@@ -2211,7 +2213,7 @@
private native String getGenericSignature();
// Generic info repository; lazily initialized
- private transient ClassRepository genericInfo;
+ private volatile transient ClassRepository genericInfo;
// accessor for factory
private GenericsFactory getFactory() {
JUnit TESTCASE :
This would be amost impossible to show in a test case.
- relates to
-
JDK-8183178 Review thread safety of java.lang.reflect.TypeVariable methods
- Closed
-
JDK-8016236 Class.getGenericInterfaces performance improvement
- Closed