为什么我收到“建议尚未应用”警告?
为什么以下代码:
pointcut callsToList() : call(* List.*(..));
before(List l) : callsToList() && target(l) {
System.out.println("cool");
}
会生成以下警告:
建议定义于 org.eclipse.ajdt.examples.ListAdvice 尚未应用 [Xlint:adviceDidNotMatch]
我正在 Eclipse 中使用。我安装了eclipsespectj插件,当然我的项目是aspectj项目。
编辑:此外,我从 ajdt 插件提供的一个工作示例开始:
pointcut callsToBeginTask() : call(void IProgressMonitor.beginTask(..));
before() : callsToBeginTask() {
System.out.println("cool");
};
除了这个示例在没有警告的情况下工作这一事实之外,我看不出任何区别......
Why does the following code:
pointcut callsToList() : call(* List.*(..));
before(List l) : callsToList() && target(l) {
System.out.println("cool");
}
generates the following warning:
advice defined in
org.eclipse.ajdt.examples.ListAdvice
has not been applied
[Xlint:adviceDidNotMatch]
I am working with in Eclipse. I installed eclipse aspectj plugin and of course my project is an aspectj project.
Edit: Moreover I started from a working example provided by ajdt plugin:
pointcut callsToBeginTask() : call(void IProgressMonitor.beginTask(..));
before() : callsToBeginTask() {
System.out.println("cool");
};
I can't see any difference except the fact that this example works without warning ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您希望 AspectJ 在 OSGi 环境中工作时,您必须使用 Equinox Aspects(又名 Equinox Weaving)。这是一种与 osgi 类加载器一起使用的加载时间编织形式。
本教程有点过时,但应该可以帮助您入门:
http://www.eclipse.org/equinox/incubator/aspects/equinox-aspects-quick-start.php
当您的各个方面都针对同一个项目时,您不需要 Equinox Aspects。常规的编译时编织就可以了,但是要跨越多个捆绑包/插件,这将不起作用。
When you want AspectJ to work in an OSGi environment, you must use Equinox Aspects (aka Equinox Weaving). This is a form of Load time weaving that works with osgi classloaders.
This tutorial is a little out of date, but should get you started:
http://www.eclipse.org/equinox/incubator/aspects/equinox-aspects-quick-start.php
When your aspects are all targeted within the same project, you do not need Equinox Aspects. Regular compile time weaving will do, but to span multiple bundles/plugins, this will not work.
我的猜测是,因为 List 是一个接口,并且您想要匹配对所有扩展类的调用,您必须使用以下语法:
更新:好的,我让它与此版本一起使用:
这也有效:
My guess is that because List is an interface and you want to match calls to all extending Classes you would have to use this syntax:
Update: OK, I got it to work with this version:
This also works: