There is no direct way to prevent sub-class from serialization in java. One possible way by which a programmer can achieve this is by implementing the writeObject() and readObject() methods in the subclass and needs to throw NotSerializableException from these methods.
Re: How to not allow serialization of attributes of a class in Java?
by Ashutosh Bhatt -
Number of replies: 0