[concurrency-interest] Thread interruption protocol: InterruptedException is a "checked" exception, correct?
peter.kovacs.1.0rc at gmail.com
Wed May 20 11:15:22 EDT 2009
I highly appreciate your input.
The doc you quoted says that the original exception is wrapped in an
InvocationTargetException instance. Similarly, I'd expect that if an
exception occurs during Class loading, it is wrapped in an
What we're seeing in our case is a plain InterruptedException:
Caused by: java.lang.InterruptedException
at java.lang.Class.forName0(Native Method)
2009/5/20 Tom Hawtin <Thomas.Hawtin at sun.com>:
> Péter Kovács wrote:
>> Is it possible to get java.lang.InterruptedException, even if none of
>> the method along the call stack declares this exception?
>> We are experiencing such a case. Class.forName(String) appears to
>> throw the exception.
> Class.newInstance is more likely to be the culprit:
> "Note that this method propagates any exception thrown by the nullary
> constructor, including a checked exception. Use of this method effectively
> bypasses the compile-time exception checking that would otherwise be
> performed by the compiler. The Constructor.newInstance method avoids this
> problem by wrapping any exception thrown by the constructor in a (checked)
> The same thing can be done with Thread.stop(Throwable), unchecked casts and
> playing silly buggers with bytecode
>> Is it not a breach of one of the fundamental contracts of the Java
>> language: "checked" exception are not allowed to be thrown in a method
>> without this method being declared to (potentially) throw it? (We
>> catch this exception as a Throwable in a catch(Throwable) clause.)
> Of the language yes (with exception for unsafe casts); of the VM no.
> Tom Hawtin
More information about the Concurrency-interest