I'm using xstream to serialize the state of an MT4j application. Deserialized
instances of Vector3D and Vertex objects do not test equal to the original
objects. Attached is a very simple JUnit test case which demonstrates the
problem.
I found that the reason for this is that xstream bypasses the constructors
entirely, so "type" never gets set. The field "type" is declared transient and
xstream ignores transient fields.
I recommend deleting the type field from Vector3D altogether and giving
Vector3D and its subclasses robust hashCode() and equals() methods. I've
attached versions of Vector3D, Vertex, and BezierVertex that have these.
Any code that calls getType() can simply use "instanceof" instead.
Original issue reported on code.google.com by drran...@gmail.com on 21 Apr 2011 at 7:14
Original issue reported on code.google.com by
drran...@gmail.com
on 21 Apr 2011 at 7:14Attachments: