JDK-8026861 : Wrong LineNumberTable for variable declarations in lambdas
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-10-18
  • Updated: 2013-11-19
  • Resolved: 2013-10-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b115Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
Consider this source code:
-----
package test;

public class LambdaLNT {
    public static void main(String... args) {
        Runnable r = () -> {
            int i = args.length;
        };
        r.run();
    }
}
-----

When compiled with -g, the LineNumberTable for the lambda method looks like this:
      LineNumberTable:
        line 1: 0
        line 7: 3

That is undoubtedly wrong: the first statement of the lambda does not start at line 1. As a consequence, debuggers would likely misbehave.

This appears to be caused by a missing TreeMaker.at in LambdaToMethod.visitVarDef.
Comments
Fixed by: http://hg.openjdk.java.net/jdk8/tl/langtools/rev/b05db8c815e8
23-10-2013