Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 5 of 5
So, for the purposes of our comparison, what needs to happen in Case 1? If a NoPassengerFoundException throws while executing the searchPassengerFlightRecord() method (the top stack frame), further execution of code halts and the Java VM receives control to implement Java's exception-handling
mechanism. The Java VM then searches in the current method for a catch clause having NoPassengerFoundException. If it doesn't find such a clause, then the Java VM pops the stack frame for the current method, and the calling method becomes
the current method. The Java VM again searches in the current method -- earlier the calling method -- for a suitable catch
clause. If the Java VM still doesn't find a suitable catch clause, it pops the current stack frame and then searches the next
stack frame for a suitable catch clause, and so on, until it finally finds an appropriate one. Or, if the thread is the last
nondaemon thread, then the application terminates with the stack trace printing on the console. In short, expending the Java
VM to handle a thrown exception requires more effort, i.e., abrupt method completion is significantly more expensive (performance-wise)
than a normal method completion.
It is important to have a well thought-out and consistent exception-handling strategy for the sake of efficiency and good programming practice. Exception handling should be considered not as an add-on but as an integral part of the development process. The power of exceptions provides a chassis on which to develop applications that are robust and dependable by design, rather than by accident.