Class StackWalkerUtil


  • public class StackWalkerUtil
    extends Object
    Utils class warpping the Stackwalker API functionality in easy to use method calls. Can be used to easily collect information about the current execution stack (method names, classes etc.)
    Author:
    markr
    • Constructor Detail

      • StackWalkerUtil

        public StackWalkerUtil()
    • Method Detail

      • getStackFramesAsList

        public static List<StackWalker.StackFrame> getStackFramesAsList()
        collect the current stack frames as a list
        Returns:
        stack frame list
      • getFirstStackFrame

        public static Optional<StackWalker.StackFrame> getFirstStackFrame()
        Collect the first available stack frame if it exists
        Returns:
        first stack frame as an optional
      • getStackFrameWithOffset

        public static StackWalker.StackFrame getStackFrameWithOffset​(int skipOffset)
        Skip any number of stack frames and return the stream at this offset point
        Parameters:
        skipOffset - offset with which to start
        Returns:
        stack frame at offset point, null if not present
      • getCallingMethodName

        public static String getCallingMethodName()
        Collect the method name of the method that is the invoker of calling this method
        Returns:
        calling method name, "unknown" if unknown
      • getCallingClassName

        public static String getCallingClassName()
        Collect the class name of the method that is the invoker of calling this method
        Returns:
        calling class name, "unknown" if unknown
      • getCallingMethodType

        public static MethodType getCallingMethodType()
        Collect the method type of the method that is the invoker of calling this method
        Returns:
        calling method type, null if unknown