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

The goto after a jsr should be mapped in line number range of goto target

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 1.4.2
    • 1.4.1
    • tools
    • mantis
    • generic
    • generic, solaris_2.6

    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 }

      badscope.java generates the following bytecodes and line
      numbers (using the 1.4 FCS javac and javap (build 1.4.0-b92)):

      % 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

      ---------------------------------------------------------

      It would make more sense for the goto after a jsr to be
      in the line number range of the target or the last close
      curly brace of the finally clause; once we have executed
      the finally clause we are no longer "within" it.


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

      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: