aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/SynchronizedMethodsOnInterfaces.java
blob: 4cddd77c99fc2b181a38c7e7db51326cdf69e5b8 (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
import org.aspectj.testing.*;
import java.lang.reflect.*;

public class SynchronizedMethodsOnInterfaces {
    public static void main(String[] args) {
        new SynchronizedMethodsOnInterfaces().realMain(args);
    }
    static {
        Tester.expectEventsInString("I,C");
    }
    public void realMain(String[] args) {
        method(new D());
        method(new C());
        Tester.checkAllEvents();
    }
    void method(Object o) {
        try {
            o.getClass().getMethod("method", new Class[]{}).invoke(o, new Object[]{});
        } catch (Throwable t) {
            Tester.check(false, t+"");
        }
    }
    
    public SynchronizedMethodsOnInterfaces() {
    }
}

interface I {}
class D implements I {}
class C {}

aspect AspectI {
    public synchronized void I.method() { Tester.event("I"); }
}
aspect AspectC {
    public synchronized void C.method() { Tester.event("C"); }
}