blob: 833d9d154c66174dca935e3c3c8f8272e38af092 (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
import java.util.*;
class C {
public void foo(List<String> listOfStrings) {}
public void bar(List<Double> listOfDoubles) {}
public void goo(List<? extends Number> listOfSomeNumberType) {}
}
aspect A {
before(List<Double> listOfDoubles) : execution(* C.*(..)) && args(listOfDoubles) {
for (Double d : listOfDoubles) {
// do something
}
}
@org.aspectj.lang.annotation.SuppressAjWarnings
before(List<Double> listOfDoubles) : execution(* C.*(..)) && args(listOfDoubles) {
for (Double d : listOfDoubles) {
// do something
}
}
@org.aspectj.lang.annotation.SuppressAjWarnings("uncheckedArgument")
before(List<Double> listOfDoubles) : execution(* C.*(..)) && args(listOfDoubles) {
for (Double d : listOfDoubles) {
// do something
}
}
before(List<Double> listOfDoubles) : execution(* C.*(List<Double>)) && args(listOfDoubles) {
for (Double d : listOfDoubles) {
// do something
}
}
}
public aspect ArgsExamples {
before() : args(List) && execution(* *(..)) {
System.out.println("args(List)");
}
before() : args(List<String>) && execution(* *(..)) {
System.out.println("args List of String");
}
before() : args(List<Double>) && execution(* *(..)) {
System.out.println("args List of Double");
}
public static void main(String[] args) {
C c = new C();
c.foo(new ArrayList<String>());
c.bar(new ArrayList<Double>());
c.goo(new ArrayList<Float>());
}
}
|