Class StackTrace gives programmatic access to the JVM stack trace.1 During construction, an instance of StackTrace initializes a collection of StateState objects, each corresponding to a single stack frame in the stack trace at the moment of the construction.
As shown in figure 10, in order to access the stack trace, class StackTrace uses an instance of class java.lang.Throwable. Method Throwable.printStackTrace() dumps the stack trace to a specified output stream. StackTrace creates a buffer of class java.io.StringWriter, then requests from a newly created Throwable object to print the stack trace to that buffer, and parses the content of the buffer to initialize a collection of StackState objects.