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

Exception variable range incorrectly extends outside catch

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 1.4.2
    • 1.4.1
    • tools
    • mantis
    • generic
    • generic

    Description



      Name: tb29552 Date: 05/31/2002


      % cat -n badscope.java
           1 public class badscope {
           2 public static final void main(String args[])
           3 {
           4 // this line should be here
           5 try {
           6 System.out.println("hi!");
           7 } catch (Exception e) {
           8 e.printStackTrace();
           9 } finally {
          10 System.out.println("done");
          11 }
          12 }
          13 }

      Compiling this using "javac -g" and 1.4 FCS generates
      the following (same for 1.4.1):

      % javap -c -l badscope
      Compiled from badscope.java
      public class badscope extends java.lang.Object {
          public badscope();
          public static final void main(java.lang.String[]);
      }

      Method badscope()
         0 aload_0
         1 invokespecial #1 <Method java.lang.Object()>
         4 return

      Line numbers for method badscope()
         line 1: 0

      Local variables for method badscope()
         badscope this pc=0, length=5, slot=0

      Method void main(java.lang.String[])
         0 getstatic #2 <Field java.io.PrintStream out>
         3 ldc #3 <String "hi!">
         5 invokevirtual #4 <Method void println(java.lang.String)>
         8 jsr 31
        11 goto 42
        14 astore_1
        15 aload_1
        16 invokevirtual #6 <Method null>
        19 jsr 31
        22 goto 42
        25 astore_2
        26 jsr 31
        29 aload_2
        30 athrow
        31 astore_3
        32 getstatic #2 <Field java.io.PrintStream out>
        35 ldc #7 <String "done">
        37 invokevirtual #4 <Method void println(java.lang.String)>
        40 ret 3
        42 return
      Exception table:
         from to target type
           0 8 14 <Class java.lang.Exception>
           0 11 25 any
          14 22 25 any
          25 29 25 any

      Line numbers for method void main(java.lang.String[])
         line 6: 0
         line 7: 8
         line 8: 14
         line 9: 19
         line 10: 25
         line 12: 42

      Local variables for method void main(java.lang.String[])
         java.lang.String[] args pc=0, length=43, slot=0
         java.lang.Exception e pc=15, length=27, slot=1


      ----------

      Is the range of e really pc=15, length=27? Seems
      like it is only defined inside the catch, not through
      the end of main() (This is the subject of 4690242)

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

      Attachments

        Issue Links

          Activity

            People

              gafter Neal Gafter
              tbell Tim Bell
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: