Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect line numbering for lambda expressions #66

Open
oxeye-gal opened this issue Nov 9, 2022 · 2 comments
Open

Incorrect line numbering for lambda expressions #66

oxeye-gal opened this issue Nov 9, 2022 · 2 comments

Comments

@oxeye-gal
Copy link

oxeye-gal commented Nov 9, 2022

Hi,

We noticed that the line numbering produced by using the --debug-line-numbers flag are incorrect for lambda expressions, consider the following example:

Original code:

import java.util.ArrayList;

public class Main {
    public static void main(String[] argv) {
        ArrayList<String> test = new ArrayList<>();
        test.add("a");
        test.add("b");
        test.add("c");
        test.forEach(str -> {



            System.out.println(str);



        });
    }
}

Decompiled code:

{
    public static void main(final String[] array) {
        final ArrayList list = /*EL:5*/new ArrayList();
        /*SL:6*/list.add("a");
        /*SL:7*/list.add("b");
        /*SL:8*/list.add("c");
        /*SL:9*/list.forEach(x -> System.out.println(x));
    }
}

As can be seen the decompiled code shows that the call to System.out.println happens in line 9, while in fact it happened in line 13.

We have an idea why this happening but we are not sure, our analysis shows that the parsing of the LineNumberTable structures from the class files bytecode refers to the wrapping function (in this case main) and not the lambda expression which leads to the incorrect line numbering report.

Please let us know your thoughts on this, and whether we could expect a fix for this issue.

Thanks.

@75ACOL
Copy link

75ACOL commented Aug 9, 2023

I found a similar problem and it would be nice if someone fixed it

@75ACOL
Copy link

75ACOL commented Aug 16, 2023

` ArrayList test = new ArrayList(); test.add("a");

    test.add("b");
    test.add("c");
    test.forEach((str) -> {






        System.out.println(str);








    });` 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants