[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] after advice with overridden methods
|
Title: Message
hello all,
if i have the following setup: (three classes,
extending each other and overriding a function)
class
A
{
void
init()
{
System.out.println("A.init()");
}
}
class B extends
A
{
void
init()
{
System.out.println("B.init()");
super.init();
}
}
class
C extends B
{
void init()
{
System.out.println("C.init()");
super.init();
}
}
private static aspect Chain
{
pointcut f() : execution(void
A.init());
after(A a) : f()
&& this(a)
{
System.out.println("After init, this
[" + a + "] thisJoinPoint [" + thisJoinPoint +
"]");
}
}
in the
main:
C c = new
C();
c.init();
output:
C.init()
B.init()
A.init()
After init, this
[com.netvisor.nvsr.client.Factorial$C@1fc2fb] thisJoinPoint [execution(void
com.netvisor.nvsr.client.Factorial.A.init())]
After init, this
[com.netvisor.nvsr.client.Factorial$C@1fc2fb] thisJoinPoint [execution(void
com.netvisor.nvsr.client.Factorial.B.init())]
After init, this
[com.netvisor.nvsr.client.Factorial$C@1fc2fb] thisJoinPoint [execution(void
com.netvisor.nvsr.client.Factorial.C.init())]
shouldn't be there only one After
init message? note that it's A.init(), not A+.init() in the pointcut! changing
to A+ does not have any effect on the output.
i can workaround the problem by adding
&& !cflowbelow(f()) to
the advice, but in a much more complex scenario it does not get called for all
the object i would like to... :(
so my question is: is everything
ok with the above output?
thanks in
advance,
101