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?

Hi Eric,
 
Your explanation makes sense. Thank you very much!
 
Sunny
 
On 4/5/06, Eric Bodden <eric.bodden@xxxxxxxxxxxxxx> wrote:
This is because the AspectJ implementation in ajc makes (at least to my
best knowledge) no effort to resolve statically if a joinpoint lies
within the control flow of another joinpoint or not (or if so, this info
is apparently not exposed). Hence, there can only be a question mark
indicating that it might be in the control flow (even if at runtime it
never will).

Eric

> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx
> [mailto: aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Sunny
> Sent: Wednesday, April 05, 2006 4:51 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] Why is this call also matched?
>
> Andy,
>
> Thank you for your quick response. Yes, there is such a '?'
> against it. But why is it a conditional match (what does a
> conditionl match mean) and all other calls within the control
> flow also have such a question mark? Thanks  a lot!
>
> Sunny
>
>
> On 4/5/06, Andy Clement <andrew.clement@xxxxxxxxx> wrote:
>
>       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 <mailto:aspectj-users@xxxxxxxxxxx >
>       > https://dev.eclipse.org/mailman/listinfo/aspectj-users
>       >
>       >
>       >
>       _______________________________________________
>       aspectj-users mailing list
>       aspectj-users@xxxxxxxxxxx
>       https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top