Closed stephan-herrmann closed 1 month ago
Interestingly, null flow analysis does not see any connection between catch blocks:
public void test() {
Exception ex = null;
try {
doStuff();
return;
} catch (NullPointerException e) {
ex = e;
} catch (Exception e) {
ex.printStackTrace(); // Null pointer access: The variable ex can only be null at this location
ex = e;
}
ex.printStackTrace();
}
Example from https://bugs.eclipse.org/466406:
Bogus error reported is:
In bugzilla I pondered if there might be a spec change behind, but §16.2.5 is pretty clear in this regard since at least SE 7: definite assignment in one catch blocks cannot influence a sibling catch block of the same try statement.