Class StackTraceUtil


  • public class StackTraceUtil
    extends Object
    Transforms a stacktrace, obtained from Throwable as an array of StackTraceElement, into a linked list of corresponding construct identifiers.

    Analyzes the bytecode in order to find methods in case of method overloading (thereby using the line numbers provided in the stack trace).

    More information can be found here: http://stackoverflow.com/questions/421280/how-do-i-find-the-caller-of-a-method-using-stacktrace-or-reflection http://stackoverflow.com/questions/15899518/modifying-line-numbers-in-javassist http://stackoverflow.com/questions/1069066/get-current-stack-trace-in-java

    • Constructor Detail

      • StackTraceUtil

        public StackTraceUtil()

        Constructor for StackTraceUtil.

    • Method Detail

      • setStopAtJUnit

        public void setStopAtJUnit​(boolean _b)

        Setter for the field stopAtJUnit.

        Parameters:
        _b - a boolean.
      • getJUnitContext

        public ConstructId getJUnitContext​(List<PathNode> _path)
        Returns the JUnit test case representing the starting point of a previously computed path. If no JUnit test case is present, the method returns null.
        Parameters:
        _path - a List object.
        Returns:
        a ConstructId object.
      • transformStackTrace

        public List<PathNode> transformStackTrace​(StackTraceElement[] _st,
                                                  PathNode _change_list_element)
        Transforms the stacktrace (obtained by, for instance, new Throwable().getStackTrace()) into a linked list of construct identifiers.
        Parameters:
        _st - an array of StackTraceElement objects.
        _change_list_element - the construct ID for which the stack trace was collected (if known by caller, can be null)
        Returns:
        a List object.
      • getPredecessorConstruct

        public ConstructId getPredecessorConstruct​(StackTraceElement[] _st)
        Given a stacktrace object return the predecessor of the element that called this stacktrace.
        Parameters:
        _st - an array of StackTraceElement objects.
        Returns:
        a ConstructId object.