Scott Hayward wrote:
Could you determine from the control flow context whether or not to
evaluate "toString()". Say, for example, you want to circumvent it when
"cflow (call (* Foo.bar(..))" is true? Perhaps, even "within" or
"withincode" could be used. Or, can you use an "if()" in the pointcut
definition to determine the appropriate action to take?
I could put wrap the toString method of expensive objects with around
advice and replace the expensive operation if I'm not debugging. But this
only works if the sole reason to evaluate the expensive toString() is for
debug logging and *nothing* else. So if the application uses the same
toString() method elsewhere, the solution cannot be used.
public pointcut insideToString() :
String around() : insideToString()
Have I missed another approach?