Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Why is this call also matched?

Does the advice marker against the a1.call2() statement by any chance
have a tiny '?' against it indicating it is a conditional match that
may not actually cause the advice to run when you execute the program?

Andy.

On 05/04/06, Sunny <sunfire001@xxxxxxxxx> wrote:
>
>
> Hi,
>
> Today I got a chance to try the solution provided by Adrian on Mar. 24. This
> solution worked fine. Then I changed it a little bit to monitor all calls
> with such patterns. Here I am listing the code and aspect.
>
> public class A
> {
>     B b = new B();
>     public static void call1(B b)
>     {
>         C c = new C();
>         c.call2(b);
>     }
>
>     public void call2()
>     {
>      call1(b);
>     }
>  }
>
> public class C
> {
>  public void call3(B b)
>  {
>   b.changeField();
>  }
>
>  public static void main(String[] args)
>  {
>   A a1 = new A();
>   a1.call2();
>  }
> }
>
>
> pointcut staticCalledFromInstance(Object caller) :
>      call(static * *.*(..)) && this(caller);
>
> pointcut calledFromWithinStaticInCflowOfInstance(Object
> caller) :
>   call(* *.* (..)) &&
> cflow(staticCalledFromInstance(caller));
>
> before(Object caller) :
> calledFromWithinStaticInCflowOfInstance(caller)
> {
>  System.out.println(caller.getClass().getName());
> }
>
>
> What confuses me is that the call a1.call2() in main is also advised by the
> pointcut calledFromWithinStaticInCflowOfInstance (there is
> an advice marker next to this statement). I did not expect this call to be
> advised since it is not in the control flow of call1(b);
> which is matched by staticCalledFromInstance pointcut. Could someone explain
> why this is the case?
>
> Thank you very much!
>
>
> Sunny
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>


Back to the top