From the javadoc of guava's ForwardingObject
:
Although this class does not implement
Serializable
, a serializable subclass may be created since this class has a parameter-less constructor.
Why is a parameterless constructor needed for a class to be able to be Serializable
? Am I misunderstanding something, or is this just an error in the javadoc?
It just means you can write:
class MyForwardingFoo extends ForwardingObject implements Serializable {
//
}
and it'll be serializable despite ForwardingObject
itself isn't serializable; mentioning empty constructor isn't probably the best wording there but from the language perspective it's a sufficient condition to achieve serializability. What's more important is the fact that ForwardingObject
itself doesn't hold any non-serializable fields.