-
Bug
-
Resolution: Future Project
-
P3
-
5.0
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2194298 | 5.0-pool | Unassigned | P5 | Closed | Won't Fix |
Currently, when ObjectInputStream.defaultReadObject sets the values of an object's serializable fields, it always uses the methods Unsafe.put{Object,Boolean,Int,...}, regardless of whether or not the field is final-- for final fields, it should instead use the methods Unsafe.put{Object,Boolean,Int,...}Volatile, in order to ensure the desired memory model semantics for final fields upon (default) deserializaion be similar to normal construction.
With this change, setting of final fields by default deserialization would be implemented like setting of final fields via reflection (using Field.set after setAccessible(true)). The JLS covers this topic somewhat generally here:
http://java.sun.com/docs/books/jls/third_edition/html/memory.html#17.5.3
The issue is also mentioned here, in a bullet of the "Miscellany" section near the end:
http://gee.cs.oswego.edu/dl/jmm/cookbook.html
With this change, setting of final fields by default deserialization would be implemented like setting of final fields via reflection (using Field.set after setAccessible(true)). The JLS covers this topic somewhat generally here:
http://java.sun.com/docs/books/jls/third_edition/html/memory.html#17.5.3
The issue is also mentioned here, in a bullet of the "Miscellany" section near the end:
http://gee.cs.oswego.edu/dl/jmm/cookbook.html
- backported by
-
JDK-2194298 use Unsafe.put*Volatile methods to set final fields during default deserialization
-
- Closed
-
- relates to
-
JDK-8074022 Serialization should issue a freeze action after reconstituting a graph that contains objects with final fields
-
- Resolved
-