Hi Guillaume,

Guillaume Nodet wrote:
The Identity class caches internally the hash code and the string representation in private attributes.
These attributes are not declared transient, thus
the computed hash code is serialized. The problem is
that the Class.hashCode() method not overriden
and so relies on the Object.hashCode() method which
is not guaranteed to give the same values when
serialized/deserialized.


Could these attributes be made transient ?


Agree with you, the Class (Object) hashCode method will not be the same in different JVM. We can - declare both fields as transient - use the class name instead the class object

First one is the safest way to go, but hashcode/toString has to be re-calculated after each serialization. Second one is not safe when using different JVM implementations (hashCode calculation of the class name can differ in different JVM implementations).
So I prefer your suggestion.


regards,
Armin

Thanks,
Guillaume


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to