By now, you should have a pretty good feel for how the serialization mechanism works for individual classes. The next step in explaining serialization is to discuss the actual serialization algorithm in a little more detail. This discussion won’t handle all the details of serialization. Instead, the idea is to cover the algorithm and protocol, so you can understand how the various hooks for customizing serialization work and how they fit into the context of an RMI application.
The first step is to discuss what gets written to the stream when an instance is serialized. Be warned: it’s a lot more information than you might guess from the previous discussion.
important part of serialization involves writing
out class-related metadata associated with an
instance. Most instances are more than one class.
For example, an instance of
String is also an
Object. Any given instance, however, is
an instance of only a few classes. These classes
can be written as a sequence:
CN, in which
C1 is a superclass of
C2 is a superclass of
C3, and so on.
This is actually a linear sequence because Java is
a single inheritance language for classes. We call
least superclass and
most-derived class. See Figure 10-4.
Figure 10-4. Inheritance diagram
After writing out the associated class information, the serialization ...