Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] binding parts of the formals

Use * to signify any single argument, or .. for 0+ arguments.

From the programming guide...

-- ... state-based pointcuts

     args(Type or Id or "..", ...)

  [...] If it is the "*" wildcard, then any argument will match, 
  and if it is the special wildcard "..", then any number of 
  arguments will match, just like in signature patterns. 
  So the pointcut 

    args(int, .., String)

  will pick out all join points where the first argument is an int 
  and the last is a String. 

-- ... semantics section:

   Formal parameter lists can use the wildcard .. 
   to indicate zero or more arguments, so 

      execution(void m(..))

   picks out execution join points for void methods named m, 
   of any number of arguments

Wes

http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/progguide/apbs02.html#d0e4935


Charles Zhang wrote:
> 
> I found it is cumbersome to write a pointcut. Say a method has 5
> arguments. Then I need to define all 5 arguments as the formals of my
> pointcut if I'm only interested in one of them. Is this just because of my
> limited understanding?
> Example: class A{ public void Method(int f, int s, int t, int forth, int
> fifth) {...}};
> My after advice only tries to check if forth is bigger than fifth. Can I
> write:
> after(int forth, int fifth):args(forth,fifth)&&call(public A.Method(//rest
> of the signature))?
> 
> My knowledge tells me this won't work since the "forth" in advice doesn't
> correspond to the "forth" in method formals. Or does it?
> 
> Reason for asking this is that to be able to bind to a subcontext allows
> me to write more flexible virtual pointcuts.
> 
> Thanks.
> 
> Charles Zhang
> Graduate Student, Middleware Systems Research Group
> ECE, U. of Toronto (http://www.eecg.utoronto.ca/~czhang)
> " Yawn!!"
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top