aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/TopmostImplements.java
blob: 23c466d0e48a4a033564e4c244b9026322438a45 (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
import org.aspectj.testing.Tester;
import java.lang.reflect.Method;

// PR#126
        
public class TopmostImplements {
    public static void main(String[] args) { test(); }
    
    public static void test() {
        BC1 bc1 = new BC1();
        BC2 bc2 = new BC2();
        String m1 = "";
        String m2 = "";
        try { 
            m1 = bc1.getClass().getMethod("m1", null).toString();
            m2 = bc2.getClass().getMethod("m1", null).toString();
        } catch ( NoSuchMethodException nsme ) {
            Tester.check(false, "method not found");
        }
        Tester.checkEqual(m1, "public java.lang.String B.m1()", "from extends, implements");
        Tester.checkEqual(m2, "public java.lang.String B.m1()", "from extends");
      
        Tester.checkEqual(bc1.m1(), "BC1", "from extends, implements");
        Tester.checkEqual(bc2.m1(), "BC2", "from extends");  
        
    }
}

aspect Introducer {    
    public String A.m1() { return getName(); }
}


interface A {
    String getName();
}

class B implements A {
    public String getName() { return "B"; }
}

class BC1 extends B implements A {
    public String getName() { return "BC1"; }
} 

class BC2 extends B {
    public String getName() { return "BC2"; }
}