summaryrefslogtreecommitdiffstats
path: root/tests/java5/generics/pointcuts/ArgsListOfSomething.aj
blob: d7fc9bad16c048cac7cd890e702c30f4f7b4b0d5 (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
import java.util.*;

public aspect ArgsListOfSomething {
	
	// args(List<?>) matches List, List<String>, List<?>, ...
		
	void rawList(List l) {}
	void listOfString(List<String> ls) {}
	void listOfSomething(List<?> ls) {}
	void listOfSomethingExtends(List<? extends Number> ln) {}
	void listOfSomethingSuper(List<? super Double> ln) {}
	
	// try a couple of nested variations too
	void mapit(Map<List<String>,List<List<Float>>> m) {}
	void setOf(HashSet<Double> sd) {}
	
	public static void main(String[] args) {
		ArgsListOfSomething a = ArgsListOfSomething.aspectOf();
		a.rawList(null);
		a.listOfString(null);
		a.listOfSomething(null);
		a.listOfSomethingExtends(null);
		a.listOfSomethingSuper(null);
		a.mapit(null);
		a.setOf(null);
	}
	
	before() : execution(* *(..)) && args(List<?>) {
		System.out.println("List<?> matches " + thisJoinPointStaticPart);
	}
	
	before() : execution(* *(..)) && args(Map<?,?>) {
		System.out.println("wild map matches " + thisJoinPointStaticPart);
	}
	@org.aspectj.lang.annotation.SuppressAjWarnings
	before() : execution(* *(..)) && args(HashMap<List<?>,List<List<?>>>) {
		System.out.println("nested wild map does not match " + thisJoinPointStaticPart);
	}
	
	before() : execution(* *(..)) && args(Map<List<String>,List<List<Float>>>) {
		System.out.println("exact wild map matches " + thisJoinPointStaticPart);
	}
	
	before() : execution(* *(..)) && args(Set<Double>) {
		System.out.println("super type exact matches " + thisJoinPointStaticPart);
	}
	
	before() : execution(* *(..)) && args(Set<?>) {
		System.out.println("super wild type matches " + thisJoinPointStaticPart);
	}
}