Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Infinite advice call problem


I have the problem of infinite advice calls as described in FAQ item 	
11.1; running the program below crashes the VM with a memory fault 
(hence the class name).

According to the FAQ answer I could use after returning instead of 
plain after to handle exceptions different from normal method 
execution, or I could use !within(theAspect). Neither works for me, 
i.e. neither changes the program behaviour.

I understand that the after returning does not have any impact on the 
sample code as nothing is thrown. 
But why doesnt !within work? Is this a problem due to indirect 

What am I missing? 

Thanks in advance,


class MemoryFault {
    public static void main(String args[]) {
        MemoryFault mf = new MemoryFault();

    public Object clone() {
        return new MemoryFault();

aspect Constructor {
    after(MemoryFault mf):
        target(mf) &&
        execution( &&
        !within(Constructor) {
        // System.out.println("In after() advice");
        MemoryFault other = (MemoryFault) mf.clone();

Back to the top