Unreachable catch classes

Stephen Colebourne scolebourne at joda.org
Thu May 26 08:14:22 UTC 2011


On 26 May 2011 03:27, David Holmes <David.Holmes at oracle.com> wrote:
> It hadn't occurred to me before but the "more precise rethrow" semantics are
> basically making the same invalid assumption about where checked exceptions
> can be thrown. Before if you catch Throwable and want to rethrow then you
> have to cast to an unchecked exception type, or else wrap with an unchecked
> exception type. Now you can catch Throwable and simply rethrow it -
> potentially letting an undeclared checked-exception to continue to make its
> escape.
>
> Now given that you could instead have only caught unchecked-exceptions, and
> the undeclared checked exception would have escaped anyway, this is perhaps
> not a big deal.
>
> But it troubles me that the language assumes things that are known to not be
> upheld by the libraries, and rather than helping to identify such cases this
> language change will now be helping to hide such cases.

To me it feels like the language is acting like the little Dutch boy
trying to stop the flow of water by sticking his finger in the dyke.
Checked exceptions are increasingly being ignored by users, and are
almost never being propagated by other languages, causing problems
with catch clauses. Its time to stop being precious and accept this.

IMO, Java should at this point (and when claiming to be in a new
"multi-lingual" world) allow the catching of checked exceptions that
are not thrown.  (Note that while I'm personally in favour of removing
checked entirely, I'm not calling for that here - just the ability to
catch anything, to reflect reality)

Stephen



More information about the core-libs-dev mailing list