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

Breakpoint inside record methods don't work #973

Closed
gmiscione opened this issue Mar 27, 2021 · 1 comment · Fixed by microsoft/java-debug#370
Closed

Breakpoint inside record methods don't work #973

gmiscione opened this issue Mar 27, 2021 · 1 comment · Fixed by microsoft/java-debug#370
Assignees
Labels
Milestone

Comments

@gmiscione
Copy link

gmiscione commented Mar 27, 2021

If you create a method inside a record (preview feature of Java 15) and you try to place a breakpoint into that method, the debugger is not able to stop at the location.

Environment
  • Operating System: Ubuntu 18.04.5
  • JDK version: 15.0.1 with preview features
  • Visual Studio Code version: code-server v3.9.2 with VSCode v1.54.2
  • Java extension version: 0.76.0
  • Java Debugger extension version: 0.32.1
Steps To Reproduce
  1. Create a record class with a method
  2. Place a breakpoint into that method
  3. Create a main class that calls the method that contains the breakpoint
  4. Launch the main class in debug mode
Code example
public class RecordTest {
    public static void main(String[] args) throws Exception {
        var rec = new TestRecord(7, 6, 8, 2);
        int res = rec.evenMinTimes2();
        System.out.println(res);
    }

    public static record TestRecord(int v1, int v2, int v3, int v4) {
        public int evenMinTimes2() {
            int res = IntStream.of(v1, v2, v3, v4) //
                    .filter(v -> v % 2 == 0) //
                    .min() //
                    .orElseThrow();
            res *= 2; // place breakpoint here, for example
            return res;
        }
    }
}
Current Result

Execution should stop at the breakpoint

Expected Result

Breakpoint is ignored and execution goes past it

Additional Informations

If you place a breakpoint in the main method and you switch to the record class, the breakpoint icon is replaced with an hollow circle and the tooltip says "Unverified breakpoint". Moreover, if you step-in into the method, the debugger is able to go over each instruction step by step.

@gmiscione
Copy link
Author

The problem is still present if the record contains another nested record definition:

public class RecordTest {
    public static void main(String[] args) throws Exception {
        var rec = new TestRecord(7, 6, 8, 2);
        int res = rec.evenMinTimes2();
        System.out.println(res);
    }

    public record TestRecord(int v1, int v2, int v3, int v4) {

        public int evenMinTimes2() {
            int res = IntStream.of(v1, v2, v3, v4) //
                    .filter(v -> v % 2 == 0) //
                    .min() //
                    .orElseThrow();
            res *= 2; // place breakpoint here, for example
            return res;
        }
    
        static record Position(int x, int y) {
    
        }
    }
}

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

Successfully merging a pull request may close this issue.

2 participants