In this chapter, you will learn:
What stacks and stack frames are
How to traverse a thread’s stack before JDK 9
How to traverse a thread’s stack in JDK 9 using the StackWalker API
How to get the caller’s class in JDK 9
What Is a Stack ?
Each thread in a JVM has a private JVM stack that is created at the same time the thread is created. The stack is a List-In-First-Out (LIFO) data structure. A stack stores frames. A new frame is created and pushed to the top of the stack each time a method is invoked. A frame is destroyed (popped out of stack) when the method invocation completes. Each frame on a stack contains ...