Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Args pointcut

> What is the rationale behind matching null arguments? 

The idea is to avoid dynamic tests when static ones are sufficient,
rather than always requiring dynamic tests.  

This choice was made in part because it's easy to avoid null args:

  pointcut pc(Object o) : args(o) && if(null != o) && ...

(But that pattern has to be repeated in each such pointcut.)

> I get the compilation error "Uses more than one .. in args" 

AFAIK this is an implementation limitation having to do with 
ambiguity in patterns like args(.., String, ..), but I can't think
of an illustrative case offhand.

Wes

> ------------Original Message------------
> From: "Jon S. Baekken" <jbaekken@xxxxxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Wed, Mar-29-2006 3:24 PM
> Subject: [aspectj-users] Args pointcut
>
> Hi all,
> 
> The programming guide,
> http://www.eclipse.org/aspectj/doc/released/progguide/semantics-pointcuts.ht
> ml,
> 
> in describing the args pointcut, says:
> 
> "args(Type or Id, ...)
> Picks out each join point where the arguments are instances of the
> appropriate type (or type of the identifier if using that form). A null
> argument is matched iff the static type of the argument (declared 
> parameter
> type or field type) is the same as, or a subtype of, the specified args
> type."
> 
> What is the rationale behind matching null arguments? If I want to 
> match
> only actual instances of a class, not null values, is there any way I 
> can do
> that except collect the context and check for null in the advice?
> 
> Another args question:
> 
> >From the eclipse AspectJ book (p. 190) I get the impression that one 
> can
> write e.g. args(.., String, ..) to match an argument list where some
> argument is of type String with possibly other arguments before and 
> after,
> as long as I only specify type and not an identifier (as that could be
> ambiguous). However, I get the compilation error "Uses more than one .. 
> in
> args" when trying this. Does that mean only one .. is allowed even in 
> this
> case?
> 
> Jon
> 
> http://www.eecs.wsu.edu/~jbaekken/
> 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 



Back to the top