[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Capture args with withincode and call

You cannot do this with withincode because withincode is a pure
lexical pointcut. It defines a region of code, no event, and a region
of code can expose no arguments. But you can use cflow(call(*
C.method1(A, B)) && args (c,d)). Note that the args is *within* the
brackets of the cflow pointcut.


On 2/13/07, bora.erbas <bora.erbas@xxxxxxxxx> wrote:

I felt like I should add some more details. This is the problem I need to solve: In a specific (private static) method call of a class (e.g. X.m1) I need to list all the calls which has a target class of some type (e.g. Y). But at the same time I need to capture the arguments to X.m1(arg1, arg2) as well. But when capturing the arguments for the X.m1 the captured calls to class Y are also confined to the calls with the same type/order of the arguments of X.m1. So I want to list all calls to the methods of class Y with any arguments. Is this possible using AspectJ constructs?

pointcut withinPrivateBaseMethod(ArgClass a, ArgClass b) :
   withincode(private static Z X.m1(ArgClass, ArgClass)) &&
   args(a, b);

pointcut allCallsToYFromPrivateBaseMethod(ArgClass a, ArgClass b) :
   withinPrivateBaseMethod(a, b) &&
   call(* Y.*(..));

So this has the problem I mentioned above. Any ideas? Cheers. -- View this message in context: http://www.nabble.com/Capture-args-with-withincode-and-call-tf3220219.html#a8943569 Sent from the AspectJ - users mailing list archive at Nabble.com.

aspectj-users mailing list

Eric Bodden
Sable Research Group
McGill University, Montréal, Canada