Discussion Forum

How to not allow serialization of attributes of a class in Java?

How to not allow serialization of attributes of a class in Java?

by Aarti Mathpal -
Number of replies: 1

How to not allow serialization of attributes of a class in Java?

In reply to Aarti Mathpal

Re: How to not allow serialization of attributes of a class in Java?

by Ashutosh Bhatt -
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.