In our application, for one class(which is Serializable) sonar is complaining - Fields in a "Serializable" class should either be transient or serializable. That class is not serialized anywhere in our application. But I am not sure why it implements serializable because that class was written long time ago.
As per the Sonar doc , Fields in a Serializable class must themselves be either Serializable or transient even if the class is never explicitly serialized or deserialized. But I didnt find any exact reason behind this.
Could you please explain why its harmful if Fields in a "Serializable" class is not transient or serializable ? if the class is never explicitly serialized or deserialized then what is the harm here ?
I was going through Fields in a “Serializable” class should either be transient or serializable, but I didnt find proper answer of my question. I found below statement but didnt understand much
For instance, under load, most J2EE application frameworks flush objects to disk, and an allegedly Serializable object with non-transient, non-serializable data members could cause program crashes, and open the door to attackers. In general a Serializable class is expected to fulfil its contract and not have an unexpected behaviour when an instance is serialized.
Thanks