[concurrency-interest] Thread interruption protocol: InterruptedException is a "checked" exception, correct?
mthornton at optrak.co.uk
Wed May 20 09:47:39 EDT 2009
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.
> 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.)
The restriction is not enforced by the JVM --- it is a compile time
rule. So native code or byte code generated by a compiler other than
javac can throw any exception regardless of whether it has been declared.
More information about the Concurrency-interest