From Effective Java “DOCUMENT ALL EXCEPTIONS THROWN BY EACH METHOD“
It should be noted that documenting all of the unchecked exceptions that each
method can throw is an ideal, not always achievable in the real world. When a
class undergoes revision, it is not a violation of source or binary compatibility if
an exported method is modified to throw additional unchecked exceptions.
Suppose a class invokes a method from another, independently written class. The
authors of the former class may carefully document all of the unchecked
exceptions that each method throws, but if the latter class is revised to throw
additional unchecked exceptions, it is quite likely that the former class (which has
not undergone revision) will propagate the new unchecked exceptions even
though it does not declare them.
I fail to understand how can former class propagate the new unchecked excpetions ? The java language doesn’t mandate the caller to catch and propagate unchecked exceptions .
It will propagate it precisely because exceptions are either caught or propagated. If not caught, an exception propagates:
In the above example, the exception thrown from
callee()will be propagated by thecaller()method, sincecaller()doesn’t catch it.