Suppose I have a Serializable
class ShapeHolder
that owns an object that implements a Serializable
Shape
interface. I wa
I want to make sure the correct concrete shape object is saved (and the correct type is later restored).
Java's default serialization (ObjectInputStream & ObjectOutputStream) does that out-of-the-box. When serializing, Java writes there the name of the concrete class and then uses in when deserializing.