Possible Duplicate:
Getting the name of the current executing method
Is there a way in Java for a given method to know its own name? If so, how can it be referenced from inside the method?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can determine it by analyzing stack trace. But it may carry quite significant performance penalty. In AOP universe you can also have aspect that will determine method name and store it in some kind of context.
In stack trace method you would do something like
or (as suggested in comment)