Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Question on args()

Hi,

reading through http://www.eclipse.org/aspectj/doc/released/progguide/language-joinPoints.html#pointcut-parameters , I can understand the difference between target() and args() pointcuts. Is it correct to say that in stead of using this:

pointcut setter(Point p, int newval): target(p) &&
                                      args(newval) &&
                                      (call(void setX(int)) ||
                                       call(void setY(int)));

I use this:

pointcut setter(Point p): target(p) &&
                                      (call(void setX(int)) ||
                                       call(void setY(int)));

and then I can also get the 'newval' by using (in the corresponding advice):

int newval = (Integer)thisJoinPoint.getArgs()[0];

I know this is not so nice, but I just want to know if they are the same. Because now I'm always using the getArgs() method, but it would be better to use the args() pointcut then (if my assumpions are right)

regards,

Wim

Back to the top