FastSerializable provides an alternative to the Serializable interface
where the exact type of the object to be serialized is known at compile
Classes implementing FastSerializable should provide a public constructor
that takes either:
Object state is read from the
stream. The ClassLoader argument,
if included, can be used to resolve any application-specific classes stored in the
stream. The FastSerialize framework generates code invoking either constructor
to build new objects when deserializing. If both constructors are present in a
given class then the two-argument constructor is used as first preference.
Some caveats apply to objects implementing FastSerializable:
- the type of object to reconstruct is typically determined at generation
time, not run time, so care must be taken that objects are restored using
the correct type. Making classes that implement FastSerializable
final may be a good idea.
- no handling of shared references to objects is done; if an object is
encountered twice during serialization, then two copies of the object will
exist upon deserialization.