I've this class hierarchy

codice:
//file Type.java

public enum Type{

 TypeA,TypeB;

}
codice:
//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

}
Now if i try to serialize and deserialize (with ObjectOutputStream and ObjectInputStream open on a socket) a MessageImpl object, i will obtain a MessageImpl instance

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:

codice:
//File MessageImpl2.java

public class MessageImpl2.java{

  private Type type;

  private int x;

 //getter and setter methods

}
the serialization of a MessageImpl2 object works well.

Do you kwow how class hierarchy can affect enum serialization???

Thanks