Community
Participate
Working Groups
Conside the following code snippets: Account.java: public class Account{ private int balance=0; public void credit(int amount){ balance=balance +amount; System.out.println("amount credited"); } } SavingsAccount.java: public class SavingsAccount extends Account{ public void credit(int amount){ super.credit(amount); } public static void main(String args[]){ SavingsAccount sa = new SavingsAccount(); sa.credit(5); } } AspectLoging.java: import Account; public aspect AspectLogging { pointcut credit(): call(void Account.credit(int)); before(): credit() { System.out.println("check balance"); } } After compiling these classes using ajc on command line, before advice gets weaved around the method call "sa.credit(5) in SavingsAccount.java, while no advice is weaved before call to super.credit(amount). Here is how code looks after de-compilation of SavingsAccount.class public class SavingsAccount extends Account { public SavingsAccount() { } public void credit(int amount) { super.credit(amount); } public static void main(String args[]) { SavingsAccount sa = new SavingsAccount(); AspectLogging.aspectOf().ajc$before$AspectLogging$6b(); sa.credit(5); } }
Thanks for the very clear report with a self-contained test. This makes it easy to understand your question. AspectJ defines call join points to be: When a method is called, not including super calls of non-static methods. see - http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj- home/doc/progguide/apb.html#joinPoints Your program is behaving exactly according to the language spec.