eclipse-jdt / eclipse-jdt/eclipse.jdt.core
[Eclipse 2025-06 regression] Java formatter strange with comments in 'enum' arguments
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
## In brief
Formatting of _line comments_ within arguments of an `enum` changed for the worse in Eclipse 2025-06 onwards, compared to how it was in Eclipse 2025-03, with no apparent way to configure.
The example below was formatted with: [formatter.xml](https://github.com/user-attachments/files/24283308/formatter.xml)
## Example
```java
enum Value {
FIRST("A",
// Comment
"B"),
SECOND(new String[] {
// Comment
"A",
// Comment
"B",
}, null),
THIRD(1, false
// Comment
|| true),
FOURTH(new long[] {
// @formatter:off
1, 2, 3,
4, 5, 6,
// @formatter:on
}, null),
;
private Value(Object arg1, Object arg2) {}
}
```
## Expected (2025-03 behaviour)
Nothing to change.
## What happens (2025-06, 2025-09, 2025-12 behaviour)
```java
enum Value {
FIRST("A", // Comment
"B"),
SECOND(new String[] { // Comment
"A", // Comment
"B",
}, null),
THIRD(1, false// Comment
|| true),
FOURTH(new long[] { // @formatter:off
1, 2, 3,
4, 5, 6,// @formatter:on
}, null),
;
private Value(Object arg1, Object arg2) {}
}
```
* Line comments move up to the end of the previous line
* `@formatter:off` is ignored and formatting happens regardless
Contributor guide
Assessment
This issue has not been assessed yet.