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 ...
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.
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:
pointcut callsToList() : call(* List+.*(..));
Update: OK, I got it to work with this version:
pointcut callsToList(List list) :
call(* java.util.List+.*(..)) && target(list);
Object around(List l) : callsToList(l) {
// code here
}
This also works:
before(List l) : callsToList(l) {
// code here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With