Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Execution pointcut semantics

After fine reading the programming guide I see that you're right. But in
explaining that example, the guide says:

execution(public void Middle.*())

picks out all method executions for public methods returning void and having
no arguments that are either declared in, or inherited by, Middle, EVEN IF
those methods are overridden in a subclass of Middle. [My emphasis]

Isn't this a too weak statement? As I interpret what the guide says above it
matches those method ONLY IF they are overridden in a subclass...?

Jon

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Wes Isberg
Sent: Friday, April 07, 2006 12:14 AM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Execution pointcut semantics


Hi -

fyi, Jon's question just came up last month:
  http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg05606.html

The semantics are stated in the semantics guide, as
discussed in the message above.

p() doesn't match in the first case because Class1 (Mid)
does not itself declare m().  In the second case, p() picks
out the implementation in Class2 (Bottom) (not Class0
(Top)) because Class2 (Bottom) overrides a method "declared
in or inherited by" Class1 (Mid).  (So the weird thing is
that even
though Class1(Mid) in the first case inherits the method implementation, it
is not ascribed the signature for purposes of pointcut matching -- which
means the refactoring of pulling a method up in the class hierarchy can
break a pointcut specifying the type of the declaring
class.)

But what does the programmer wants?

Jim Hugunin, eons ago, said that most programmers should
not use the type but instead should use target, e.g.,
 
not: call(void Class1.m())
but: call(void m()) && target(Class1)

He was talking about call, but it's true for execution as
well in situations like this.  (However, in the current implementation using
target() makes the pointcut not staticly determinable and hence unusable in
declare-error.)

hth - Wes

Overriding is indeed the issue, but 

On Fri, 7 Apr 2006 01:25:39 +0200
 "Thiago Bartolomei" <thiagobart@xxxxxxxxx> wrote:
> Hi,
> 
> I think this paper may help you:
> 
>
http://www.cs.iastate.edu/~leavens/FOAL/papers-2004/barzilay-etal.pdf
> 
> Basically, the difference is that call pointcuts
> semantics depend on the
> static types, whereas execution pointcuts depend on
> dynamic types. A more
> detailed explanation is in the paper (I read it a while
> ago). At least it
> was true for version 1.1.1, I haven't tested it with new versions...
> 
> Hope it helps,
> Thiago Bartolomei
> 
> On 4/7/06, Jon S. Baekken <jbaekken@xxxxxxxxxxxx> wrote:
> >
> > Yes, I've tried that, but it doesn't make me any wiser,
> as with the + I
> > get
> > a superset of what I get without it, and without it I'm
> already matching
> > more than I expected.
> >
> > Any AspectJ developers who know more on this?
> >
> > Jon
> >
> > -----Original Message-----
> > From: Ron DiFrango
> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of
> > Ron DiFrango
> > Sent: Thursday, April 06, 2006 12:32 PM
> > To: aspectj-users@xxxxxxxxxxx
> > Subject: RE: [aspectj-users] Execution pointcut
> semantics
> >
> >
> > Jon,
> >
> > I am not sure what exact matching rules are coming into
> play, but did you
> > try something like the following:
> >
> > pointcut p() : execution(public void Class0+.m());
> >
> >
> > This should pickup the execution of any call to this
> method in any object
> > in
> > Class0's heirarchy.
> >
> > I think by matching, at the Class1 level even though it
> is inherit limits
> > it
> > to the Class1.  One of hte aspectj developers would be
> able to give a
> > better
> > explanation than I.
> >
> > Ron
> >
> >   _____
> >
> > From: aspectj-users-bounces@xxxxxxxxxxx on behalf of
> Jon S. Baekken
> > Sent: Thu 4/6/2006 3:07 PM
> > To: aspectj-users@xxxxxxxxxxx
> > Subject: [aspectj-users] Execution pointcut semantics
> >
> >
> >
> > Folks,
> >
> > I wondered if somebody could explain the semantics of
> the execution
> > pointcut
> > in the context of inheritance. Consider the following
> example.
> >
> > public class Class0 {
> >         public void m() {
> >                 System.out.println("m");
> >         }
> > }
> >
> > public class Class1 extends Class0 {
> > }
> >
> > public class Class2 extends Class1 {
> > }
> >
> > public class Client {
> >         public static void main(String[] args) {
> >                 Class2 c = new Class2();
> >                 c.m();
> >         }
> > }
> >
> > public aspect A {
> >         pointcut p() : execution(public void
> Class1.m());
> >         before() : p() {
> >                 System.out.println(thisJoinPoint);
> >         }
> > }
> >
> > When running this example, p() does not match the
> execution of c.m().
> > Notice
> > that Class1 is the class specified in the pointcut, and
> that m() is not
> > declared in Class1. However, Class1 inherits m() from
> Class0, and so does
> > Class2. A call pointcut would match in this situation,
> so there is
> > obviously
> > a difference in the semantics of the two.
> >
> > What confuses me though, is that if we add m() to
> Class2:
> >
> > public class Class2 extends Class1 {
> >         public void m() {
> >                 System.out.println("m");
> >         }
> > }
> >
> > The pointcut p() matches. But this happens only if both
> Class0 and Class2
> > declares m(), not just one of them. Why is this, and
> what is the matching
> > rule coming into play here? Is it overriding that
> somehow is the key?
> >
> > Jon
> >
> > http://www.eecs.wsu.edu/~jbaekken/
> >
> >
> > _______________________________________________
> > 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