Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
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


<<winmail.dat>>


Back to the top