Reputation: 115
I am trying to create an around advice here using LTW. The com.sample.core.Task is in a different library jar. when I try to compile, I get warning
"advice defined in com.aop.MyAspect has not been applied [Xlint:adviceDidNotMatch]
MyAspect.java:19"
Any ideas whats the problem ? Also when I run with the javaagent, the point cut is not called. Am I missing anything ?
@Aspect
public class MyAspect {
@Pointcut("call(* com.sample.core.Task.*(..))")
public void callcs() {
}
@Around("com.test.callcs()")
public Object myTrace(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println("hijacked method : " + joinPoint.getSignature().getName());
System.out.println("hijacked arguments : " + Arrays.toString(joinPoint.getArgs()));
Object retVal = null;
try {
retVal = joinPoint.proceed();
} finally {
//do nothing
}
return retVal;
}
}
Upvotes: 1
Views: 96
Reputation: 2560
For the load time weaving use case I don't expect the advice to apply when you compile it. With load time weaving the advice will apply when the system loads the types involved.
This means on compilation you will typically see an adviceDidNotMatch
. You can suppress it by adding an annotation to the advice:
@SuppressAjWarnings("adviceDidNotMatch")
Now if it isn't applying at load-time, that is different and it is unrelated to the warning there. As Hakan comments, you don't need to qualify your pointcut, it should be @Around("callcs()")
. With load time weaving I might turn on the showWeaveInfo
option in the aop.xml to see if the pointcut/advice is matching.
Upvotes: 1