Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] execution join points and overridden methods

Wes Isberg writes:
 > This has been the behavior since (at least) AspectJ 1.0.
 > 
 > In this code
 > 
 > > public class A1 { public void f() {} }
 > > public class A2 extends A1 { public void f() {} }
 > 
 > the method-signature 'void f()' is defined in A1 and 
 > overridden in A2.  So 
 > 
 >    execution(void A1.f())
 > 
 > will pick out any f() implemented in A1 or any subclass of A1.
 > We did it this way to satisfy the Liskov substitution principle, 
 > so advice on a method also works for any implementation of it.
 > If A2 did not extend A1, then the pointcut would not match.
 > 
 > To define a pointcut for lexical per-class behavior, use
 > && within(A1).

OK, thanks.  Actually, it looks like A1.f() only matches if there is
actually an f() defined in A1; otherwise you'd have to use A1+.f().
Is that right?  Is this specified somewhere in the language semantics
(or any other docs)?

--dougo@xxxxxxxxx


Back to the top