For the test case: class T { int t() { try { return 0; } finally { } } } Compare the bytecode created with 3.2.2: Method name:"t" Signature: 6=()int Attribute "Code", length:26, max_stack:1, max_locals:1, code_length:2 0: iconst_0 1: ireturn vs. current CVS: Method name:"t" Signature: 6=()int Attribute "Code", length:48, max_stack:2, max_locals:4, code_length:16 0: iconst_0 1: istore_1 2: jsr 13 5: iload_1 6: ireturn 7: astore_3 8: jsr 13 11: aload_3 12: athrow 13: astore_2 14: ret 2 Exceptions (count: 1): start: 0, end: 7, handler: 7, type: 0 /* finally */ Probably caused by: 2003-09-03 Jeff Sturm <jsturm@one-point.com> * parse.y: Include cgraph.h. (block): Don't special-case empty block production.
Forgot to mention: this is a 3.4 regression, though we are no worse off than javac (which doesn't strip the useless try/finally).
Forgot to mention I can confirm this on the mainline (20031022).
http://gcc.gnu.org/ml/gcc-patches/2003-10/msg02405.html
Subject: Bug 12739 CVSROOT: /cvs/gcc Module name: gcc Changes by: jsturm@gcc.gnu.org 2003-11-18 03:42:30 Modified files: gcc/java : ChangeLog java-tree.h parse.y Log message: Fix PR java/12739. * java-tree.h (BLOCK_EMPTY_P): Define. * parse.y (java_complete_lhs): Check for empty blocks in TRY_FINALLY_EXPR case. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1293&r2=1.1294 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/java-tree.h.diff?cvsroot=gcc&r1=1.187&r2=1.188 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/parse.y.diff?cvsroot=gcc&r1=1.455&r2=1.456
Patch applied.