File: Standardize.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 (105 lines) | stat: -rw-r--r-- 3,483 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package flowexpression;

import java.io.FileInputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import testlib.flowexpression.qual.FlowExp;

public class Standardize {
    Object field;

    @SuppressWarnings("assignment.type.incompatible")
    @FlowExp("field") Object fieldField = null;

    void variableDecls(@FlowExp("field") Standardize this, @FlowExp("field") Object paramField) {

        @FlowExp("field") Object localField = fieldField;

        @FlowExp("field") Object o1 = fieldField;
        @FlowExp("this.field") Object o2 = fieldField;

        @FlowExp("field") Object o3 = paramField;
        @FlowExp("this.field") Object o4 = paramField;

        @FlowExp("field") Object o5 = localField;
        @FlowExp("this.field") Object o6 = localField;

        try (@SuppressWarnings("assignment.type.incompatible")
                @FlowExp("field") FileInputStream in = new FileInputStream("")) {
            in.read();
            @FlowExp("field") Object o7 = in;
            @FlowExp("this.field") Object o8 = in;
        } catch (
                @SuppressWarnings("exception.parameter.invalid")
                @FlowExp("field") Exception ex) {
            @FlowExp("field") Object o9 = ex;
            @FlowExp("this.field") Object o10 = ex;
        }

        @FlowExp("field") Object o11 = this;
        @FlowExp("this.field") Object o12 = this;
    }

    class MyGen<T extends @FlowExp("field") Object> {}

    <X extends @FlowExp("field") Object, Y extends @FlowExp("this.field") Object>
            void typeVariables(X x) {
        MyGen<X> o1;
        MyGen<Y> o2;
        MyGen<@FlowExp("this.field") String> o3;
        MyGen<@FlowExp("field") String> o4;

        @FlowExp("field") Object o5 = x;
        @FlowExp("this.field") Object o6 = x;
    }

    <A> void typeVariable2(A a, @FlowExp("#1") A a2) {}

    void callTypeVariable2(@FlowExp("field") Object param) {
        typeVariable2(field, param);
        typeVariable2(this.field, param);
    }

    @FlowExp("field") Object testReturn(@FlowExp("this.field") Object param) {
        @FlowExp("this.field") Object o = testReturn(param);
        return param;
    }

    void testCasts() {
        @SuppressWarnings("cast.unsafe")
        @FlowExp("this.field") Object o = (@FlowExp("field") Object) new Object();
        @FlowExp("this.field") Object o2 = (@FlowExp("field") Object) o;
    }

    void testNewClassTree() {
        // :: warning: (cast.unsafe.constructor.invocation)
        @FlowExp("this.field") Object o = new @FlowExp("field") Object();
    }

    void list(List<@FlowExp("field") Object> list) {
        Object field = new Object();
        // "field" is  local variable, but list.get(1) type is @FlowExp("this.field")
        @FlowExp("field")
        // :: error: (assignment.type.incompatible)
        Object o1 = list.get(1);
        @FlowExp("this.field") Object o2 = list.get(1);
    }

    Object dict = new Object();

    void typvar() {
        // TODO: Why doesn't the diamond operator work?
        // Map<@FlowExp("this.dict") String, String> that = new HashMap<>();
        Map<@FlowExp("this.dict") String, String> that =
                new HashMap<@FlowExp("dict") String, String>();
    }

    void newArray() {
        @FlowExp("this.dict") String[] s = new @FlowExp("dict") String[1];
    }

    void clasLiteral(@FlowExp("java.lang.String.class") String param) {
        @FlowExp("String.class") String s = param;
    }
}