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

public aspect AspectOnInterface /*of eachobject(instanceof(I1))*/ {
    before (I1 i1): target(i1) && call(String process()) {
	i1.addToS("-advised");
    }
    
    public static void main(String[] args) { test(); }

    public static void test() {
        ConcreteC1 c1 = new ConcreteC1();
        Tester.checkEqual(c1.process(), "foo-advised-processed", "");
    }
}
	
interface I1 {
    public void addToS(String newS);
    public String process();
}

class ConcreteC1 implements I1 {
    String s = "foo";
    public void addToS(String newS) { s += newS; }
    public String process() {
        return s + "-processed";
    }
}