Can't add execution pointcuts to external jar classes with AspectJ. Why?

陌路散爱 提交于 2019-12-11 02:18:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!