If there is an exception, an exception object is created.
If the exception was not handled, what happens to this exception object and what is the internal mechanism?
You can check how processed exceptions are handled :
Java actually handles uncaught exceptions according to the thread in which they occur. When an uncaught exception occurs in a specific thread, Java looks for what is called an opaque exception handler, actually an implementation of the UncaughtExceptionHandler interface. The last interface has a handleException () method that the executor redefines to take appropriate measures, such as printing a stack to the console. As we will see now, we can set our own instance of UncaughtExceptionHandler to handle thrown exceptions from a specific thread or even for the whole system.The specific procedure is as follows. When an uncaught exception occurs, the JVM does the following:it calls the special private method dispatchUncaughtException () in the Thread class in which an exception occurs;, 1.
Java actually handles uncaught exceptions according to the thread in which they occur. When an uncaught exception occurs in a specific thread, Java looks for what is called an opaque exception handler, actually an implementation of the UncaughtExceptionHandler interface. The last interface has a handleException () method that the executor redefines to take appropriate measures, such as printing a stack to the console. As we will see now, we can set our own instance of UncaughtExceptionHandler to handle thrown exceptions from a specific thread or even for the whole system.
The specific procedure is as follows. When an uncaught exception occurs, the JVM does the following:
Exception AND IS THROWN, .
, Exception, . , , , ..
e= new Exception(); StackTraceElement[] st = e.getStackTrace(); for(StackTraceElement s:st) { s.getLineNumber() } // NO throw
Source: https://habr.com/ru/post/1606255/More articles:Как выполнять параллельные загрузки в Go - concurrencyHow to create rating bars in Android? - androidWhere is the nuget cache for the LOCAL SYSTEM account located? - nugetWhy does dependencyGraph throw an IllegalStateException: does the sbt-dependency-graph plugin only support InlineConfiguration? - sbtAn effective way to apply the mirror effect when turning a quaternion? - mathSetting colors in draw_networkx and in matplotlib - pythonWarning Implicit declaration posix_memalign - cSUM dynamic columns in a PIVOT table in SQL Server - sql-serverPython: printing without overwriting print lines - pythonjQuery Datatables: search and filter by Ajax pagination - jqueryAll Articles