Bug 569413 - error: "Evaluations must contain either an expression or a block of well-formed statements
Summary: error: "Evaluations must contain either an expression or a block of well-form...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.18   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.20 M3   Edit
Assignee: Amedeo Santarelli CLA
QA Contact: Gayan Perera CLA
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2020-12-02 21:20 EST by dd ad CLA
Modified: 2022-09-21 07:24 EDT (History)
6 users (show)

See Also:


Attachments
bug case (119.54 KB, image/png)
2020-12-02 21:20 EST, dd ad CLA
no flags Details
a debug test project (50.85 KB, application/zip)
2020-12-02 21:23 EST, dd ad CLA
no flags Details
Example of the error (915 bytes, text/plain)
2021-04-05 15:33 EDT, Amedeo Santarelli CLA
no flags Details
[patch] Bug569413 junit test (5.21 KB, patch)
2021-04-10 03:23 EDT, Amedeo Santarelli CLA
no flags Details | Diff
a working example with inner class (550 bytes, application/octet-stream)
2022-09-21 04:51 EDT, Remo Liechti CLA
no flags Details
a failing example with inner class (616 bytes, application/octet-stream)
2022-09-21 04:51 EDT, Remo Liechti CLA
no flags Details
a working example with generics (1.29 KB, application/octet-stream)
2022-09-21 04:51 EDT, Remo Liechti CLA
no flags Details
a failing example with generics (1.30 KB, application/octet-stream)
2022-09-21 04:52 EDT, Remo Liechti CLA
no flags Details
a failing example with generics (1.11 KB, application/octet-stream)
2022-09-21 06:05 EDT, Remo Liechti CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description dd ad CLA 2020-12-02 21:20:49 EST
Created attachment 284947 [details]
bug case

