I have class SuperYo extending class Persona, like this:
public class SuperYo extends Persona {
private NotSerializableObj obj1
private NotSerializableObj obj2
private NotSerializableObj obj3
}
public class Persona {
private SerializableObj sObj1
private SerializableObj sObj2
private SerializableObj sObj3
}
The thing is, that I add to a LinkedList an Instance of Persona from SuperYo:
LinkedList<Persona> list = new LinkedList<Persona>();
list.add((Persona) superYo);
It adds it as a SuperYo Object! With all the NonSerializableObjs on it… and thus, cant be sent from a Socket :(.
So, the question is… is there any way of “downcasting” an object to its father class, so its attributtes are non present?
Thanks!
Implement
readObjectandwriteObjectinSuperYoas below:Once you do this, there will be no need of down-casting. Also you may have better control on other non-serializable attributes in the object.