Comments: Get the name of currently executing method in Java

Here we are able to get the method name as a string.What if i want to get the currently exceuting method as a 'Method' object? so that i can use it to get the annotations associated with that method using getAnnotations().

Posted by PBR at March 9, 2006 11:11 PM

Thanks for comments PBR. Just from the top of my head, it'd be something like this:

Class params[] = {};
Class executingClass = Class.forName(elements[1].getClassName() );
Method executingMethod = executingClass.getDeclaredMethod(elements[1].getMethodName(), params);

Posted by alphageek at March 13, 2006 12:23 PM
Post a comment









Remember personal info?