Hi Wim,
Creating thisJoinPoint does require some
overhead: I think it’s only “expensive” if you do it a lot,
i.e., the actual cost per invocation is quite low. However, using args is clearly
more efficient and is preferable when you know the number of arguments. In many
cases you can even use args to match some cases where there are many arguments,
e.g., see http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg05982.html
for an example of this.
From:
aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Wim Deblauwe
Sent: Sunday, September 10, 2006
1:59 AM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users]
Question on args()
And is there any
difference on performance (using LTW)? I've read that constructing
thisJoinPoint is an expensive operation. Would using args() avoid this?
regards,
Wim
2006/9/8, Adrian Colyer < adrian.colyer@xxxxxxxxx>:
Yes, both examples will do the same thing here.
On 8 Sep 2006, at 15:24, Wim Deblauwe wrote:
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
_______________________________________________
aspectj-users mailing list
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users