Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Calling super from around advice

Hi,
I have this example code:


public class A {
    public String getName() { return "A"; }
}

public class B extends A {
    @Override
    public String getName() { return "B";}
}

public aspect Test {
    String around(): execution(public String A+.getName())
                     && !within(A) {
        String text = "advice";
        // text = super.getName();
        System.out.println(text);
        return proceed();
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new B().getName());
    }
}


If I run the main method I get this output:
    advice
    B

Now I hoped that by removing the comment from the line inside
the advice I would get:
    A
    B

But the code simply doesn't compile, with this message:
    The method getName() is undefined for the type Object

I found this message:
    https://dev.eclipse.org/mhonarc/lists/aspectj-users/msg12163.html
and it seems quite clearly to explain what's the issue with my example.
Since some time has passed I would like to ask if it's still not possible
to call the base method using super.

Regards,
Karl


Back to the top