Skip to main content

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

Hi Sanders,

This is just because the super you're calling is from the aspect's supertype, which is the type object in this case...

Em sex, 6 de out de 2017 às 13:37, Karl Sanders <karlsanders75@xxxxxxxxx> escreveu:
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
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users
--
...............................................................................................................................
Henrique Rebelo
http://www.cin.ufpe.br/~hemr
Centro de Informática
Universidade Federal de Pernambuco , Brazil

Back to the top