blob: 207563844a855307b53ac78f12ce2cb7426ed202 (
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
|
import java.util.*;
public aspect WildcardArgsExamples {
before(List<? extends Number> aListOfSomeNumberType)
: call(* foo(..)) && args(aListOfSomeNumberType) {
System.out.println("advice match at " + thisJoinPointStaticPart);
}
before(List<? extends Number> aListOfSomeNumberType)
: (call(* goo*(List<Number+>)) || call(* goo*(List<? extends Number>)))
&& args(aListOfSomeNumberType) {
System.out.println("advice match 2 at " + thisJoinPointStaticPart);
}
public static void main(String[] args) {
C c = new C();
List<String> ls = new ArrayList<String>();
List<Double> ld = new ArrayList<Double>();
c.foo("hi");
c.foo(ls);
c.foo(ld);
List<Number> ln = new ArrayList<Number>();
c.goo1(ln);
c.goo2(ld);
c.goo3(ls);
List<? extends Number> lsn = ln;
c.goo4(lsn);
List l = new ArrayList();
c.goo5(l);
c.goo6(new Object());
}
}
class C {
public void foo(Object anObject) {}
public void goo1(List<Number> ln) {}
public void goo2(List<Double> ld) {}
public void goo3(List<String> ls) {}
public void goo4(List<? extends Number> lsn) {}
public void goo5(List l) {}
public void goo6(Object o) {}
}
|