In the program:
class Ideone
{
public static void main (String[] args){
try{} catch (NumberFormatException e){ }
}
}
Actually, the JLS 11.2.3 describes behavior in such cases:
It is a compile-time error if a catch clause can catch checked exception class
E1and it is not the case that the try block corresponding to the catch clause can throw a checked exception class that is a subclass or superclass ofE1, unlessE1isExceptionor a superclass ofException.
In my case the catch clause can catch NumberFormatException that is neither Exception nor superclass of Exception. Try block can throw nothing, because there are no statements in there. So, why the code is compiled fine?