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
64
65
|
import java.util.*;
public aspect GenericParameterMatching {
pointcut takesAMap() : execution(* *(Map<Double,Short>));
// matches takesAMap, staticTakesAMap
pointcut takesAnyMapType() : execution(* *(Map+<Double,Short));
// matches takesAMap, staticTakesAMap, takesAHashmap
pointcut collectionOfAnything() : execution(* *(Collection<?>));
// matches collectionOfAnything
pointcut collectionOfAnyNumber() : execution(* *(Collection<? extends Number));
// matches collectionOfAnyNumber
pointcut collectionOfTakingDouble() : execution(* *(Collection<? super Double>));
// matches collectionOfAnythingTakingADouble
pointcut anyCollection() : execution(* *(Collection<*>));
// matches all 3 collection methods
pointcut anyObjectOrSubtypeCollection() : execution(* *(Collection<? extends Object+>));
// matches collection of any number
pointcut superTypePattern(): execution(* *(Collection<? super Number+>));
// matches collection of anything taking a double
// RTT matching...
pointcut mapargs() : args(Map<Double,Short>);
// matches takesAMap, staticTakesAMap, takesAHashmap
pointcut hashmapargs() : args(HashMap<Double,Short>);
// matches takesAHashmap, RT test for takesAMap, staticTakesAmap
pointcut nomapargs(): args(Map<Object,Object>);
// no matches
pointcut wildargs() : args(Map<? extends Number, Short>);
// matches takesAMap, staticTakesAMap, takesAHashmap
pointcut nowildargs() : args(Map<? extends String, Short>);
// no matches
pointcut wildsuperargs() : args(Map<Double, ? super Short>);
// matches takesAmap, staticTakesAmap, takesAHashmap
// RTT matching with signature wildcards
pointcut collAnythingArgs() : args(Collection<?>);
// matches all collection methods
pointcut collNumberArgs() : args(Collection<Number>);
// does NOT match collectionOfAnyNumber (can't insert safely)
// does NOT match collectionOfAnythingTakingADouble (can't remove safely)
pointcut collNumberArgsWild() : args(Collection<? extends Number>);
// matches collection of any number
pointcut superDoubleArgs(): args(Collection<? super Number+>);
// matches coll taking a double
// add max and copy tests here...
}
|