Ticket #162 (closed enhancement: fixed)
Opened 9 years ago
Call custom restore method after unmarshaling or cloning an object
|Reported by:||Bernhard Haumacher (haui at haumacher dot de)||Owned by:|
A transportable class may provide a private method named "restoreAfterUnmarshal()" that takes no arguments and declares IOException and ClassNotFoundException to be thrown. This method is automatically called during the unmarshaling and deep cloning process of an object of this class. restoreAfterUnmarshal() is called after all state of the corresponding object has been unmarshaled up to the actual class in the class hierarchy. This method can be used for example to restore transient state that is not marshaled along with the object.
It is critical that both exceptions (IOException and ClassNotFoundException) are declared for restoreAfterUnmarshal(), because this method is also called after a deep clone of the object. Because the corresponding deep clone method does not throw any of these exceptions, catch clauses have to be generated for them. But it is illegal to declare a catch clause, if the exception might not be thrown wihin the body of the try statement.
User code in the custom restoreAfterUnmarshal() method may experience references to uninitialized objects (see ticket:193).
implemented since 1.08a.