The pre-Java 9 situation
The JVM throws StackOverflowError when it is asked to perform data computation in a thread that has insufficient stack space and does not have permission to allocate additional space. This is an asynchronous exception. The JVM can also throw the StackOverflowError exception synchronously when a method is invoked.
When a method is invoked, an internal process is used to report the stack overflow. While the current schema works sufficiently for reporting the error, there is no room for the calling application to easily recover from the error. This can result in being more than a nuisance for developers and users. If the StackOverflowError was thrown during a critical computational operation, the data might be corrupted, causing additional problems.
While not the sole cause of these problems, the effected status of locks from the ReentrantLock class were a common cause of undesirable outcomes. This issue was evident in Java 7 because the ConcurrentHashMap code implemented the ReentrantLock class. The ConcurrentHashMap code was modified for Java 8, but problems still persisted for any implementation of the ReentrantLock class. Similar problems existed beyond just ReentrantLock class usage.
The following diagram provides a broad overview of the StackOverflowError problem:
In the next section, we will look at how this issue was resolved for Java 9.