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

regression: Compiler generates unnecessary jump and line number table entry

    XMLWordPrintable

Details

    • mantis
    • generic
    • solaris_8

    Description

      From: <jjh@nil>
      Date: Mon, 22 Apr 2002 10:26:43 -0700 (PDT)
      To: ###@###.###
      Subject: Compiler line number issue

      Hi ###@###.### I thought I sent this msg last week bug I can't find any
      evidence that I did, so here it is again.

      The question is, are you going to fix javac to revert to
      the previous behavior for this case, or should we fix our testcase
      to comply with the current javac?

      Thanks.


      -jjh


      jjh writes:
       > Subject: A debug test has started failing with build b05
       > Date: Wed, 13 Mar 2002 14:04:44 -0800 (PST)
       >
       >
       > The test is called StepTest.java. It does lots of stepping
       > and makes sure that the expected results occur.
       >
       > The test is line number sensitive and is failing in b05
       > because the compiler is outputting more line numbers than
       > it did before b05.
       >
       > Here is an example:
       >
       > 1
       > 2 import java.io.IOException;
       > 3
       > 4 public class jj {
       > 5
       > 6 public static void main() {
       > 7
       > 8 try {
       > 9 System.out.println("hi there");
       > 10 } catch (Exception ee) {
       > 11 System.out.println("??");
       > 12 }
       > 13 System.out.println("bye");
       > 14 }
       > 15 }
       >
       > Here is the javap -l -c result on a .class file genereated by b04 javac:
       >
       > Compiled from jj.java
       > public class jj extends java.lang.Object {
       > public jj();
       > public static void main();
       > }
       >
       > Method jj()
       > 0 aload_0
       > 1 invokespecial #1 <Method java.lang.Object()>
       > 4 return
       >
       > Line numbers for method jj()
       > line 4: 0
       >
       > Method void main()
       > 0 getstatic #2 <Field java.io.PrintStream out>
       > 3 ldc #3 <String "hi there">
       > 5 invokevirtual #4 <Method void println(java.lang.String)>
       > 8 goto 20
       > 11 astore_0
       > 12 getstatic #2 <Field java.io.PrintStream out>
       > 15 ldc #6 <String "??">
       > 17 invokevirtual #4 <Method void println(java.lang.String)>
       > 20 getstatic #2 <Field java.io.PrintStream out>
       > 23 ldc #7 <String "bye">
       > 25 invokevirtual #4 <Method void println(java.lang.String)>
       > 28 return
       > Exception table:
       > from to target type
       > 0 8 11 <Class java.lang.Exception>
       >
       > Line numbers for method void main()
       > line 9: 0
       > line 10: 8
       > line 11: 11
       > line 13: 20
       > line 14: 28
       > =====================================================
       >
       > And here is the result when b05 javac is used
       >
       >
       > Compiled from jj.java
       > public class jj extends java.lang.Object {
       > public jj();
       > public static void main();
       > }
       >
       > Method jj()
       > 0 aload_0
       > 1 invokespecial #1 <Method java.lang.Object()>
       > 4 return
       >
       > Line numbers for method jj()
       > line 4: 0
       >
       > Method void main()
       > 0 getstatic #2 <Field java.io.PrintStream out>
       > 3 ldc #3 <String "hi there">
       > 5 invokevirtual #4 <Method void println(java.lang.String)>
       > 8 goto 23
       > 11 astore_0
       > 12 getstatic #2 <Field java.io.PrintStream out>
       > 15 ldc #6 <String "??">
       > 17 invokevirtual #4 <Method void println(java.lang.String)>
       > 20 goto 23
       > 23 getstatic #2 <Field java.io.PrintStream out>
       > 26 ldc #7 <String "bye">
       > 28 invokevirtual #4 <Method void println(java.lang.String)>
       > 31 return
       > Exception table:
       > from to target type
       > 0 8 11 <Class java.lang.Exception>
       >
       > Line numbers for method void main()
       > line 9: 0
       > line 10: 8
       > line 11: 11
       > line 12: 20
       > line 13: 23
       > line 14: 31
       >
       > javac is now generating a goto at 20 that is unneeded
       > (at least in this case). There is a entry in the line number
       > table for this. This is the cause of our problems.
       >
       >
       > Is this an intentional change, in which case we have to
       > fix our tests, or is this a problem in javac?
       >
       >
       > Thanks

      Neal reponds:
       > Neither. It is an unintentional change, but the code is
       > correct. I will aim to revert to the old behavior for this
       > case, but there are other cases for which we will likely
       > have different behavior.
       >
       > -Neal

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: