问题
I am having some trouble trying to detect when SWT's Shell.setText() is being executed.
I created two simple pointcuts, and while one works, the other does not:
From my understanding, this happens because AspectJ is not detecting the SWT library in it's classpath or something.
Ideally I'd want to use Load-Time-Weaving, so I added to Eclipse's LTW-Classpath the following Jar file:
org.eclipse.swt.win32.win32.x86_64_3.102.0.v20130311-2025.jar
which I found in the set of "Referenced Libraries" in my Hello World SWT Project.
But the problem is still the same, both Eclipse (and my little application) mark the execution pointcut not be applied to anything.
Can anyone point me out the reason?
回答1:
There are two reasons.
Eclipse's AspectJ Plugin won't identify anything that applies outside the scope of the project (in this case, SWT), so taking our conclusions out of the context info would get us nowhere. Also, although Shell inherits a setText() method, it's setText() is defined in Decorations, so AspectJ won't match it as I have written.
Those were the reasons.
来源:https://stackoverflow.com/questions/16093637/cant-add-execution-pointcuts-to-external-jar-classes-with-aspectj-why