Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4505

Rogue line number for method declarations confuses IDE debuggers

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.5
    • 1.7.6, 1.8-beta-3
    • bytecode
    • None

    Description

      Do a javap -l on the following code:

      class Runner {
      	public void printit() {
      		x("III")
      		x("III")
       	}
      }
      

      and the printit method will look something like this:

      public void printit();
        LineNumberTable: 
         line 2: 4
         line 3: 4
         line 4: 17
        LocalVariableTable: 
         Start  Length  Slot  Name   Signature
         0      31      0    this       LRunner;
      

      Notice that the LineNumberTable has 3 entries, but the original method has only 2 instruction lines of code. The first, rogue line number corresponds to the method's block statement.

      The problem is that there are 2 entries corresponding to the #4 instruction. This occasionally confuses the debugger when it is trying to install the breakpoint on a running app (ie- sometimes it works and sometimes it does not).

      I tracked the problem down to AsmClassGenerator.visitBlockStatement(), which calls the onLineNumber method and (incorrectly, it seems) adds a line number entry for the start of the block statement. Simply commenting this line out (line 721 on version 1.7.5) appears to work for me.

      Is there any reason why we should not go ahead with the fix?

      Attachments

        Activity

          People

            guillaume Guillaume Sauthier
            werdna Andrew Eisenberg
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: