File: UnannoPrimitives.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,840 kB
  • sloc: java: 145,910; xml: 839; sh: 518; makefile: 401; perl: 26
file content (49 lines) | stat: -rw-r--r-- 1,289 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import org.checkerframework.checker.nullness.qual.*;

class UnannoPrimitives {
    // :: error: (type.invalid.annotations.on.use)
    @Nullable int f;

    // TODO:: error: (type.invalid)
    @NonNull int g;

    void local() {
        // test whether an arbitrary declaration annotation gets confused
        @SuppressWarnings("tata")
        int h = Integer.valueOf(5);

        int i = Integer.valueOf(99) + 1900;
        int j = 7 + 1900;

        // :: error: (type.invalid.annotations.on.use)
        @Nullable int f;

        // TODO:: error: (type.invalid)
        @NonNull int g;
    }

    static void testDate() {
        @SuppressWarnings("deprecation") // for iCal4j
        int year = new java.util.Date().getYear() + 1900;
        String strDate = "/" + year;
    }

    // :: error: (type.invalid.annotations.on.use)
    @Nullable byte[] d1 = {4};
    byte @Nullable [] d1b = {4};

    @SuppressWarnings("ha!")
    byte[] d2 = {4};

    // :: error: (type.invalid.annotations.on.use)
    Object ar = new @Nullable byte[] {4};

    // TODO:: error: (type.invalid)
    Object ar2 = new @NonNull byte[] {42};

    void testCasts(Integer i1) {
        Object i2 = (int) i1;
        // :: error: (type.invalid.annotations.on.use)
        Object i3 = (@Nullable int) i1;
    }
}