Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6271340

Superflous exception handler for finally clause

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_8

      Description

      The following Test class:

      public class Test
      {
          static int i = 0;
          static int j = 0;
          void test() {
              try {
      i = 5;
      } finally {
      j = 6;
              }
          }
      }

      produces these bytecodes for the method test():

      --------
      | test |
      --------
      00ee 0000 access_flags:
      00f0 000d name: "test"
      00f2 000a descriptor: "()V"
      00f4 0001 attributes_count: 1

      00f6 000b 0000004d Attribute "Code" len=77
      00fc 0001 max_stack: 1
      00fe 0003 max_locals: 3
      0100 00000019 code_length: 25

      0104 08 0 iconst_5
      0105 b3 0002 1 putstatic #2 "Test" ("i" "I")
      0108 a8 000c 4 jsr 16
      010b a7 0011 7 goto 24
      010e 4c 10 astore_1
      010f a8 0005 11 jsr 16
      0112 2b 14 aload_1
      0113 bf 15 athrow
      0114 4d 16 astore_2
      0115 10 06 17 bipush 6
      0117 b3 0003 19 putstatic #3 "Test" ("j" "I")
      011a a9 02 22 ret 2
      011c b1 24 return

      011d 0002 exception_table_length: 2
            exception handler #1
      011f 0000 start_pc: 0
      0121 0007 end_pc: 7
      0123 000a handler_pc: 10
      0125 0000 catch_type: 0 - Catches all exceptions.
            exception handler #2
      0127 000a start_pc: 10
      0129 000e end_pc: 14
      012b 000a handler_pc: 10
      012d 0000 catch_type: 0 - Catches all exceptions.

      =================================================================

      Notice that exception handler #2 describes a "try" range that is part of the finally clause, and it designates itself as the handler for this try range. This is a recursive reference that doesn't make sense. In this case, the bytecodes in that range cannot throw any exceptions. Hence, this exception handler info is useless at best, and erroneous otherwise because it refers to itself as the handler for exceptions thrown in its range.

      ###@###.### 2005-05-17 00:20:26 GMT

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vromero Vicente Arturo Romero Zaldivar
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: