Community
Participate
Working Groups
Build R2.1 When generating subroutine invocations during return (inside try/finally) bytecode sequences, once JSR bytecode has returned, the trailing code until return/branch bytecode should not be inside the JSR-finally ANY exception handler, since any failure at this point would re-run the finally block through the exception handler. Our current exception handling is ranging from try start to catch-end, and should better exclude portions of the bytecode: e.g. static int foo(boolean bool) { int j; try { if (bool) return 1; j = 2; } finally { j = 3; } return j; } 0 iload_0 1 ifeq 9 4 jsr 20 7 iconst_1 // should be excluded from ANY exception handler range 8 ireturn // should be excluded from ANY exception handler range 9 iconst_2 10 istore_1 11 goto 25 14 astore_3 15 jsr 20 18 aload_3 19 athrow 20 astore_2 21 iconst_3 22 istore_1 23 ret 2 25 jsr 20 28 iload_1 29 ireturn Exception Table: [pc: 0, pc: 14] -> 14 when : any
Also, the natural exit (25 jsr 20 ), should be associated with an ANY exception handler as well.
Fixed. Added sequence of any exception handlers (and SubRoutineStatement intermediate node).
Verified.