Class StackTraceUtils

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Class<?> getCallerClassInStatckTrace()
      Get caller class from stack traces
      static java.lang.Class<?> getCallerClassInStatckTrace​(int invocationFrame)
      Get caller class in General JVM
      static java.lang.String getCallerClassNameInStackTrace()
      General implementation, get the calling class name
      static java.lang.String getCallerClassNameInStackTrace​(int invocationFrame)
      General implementation, get the calling class name by specifying the calling level value
      static java.lang.StackTraceElement[] getStackTrace()
      Retrieves the stack trace elements for the current thread's call stack.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getCallerClassInStatckTrace

        public static java.lang.Class<?> getCallerClassInStatckTrace()
        Get caller class from stack traces
        Returns:
        Caller Class
        See Also:
        getCallerClassInStatckTrace(int)
      • getCallerClassNameInStackTrace

        public static java.lang.String getCallerClassNameInStackTrace()
        General implementation, get the calling class name
        Returns:
        call class name
        See Also:
        getCallerClassNameInStackTrace(int)
      • getCallerClassInStatckTrace

        public static java.lang.Class<?> getCallerClassInStatckTrace​(int invocationFrame)
        Get caller class in General JVM
        Parameters:
        invocationFrame - invocation frame
        Returns:
        caller class
        See Also:
        getCallerClassNameInStackTrace(int)
      • getCallerClassNameInStackTrace

        public static java.lang.String getCallerClassNameInStackTrace​(int invocationFrame)
                                                               throws java.lang.IndexOutOfBoundsException
        General implementation, get the calling class name by specifying the calling level value
        Parameters:
        invocationFrame - invocation frame
        Returns:
        specified invocation frame class
        Throws:
        java.lang.IndexOutOfBoundsException
      • getStackTrace

        @Nonnull
        public static java.lang.StackTraceElement[] getStackTrace()
        Retrieves the stack trace elements for the current thread's call stack.

        This method is useful for inspecting the sequence of method calls that led to the current point of execution. It can be used for debugging, logging, or monitoring purposes.

        Example Usage

        
         StackTraceElement[] stackTrace = StackTraceUtils.getStackTrace();
         for (StackTraceElement element : stackTrace) {
             System.out.println(element);
         }
         
        Returns:
        a non-null array of StackTraceElement representing the current thread's stack trace