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

public class AddObjectOnAbstract {
    
    advice (I1 i1): i1 && String process() {
	    before {	    
            i1.addA();
	    }   
    }
    
    public static void main(String[] args) { test(); }

    public static void test() {
        AddObjectOnAbstract a = new AddObjectOnAbstract();
        ConcreteC1 c1 = new ConcreteC1();
        a.addObject(c1);
        Tester.checkEqual(c1.process(), "ab", "");
    }
}
	
abstract class I1 {
    public String s = "";
    public abstract void addA();
    public abstract String process();  
}

class ConcreteC1 extends I1 {
    public void addA() {
        s += "a";
    }
    public String process() {
        s += "b";
        return s;
    }
}