/* illustrating the difference between 'this' and 'target' pointcuts */ class A { public void f() { System.out.println("don't give me an f"); } } class B { public void g(A n) { n.f(); } } public class thistarget { public static void main(String[] av) { A n = new A(); B p = new B(); // 'this(x) pointcut captures value of 'this' in this context. p.g(n); // target is the target object, p, that call is made on. } } // should be in separate file... aspect thisandtarget { before(A x, B y): call(void A.f()) && this(y) && target(x) { System.out.println("Object "+y+" is calling f on object "+x); } void around(thistarget instance): call(void B.g(..)) && withincode(static void thistarget.main(..) && this(instance) { System.out.println("about to call g from main"); proceed(instance); } } /* output: Object B@677327b6 is calling f on object A@14ae5a5 don't give me an f Question: would the around advice run for the call to p.g from main? Answer: NO! because main is static, which means there is no 'this'. Try System.out.println(this); from main and see what happens. Don't use 'this' pointcut with 'execution' instead of call. */