How do I access private fields with AspectJ?

Viewed 2490

I am investigating AspectJ and its many uses and have discovered mixins.

I can find many examples employing pure AspectJ .aj aspects however I need to use only @AspectJ annotations.

What I am trying to achieve is the following:-

I have a class that I cannot amend, it has a private class variable that I need to interrogate after a particular class method has completed execution. This class does not have getter or setter methods associated with this private class variable.

public final class CannotAmend {

    private Uri privateUri;

    public final void methodOne(){}

    public final void methodTwo(){}

    public final void methodThree(){

        privateUri = "something";   

    }
}

I require an aspect/mixin that can capture @After methodThree() and allow me to see the value set in privateUri.

Is this possible to achieve?

With @AspectJ annotations?

Where can I discover documentation/tutorial/examples of how to achieve this?

2 Answers
Related