1 package nullnessAnnotations;
2
3 import javax.annotation.CheckForNull;
4 import javax.annotation.Nonnull;
5
6 public class UseAnnotations {
7
8 @CheckForNull Object f(int x) {
9 if (x == 0) return null;
10 return (Integer) x;
11 }
12
13 int g(@Nonnull Object x) {
14 return 42;
15 }
16 int foo() {
17 return g(f(12));
18 }
19 int foo2() {
20 return g(null);
21 }
22 int foo3(int x) {
23 Object y = null;
24 if (x > 0) y = "";
25 return g(y);
26 }
27 int foo4() {
28 return f(12).hashCode();
29 }
30
31 int bar() {
32 return f(12).hashCode();
33 }
34 int bar2() {
35 Object x = null;
36 return x.hashCode();
37 }
38 int bar3(int x) {
39 Object y = null;
40 if (x > 0) y = "";
41 return y.hashCode();
42 }
43 int bar4(int x) {
44 Object y = null;
45 if (x > 0) y = "";
46 return y.hashCode();
47 }
48
49 }