I've this class hierarchy
codice://file Type.java public enum Type{ TypeA,TypeB; }Now if i try to serialize and deserialize (with ObjectOutputStream and ObjectInputStream open on a socket) a MessageImpl object, i will obtain a MessageImpl instancecodice://File Message.java public abstract class Message { private Type type; //getter and setter methods } //File MessageImpl.java public class MessageImpl extends Message { private int x; //getter and setter methods }
with the same 'x' value but with a null value for type field also if i've specified one.
The strange thing is that if i use this class:
the serialization of a MessageImpl2 object works well.codice://File MessageImpl2.java public class MessageImpl2.java{ private Type type; private int x; //getter and setter methods }
Do you kwow how class hierarchy can affect enum serialization???
Thanks

Rispondi quotando

