Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the role of an application provided uncaught exception handler in printing the stack trace?

Tags:

java

My first question is who actually prints the prints the stack trace ? Is it the JVM or some other entity? What happens behind the scene when stack trace is printed ? I am looking specifically for an answer that tells me the role of Uncaught exception handlers in printing the stacktrace if there is an application provided UncaughtExceptionhandler.

like image 683
Geek Avatar asked Jan 28 '26 08:01

Geek


1 Answers

1. When an exception occurs it is thrown to the JVM.

2. JVM then prints the StackTrace.

3. StackTrace includes the Method name, Class name, File name, and the Line number.

4. fillInStackTrace() method is called to re-initialize the stack trace data in the newly created throwable. Will be helpful in masking the info about the exception when tries to access the API.

like image 91
Kumar Vivek Mitra Avatar answered Jan 29 '26 20:01

Kumar Vivek Mitra