Class StackTraceUtil
- java.lang.Object
-
- org.eclipse.steady.java.monitor.trace.StackTraceUtil
-
public class StackTraceUtil extends Object
Transforms a stacktrace, obtained fromThrowableas an array ofStackTraceElement, 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 Summary
Constructors Constructor Description StackTraceUtil()Constructor for StackTraceUtil.StackTraceUtil(LoaderHierarchy _hier, Loader _loader)Constructor for StackTraceUtil.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConstructIdgetJUnitContext(List<PathNode> _path)Returns the JUnit test case representing the starting point of a previously computed path.ConstructIdgetPredecessorConstruct(StackTraceElement[] _st)Given a stacktrace object return the predecessor of the element that called this stacktrace.voidsetStopAtJUnit(boolean _b)Setter for the fieldstopAtJUnit.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.
-
-
-
Constructor Detail
-
StackTraceUtil
public StackTraceUtil()
Constructor for StackTraceUtil.
-
StackTraceUtil
public StackTraceUtil(LoaderHierarchy _hier, Loader _loader)
Constructor for StackTraceUtil.
- Parameters:
_hier- aLoaderHierarchyobject._loader- aLoaderobject.
-
-
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- aListobject.- Returns:
- a
ConstructIdobject.
-
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 ofStackTraceElementobjects._change_list_element- the construct ID for which the stack trace was collected (if known by caller, can be null)- Returns:
- a
Listobject.
-
getPredecessorConstruct
public ConstructId getPredecessorConstruct(StackTraceElement[] _st)
Given a stacktrace object return the predecessor of the element that called this stacktrace.- Parameters:
_st- an array ofStackTraceElementobjects.- Returns:
- a
ConstructIdobject.
-
-