Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Exception handling is quite difficult to implement. When you throw an exception, you need to unwind every stack frame between where the exception was thrown and where it is caught. There are a few ways of doing this. In a language with stack introspection like Smalltalk, it’s relatively easy. The exception can look at each stack frame and perform the unwinding.
In Java and similar languages, it is commonly implemented by returning two values. In a typical Java VM, one register will be reserved for returning the exception object. After every call, the JVM will check that this register is zero, and branch to the exception-handling code if it isn’t.