Question

I have the following situation:

public class MyHandler extends DefaultHandler {
    public class CustomException extends SAXException {

    }
}

Eclipse is telling me that SAXException is serializable, and that I should either add a serialVersionUID to CustomException or suppress the warnings.

Questions:

  1. Why does such exception implement serializable?
  2. CustomException is empty. Should I add a serialVersionUID or suppress the warnings?


Related problem (less important): why does Eclipse always tell me that a serialVersionUID is missing, even when I add one?

Was it helpful?

Solution

1 All exceptions are Serializable because Throwable, the super class for all exceptions, is Serializable. It is used in RMI, if a remote method throws an exception this exception will be returned to client using serialization

2 You can do both, if you are not going to serialize your custom exception, it makes no difference

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top