aboutsummaryrefslogtreecommitdiffstats
path: root/tests/java5/bridgeMethods/AspectX.aj
blob: 12ecf12fcf11bbe4f193211a67d0d33a71a27c47 (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
import java.util.*;

public aspect AspectX {

  static Set matchedJps = new HashSet();
	
  before(): call(* Number.compareTo(..)) {
  	matchedJps.add(new String("call() matched on "+thisJoinPoint.toString()));
  }
  
  before(): execution(* Number.compareTo(..)) {
  	matchedJps.add(new String("execution() matched on "+thisJoinPoint.toString()));
  }
	
  public static void main(String []argv) {
  	Number n1 = new Number(5);
  	Number n2 = new Number(7);
  	n1.compareTo(n2);
    n1.compareTo("abc"); // A Java5 compiler would *not* allow this, a call to a bridge method: error should be:
    /**
       AspectX.java:19: compareTo(Number) in Number cannot be applied to (java.lang.String)
       n1.compareTo("abc");
          ^
       1 error
     */ 
  	
  	Iterator i = matchedJps.iterator();
  	while (i.hasNext()) {
  		String s = (String)i.next();
  		System.err.println(s);
  	}
  }
}