Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Is this possible with AspectJ (or AOP in general)?

Paulo Alexandre Corigo Zenida wrote:
Hello Ernii,

As far as I know, it is not possible for AspectJ to do weaving in JDK classes. From what you have described, I suppose what you are defining in your pointcut is something like:

public pointcut myPointcut() :
    execution(public void java.awt.Component+.paint(java.awt.Graphics));

before() :
    myPointcut() {
    ...
}

The previous will try to do weaving on the callee code, i.e., on the Swing class that, if belongs to the JDK, will not be weaved. You will only have success for your own classes extending Swing ones or calls to Swing methods that occur within your own project.

I hope this helps. Regards,

Paulo Zenida


If you use "call" instead of "execution" in the pointcut definition, AspectJ will advise all join points in your code that call the Swing methods you care about. AspectJ can access your code, while licensing restrictions prevent you from advising the JDK library, as another respondent mentioned.

So, you still won't affect calls from within Swing to itself, but hopefully you only really need to advise Swing calls from your own code.

Dean


--
Dean Wampler, Ph.D.
dean at aspectprogramming.com
objectmentor.com <http://www.objectmentor.com>
aspectprogramming.com <http://www.aspectprogramming.com>
contract4j.org <http://www.contract4j.org>

I want my tombstone to say:
Unknown Application Error in Dean Wampler.exe.
Application Terminated.
Okay 	Cancel



Back to the top