Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] capturing implicit toString() function calls


Hi Ben,

Depending on what you are trying to do you may prefer to use 'execution' instead of 'call'.  For your example the pointcut would be:

execution (String HelloWorld.toString())

and would result in "jpt hit" being printed out twice.

Regards,

Sian




"Benjamin Mesing" <benjamin.mesing@xxxxxxxxxxxxxxx>
Sent by: aspectj-users-admin@xxxxxxxxxxx

11/11/2004 12:25

Please respond to
aspectj-users

To
aspectj-users@xxxxxxxxxxx
cc
Subject
[aspectj-users] capturing implicit toString() function calls





Hello,

I have stumbled over a problem. When specifying a pointcut, implicit
calls of toString functions will not be captured. Consider the following
example, wher "jpt hit" will be printed only once.
Is there anything I can do about it?

public class HelloWorld {

                public static void main(String[] args) {
                                 HelloWorld hw = new HelloWorld();
                                 // here occurs an explicit and an implicit call of
                                 // toString()
                                 System.out.println(hw.toString() + hw);
                }
                public String toString()
                {
                                 return "Hello World ";
                }
}

public aspect TestAspect
{
                before() : call (String HelloWorld.toString())
                {
                                 System.out.println("jpt hit");
                }
}

Greetings Ben
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top