Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The detailed flowchart of full uncaught exception handling is given here: <a href="http://www.javamex.com/tutorials/exceptions/exceptions_uncaught_handler.shtml" rel="nofollow noreferrer">How uncaught exceptions are handled in Java</a>.</p> <blockquote> <p>When an uncaught exception occurs, the JVM does the following:</p> <ul> <li>it calls a special private method, <code>dispatchUncaughtException()</code>, on the <code>Thread</code> class in which the exception occurs; <ul> <li>[...which] calls the thread's <code>getUncaughtExceptionHandler()</code> method to find out the appropriate uncaught exception handler to use. Normally, this will actually be the thread's parent <code>ThreadGroup</code>, whose <code>handleException()</code> method by default will print the stack trace. </li> </ul></li> <li>it then <em>terminates</em> the thread in which the exception occurred. </li> </ul> </blockquote> <p>Therefore you can, if you wish to, create your own custom uncaught exception handler.</p> <p>It should also be noted that while <code>main</code> is commonly used as a Java application entry point, the method is just like any other methods in that it <em>can</em> also be called from other contexts (e.g. other <code>main</code> methods, or even itself recursively!). In that case, the caller can catch exceptions thrown.</p> <pre><code>public class SelfCatch { public static void main(String args[]) throws Exception { if (args == null) throw new Exception("Hi there!"); try { main(null); } catch (Exception e) { System.out.println("Caught: " + e); } System.out.println("Exiting..."); } } </code></pre> <p>Output:</p> <pre><code>Caught: java.lang.Exception: Hi there! Exiting... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload