I have been developing in Java since 8 months, and I didn't face a case where I went to serialize an exception, I'm asking because I saw the serialVersionUID
and how Eclipse advise to add it explicitly in the Exception class that you define. So, I think that every(or the majority) exception is being serialized and I don't know that, maybe because the framework or the language itself is handling this issue.
I know that serialization is needed when you need to transfer the object through the network or when you need to store it, and I get the idea that we actually serialize the exception when we save the logs/exception backtrace into for example, catalina.out
file, am I correct? and what other use cases that may need to serialize the exception?
serialVersionUID
for exception classes more than other classes? I understand thatserialVersionUID
is more related to network rather than storing, and I don't see in which case we want to transfer an exception through the network.serialVersionUID
in all classes implementing the Serializable interface. Throwable implements Serializable, and so your subclass inherits that.