aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/SuperInIntroductionCE.java
blob: fb8784156d83c87519dc256268b3d4af5de2269d (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
import org.aspectj.testing.Tester;

public class SuperInIntroductionCE {
    public static void main (String[] args) {
        int result = new Sub().getInt();
        Tester.check(2==result, "new Sub().getInt() !2==" + result);
    } 
}

class Super {
    private int privateInt = 1;
    private int privateIntMethod() { return privateInt; }
    int defaultedInt = 1;
    int defaultIntMethod() { return privateInt; }
}

class Sub extends Super { }

class ObjectSub { }

aspect A {
    /** @testcase accessing private and default method and field of class within code the compiler controls */
    public int Sub.getInt() {
        int result = super.privateInt;       // CE 25 expected here
        result += super.privateIntMethod();  // CE 26 expected here
        // todo: move A and Super to separate packages
        //result += defaultInt;                // CE expected here
        //result += defaultIntMethod();        // CE expected here
        return result;
    }
}