Wednesday, February 19, 2014

How to find the Class/Object which invoke a method ?


Throwable t = new Throwable(); 
StackTraceElement[] elements = t.getStackTrace(); 
String calleeMethod = elements[0].getMethodName(); 
String callerMethodName = elements[1].getMethodName(); 
String callerClassName = elements[1].getClassName(); 

No comments:

Post a Comment