aboutsummaryrefslogtreecommitdiffstats
path: root/tests/errors/AccessingInstanceFieldsStatically.java
blob: 11a09089095767a64724d7ba33457d1fd6f8072f (plain)
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
public class AccessingInstanceFieldsStatically {
    public static void main(String[] args) {
        new AccessingInstanceFieldsStatically().realMain(args);
    }
    public void realMain(String[] args) {
    }
}

class T {
    public void printIt() {}

    public int getJ() { return -1; }

    public static void m() {
        Object o = this; //ERROR static reference to this
        this.clay++;     //ERROR static reference to instance field
        clay++;          //ERROR static reference to instance field
        printIt();       //ERROR static reference to instance method
    }

    public T(int i, int j) {
        clay = i;
    }

    public T() {
        this(clay,     //ERROR static reference to instance field
             getJ());  //ERROR static reference to instance method
        clay++;
        getJ();
        1+1; //ERROR not a legal statement
    }
}

aspect TAspect {
    int T.clay = 0;
    void around (T tt):
        target(tt) && call(void printIt()) {
        T.clay = 1; // ERROR static reference to instance field
        T.getJ(); //ERROR static reference to instance method
    }
}