File: NullnessReleaseTests.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,104 kB
  • sloc: java: 145,916; xml: 839; sh: 518; makefile: 404; perl: 26
file content (33 lines) | stat: -rw-r--r-- 924 bytes parent folder | download | duplicates (3)
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
import java.util.LinkedList;
import java.util.List;
import org.checkerframework.checker.nullness.qual.*;

/**
 * This class is based on NullnessExample. This version contains additional tests to ensure that a
 * build works correctly.
 */
public class NullnessReleaseTests {

    public void example() {
        @NonNull String foo = "foo";
        @NonNull String bar = "bar";

        foo = bar;
        bar = foo;
    }

    public @NonNull String exampleGenerics() {
        List<@NonNull String> foo = new LinkedList<@NonNull String>();
        List<@NonNull String> bar = foo;

        @NonNull String quux = "quux";
        foo.add(quux);
        foo.add("quux");
        @NonNull String baz = foo.get(0);
        return baz;
    }

    // For some reason this class causes an exception if the Checker
    // Framework is compiled with JDK 7 and then executed on JDK 6.
    class TestException extends Exception {}
}