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

public class CallsToArray {
    public static void main(String[] args) {
	byte[] a = new byte[] {0, 1};
	byte[] b = (byte[])a.clone();

	Tester.check(a != b, "cloned array is different");
	Tester.check(a[0] == b[0] && a[1] == b[1], "but compares equal");

	Tester.check(A.returnedClone == b, "advice did right thing");
    }

}


aspect A {
    static Object returnedClone;
    after () returning(Object cloned): call(Object Object.clone()) {
	System.out.println("running advice");
	A.returnedClone = cloned;
    }
    /*
    static after () returning(Object cloned): calls(Object .clone()) {
	System.out.println("running advice on byte[]");
	A.returnedClone = cloned;
    }
    */
}