Community
Participate
Working Groups
On the following test case, the bytecode at 34 could have been optimized out. public class X{ public static void main(String args[]) { try{ try{ System.out.println("xxx"); } finally{ System.out.println("xxx"); } } finally{ System.out.println("xxx"); } } } 0xB2 0x00 0x12 /*0 : getstatic [12] : Ljava/io/PrintStream; java/lang/System.out */ 0x12 0x14 /*3 : ldc [14] : xxx */ 0xB6 0x00 0x1A /*5 : invokevirtual [1A] : java/io/PrintStream.println(Ljava/lang/String;)V */ 0xA7 0x00 0x09 /*8 : goto pc 17 : offset 9 */ 0x4E /*11 : astore_3 */ 0xA8 0x00 0x0B /*12 : jsr pc 23 : offset 11 */ 0x2D /*15 : aload_3 */ 0xBF /*16 : athrow */ 0xA8 0x00 0x06 /*17 : jsr pc 23 : offset 6 */ 0xA7 0x00 0x17 /*20 : goto pc 43 : offset 23 */ 0x4D /*23 : astore_2 */ 0xB2 0x00 0x12 /*24 : getstatic [12] : Ljava/io/PrintStream; java/lang/System.out */ 0x12 0x14 /*27 : ldc [14] : xxx */ 0xB6 0x00 0x1A /*29 : invokevirtual [1A] : java/io/PrintStream.println(Ljava/lang/String;)V */ 0xA9 0x02 /*32 : ret local variable 2 */ 0xA7 0x00 0x09 /*34 : goto pc 43 : offset 9 */ 0x4D /*37 : astore_2 */ 0xA8 0x00 0x0B /*38 : jsr pc 49 : offset 11 */ 0x2C /*41 : aload_2 */ 0xBF /*42 : athrow */ 0xA8 0x00 0x06 /*43 : jsr pc 49 : offset 6 */ 0xA7 0x00 0x0E /*46 : goto pc 60 : offset 14 */ 0x4C /*49 : astore_1 */ 0xB2 0x00 0x12 /*50 : getstatic [12] : Ljava/io/PrintStream; java/lang/System.out */ 0x12 0x14 /*53 : ldc [14] : xxx */ 0xB6 0x00 0x1A /*55 : invokevirtual [1A] : java/io/PrintStream.println(Ljava/lang/String;)V */ 0xA9 0x01 /*58 : ret local variable 1 */ 0xB1 /*60 : return */ 0x0002 /*exception table : count = 2*/ 0x0000 /*catch ANY : from 0 to 11 goto 11 */ 0x000B 0x000B 0x0000 0x0000 /*catch ANY : from 0 to 37 goto 37 */ 0x0025 0x0025 0x0000 NOTES: PM (5/11/00 2:23:24 PM) This extra bytecode is actually generated as the inside try block natural exit. However, the only reference to it (goto at 20) got optimized since it is a transitive goto, and thus in the end bytecode 34 is indeed unreachable.
PRODUCT VERSION: 11b(5/11/00 2:22:56 PM)
Defer
reopening
Olivier - is this still an issue ? Especially in the light of stackmap tables.
Not a problem anymore. The actual code gen is: 0 getstatic System.out : PrintStream [16] 3 ldc <String "xxx"> [22] 5 invokevirtual PrintStream.println(String) : void [24] 8 goto 28 11 astore_2 12 jsr 17 15 aload_2 16 athrow 17 astore_1 18 getstatic System.out : PrintStream [16] 21 ldc <String "xxx"> [22] 23 invokevirtual PrintStream.println(String) : void [24] 26 ret 1 28 jsr 17 31 goto 53 34 astore 4 36 jsr 42 39 aload 4 41 athrow 42 astore_3 43 getstatic System.out : PrintStream [16] 46 ldc <String "xxx"> [22] 48 invokevirtual PrintStream.println(String) : void [24] 51 ret 3 53 jsr 42 56 return Exception Table: [pc: 0, pc: 11] -> 11 when : any [pc: 28, pc: 31] -> 11 when : any [pc: 0, pc: 34] -> 34 when : any [pc: 53, pc: 56] -> 34 when : any This might be a consequence of the change you made to remove dead code a while ago. Closing as WORKSFORME?
Likely yes, pls close as worksforme, and add a regression test.
Added org.eclipse.jdt.core.tests.compiler.regression.TryStatementTest#test058
Verified for 3.3 M7 using build I20070418-1012 (and source code v_751).
Wrong build id: Verified for 3.3 M7 using build I20070418-1012 (and source code v_751).