Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Caller instance

Suggest using the this() pcd:

Something like:

pointcut tracedCall(Object caller) : call(* *.*) && this(caller);

before(Object caller) : tracedCall(caller)
{
  // Do tracing before
System.out.println("Before trace, caller:" + caller);
}

after(Object caller) : tracedCall(caller)
{
  // Do tracing after
System.out.println("After trace, caller: " + caller);
}

Worth bearing in mind though that the previous pcd won't catch calls made from within static code blocks as there is no 'caller' as such at those join points and so nothing can match to the this() pcd. You can also include static calls where there is no this(), there's an example available in the accompanying source code at www.aspectjcookbook.com.

Hope this helps,

Russ

On 30 Nov 2004, at 18:14, Rafael Cepeda wrote:

Hi,

I'm working on a tracer program.
I know that I can get the callee (the object called) memory address
with getTarget, but how can I get the caller memory address?

Thanks,
Rafael CepĂȘda.

---------------------------------------------------------------
Computer Science Department
Federal University of Rio de Janeiro (UFRJ)
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-dev



Back to the top