I am using aspectj for analysis of my program. Currently my aspect looks like:
@Aspect
public class InvokeAspect {
@Before("anyCall(t, s)")
public void processInvocation(JoinPoint point, JoinPoint.EnclosingStaticPart enclosingStatic, Object t, Object s){
System.out.println("***");
System.out.println("Invoker: " + s.toString());
System.out.println("Invoker: " + enclosingStatic.getSignature().toLongString());
System.out.println("Invoked object: " + t.toString());
System.out.println("Invoked: " + point.getSignature().toLongString());
System.out.println("");
System.out.println("***");
}
@Pointcut("call(* *(..)) && !within(cz.cvut.kbss.odra..*) && target(t) && this(s)")
public void anyCall(Object t, Object s){}
}
Everything works as expected, but is there any way to convice aspectj to use the aspect, even if this or source do not exist? (static method call or call from static method). Or do I have to write 3 aspects?
Thanks.
Yes, I think you will have to write three pointcuts – one along the lines of what you have, second a call from a static method and the third for a call from an object to a static method, probably three different advices also, delegating to the
processInvocationmethod above