As David Holmes just reminded me, and has been mentioned briefly
before on this list, the draft JSR
probably specifically mention the impact of JMM revisions on
serialization; in particular the fact that final fields are restored
by native default-deserialization mechanisms. This restoration occurs
(via defaultReadObject) AFTER the default-constructor for the object
is invoked. But, unless people do something very strange, restoration
occurs before the object is visible to any other.
As an aside, note that is all but impossible to declare a "final"
field as "transient", since there is no way to legally assign it
a value inside readObject. The only workaround I know is to
define the default-constructor to pick up the desired initial
value from some some other already-constructed object, which is
difficult to arrange.
-- Doug Lea, Computer Science Department, SUNY Oswego, Oswego, NY 13126 USA email@example.com 315-341-2688 FAX:315-341-5424 http://gee.cs.oswego.edu/ ------------------------------- JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel
This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:25 EDT