Display the Stack Trace

Display the Stack Trace

The stack trace is a useful debugging tool that you’ll normally take advantage of when an exception has been thrown. It provides information on the execution history of the current thread, displaying the names of the classes and methods within those classes that had been called at the point when the exception occurred. However, there are times when it’s helpful to display the stack trace even though an exception has not been thrown. The easiest way to do this is to use the static dumpStack() method in the Thread class:


This technique is useful, for example, when you have a method that is called from a variety of places within your code and you want to learn where it is being called from when a particular problem occurs.


Share the Post: