Making class fields non serializable using PropertyDescriptor
posted 7 years ago
Hello to all readers of this topic!
Suppose I have a class A with set of fields and method that makes em non-serializable:
And class B that extends class A and has static initializer that calls A.makePropertiesTransient :
Now comes the question When I create new instance of B method call makePropertiesTransient(B.class) is executed so all inherited fields in B become transient. But I found that for superclass (i.e. class A) they are also become transient so serialization process for instance of class A skips all fields too.
Could you suggest how to avoid propagation of transient properties to superclass, so instances of class A would be serialized completely, but instances of class B not ?