O'Reilly logo

The Java® Virtual Machine Specification, Java SE 7 Edition, Third Edition by Alex Buckley, Gilad Bracha, Frank Yellin, Tim Lindholm

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.13. Compiling finally

(This section assumes a compiler generates class files with version number 50.0 or below, so that the jsr instruction may be used. See also §4.10.2.5.)

Compilation of a try-finally statement is similar to that of try-catch. Prior to transferring control outside the try statement, whether that transfer is normal or abrupt, because an exception has been thrown, the finally clause must first be executed. For this simple example:

void tryFinally() {    try {        tryItOut();    } finally {        wrapItUp();    }}

the compiled code is:

Method void tryFinally()0   aload_0             // Beginning of try block1   invokevirtual #6    // Method Example.tryItOut()V4   jsr 14              // Call finally block7   return              // ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required