Image can't be shown :(

What is Java Call Stack?

Tech Insights

To start with, what does an Exception mean?

It is an event that disrupts the normal flow of a program’s execution.

When an exception is thrown from inside a method, the Java Runtime System attempts to find an ordered list of methods that had been called to reach the method where the error occurred. This list (of methods and its local variables) is known as the Java Call Stack.

Please see the figure below:

Image can't be shown :(
Java Call Stack

The job of runtime system is to search the call stack for a method which contains a block of code that can handle the exception. This block of code is called exception handler. The runtime system starts a search with the method in which the error occurred and proceeds through the call stack in the reverse order of method invocation.

The runtime system passes the exception to the appropriate exception handler when found one. An exception handler is considered appropriate if the type of exception object thrown, matches the type that can be handled by that exception handler.