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

Implicit catch clauses not given correct line number

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 1.3.0
    • 1.3.0
    • tools
    • beta
    • generic
    • generic
    • Verified

    Description

      Implicit catches of any exception are generated by the compiler when a finally clause or synchronized block is present in the code. These clauses are not assigned to the most appropriate line number in the generated line number table. For example,

      public class Bug3 {
          public static void main(String args[]) {
              try {
                  throw new Exception();
              } catch (Exception e) {
                  System.out.println("Caught!");
              } finally {
                  System.out.println("Finally!");
              }

              synchronized(Bug3.class) {
                  System.out.println("Synchronized!");
              }

              System.out.println("Done!");
          }
      }

      There are two implicit catch clauses generated by the compiler here (see javap output below). From bytecode 23 through 28 is given line 6, but ought to be assigned to 7 or possibly 8. Bytecodes 77 through 83 are assigned to line 12, but ought to be assigned to 13.

      Method void main(java.lang.String[])
         0 new #7 <Class java.lang.Exception>
         3 dup
         4 invokespecial #8 <Method java.lang.Exception()>
         7 athrow
         8 astore_1
         9 getstatic #9 <Field java.io.PrintStream out>
        12 ldc #10 <String "Caught!">
        14 invokevirtual #11 <Method void println(java.lang.String)>
        17 jsr 29
        20 goto 40
        23 astore_2
        24 jsr 29
        27 aload_2
        28 athrow
        29 astore_3
        30 getstatic #9 <Field java.io.PrintStream out>
        33 ldc #12 <String "Finally!">
        35 invokevirtual #11 <Method void println(java.lang.String)>
        38 ret 3
        40 getstatic #13 <Field java.lang.Class class$Bug3>
        43 ifnonnull 58
        46 ldc #14 <String "Bug3">
        48 invokestatic #15 <Method java.lang.Class class$(java.lang.String)>
        51 dup
        52 putstatic #13 <Field java.lang.Class class$Bug3>
        55 goto 61
        58 getstatic #13 <Field java.lang.Class class$Bug3>
        61 astore_1
        62 aload_1
        63 monitorenter
        64 getstatic #9 <Field java.io.PrintStream out>
        67 ldc #16 <String "Synchronized!">
        69 invokevirtual #11 <Method void println(java.lang.String)>
        72 aload_1
        73 monitorexit
        74 goto 84
        77 astore 4
        79 aload_1
        80 monitorexit
        81 aload 4
        83 athrow
        84 getstatic #9 <Field java.io.PrintStream out>
        87 ldc #17 <String "Done!">
        89 invokevirtual #11 <Method void println(java.lang.String)>
        92 return
      Exception table:
         from to target type
           0 8 8 <Class java.lang.Exception>
           0 23 23 any
          64 77 77 any

      Line numbers for method void main(java.lang.String[])
         line 4: 0
         line 6: 9
         line 8: 30
         line 11: 40
         line 12: 64
         line 15: 84

      Name: ssC76496 Date: 08/31/99

      Implicit catch clauses are given correct line number
      verified in the (1.3-0-D) build.
      ###@###.###, 1 Sept 99.
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              wmaddoxsunw William Maddox (Inactive)
              ghirschsunw Gordon Hirsch (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: