summaryrefslogtreecommitdiff
path: root/java/java-tests/testData/inspection/dataFlow/fixture/CatchRuntimeException.java
blob: e635b8dbd9a9e7ef9cf02e5ee275b54e388a2e2c (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import org.jetbrains.annotations.NotNull;

class BrokenAlignment {

  @NotNull
  Object test1() {
    try {
      bar(<warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>);
      return <warning descr="'null' is returned by the method declared as @NotNull">null</warning>;
    }
    catch (RuntimeException e) {
      return <warning descr="'null' is returned by the method declared as @NotNull">null</warning>;
    }
  }

  @NotNull
  Object test2() {
    try {
      bar(<warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>);
      return <warning descr="'null' is returned by the method declared as @NotNull">null</warning>;
    }
    catch (IllegalArgumentException | IllegalStateException e) {
      return <warning descr="'null' is returned by the method declared as @NotNull">null</warning>;
    }
  }

  @NotNull
  Object test3() {
    try {
      bar(<warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>);
      return <warning descr="'null' is returned by the method declared as @NotNull">null</warning>;
    }
    catch (AssertionError | IllegalStateException e) {
      return <warning descr="'null' is returned by the method declared as @NotNull">null</warning>;
    }
  }

  public void bar(@NotNull Object foo) {
    if (<warning descr="Condition 'foo != null' is always 'true'">foo != null</warning>);
  }

  public void bar2(@NotNull Object foo) {
    assert <warning descr="Condition 'foo != null' is always 'true'">foo != null</warning>;
    try { }
    catch (java.lang.RuntimeException ex) { }
  }

}