Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Call pointcut semantics for toString

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();
	}
}


Back to the top