Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to get caller method name, little urgent.

You could use something like the following to get a stack trace
        Thread current = Thread.currentThread();
        StackTraceElement[] stack = current.getStackTrace();
        for ( StackTraceElement stackElement : stack )    {
            String className = stackElement.getClassName();
...
        }
You can use the className to match against the source location.
   



From: Andrew Eisenberg <andrew@xxxxxxxxxxxx>
To: aspectj-users@xxxxxxxxxxx
Sent: Wed, 9 June, 2010 16:29:47
Subject: Re: [aspectj-users] How to get caller method name, little urgent.

There is no direct way to get the name of the calling method using
AspectJ.  The best solution is to look at
thisJoinPointStaticPart.getSourceLocation() and then map the resulting
location back to a method in the original text.




Back to the top