In some new versions, the debugger cannot perform expression evaluation (error: "Evaluations must contain either an expression or a block of well-formed statements'), but it can be done in the 2017 version of eclipse. It is found through the tracking code that the problem is Java file: ASTEvaluationEngine.java->createExpressionFromAST, it seems that there is an error in the judgment of runMethodError. Please fix it, this bug affects multiple versions of eclipse!
Comment 1 dd ad CLA 2020-12-02 21:23:41 EST
Created attachment 284948 [details]
a debug test project
Comment 2 Tom Vandenbussche CLA 2021-01-06 03:57:48 EST
I'm having similar issues, and it seems to affect the Debug Shell and Conditional Breakpoints as well. From what I can tell the problem occurs for breakpoints inside a lambda. Outside of lambdas everything works fine.

If I had to guess the problem is might caused by using a newer version of Java (11 in my case), but that is pure speculation.


Eclipse installation:

Version: 2020-12 (4.18.0)
Build id: 20201210-1552
Java Version: GraalVM EE 20.2.1
Comment 3 Sarika Sinha CLA 2021-01-06 05:29:25 EST
Can you attach s simple project to reproduce?
I tried this :
Arrays.asList("ab", "b","c").stream().filter(s -> s.length() >1).forEach(s -> {
			System.out.println(s); // breakpoint here
		});

And could evaluate "s" in the Expression view.
Comment 4 Amedeo Santarelli CLA 2021-04-05 15:33:56 EDT
Created attachment 286031 [details]
Example of the error

Hello,
I too get the error using Eclipse 2021-03, never got it before.

I've addded a Java class to reproduce the error with some comments on where to set the breakpoints.


In the .log file I see the following message:

!ENTRY org.eclipse.debug.core 2 0 2021-04-05 21:25:14.363
!MESSAGE Compile error during code evaluation: Only the first formal parameter may be declared explicitly as 'this'
Comment 5 Amedeo Santarelli CLA 2021-04-07 12:31:31 EDT
it seems the following assignment triggers the problem:

class: org.eclipse.jdt.internal.debug.core.model.JDIStackFrame.LambdaASTVisitor

method: visit

```
if (i == 0) {
HERE --> newName = "this";
} else {
	newName = synVars[i - 1].getName();
}
```


Related Bug where the changes were made: Bug 534687
Comment 6 Andrey Loskutov CLA 2021-04-08 02:45:39 EDT
(In reply to Amedeo Santarelli from comment #5)
> Related Bug where the changes were made: Bug 534687

That was long time ago.
Comment 7 Amedeo Santarelli CLA 2021-04-10 03:23:19 EDT
Created attachment 286075 [details]
[patch] Bug569413 junit test
Comment 8 Amedeo Santarelli CLA 2021-04-10 03:24:39 EDT
(In reply to Andrey Loskutov from comment #6)
> (In reply to Amedeo Santarelli from comment #5)
> > Related Bug where the changes were made: Bug 534687
> 
> That was long time ago.

indeed, but it seems that line is never reached at least running the EvalTestSuite.

I've attached a patch that will create the junit test for the Bug, with 2 tests, when one of the two is now failing of course
Comment 9 Andrey Loskutov CLA 2021-04-10 03:43:23 EDT
(In reply to Amedeo Santarelli from comment #8)
> (In reply to Andrey Loskutov from comment #6)
> > (In reply to Amedeo Santarelli from comment #5)
> > > Related Bug where the changes were made: Bug 534687
> > 
> > That was long time ago.
> 
> indeed, but it seems that line is never reached at least running the
> EvalTestSuite.
> 
> I've attached a patch that will create the junit test for the Bug, with 2
> tests, when one of the two is now failing of course

Many thanks. We use Gerrit to push patches, could you please try? 
https://wiki.eclipse.org/Platform/How_to_Contribute
Comment 10 Eclipse Genie CLA 2021-04-10 08:17:18 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/179139
Comment 11 Eclipse Genie CLA 2021-04-25 04:17:46 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/179804
Comment 12 Andrey Loskutov CLA 2021-04-28 13:36:57 EDT
Gayan, is this something you could check?
Comment 13 Gayan Perera CLA 2021-04-28 14:58:59 EDT
(In reply to Andrey Loskutov from comment #12)
> Gayan, is this something you could check?

Sure i can have a look. Does the two gerrits have already fixed this or do i need to look for a fix ?
Comment 14 Andrey Loskutov CLA 2021-04-28 15:39:42 EDT
(In reply to Gayan Perera from comment #13)
> (In reply to Andrey Loskutov from comment #12)
> > Gayan, is this something you could check?
> 
> Sure i can have a look. Does the two gerrits have already fixed this or do i
> need to look for a fix ?

I had no time to verify if the problem is a regression or not, this is what is most interesting. The first patch is a test, second is supposed to be the fix.
Comment 15 Gayan Perera CLA 2021-04-29 02:36:25 EDT
(In reply to Andrey Loskutov from comment #14)
> (In reply to Gayan Perera from comment #13)
> > (In reply to Andrey Loskutov from comment #12)
> > > Gayan, is this something you could check?
> > 
> > Sure i can have a look. Does the two gerrits have already fixed this or do i
> > need to look for a fix ?
> 
> I had no time to verify if the problem is a regression or not, this is what
> is most interesting. The first patch is a test, second is supposed to be the
> fix.

I can have a look at it in the weekend @Andrey
Comment 17 Sarika Sinha CLA 2021-05-09 13:57:07 EDT
Thanks Amedeo for providing a fix.

Thanks Gayan for reviewing.
Comment 18 Sarika Sinha CLA 2021-05-18 16:43:20 EDT
Build id: I20210518-0850
Comment 19 Remo Liechti CLA 2022-09-21 04:50:43 EDT
this bug still exists and happens when generics "unbounded wildcard" are used in the code that gets debugged, or when having inner classes.
See attached junit tests that show working and non working examples (EclipseBug_*.java)
Comment 20 Remo Liechti CLA 2022-09-21 04:51:07 EDT
Created attachment 288749 [details]
a working example with inner class
Comment 21 Remo Liechti CLA 2022-09-21 04:51:30 EDT
Created attachment 288750 [details]
a failing example with inner class
Comment 22 Remo Liechti CLA 2022-09-21 04:51:55 EDT
Created attachment 288751 [details]
a working example with generics
Comment 23 Remo Liechti CLA 2022-09-21 04:52:11 EDT
Created attachment 288752 [details]
a failing example with generics
Comment 24 Remo Liechti CLA 2022-09-21 06:05:25 EDT
Comment on attachment 288752 [details]
a failing example with generics

do not use, more simplified version available
Comment 25 Remo Liechti CLA 2022-09-21 06:05:50 EDT
Created attachment 288753 [details]
a failing example with generics
Comment 26 Andrey Loskutov CLA 2022-09-21 07:24:21 EDT
(In reply to Remo Liechti from comment #19)
> this bug still exists and happens when generics "unbounded wildcard" are
> used in the code that gets debugged, or when having inner classes.
> See attached junit tests that show working and non working examples
> (EclipseBug_*.java)

Please report new bug here:
https://github.com/eclipse-jdt/eclipse.jdt.debug/issues