The following program should compile with an error. Instead, javac allows it.
/*
* @test @(#)T4717164.java 1.1 02/07/23
* @bug 4717164
* @summary missing catch not reachable error when nested try-finally returns in finally
* @author Neal Gafter (gafter)
*
* @compile/fail T4717164.java
*/
class T4717164 {
public static void main(String[] args) {
try {
try {
throw new ClassNotFoundException();
} catch (ClassNotFoundException e) {
throw e;
} finally {
return; // discards ClassNotFoundException
}
} catch (ClassNotFoundException e1) { // error: unreachable
}
}
}
/*
* @test @(#)T4717164.java 1.1 02/07/23
* @bug 4717164
* @summary missing catch not reachable error when nested try-finally returns in finally
* @author Neal Gafter (gafter)
*
* @compile/fail T4717164.java
*/
class T4717164 {
public static void main(String[] args) {
try {
try {
throw new ClassNotFoundException();
} catch (ClassNotFoundException e) {
throw e;
} finally {
return; // discards ClassNotFoundException
}
} catch (ClassNotFoundException e1) { // error: unreachable
}
}
}