无法使用AspectJ将执行切入点添加到外部jar类.为什么? [英] Can't add execution pointcuts to external jar classes with AspectJ. Why?

查看:223
本文介绍了无法使用AspectJ将执行切入点添加到外部jar类.为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试检测SWT的Shell.setText()何时执行时遇到了一些麻烦.

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:

据我所知,发生这种情况是因为AspectJ没有在其类路径或其他内容中检测到SWT库.

From my understanding, this happens because AspectJ is not detecting the SWT library in it's classpath or something.

理想情况下,我想使用加载时编织",因此我将以下Jar文件添加到Eclipse的LTW-Classpath中:

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

我在Hello World SWT项目的参考库"集中找到了

.

which I found in the set of "Referenced Libraries" in my Hello World SWT Project.

但是问题仍然存在,Eclipse(和我的小应用程序)都标记execution切入点不能应用于任何东西.

But the problem is still the same, both Eclipse (and my little application) mark the execution pointcut not be applied to anything.

有人可以指出原因吗?

推荐答案

有两个原因.

Eclipse的AspectJ插件不会识别超出项目范围的任何东西(在本例中为SWT),因此将我们的结论排除在上下文信息之外将无济于事.另外,尽管Shell继承了setText()方法,但它是在Decorations中定义的setText(),所以AspectJ与我所写的不匹配.

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.

那是原因.

这篇关于无法使用AspectJ将执行切入点添加到外部jar类.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