StackTrace is more than debuging

I’ve never think about what else StackTrace could do other than debuging, util I read this post.

public static String getCallingMethodInfo() {
final Throwable fakeException = new Throwable();
final StackTraceElement[] stackTrace = fakeException.getStackTrace();
if(stackTrace != null && stackTrace.length >= 2) {
StackTraceElement s = stackTrace[2];
if(s != null) {
return s.getClassName() + “.(” + s.getMethodName() +”):[“+ s.getLineNumber() + “] -:”; }
} return null;
}

Advertisements