Skip to content

Lambda evaluation - Cannot evaluate because of compilation error(s): Evaluations must contain either an expression or a block of well-formed statements #754

Closed

Description

Environment
  • Operating System: Win 10
  • JDK version: openjdk version "11.0.5" 2019-10-15
  • Java extension version: ?? do you mean "Language Support for Java(TM) by Red Hat"? if so 0.55.1
  • Java Debugger extension version: 0.24.0
  • Visual Studio Code Version: 1.41.1 (user setup)
  • Commit: 26076a4de974ead31f97692a0d32f90d735645c0
  • Date: 2019-12-18T14:58:56.166Z
  • Electron: 6.1.5
  • Chrome: 76.0.3809.146
  • Node.js: 12.4.0
  • V8: 7.6.303.31-electron.0
  • OS: Windows_NT x64 10.0.18363
Steps To Reproduce
  1. Use a Stream.forEach() and try to evaluate something in the debug console

Sample project

java test runner - can't evaluate.log

Current Result

image

maybe it more has to do w/ lambda's? 🤔

image

Expected Result

image

image

Additional Informations

Activity

  1. spottedmahn commented on Feb 3, 2020

    @spottedmahn
    Author

    Also, the debugger variables window is able to see the values:

    image

  2. akaroml commented on Feb 7, 2020

    @akaroml
    Member

    Michael DePouw (@spottedmahn) thanks for reaching out. It looks like a bug to me. Jinbo Wang (@testforstephen) please take a look.

  3. testforstephen commented on Feb 10, 2020

    @testforstephen
    Contributor

    The upstream jdt has the same error on inspecting variable in the lambda expression. Need take a look at the upstream jdt first.

  4. spottedmahn commented on Feb 10, 2020

    @spottedmahn
    Author
  5. puremourning commented on May 13, 2020

    @puremourning

    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 ?

  6. noel-yap commented on Jul 14, 2020

    @noel-yap

    Any update on this issue? This is adding a lot of friction for me while debugging.

  7. testforstephen commented on Jul 15, 2020

    @testforstephen
    Contributor

    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.

  8. rposener commented on Jul 16, 2020

    @rposener

    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.

  9. testforstephen commented on Jul 17, 2020

    @testforstephen
    Contributor

    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.

  10. Faputa commented on Nov 2, 2020

    @Faputa

    image
    Obviously, this problem is still unresolved, sad.

  11. massimeddu-sonic commented on Jan 13, 2021

    @massimeddu-sonic

    Hi all,

    I've the same issue trying to evaluating expression in a Tomcat application. Do you know how to solve it?

    Thanks,

  12. michaellilltokiwa commented on Nov 12, 2021

    @michaellilltokiwa

    Rome Li (@akaroml) since this is not fixed, please consider reopening.

  13. testforstephen commented on Nov 15, 2021

    @testforstephen
    Contributor

    let's reopen the issue and revisit it.

  14. testforstephen commented on Dec 14, 2021

    @testforstephen
    Contributor

    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.
        image

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

    • Unsupported cases

      • Cannot evaluate variables from enclosing methods when using lambda in a chain call.
        image

      • Cannot evaluate variables in self-defined chain calls.
        image

  15. 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
  16. testforstephen commented on Jan 11, 2022

    @testforstephen
    Contributor

    Opened issues on the upstream JDT to track the progress.

    • Bug 578145 - Evaluations are not working on chain calls for lambda variables.
    • Bug 578147 - Evaluations for lambda variables are not working when using generic type arguments on lambda.
  17. testforstephen commented on Apr 15, 2022

    @testforstephen
    Contributor

    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)

  18. prumseycsi commented on Apr 20, 2022

    @prumseycsi

    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.

  19. testforstephen commented on Apr 20, 2022

    @testforstephen
    Contributor

    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?

  20. martinkunc commented on May 15, 2022

    @martinkunc

    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;
        }
    }
    

    cannot-evaluate

    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

  21. testforstephen commented on May 16, 2022

    @testforstephen
    Contributor

    Martin Kunc (@martinkunc) Your case is not related with this issue, I created a new one to track your case. #1163

  22. locked as resolved and limited conversation to collaborators on May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions