Class StackTraces


  • public final class StackTraces
    extends Object
    Utilities for StackTraceElement & Co.
    Author:
    Michael Vorburger.ch, based on an idea by Stephen Kitt
    • Method Detail

      • getCallersCallerMethodName

        public static String getCallersCallerMethodName()
        Obtain the name of the method that is the method calling this one. This is just a short cut for getCallerMethodName(2), and is typically what one wants when using this from another utility.
        Returns:
        name of calling Java method
      • getCallerMethodName

        public static String getCallerMethodName​(int depth)
        Obtain the name of the method that is depth N way up the call stack from invoking this. So e.g. depth 0 is the name of the method calling this; but is rarely what one wants - as that is already known at that point. Typically depth 1 or 2 is what one intends.
        Parameters:
        depth - depth into call stack
        Returns:
        name of calling Java method