Java: account for generic exceptions in java/unreachable-catch-clause

This commit is contained in:
yh-semmle
2018-10-08 22:27:39 -04:00
parent 7962530789
commit 001b9f8b56
2 changed files with 14 additions and 1 deletions

View File

@@ -68,6 +68,14 @@ public class PartiallyMaskedCatchTest {
} catch (IOException e) {
// reachable: IOException is thrown by getClosableThing()
}
try (ClosableThing thing = new ClosableThing()) {
genericThrowingMethod(IOException.class);
} catch (ExceptionA e) {
// reachable: ExceptionA is thrown by implicit invocation of CloseableThing.close()
} catch (IOException e) {
// reachable: IOException is thrown by invocation of genericThrowingMethod(IOException.class)
}
}
public static ClosableThing getClosableThing() throws IOException {
@@ -94,4 +102,6 @@ public class PartiallyMaskedCatchTest {
throws ClassNotFoundException,
NoSuchMethodException, InstantiationException, IllegalAccessException,
InvocationTargetException {}
public static <E extends Exception> void genericThrowingMethod(Class<E> c) throws E {}
}