Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Bizarre behavior with args pointcut

this(), target(), and args() always (act as if they) do a dynamic instance-of check on the object. The semantics are the same whether the object is bound to a variable or not. (And as per
instanceof, a null object will not match.)

More to the point for your code, args(Foo) will only exclude any
method execution with n!=1 arguments, so

   ... && args(double) && ...

will never match

   void boolean transfer(Account target, double amount) { .. }

which has n=2 arguments.

Wes


Antti Karanta wrote:
On Wednesday 31 March 2004 15:57, George Harley1 wrote:


 Now I would assume that both pieces of before advice in the above
aspect match the same join points as the only difference is that the
first collects context whereas the latter does not.

I'm afraid that is a bad assumption. Keep in mind that "args" is not just
for grabbing context, it is a primitive pointcut that can be used to pick
out join points such as method and constructor executions or exception
handlers where there is a related argument or arguments.


Ok. I was (erroneusly) assuming it (the args() pointcut) is used either to collect context or to pick join points, but not both at the same time. This is the case with this() and target() pointcuts - if you provide a type name, they pick join points and if you provide an id they collect context. Or am I wrong here, too?





Back to the top