4.10. Onward

Java metadata makes basic serialization trivial. If you mark a class Serializable, an ObjectOutputStream can discover your class's fields via reflection, and it can automate the process of writing an instance to a stream or reading it back again. This alone is quite a trick if you come from a language background that does not include metadata.

The interesting parts of Java serialization, though, are the hooks that Java provides to fine-tune how your classes transition to and from object streams. You can use the readObject and writeObject methods to add custom perinstance data or validation to the default serialization behavior. With class annotation, you can add custom per-class data, typically to support dynamically downloading ...

Get Component Development for the Java™ Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.