Community
Participate
Working Groups
I would like to be able to control the precedence of advice from an abstract base aspect in a concrete derived aspect, i.e., to change so that the concrete aspect's advice can run with lower precedence. Unfortunately, declare precedence only defines precedence with respect to concrete aspects (*). So you can't order advice to make this example program print AB: abstract aspect Base { abstract protected pointcut run(); after() returning : run() { System.out.print("A"); } } public aspect Derived extends Base { declare precedence: Base, (!Base && Base+); // no-op! public static void main(String argz[]) { } protected pointcut run() : execution(* main(..)); after() returning : run() { System.out.print("B"); } } My work-around is to use a static inner aspect that has the advice. This works for singleton aspects but is trickier for perXXX aspects. The real use case I have for this is to allow capturing additional data in a concrete monitoring subaspect's after advice before the abstract base aspect's after advice runs... In my case I don't want to use a template method because the common base aspect advice typically advises case1()||case2()||case3() and I want to run different after advice on case1(), case2(), and case3() before the common base aspect's generic advice, after binding additional context data (often this or args). Because I need to advise additional data, I can't extract a method in the base aspect and advise that. (*) My memory was rusty so I had to reread the programmer's guide. It would also be helpful if it produced a warning if you try to use declare precedence with an abstract aspect as a specific type.
unsetting the target field which is currently set for something already released