[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Re: Call pointcut semantics for toString
|
For the first code (call), see the warnings below from the
compiler.
For the execution case, a class also "has" the signatures
it inherits for the purpose of matching; i.e., T has R'
m(String s) because it extends S and m(String) is visible.
To restrict matching to lexically-enclosing, use
within(..).
Wes
C:\home\wes\dev\tools\aspectj-1.5\bin\ToStringAndCallPointcut.java:15
[warning] does not match because declaring type is
java.lang.Object, if match desired use
target(ToStringAndCallPointcut$Foo)
[Xlint:unmatchedSuperTypeInCall]
pointcut tostringCall(): call(String Foo.toString());
^^^^^^^^^^^
[Xlint:unmatchedSuperTypeInCall]
see also:
C:\home\wes\dev\tools\aspectj-1.5\bin\ToStringAndCallPointcut.java:27::0
C:\home\wes\dev\tools\aspectj-1.5\bin\ToStringAndCallPointcut.java:15
[warning] does not match because declaring type is
java.lang.Object, if match desired use
target(ToStringAndCallPointcut$Foo)
[Xlint:unmatchedSuperTypeInCall]
pointcut tostringCall(): call(String Foo.toString());
^^^^^^^^^^^
[Xlint:unmatchedSuperTypeInCall]
see also:
C:\home\wes\dev\tools\aspectj-1.5\bin\ToStringAndCallPointcut.java:24::0
C:\home\wes\dev\tools\aspectj-1.5\bin\ToStringAndCallPointcut.java:16
[warning] does not match because declaring type is
java.lang.Object, if match desired use
target(ToStringAndCallPointcut$SubFoo)
[Xlint:unmatchedSuperTypeInCall]
pointcut tostringCall2():call(String SubFoo.toString());
^^^^^^^^^^^^^^
[Xlint:unmatchedSuperTypeInCall]
see also:
C:\home\wes\dev\tools\aspectj-1.5\bin\ToStringAndCallPointcut.java:24::0
C:\home\wes\dev\tools\aspectj-1.5\bin\ToStringAndCallPointcut.java:16
[warning] does not match because declaring type is
java.lang.Object, if match desired use
target(ToStringAndCallPointcut$SubFoo)
[Xlint:unmatchedSuperTypeInCall]
pointcut tostringCall2():call(String SubFoo.toString());
^^^^^^^^^^^^^^
[Xlint:unmatchedSuperTypeInCall]
see also:
C:\home\wes\dev\tools\aspectj-1.5\bin\ToStringAndCallPointcut.java:27::0
On Sat, 30 Dec 2006 22:45:41 -0800
"Mr. Patient" <mr.patient@xxxxxxxxx> wrote:
> 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();
> > }
> > }
> >
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users