01: package edu.umd.cs.findbugs;
02:
03: /** class Test.
04: */
05: public final class Test {
06: // 1) mark variables you want by design as being never null
07: @edu.umd.cs.findbugs.annotations.NonNull
08: final String a;
09:
10: @edu.umd.cs.findbugs.annotations.CheckForNull
11: final String b;
12:
13: @edu.umd.cs.findbugs.annotations.Nullable
14: public String cache = null;
15:
16: @edu.umd.cs.findbugs.annotations.UnknownNullness
17: public String val = null;
18:
19: /** Constructor. */
20: public Test(String aa, String bb) {
21: this .a = aa;
22: this .b = bb;
23: this .cache = aa;
24: this .val = aa;
25:
26: }
27:
28: @edu.umd.cs.findbugs.annotations.OverrideMustInvoke
29: @Override
30: public final String toString() {
31: return "Just a test..." + a;
32: }
33:
34: @edu.umd.cs.findbugs.annotations.CheckReturnValue(explanation="please check the receivedvalue")
35: public int lengthB() {
36: return b.length();
37: }
38:
39: public static void main(String[] args) {
40: Test t = new Test(null, null);
41: System.out.println("" + t.lengthB());
42: }
43:
44: }
|