Bug 51167 - Aspect J compiler does not recognise the super keyword while weaving method call advice
Summary: Aspect J compiler does not recognise the super keyword while weaving method c...
Status: RESOLVED INVALID
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jim Hugunin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-04 10:39 EST by Manoj K. Gupta CLA
Modified: 2004-02-04 12:41 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Manoj K. Gupta CLA 2004-02-04 10:39:28 EST
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);
    }
}
Comment 1 Jim Hugunin CLA 2004-02-04 12:41:38 EST
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.