Hi,

Advice ordering rules are discussed here (end of the page):
http://www.eclipse.org/aspectj/doc/released/progguide/semantics-advice.html
(declare precedence can't be used for ordering advice within an aspect)

This ordering will compile:
aspect Precedence {
    pointcut p1() : execution(String Preced.foo());
    pointcut p2() : execution(String Preced.foo());

    String around () : p1(){
        System.err.println("around in");
        proceed();
        System.err.println("around out");
        return "around";
    }

    before () : p1(){
        System.err.println("before");
    }
    after () : p2(){
        System.err.println("after");
    }
    //declare precedence: Precedence.p1, Precedence.p2;
}


cheers
Andy

On 11 February 2012 13:08, Dénes Németh <[email protected]> wrote:
> Hi
>
> The compiler reports that I have circular advice precedence.
> If either before/after/around is commented out it compiles.
>
> If we move after and p2 to a different aspect and define
> precedence between the two aspects it works.
>
> Is it possible to get this working without moving p2 to a different aspect.
>
> best wishes,
> D
>
> Again this is just an example to try out how aspectj works, so please do not
> try to make sense from it.
>
> package info.caforge.aspectj.model.advice;
> public class Preced {
>     public String foo(){
>         System.err.println("foo");
>         return "foor";
>     }
> }
>
> package info.caforge.aspectj.aspects;
> import info.caforge.aspectj.model.advice.Preced;
> public aspect Precedence {
>     pointcut p1() : execution(String Preced.foo());
>     pointcut p2() : execution(String Preced.foo());
>
>     before () : p1(){
>         System.err.println("before");
>     }
>     after () : p2(){
>         System.err.println("after");
>     }
>     String around () : p1(){
>         System.err.println("around in");
>         proceed();
>         System.err.println("around out");
>         return "around";
>     }
>
>     //declare precedence: Precedence.p1, Precedence.p2;
> }
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to