out.defaultWriteObject(); out.writeInt(super.field1); out.writeObject(super.stringfield); // etc.
nkd07 wrote:You're welcome.
Thanks for clearing up what exactly transient should be in front of, which makes sense because we also have to override the writeObject and readObject method calls and make appropriate changes to these now that the class extends a nonserializable class.
In your #4 you said to serialize properties of a super class follow the example code, so does that mean even if the super class isn't serializable some of its properties can still be?Yes. If the type of the field (or property) implements Serializable or extends something that implements Serializable (e.g. String is Serializable, so is Integer because it extends Number, but OutputStream is not Serializable).
[...] So to override these calls I must pass in the properties defined in the current class and just omit the properties in the super class? or do i just place them in here and put them in as transient? or still define them as I have placed here?No, defaultWriteObject() takes care of the properties for the class it's defined in and any subclasses you make in the future. You just need to write super's properties. (Same for readObject and defaultReadObject).