aboutsummaryrefslogtreecommitdiffstats
path: root/tests/features151/ataround/A7.java
blob: 6daf99524d0e107df77ecfbf4b8417b8780c18ff (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
// Bind the this on a call and change it with proceed... makes no difference
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

@Aspect
public class A7 {
  N newN = new N();

  @Around("call(void M.method(String)) && args(p) && this(t)")
  public void a( ProceedingJoinPoint pjp, N t,String p) throws Throwable {
    System.err.println("advice from ataj aspect");
    pjp.proceed(new Object[]{newN,"faked"});
  }

  public static void main(String []argv) {
    N.main(argv);
  }
}

class N {
 public static void main( String[] args ) {
   N n = new N();
   n.methodCaller("real");
 }


 public void methodCaller(String param) {
   M m = new M("1");
   m.method(param);
 }

}


class M {
 String prefix;
 public M(String prefix) { this.prefix = prefix; }
 public void method(String s) { System.err.println(prefix+s); }
}

/*
class M {

 String prefix;

 public M(String prefix) { this.prefix = prefix; }

 public static void main( String[] args ) {
   M m = new M("1");
   m.methodCaller("real");
 }

 public void methodCaller(String param) {
   method(param);
 }

 public void method(String s) { System.err.println(prefix+s); }

}
*/