previous | start | next

## Serialing Unserializable Classes

- Some classes are not serializable
- Security? Anonymous classes? Programmer cluelessness?
- Example: `Ellipse2D.Double`
- How can we serialize `Car`?
- Suppress default serialization to avoid exception
- Mark with `transient`:
  `private transient` `Ellipse2D frontTire;`
- Supply `private` (!) methods
  `private void writeObject(ObjectOutputStream out)
  private void readObject(ObjectInputStream in)`
- In these methods
  - Call `writeDefaultObject`/`readDefaultObject`
  - Manually save other data
- Ch7/serial/Car.java

previous | start | next