Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] infinite recursion with this()

Here:

before(): execution(* *(..)) {
  System.out.println("abc");
}

There are these joinpoints:

Join point 'adviceexecution(void X.ajc$before$X$1$3444dde4())'
Join point 'field-get(java.io.PrintStream java.lang.System.out)'
Join point 'method-call(void java.io.PrintStream.println(java.lang.String))'

If you use !adviceexecution() then you only deselect adviceexecution,
you will still match field-get and method-call.  If you use
!cflow(adviceexecution()) you will deselect them all - and any others
downstream (in PrintStream.println).  Because the
field-get/method-call and anything that happens because of them are in
the control flow of the adviceexecution.

cheers
Andy

On 4 January 2012 03:19, Dénes Németh <mr.nemeth.denes@xxxxxxxxx> wrote:
> Hi
>
> What is the difference between !adviceexecution() and !cflow(adviceexecution())
>
> Best wishes,
> Denes
>
> ps. I know that these examples are look "insane", I am just learning AspectJ an
> trying to test each functionality by a dummy example.
>
> 2012/1/3 Andy Clement <andrew.clement@xxxxxxxxx>:
>> I wouldn't recommend a pointcut that has no 'kind' to it (you are
>> going to hit a lot of joinpoints), but maybe it is what you meant...
>>
>> Anyway, you probably need to use cflow().
>>
>> && !within(Context) && !withincode(Simple.new()) && !cflow(adviceexecution());
>>
>> cheers,
>> Andy
>>
>> On 2 January 2012 06:04, Dénes Németh <mr.nemeth.denes@xxxxxxxxx> wrote:
>>> Hi
>>>
>>> Can someone help me to avoid infinite recursion in the aspect.
>>> I tried to add "&& !within(Context) && !withincode(Simple.new()) &&
>>> !adviceexecution()" to
>>> the pointcut, it it did not help.
>>>
>>> public class Simple {
>>>        public void foo1(){ }
>>> }
>>>
>>> public aspect Context {
>>>        before (Simple s) : this(s) {
>>>                System.out.println("p4");
>>>                s.foo1();
>>>        }
>>> }
>>>
>>> Thanks Denes
>>> _______________________________________________
>>> 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
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top