File: ViewpointAdaptation.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 (41 lines) | stat: -rw-r--r-- 1,193 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
import testlib.flowexpression.qual.FlowExp;

public class ViewpointAdaptation {

    class MyClass {
        protected final Object field = new Object();

        protected @FlowExp("field") Object annotatedField1;

        protected @FlowExp("this.field") Object annotatedField2;

        public @FlowExp("field") Object getAnnotatedField1() {
            return annotatedField1;
        }
    }

    class Use {
        final MyClass myClass1 = new MyClass();
        final Object field = new Object();

        @FlowExp("this.myClass1.field") Object o1 = myClass1.annotatedField1;

        @FlowExp("this.myClass1.field") Object o2 = myClass1.annotatedField2;

        @FlowExp("field")
        // :: error: (assignment.type.incompatible)
        Object o3 = myClass1.annotatedField1;

        @FlowExp("this.field")
        // :: error: (assignment.type.incompatible)
        Object o4 = myClass1.annotatedField2;

        @FlowExp("field")
        // :: error: (assignment.type.incompatible)
        Object oM2 = myClass1.getAnnotatedField1();

        @FlowExp("this.field")
        // :: error: (assignment.type.incompatible)
        Object oM3 = myClass1.getAnnotatedField1();
    }
}