summaryrefslogtreecommitdiff
path: root/java/java-tests/testData/inspection/dataFlow/CheckedExceptionDominance/src/Test.java
blob: 4f0586d30a9681c9cb252d71ec19e354e45ae1c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 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();
   }
 }