Re: Exception Names
Karl Uppiano wrote:
Not so much a naming thing, but I kinda wish InterruptedException was a
runtime exception instead of a checked exception. IMHO, there may be
Then no one would handle it.
more incorrect code written to handle InterruptedException than all of
the others combined. More often than not, it seems when someone wants to
This is only the tip of the iceberg when it comes to incorrect thread programming.
wait, they catch and "eat" the InterruptedException, often resuming in
some loop, when someone much higher up wanted to interrupt the wait and
regain control of the thread.
These folks have obviously not read and assimilated /Java Concurrency in
Practice/ by Brian Goetz, et al.
Making 'InterruptedException' runtime would not have helped; indeed, it would
have exacerbated the problem. People would have learned the hard way that
they were getting the exception, then still handled it incorrectly.
Face it, Java is a language that must be studied, and it must be learned.
Some of the problems it solves, such as multi-threaded programming, are
inherently hard. The language cannot make the problem easier; the best it can
do is not make it any harder.
The point of making an exception checked or not is not to prevent abuse of the
exception. Nothing but care by the practitioner can do that. The point of
making an exception checked is to identify methods that intentionally throw
that exception, and force their clients to deal with it with a compile-time
check. Forcing clients to deal with the exception correctly is something that
Java as a language cannot do.
Give us smarter programmers, not a smarter programming language.
--
Lew