Hi,
We have a requirement where we would like to retrieve Calling Class name(with Package structure)and use it inside the called class.
I have searched and found out two ways ...
1) String callingClassName = new Throwable().fillInStackTrace().getStackTrace()[1].getClassName();
and
2) String callingClassName =
sun.reflect.Reflection.getCallerClass(2).getName();
but these two approaches pose performance issue as both take arround 15-16 millisecond to execute, which is not acceptable in large application.
Any other suggestions or enhancement to above two approach would be highly appreciated.