Hello Mohan, You are right about using the 'call' pointcut and my guess is, if 'call' is used, one would not need the 'withincode' part. However, as advised in AspectJ docs, it is better to have a 'within' pointcut as it will be faster and have a smaller footprint than just a 'call' pointcut, especially in scenarios like load time weaving.
So I always preferred a combination of 'within' and 'execution' pointcuts to match my method calls but I can't seem to use them for inherited methods for some reason. Any ideas/thoughts? Thanks -Arvind Mohan Radhakrishnan wrote: > > Hi Ashank, > > Still guessing but based on what I understand this pointcut shows the > eclipse marker > > at this line - > b.m(); // Want to catch this inherited method only. > > pointcut p() : call(* B.*()) && !withincode(* A+.m()); > > Thanks, > Mohan > > On Thu, Apr 29, 2010 at 6:03 PM, Ashank <[email protected]> > wrote: >> >> Hello Mohan, >> >> Thanks for the reply. I wasn't looking to capture calls to overridden >> methods. Going by your example, >> >> public class A { >> public void m(){ >> System.out.println( "Test A" ); >> } >> } >> >> public class B extends A { >> >> } >> >> class C { >> public void methodC() { >> B b = new B(); >> b.m(); // Want to catch this inherited method only. >> } >> } >> >> To reiterate, Class B does not override method m. It simply inherits it. >> I >> wish to catch calls to b.m() where b is an instance of class B. thanks >> >> -Arvind >> >> >> Mohan Radhakrishnan wrote: >>> >>> Hi Ashank, >>> >>> Is this pointcut what you are looking for ? >>> >>> pointcut p() : execution(* B.m()); >>> >>> public class A { >>> >>> public void m(){ >>> System.out.println( "Test A" ); >>> } >>> } >>> >>> public class B extends A { >>> >>> public void m(){ >>> System.out.println( "Test B" ); >>> } >>> >>> } >>> >>> Thanks, >>> Mohan >>> >>> On Thu, Apr 29, 2010 at 3:57 PM, Ashank <[email protected]> >>> wrote: >>>> >>>> Hello All, >>>> >>>> I have a simple question. The same question was asked in this post but >>>> it >>>> seems to have gone unaddressed as far as my understanding goes. >>>> http://old.nabble.com/Weaving-inherited-methods-to15405848.html#a15405848 >>>> >>>> Anyway, the question is, I want a pointcut to match method >>>> calls/executions >>>> of inherited methods in a subclass. For instance. >>>> >>>> Class A{ >>>> public void methodA() {} >>>> } >>>> >>>> Class B extends A() { >>>> } >>>> >>>> Class C() { >>>> B b = new B(); >>>> b.methodA(); // Want to catch this. >>>> } >>>> >>>> As mentioned, I want to match the statement ending with the comment. >>>> Please help me out with the pointcut. Thank you very much >>>> >>>> -- >>>> View this message in context: >>>> http://old.nabble.com/pointcut-to-match-inherited-methods-tp28398859p28398859.html >>>> Sent from the AspectJ - users mailing list archive at Nabble.com. >>>> >>>> _______________________________________________ >>>> aspectj-users mailing list >>>> [email protected] >>>> https://dev.eclipse.org/mailman/listinfo/aspectj-users >>>> >>> _______________________________________________ >>> aspectj-users mailing list >>> [email protected] >>> https://dev.eclipse.org/mailman/listinfo/aspectj-users >>> >>> >> >> -- >> View this message in context: >> http://old.nabble.com/pointcut-to-match-inherited-methods-tp28398859p28399940.html >> Sent from the AspectJ - users mailing list archive at Nabble.com. >> >> _______________________________________________ >> aspectj-users mailing list >> [email protected] >> https://dev.eclipse.org/mailman/listinfo/aspectj-users >> > _______________________________________________ > aspectj-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > -- View this message in context: http://old.nabble.com/pointcut-to-match-inherited-methods-tp28398859p28408493.html Sent from the AspectJ - users mailing list archive at Nabble.com. _______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
