Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] LTW: Weaving a class that extends an Abstract Class

And if you want to detect myMethod() on A and all its subclasses, overridden or not, use this:

execution(* mypackage.A+.myMethod())
--
Alexander Kriegisch


Am 07.12.2012 um 22:48 schrieb Andy Clement <andrew.clement@xxxxxxxxx>:

Yep that is normal behaviour. The joinpoint for the method is only mypackage.A.myMethod()

If you wanted to detect myMethod() running on a B, use this:

execution(* myMethod()) && this(mypackage.B)



On 7 December 2012 07:42, <jeanlouis.pasturel@xxxxxxxxxx> wrote:
hello,
just a question about methods implemented in Abstract Classes :

package mypackage;
public abstract class A {
        public void myMethod() { System .out.println("myMethod in Abstract
Class");
        }
}

package mypackage;
public class B extends A {
}


package mypackage;
        public class Main {
        public static void main(String[] args) {
                B b=new B();
                b.myMethod();
        }
}

the aspect with this pointcut below doesn't weave :

public final pointcut methods(): execution( * mypackage.B.myMethod());
after methods() {
System.out.println("does-it weave ?");
}

the pointcut : execution( * mypackage.A.myMethod()); correctly weaves.

Is it the normal behaviour ?

Back to the top