You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lambda evaluation - Cannot evaluate because of compilation error(s): Evaluations must contain either an expression or a block of well-formed statements #754
Apologies for slightly hijacking this issue, but i have a very similar issue and want to check if it is same/related. When trying to evaluate in generic code, all evaluations fail with "Cannot evaluate because of a compilation error(s): Evaluations must contain either an expression or a block of well-formed statements". This is not a lambda, it's just a plain method of a (generic) type. I tried a trivial example and expressions worked with generics, so does this sound like the same bug ?
Rome Li (@akaroml)Jinbo Wang (@testforstephen) - any idea when that eclipse fix will be incorporated with vs code extension / tools? Also, looking at the issue on the eclipse site it appears that working with streams it's still not fixed.
The evaluation of partial lambda expressions has been supported in the latest version of the debugger, and we will keep investigating the root cause of the unsupported cases.
Supported cases
Can evaluate lambda variables in non-chain calls.
Can evaluate local variables in chain calls of standard Java Streams.
Unsupported cases
Cannot evaluate variables from enclosing methods when using lambda in a chain call.
Cannot evaluate variables in self-defined chain calls.
Reacted by Michael Lill, Michael DePouw and Al Johri
changed the title [-]Cannot evaluate because of compilation error(s): Evaluations must contain either an expression or a block of well-formed statements[/-][+]Lambda evaluation - Cannot evaluate because of compilation error(s): Evaluations must contain either an expression or a block of well-formed statements[/+]on Dec 14, 2021
peter rumsey (@prumseycsi) The original issue reported at #844 is about the compilation errors for lambda variable evaluation. Have a look at your comment #844 (comment), I don't understand what's your use case, could you pls open a new issue to describe your problem?
Hi, I have a similar problem with internal field initializer.
import java.util.*;
public class RomanToInteger {
public int romanToInt(String s) {
var ri = new HashMap<Character,Integer>() {{
put('I', 1);
}};
var c = ri.get(s.charAt(0)); // ri returns cannot evaluate
return 0;
}
}
Environment
Operating System: Win 11
JDK version: openjdk version "11.0.12" 2021-07-20
Java extension version: Language Support for Java(TM) by Red Hat 0.40.1
Java Debugger extension version: 0.40.1
Visual Studio Code Version: 1.67.1
Commit: da15b6fd3ef856477bf6f4fb29ba1b7af717770d
Activity
spottedmahn commentedon Feb 3, 2020
Also, the debugger variables window is able to see the values:
akaroml commentedon Feb 7, 2020
Michael DePouw (@spottedmahn) thanks for reaching out. It looks like a bug to me. Jinbo Wang (@testforstephen) please take a look.
testforstephen commentedon Feb 10, 2020
The upstream jdt has the same error on inspecting variable in the lambda expression. Need take a look at the upstream jdt first.
spottedmahn commentedon Feb 10, 2020
upstream jdt is https://github.com/eclipse/eclipse.jdt.debug? 🤔
puremourning commentedon May 13, 2020
Apologies for slightly hijacking this issue, but i have a very similar issue and want to check if it is same/related. When trying to evaluate in generic code, all evaluations fail with "Cannot evaluate because of a compilation error(s): Evaluations must contain either an expression or a block of well-formed statements". This is not a lambda, it's just a plain method of a (generic) type. I tried a trivial example and expressions worked with generics, so does this sound like the same bug ?
noel-yap commentedon Jul 14, 2020
Any update on this issue? This is adding a lot of friction for me while debugging.
testforstephen commentedon Jul 15, 2020
The upstream has added the support for the lambda support in 2020-03 release, and already integrated to the debugger extension. See the upstream issue https://bugs.eclipse.org/bugs/show_bug.cgi?id=560392
Ben Jackson (@puremourning) Noel Yap (@noel-yap) Could you please open a new bug for your issue? Also please add the code snippet to explain your scenario.
rposener commentedon Jul 16, 2020
Rome Li (@akaroml) Jinbo Wang (@testforstephen) - any idea when that eclipse fix will be incorporated with vs code extension / tools? Also, looking at the issue on the eclipse site it appears that working with streams it's still not fixed.
testforstephen commentedon Jul 17, 2020
Debugger 0.27.0 just released today, the fix should be already there. Could you try again?
BTW, you also need update Language Support for Java by Red Hat extension to latest version 0.64.1.
Faputa commentedon Nov 2, 2020
Obviously, this problem is still unresolved, sad.
massimeddu-sonic commentedon Jan 13, 2021
Hi all,
I've the same issue trying to evaluating expression in a Tomcat application. Do you know how to solve it?
Thanks,
michaellilltokiwa commentedon Nov 12, 2021
Rome Li (@akaroml) since this is not fixed, please consider reopening.
testforstephen commentedon Nov 15, 2021
let's reopen the issue and revisit it.
testforstephen commentedon Dec 14, 2021
The evaluation of partial lambda expressions has been supported in the latest version of the debugger, and we will keep investigating the root cause of the unsupported cases.
Supported cases
Can evaluate lambda variables in non-chain calls.

Can evaluate local variables in chain calls of standard Java Streams.

Unsupported cases
Cannot evaluate variables from enclosing methods when using lambda in a chain call.

Cannot evaluate variables in self-defined chain calls.

[-]Cannot evaluate because of compilation error(s): Evaluations must contain either an expression or a block of well-formed statements[/-][+]Lambda evaluation - Cannot evaluate because of compilation error(s): Evaluations must contain either an expression or a block of well-formed statements[/+]testforstephen commentedon Jan 11, 2022
Opened issues on the upstream JDT to track the progress.
testforstephen commentedon Apr 15, 2022
Hi all, we have fixed the lambda evaluation bug in the upstream eclipse jdt repository.
Please update Language Support for Java(TM) by Red Hat to latest version 1.5.0, which includes our fix for lambda evaluation.
// fyi: Michael DePouw (@spottedmahn) Noel Yap (@noel-yap) Ryan Posener (@rposener) Ben Jackson (@puremourning) refcell (@refcell) Michael Lill (@michaellilltokiwa) massimeddu-sonic peter rumsey (@prumseycsi) vic (@acodervic) praxem Rana Ahmed (@ahmednrana)
prumseycsi commentedon Apr 20, 2022
Apparently not a duplicate of my problem reported to #844. Redhat 1.5 does not fix it. Please reopen something, or tell me to open something new.
testforstephen commentedon Apr 20, 2022
peter rumsey (@prumseycsi) The original issue reported at #844 is about the compilation errors for lambda variable evaluation. Have a look at your comment #844 (comment), I don't understand what's your use case, could you pls open a new issue to describe your problem?
martinkunc commentedon May 15, 2022
Hi, I have a similar problem with internal field initializer.
Environment
Operating System: Win 11
JDK version: openjdk version "11.0.12" 2021-07-20
Java extension version: Language Support for Java(TM) by Red Hat 0.40.1
Java Debugger extension version: 0.40.1
Visual Studio Code Version: 1.67.1
Commit: da15b6fd3ef856477bf6f4fb29ba1b7af717770d
testforstephen commentedon May 16, 2022
Martin Kunc (@martinkunc) Your case is not related with this issue, I created a new one to track your case. #1163