Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-dev] type pattern "+" for declaring class

In understanding what + means, it is useful to compare:

execution(void Shape.set*(*))
execution(void Shape+.set*(*))

The first pointcut won't match execution of the Point.setX method. That's because
the signature of that method is 'void Point.setX(int)'. So only the second pointcut
matches it.

So that demonstrates part of the purpose of +. It's a way to say that you want to
talk about signatures of methods/fields declared under a specific type. So things
like Foo+.xxx* are a pretty common use of it, although there are other uses as well.


> -----Original Message-----
> From: aspectj-dev-admin@xxxxxxxxxxx 
> [mailto:aspectj-dev-admin@xxxxxxxxxxx] On Behalf Of Wes Isberg
> Sent: Thursday, February 10, 2005 8:34 AM
> To: aspectj-dev@xxxxxxxxxxx
> Subject: Re: [aspectj-dev] type pattern "+" for declaring class
> 
> > without "+" a type pattern specifies the exact type without 
> sub types. 
> 
> true
> 
> > I expected that the pointcut only 
> > matches at point (1). But it matches at point (1) and point (2)
> 
> Briefly:
> Matching both is correct, since both have that signature.
> An execution join point can have more than one signature.
> 
> More detail:
> Shape declares the join point signature moveBy(int, int),
> regardless of whether Point also declares it.  This is 
> specified in the programming guide semantics appendix 
> section on matching:
> ------------------------------
> When matching method-execution join points, if the execution 
> pointcut method signature specifies a declaring type, the 
> pointcut will only match methods declared in that type, or 
> methods that override methods declared in or inherited by that type
> ------------------------------
> 
> Put another way, the bytecode shadow for Point.moveBy(int,int)
> has more than one signature:
> 
>   void Shape.moveBy(int, int)
>   void Point.moveBy(int, int)
> 
> The AspectJ 5 developers notebook mentions the many
> signatures for an execution join point signature.
>   
> http://dev.eclipse.org/viewcvs/indextech.cgi/%7Echeckout%7E/as
> pectj-home/doc/ajdk15notebook/join-point-signatures.html#d0e351
> 
> This can sound funny, but it tracks what developers expect.
> Most developers want to advise any implementation of a given
> method.  Those who want to specify a particular lexical class
> can say
> 
>   within(Shape) && execution(void Shape.moveBy(int, int))
> 
> Hope this helps!
> 
> Wes
> 
> > ------------Original Message------------
> > From: Christoph Bockisch <bockisch@xxxxxxxxxxxxxxxxxxxxxxxxxx>
> > To: aspectj-dev@xxxxxxxxxxx
> > Date: Thu, Feb-10-2005 5:11 AM
> > Subject: [aspectj-dev] type pattern "+" for declaring class
> >
> > In each documentation about AspectJ that I found, it is stated that 
> > without "+" a type pattern specifies the exact type without 
> sub types. 
> > However this documentation is at least ambiguous for type 
> patterns used 
> > 
> > for the declaring class. Look at the following example:
> > 
> > class Shape {
> >    void moveBy(int x, int y) { (1) ... }
> > }
> > 
> > class Point extends Shape {
> >    void moveBy(int x, int y) { (2) ... }
> > }
> > 
> > Consider the pointcut: execution(* Shape.moveBy(int, int))
> > 
> > After reading the documentation, I expected that the pointcut only 
> > matches at point (1). But it matches at point (1) and point (2). I 
> > think, given that Java provides polymorphism, this behavior 
> is correct. 
> > 
> > However I think that this breaks the invariant (which is 
> stated in the 
> > documentation) that type patterns without "+" always 
> specify the exact 
> > class.
> > 
> > I would be happy to hear from you how the semantics for 
> type patterns 
> > with and without "+" in the declaring class are intended to be.
> > 
> > Thanks in advance,
> > Christoph Bockisch
> > 
> > 
> > -- 
> > Dipl.-Inform. Christoph Bockisch    
> bockisch@xxxxxxxxxxxxxxxxxxxxxxxxxx
> > Software Technology Group           Phone:  ++49 (0) 6151-16-3608
> > Darmstadt University of Technology  Fax:    ++49 (0) 6151-16-5410
> > Hochschulstr. 10, 64289 Darmstadt, Germany 
> > http://www.st.informatik.tu-darmstadt.de/
> > _______________________________________________
> > aspectj-dev mailing list
> > aspectj-dev@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/aspectj-dev
> > 
> 
> 
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-dev
> 




Back to the top