Here are two snippets:
import sun.reflect.Reflection;
String callerName = Reflection.getCallerClass(2).getName();
I found the answer right after I typed the earlier question in http://www.javaspecialists.eu/archive/Issue087.html fyi.
Maybe someone else will find it useful, thanks.
how do I get the class name of the calling class while in the called class's method?
I'm seeking to put this name in a new log message based upon some validation results that will be performed in the called method. I cannot change the interface easily so I am trying to figure out how to...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.