The JVM (abbreviated for Java virtual machines) uses the method call stack to track a series of method invocation procedures. The stack holds the local information for each calling method. When a new method is invoked, the JVM puts the stack structure that describes the method on top of the stack, and the method at the top of the stack is the method being executed.
If an exception is thrown during the execution of the method, the JVM must find a catch block that can catch the exception
(1) It first observes whether the current method has a catch block and, if it exists, executes the catch code block
(2) If it does not exist, the JVM pops the stack structure of the method from the call stack and continues to find the appropriate catch block in the previous method
(3) when the JVM traces back to the bottom of the call stack, if the code block that handles the exception is still not found, the exception object's Printstacktrace () method is invoked, the exception information from the method call stack is printed, and the entire application is terminated.
Thus, in the process of backtracking, if the JVM finds a block of code in a method that handles the exception, the stack structure of the method is called the top of the stack, and the program process goes on to the exception-handling code portion of the method.
I personally think that in the Java look for anomalies in the first place, through the debugging information table a slowly back to the original exception, need to see the console printstacktrace () printing information, relative to OC, I think OC used exception breakpoint more real, Locate directly in the place where the anomaly occurs. Easy to locate.