mardi 22 septembre 2015

Get caller class and method name

I am trying to get the caller class and method name inside a function in a Scala app. I am currently making use of the stack trace, but the performance has decreased. I am doing something like

stackTrace(CodeDepth).getClassName
stackTrace(CodeDepth).getMethodName

I have found the Java reflection to be a lot more faster, but i can only get the class name with

sun.reflect.Reflection.getCallerClass(CodeDepth).getName()

Is there a way to get the method name (and optionally the line number) via reflection? Maybe using Scala's reflection?

Thanks





Aucun commentaire:

Enregistrer un commentaire