-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b136
-
generic
-
generic
-
Verified
The compiler fails to reject this program:
import java.io.*;
class T6412514 {
void f() {
try {
throw new FileNotFoundException();
} catch (FileNotFoundException x) {
} catch (IOException x) { // ERROR
/*
It is a compile-time error if a catch clause catches checked
exception type E1 but there exists no checked exception type
E2 such that all of the following hold:
* E2 <: E1
* The try block corresponding to the catch clause can throw E2
* No preceding catch block of the immediately enclosing try
statement catches E2 or a supertype of E2.
*/
}
}
}
It is actually correct according to the specification. However, the specification
requires this version to be rejected:
void f() {
try {
throw new IOException();
} catch (IOException ex) {
}
}
The specification issue is tracked in 6412514.
import java.io.*;
class T6412514 {
void f() {
try {
throw new FileNotFoundException();
} catch (FileNotFoundException x) {
} catch (IOException x) { // ERROR
/*
It is a compile-time error if a catch clause catches checked
exception type E1 but there exists no checked exception type
E2 such that all of the following hold:
* E2 <: E1
* The try block corresponding to the catch clause can throw E2
* No preceding catch block of the immediately enclosing try
statement catches E2 or a supertype of E2.
*/
}
}
}
It is actually correct according to the specification. However, the specification
requires this version to be rejected:
void f() {
try {
throw new IOException();
} catch (IOException ex) {
}
}
The specification issue is tracked in 6412514.
- relates to
-
JDK-7039937 Improved catch analysis fails to handle a common idiom in the libraries
- Closed
-
JDK-6435972 "except.never.thrown.in.try" have to be reported in extra cases
- Closed
-
JDK-6412514 Message "except.never.thrown.in.try" have to be reported in extra cases
- Closed