-
Notifications
You must be signed in to change notification settings - Fork 339
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
While debugging Java, 'Cannot evaluate because of compilation error(s): Evaluations must contain either an expression or a block of well-formed statements' #1158
Comments
@prumseycsi Would you mind sharing a screenshot to show the snippet you evaluate and the error message you get? thanks. |
Original comment has been updated with a screenshot. Before stepping the offending statement, the string literal "before step" evaluated properly. After stepping, the string literal "after step" didn't. |
That'd be Adopt OpenJDK 11.0.10+9, the only version 11 JDK that VSCode would install for me at the time (March 2021). |
I have the same problem, also using OpenJDK, but I don't have a maven project. |
@clankill3r Could you please provide more details about your case? It's better to provide the snippet and a sample project? |
Ok, I boiled it down to this: package vscode_bugged;
public class VSCode_Bugged_Example_3 {
public static void main(String[] args) {
foo(tree_builder);
}
static public class Node<T extends Node<T>> {
public T parent;
}
static public class Tree_Builder<T extends Node<T>> {
public T current;
}
static public class Element extends Node<Element> {
public String name;
}
static public Tree_Builder<Element> tree_builder = new Tree_Builder<>();
static public <T extends Node<T>> void foo(Tree_Builder<T> builder) {
String s = "nope";
if (builder.current != null) {
}
System.out.println(s); // breakpoint here
}
} It might be possible to boil it down a bit further but my attempts failed so far. This is not a maven project or the like, just |
@clankill3r thanks for the snippet, I can reproduce it and it's a bug. I create a new issue to track your use case. #1169 |
This is still an issue, I presume #1169 is too In the 'variables' panel I can see vscjava.vscode-java-debug v0.58.0 Gradle reports the following compiler args, maybe something is wrong here?
While we did occasionally experience this issue in Eclipse's debugger, it was only occasionally. The workaround was just to restart the server, but that doesn't seem to work here. It happens for any expression entered, interestingly it will correctly identify when a property/method doesn't exist before it prints the error message; Other fixes to this issue in Eclipse I've found online include;
These and other solutions for eclipse don't appear to be solutions for VSCode. Interestingly the issue only seems to appear once I step over a few expressions, but all the methods I tested are just plain java code; method calls, variable declarations, a few literals, and in one case a typecast. @testforstephen is there any plan to resolve this? |
As an experiment I've upgraded to Java 22 with the below gradle config and java.sourceCompatibility = JavaVersion.VERSION_22
java.targetCompatibility = JavaVersion.VERSION_22 The issue persists, though it seems that it's a little better in some circumstances (this may be entirely subjective). |
Issue Type: Bug
In a Maven project, creating a TableRowSorter breaks the Debug Console evaluator.
Set a breakpoint at the indicated line in the source file. At the breakpoint, type a simple expression (e.g. "before step") in the Debug Console. It works normally. Step the statement. Type an expression again and it fails.
Extension version: 0.40.1
VS Code version: Code 1.66.2 (dfd34e8260c270da74b5c2d86d61aee4b6d56977, 2022-04-11T07:46:01.075Z)
OS version: Windows_NT x64 10.0.19044
Restricted Mode: No
Extensions (16)
.project file:
Source file (SlideCatalog.java, located in the src/main/java/SlideCatalog subfolder of .project's folder):
The text was updated successfully, but these errors were encountered: