Bug 262717 - Wrong line numbers in classfile
Summary: Wrong line numbers in classfile
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-28 04:43 EST by David Audel CLA
Modified: 2009-03-10 11:38 EDT (History)
0 users

See Also:


Attachments
Proposed fix (1.45 KB, patch)
2009-01-28 12:27 EST, Olivier Thomann CLA
no flags Details | Diff
Same patch with regression test (3.96 KB, patch)
2009-01-28 12:48 EST, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Audel CLA 2009-01-28 04:43:56 EST
build I20090126-1300

1) create test/Test.java
package test;

public class Test{
  public static void main(String[] args) {
	  new Test().new Inner().foo();
  }
  public class Inner {
	  public void foo() {
		  int i = 0;
		  final int NEW = 1;
		  if (i == NEW) {// line 11
			  System.out.println();// line 12
		  }
		  bar();// line 14
	  }
  }
  
  public void bar() {
	  System.out.println();
  }
}
2) put a breakpoint on line 11 and debug this program
3) when the you hit the breakpoint do a step into
the cursor move on line 12 but it should move on line 14 because the condition is false.

Open the generated test/Test$Inner.class to see the following content

  // Method descriptor #14 ()V
  // Stack: 2, Locals: 3
  public void foo();
     0  iconst_0
     1  istore_1 [i]
     2  iconst_1
     3  istore_2 [NEW]
     4  iload_1 [i]
     5  iconst_1
     6  if_icmpne 15
     9  getstatic java.lang.System.out : java.io.PrintStream [20]
    12  invokevirtual java.io.PrintStream.println() : void [26]
    15  aload_0 [this]
    16  getfield test.Test$Inner.this$0 : test.Test [10]
    19  invokevirtual test.Test.bar() : void [31]
    22  return
      Line numbers:
        [pc: 0, line: 9]
        [pc: 2, line: 10]
        [pc: 4, line: 11]
        [pc: 9, line: 12]
        [pc: 19, line: 14]
        [pc: 22, line: 15]
      Local variable table:
        [pc: 0, pc: 23] local: this index: 0 type: test.Test.Inner
        [pc: 2, pc: 23] local: i index: 1 type: int
        [pc: 4, pc: 23] local: NEW index: 2 type: int

I think that the pc for line number 14 should be 15 instead of 19.
Comment 1 Olivier Thomann CLA 2009-01-28 11:34:11 EST
We should update the line number information before we dump the receiver and not after.
Comment 2 Olivier Thomann CLA 2009-01-28 12:27:07 EST
Created attachment 124053 [details]
Proposed fix

I'll add a regression test.
Comment 3 Olivier Thomann CLA 2009-01-28 12:48:11 EST
Created attachment 124055 [details]
Same patch with regression test
Comment 4 Olivier Thomann CLA 2009-01-28 13:47:57 EST
Released for 3.5M6.
Regression test added in org.eclipse.jdt.core.tests.compiler.regression.DebugAttributeTest#test004
Comment 5 Kent Johnson CLA 2009-03-10 11:38:25 EDT
Verified for 3.5M6 using I20090310-0100