Jon Skeet said:
And you can do all of that with checked exceptions too - it's just the
compiler forces you to do it, and doesn't rely on the docs being
correct. All you do is add a "throws" clause to the method declaration
if you can't handle the exception.
Very true, but also consider the scenario where you're calling three
different methods inside your method, each of which throws three different
exceptions. If you don't want to handle the exceptions in that method,
you're going to have a very long throws clause. Alternatively you'd just say
throws Exception, but that sort of defeats the purpose of the throws
statement.
Plus, if the API writers go along and adds an exception to the throws clause
of a method buried deep in their object hierarchy, the API consumer is going
to be working like mad to update all their code to handle the new exception
type, adding throws clauses, or adding catch statements, or changing the
throws/catches to Exception...