Files
openide/java/java-tests/testData/inspection/dataFlow/ancient/CheckedExceptionDominance.java

27 lines
572 B
Java

import java.util.Random;
public class CheckedExceptionDominance {
private static class CheckedException extends Exception {}
public static void foo() {
boolean flag = true;
try {
bar();
}
catch (CheckedException e) {
flag = false;
}
catch (Exception e) {
}
if (flag) { // This should not be highlighted as always true;
System.out.println("Must not happen");
}
}
public static void bar() throws CheckedException {
if (new Random().nextInt() > 2) throw new CheckedException();
}
}