microsoft / vscode-java-debug

Java Debugger for Visual Studio Code.
Other
524 stars 334 forks source link

Cannot evaluate because of compilation error(s). Occurs within watch expressions. #1096

Open mpette200 opened 2 years ago

mpette200 commented 2 years ago

While debugging, watches display "Cannot evaluate because of compilation error(s): ......". This is annoying, and actually the same issue seems to prevent conditional breakpoints from working. This seems to occur whenever an inner class is present within the method.

Environment
Steps To Reproduce
  1. Create the slightly modified "Hello World" by copy / pasting the code below.
  2. Add a breakpoint then debug.
  3. Set a watch expression for msg.length()
import java.util.List;
import java.util.ArrayList;

public class Hello {
    public static void main(String[] args) {

        class Position {
            int x;
            int y;
        }

        String msg = "Hello World";
        List<Position> x = new ArrayList<>();
        System.out.println(msg + x);
    }

}
Current Result

image

Expected Result

msg.length() should evaluate to a number.

Additional Informations

If I move the "class Position {}" so that it is no longer an inner class then the debugger seems to work correctly.

testforstephen commented 2 years ago

Thanks for the information. I can reproduce it, it's a bug.

testforstephen commented 2 years ago

Opened an issue at the upstream JDT. https://bugs.eclipse.org/bugs/show_bug.cgi?id=578148

jasondamour commented 4 months ago

RIP

HairyMike commented 1 week ago

any update? been a few years