Details
-
Bug
-
Resolution: Fixed
-
P2
-
8
-
b15
-
generic
-
generic
-
Not verified
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8065499 | 8u45 | Martin Buchholz | P2 | Resolved | Fixed | b01 |
JDK-8070051 | emb-8u47 | Martin Buchholz | P2 | Resolved | Fixed | team |
JDK-8072332 | 7u85 | Ivan Gerasimov | P2 | Resolved | Fixed | b01 |
JDK-8065887 | 7u80 | Ivan Gerasimov | P2 | Closed | Fixed | b04 |
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.
making effectively final fields truly final, as was done in
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.
Attachments
Issue Links
- backported by
-
JDK-8065499 More thread safety problems in core reflection
-
- Resolved
-
-
JDK-8070051 More thread safety problems in core reflection
-
- Resolved
-
-
JDK-8072332 More thread safety problems in core reflection
-
- Resolved
-
-
JDK-8065887 More thread safety problems in core reflection
-
- Closed
-
- relates to
-
JDK-8064846 Lazy-init thread safety problems in core reflection
-
- Closed
-
-
JDK-8062771 Core reflection should use final fields whenever possible
-
- Closed
-
(1 relates to)