Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] what for args pointcut designator?

There was a period of time when AspectJ didn't have args. Instead, as you
suggest, the syntax was like:

             before(int x): execution(void C.foo(x))              {...}
instead of
             before(int x): execution(void C.foo(int)) && args(x) {...}
 

The change was made for a variety of reasons (note that memory is not
guaranteed to be perfect here):

 - one is that its difficult to get both 'this' and 'target' to fit into
   the positional syntax.  Target is easy, you can put it in the target
   class position (i.e. 'C'). But then where does this go? Except that
   maybe the 'C' position should actually be this for execution and
   target for call? There was room for confusion there.

 - a second was the subtly different semantics of matching between
   this, target, args and execution. We felt that providing both
   semantics was useful, and so introduced two forms for them

 - a third was a desire to delineate the pointcuts that the programmer
   can be sure are tested statically from those that might require a
   dynamic test. One benefit of that is that it makes the rule for
   using the special declarative error and warning advice simple, the
   expanded pointcut cannot use this, target, args, cflow or cflowbelow.



> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx 
> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Kamil 
> Dworakowski
> Sent: Sunday, September 03, 2006 2:42 AM
> To: wes@xxxxxxxxxxxxxx; aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] what for args pointcut designator?
> 
> When I read your response I have an impression that you have not read 
> the message. You respond to the question in the topic. Why 
> would I write 
> the body if not for you to read it? The body clarifies the meaning of 
> the question in the topic.
> 
> In the message I asked for the most important reason for 
> having args in 
> the language. I mentioned that I don't view the type bounding as an 
> important reason. I expect something more.
> 
> Luntain
> 
> Wes wrote:
> > this(), args(), and target() allow you to bind variables in 
> a type-safe way and to do runtime tests.
> >
> > E.g., for 
> >
> >     void put(Object key, Object value)
> >
> > you might want to pick out only join points with keys of type foo:
> >
> >     execution(void put(Object, Object)) && args(Foo, Object)
> >
> > If you were to do something with it (e.g., put Foo in a 
> wrapper with a better hashcode), then you'd want to bind the 
> variable.  Without binding (i.e., using reflection) you only 
> get Object, which makes for a lot of runtime ClassCastException.
> >
> > Wes
> >
> >   
> >> What is the most important reason for having args pointcut 
> designator 
> >> in 
> >> aspectj language? I would prefer exposing args in 
> signature like this
> >>
> >> aPointcut(int i): execution( * *.method( int i ) );
> >>
> >> The one thing that comes to my mind is
> >>
> >> execution( * *.meth( Object) ) && args( String )
> >>
> >> That is, however, not an everyday use and can be achieved by type 
> >> checking in the advice body.
> >>
> >> The reason I go through it is because I want to implement 
> aspectj like 
> >> aop. I mean a reasonable subset. I wonder if I could just 
> forget about 
> >> args.
> >>
> >> Luntain
> >> _______________________________________________
> >> aspectj-users mailing list
> >> aspectj-users@xxxxxxxxxxx
> >> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >>
> >>     
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >   
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> 




Back to the top