aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs152/pr122253/PerThis.java
blob: 2079c8185dceb3e921b8cf4d2d6a08e8be101398 (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
import org.aspectj.lang.*;

public aspect PerThis perthis(execution(* m(..))) {

  before(): execution(* Foo.*(..)) {}

  public static void main(String []argv) {
	print("before");
    new Foo().m();
    print("after");
  }
  
  public static void print(String prefix) {
    System.err.println(prefix);
    boolean b1 = Aspects14.hasAspect(PerThis.class,null);
    boolean b2 = PerThis.hasAspect(null);
    Object   o1 = (b1?Aspects14.aspectOf(PerThis.class,null):null);
    Object   o2 = (b2?PerThis.aspectOf(null):null);
    System.err.println("hasAspect?  "+b1+" : "+b2);
    System.err.println("aspectOf? "+o1+" : "+o2);   
  }
  
  public String toString() { return "PerThisInstance"; }
}

class Foo {
  public void m() { print("during");}
  public void print(String prefix) {
    System.err.println(prefix);
    boolean b1 = Aspects14.hasAspect(PerThis.class,this);
    boolean b2 = PerThis.hasAspect(this);
    Object   o1 = (b1?Aspects14.aspectOf(PerThis.class,this):null);
    Object   o2 = (b2?PerThis.aspectOf(this):null);
    System.err.println("hasAspect?  "+b1+" : "+b2);
    System.err.println("aspectOf? "+o1+" : "+o2);   
  }
}