eclipse-jdt / eclipse-jdt/eclipse.jdt.debug

Local class within a method causes error when evaluating an expression in conditional breakpoints

Open
#626 5 comments 0 reactions 0 assignees View on GitHub
bug help wanted
Dominant language
Java
Stars
23
Forks
68
Avg merge
1d 1h
Merged PRs (30d)
16

Description

There is an issue with expression evaluation and conditional breakpoints in Eclipse.
I'm using Eclipse 2024-12, java-21-openjdk-amd64 and the application is started as a "Java Application" through a main class. I reproduced it also with java 1.8, 11 and 17.
The OS is Ubuntu 24 LTS with all updates installed.

_Later Edit: This report was updated, that's why first comment seems a little off_

The error appears for any expression, even the simpliest ones.

Steps to reproduce:

0. Create a new mavem project of quickstart archetype

1. Define a local class within a method and then declare a variable of a parameterized type that uses this local class as one of its type arguments. Simply declaring a local variable of the local class type isn’t sufficient; you must explicitly use the local class as a type argument in the parameterized type declaration.

Minimum required to trigger the issue:
```java
import java.util.HashMap;
import java.util.Map;

/**
* Hello world!
*/
public class App {
public static void main(String[] args) {
class NameGenerator {
}
Map namesPerId = new HashMap<>(); // last line where conditional breakpoint / expression evaluation works in debug mode
System.out.println("From this line on, (until the end of the try-catch block, if there is one) no conditional breakpoint / expression evaluation works");
}
}
```

2. Add a condintional breakpoint on line
`System.out.println([...])`

![Image](https://github.com/user-attachments/assets/91cef145-8de7-4091-ae37-0e439c4125b6)

3. Start a debugger

The execution stops at the conditional breakpoint with the message:
```
Conditional breakpoint has compilation error(s).
Reason:
Evaluations must contain either an expression or a block of well-formed statements
```

Error dialog:
![Image](https://github.com/user-attachments/assets/4c82098d-1690-4961-8500-dc4a3cf18e73)

Expression evaluation window:
![Image](https://github.com/user-attachments/assets/bffc46f7-f3f3-4793-b3b0-d0b5693fa621)

4. Additional information
If the declaration of the parametrizied type variable is within a try-catch block, after the catch block the expression evaluation works again (details and an additional example in comments).

5. The Eclipse log shows the following messages when the exection stops at the breakpoint.

```
!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.203
!MESSAGE Compile error during code evaluation: Syntax error on token "new", @ expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.203
!MESSAGE Compile error during code evaluation: Syntax error, insert "?" to complete Wildcard

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.203
!MESSAGE Compile error during code evaluation: Syntax error, insert ", TypeArgument1" to complete TypeArgumentList1

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.203
!MESSAGE Compile error during code evaluation: Syntax error, insert "... VariableDeclaratorId" to complete FormalParameter

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.204
!MESSAGE Compile error during code evaluation: Syntax error, insert ")" to complete MethodDeclaration

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.204
!MESSAGE Compile error during code evaluation: Syntax error on tokens, ReferenceType expected instead

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.204
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.204
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.204
!MESSAGE Compile error during code evaluation: Syntax error on token ".", = expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.204
!MESSAGE Compile error during code evaluation: Syntax error on token ",", . expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.204
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.204
!MESSAGE Compile error during code evaluation: Syntax error on token ".", = expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.204
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.204
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.204
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.204
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.204
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on token(s), misplaced construct(s)

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on tokens, Type expected instead

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.205
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.206
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.207
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.208
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.208
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.208
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.208
!MESSAGE Compile error during code evaluation: Syntax error on token ",", ; expected

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.208
!MESSAGE Compile error during code evaluation: Syntax error, insert ";" to complete LocalVariableDeclarationStatement

!ENTRY org.eclipse.debug.core 2 0 2025-03-03 10:49:08.208
!MESSAGE Compile error during code evaluation: Syntax error, insert "}" to complete MethodBody
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.