summaryrefslogtreecommitdiffstats
path: root/tests/new/IntroduceInnerInterfaceCF.java
blob: 70566931c0366f34ba41482f34a9d703bf899030 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import org.aspectj.testing.Tester; 
import org.aspectj.testing.Tester;

public class IntroduceInnerInterfaceCF {
    public static void main(String[] args) {
        Tester.checkFailed("!compile");
    }
    private static final String[] EXPECTED;
    static {
        EXPECTED = new String[] 
        { "walk", "execution(void TargetClass.walk())" };
        Tester.expectEventsInString(EXPECTED);
    }
}
class TargetClass {
    /** @testcase PR#494 compile should fail if implementing method is not public */
    void defaultMethod() { }               // errLine 18
    private void privateMethod() { }       // errLine 19
    protected void protectedMethod() { }   // errLine 20
}

class AnotherClass{}  
class AThirdClass extends TargetClass implements Aspect.Inner {} // errLine 24

aspect Aspect {
    private interface Inner {
        // all automagically interpreted as public
        void defaultMethod();
        void privateMethod();
        void protectedMethod();
    }
    declare parents
        : TargetClass implements Inner;
    before() : execution(void Inner.*()) {
    }
}

aspect PeekingAspect {
    after(TargetClass tc) : this(tc) && execution(void TargetClass.walk()) {
        /** @testcase PR#494 compile should fail to bind private interface name outside of Aspect */
        if (tc instanceof Aspect.Inner) {                         // errLine 42
            Tester.checkFailed("(tc instanceof Aspect.Inner)");
        }
        if (Aspect.Inner.class.isAssignableFrom(tc.getClass())) { // errLine 45
            Tester.checkFailed("(Aspect.Inner.class.isAssignableFrom(tc.getClass())");
        }
        ((Aspect.Inner) tc).defaultMethod();                      // errLine 48
    }
    declare parents : AnotherClass implements Aspect.Inner;       // errLine 50
}

abstract aspect AbstractAspect {
    private interface Private {}
}
aspect HideFromChild extends AbstractAspect {
    /** @testcase PR#494 compile should fail to bind private interface name in aspect subclass */
    declare parents : AnotherClass implements Private;              // errLine 58
}

// todo: test cases to validate inner interfaces with package and protected