Recently I was investigating issue in our internal software , where I needed to get the current executing method name ( similar to c++ __FUNCTION___ ) and caller name.
It is possible get this information using getting access to stack trace in java. see the example below.
public class DebugInfo { |
| Java2html |
Usage:
public class Foo
{
public void bar(){// print the current method nameSystem.out.println( DebugInfo.myMethodName());// print the current calling method nameSystem.out.println( DebugInfo.getCallingMethodName());}
public static void main(String [] args ){Foo f = new Foo();f.bar();}
}