[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Re: Call pointcut semantics for toString
|
Hi again,
This is a follow-up question about the semantics of execution, as well as
the join point matching mechanism in AspectJ.
According to the join point signature section of the developer's notebook:
http://www.eclipse.org/aspectj/doc/released/adk15notebook/join-point-signatures.html#method-execution-join-point-signatures,
for the attached example, the signatures of the join point arising from the
execution of the m method in class U would be:
R' U.m(String)
R' S.m(String)
R P.m(String)
R Q.m(String)
Notice that there is no signature involving T, but why this join point
is matched
by pointcut: execution(* T.m(String))? The signature pattern needs to exactly
match at least one signature of the join point, right?
Thanks again!
David
======= the code ===================
interface Q {
R m(String s);
}
class P implements Q {
R m(String s) {...}
}
class S extends P {
R' m(String s) {...}
}
class T extends S { }
class U extends T {
R' m(String s) {...}
}
On 12/30/06, Mr. Patient <mr.patient@xxxxxxxxx> wrote:
Hi All,
Please see the following code: if the toString method is NOT declared in
SuperFoo class, both pointcut will match nothing -- I understand that is
because both toString calls (in the main method) have the signature
"String Object.toString()" only.
However, when a toString method is declared in class SuperFoo, both
pointcuts will match some calls! This seems contradictory to the previous
one, since in this case, both toString calls have signatures:
"String Object.toString()" and "String SuperFoo.toString()". -- Still,
none of them
could be matched by any of those two pointcuts.
Is this a bug or there is something I misunderstood?
I'm using AJDT 1.4.1. Thanks a lot!
Thanks,
David
===================================
public aspect ToStringAndCallPointcut {
static class SuperFoo {
// public String toString() {
// return "sub foo";
// }
}
static class Foo extends SuperFoo {
}
static class SubFoo extends Foo {
}
static aspect Aspect {
pointcut tostringCall(): call(String Foo.toString());
pointcut tostringCall2():call(String SubFoo.toString());
before():tostringCall(){}
before():tostringCall2(){}
}
public static void main(String[] args) {
Foo foo = new SubFoo();
System.out.println(foo.toString());
SubFoo sf = (SubFoo)foo;
sf.toString();
}
}