False positive "Flexible Constructor Bodies is only available with source level 25 and above" with Lombok @RequiredArgsConstructor on Java 21
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start with the minimal Maven reproducer and its Java 21 maven.compiler.release setting, then reproduce the diagnostic in VS Code with [email protected]. Compare the JDT Language Server/Lombok processing of @RequiredArgsConstructor with Maven's successful build; done means the false Java 25 Flexible Constructor Bodies diagnostic no longer appears for the reproducer.
由索引模型根據 Issue 內容生成。
描述
Description
I am seeing a false-positive Java compiler diagnostic in VS Code when using Lombok @RequiredArgsConstructor in a Java 21 Maven project.
The project compiles and installs successfully with Maven, but VS Code reports:
The Java feature 'Flexible Constructor Bodies' is only available with source level 25 and above
The source code itself does not use Flexible Constructor Bodies or any Java 25 syntax.
Environment
- VS Code Java extension:
[email protected](pre-release) - Project source level: Java 21
- Build system: Maven
- Lombok: used through Maven dependency / annotation processing
mvn install: SUCCESS
Minimal reproducer
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class Test {
private final String value;
}
Maven configuration:
<properties>
<maven.compiler.release>21</maven.compiler.release>
</properties>
Steps to reproduce
- Create a Maven project targeting Java 21.
- Add Lombok.
- Create a class containing a
finalfield. - Add Lombok
@RequiredArgsConstructor. - Open the project in VS Code with
[email protected]. - Let the Java Language Server finish importing and analysing the project.
Actual behavior
VS Code reports:
The Java feature 'Flexible Constructor Bodies' is only available with source level 25 and above
even though the source code does not contain a constructor using Flexible Constructor Bodies.
The error appears to be related to the constructor generated by Lombok.
Expected behavior
No Java 25 / Flexible Constructor Bodies diagnostic should be reported.
The generated constructor is equivalent to ordinary Java 21-compatible code:
public Test(String value) {
this.value = value;
}
Maven result
The project builds successfully:
mvn install
BUILD SUCCESS
Therefore the issue appears to be limited to VS Code / JDT Language Server diagnostics rather than the Maven compiler configuration.
Additional information
The same issue occurs in a real Spring project using:
@RequiredArgsConstructor
public class ProdCatalog {
private final DoubleThrower<RestFunctionsException, RuntimeException> thrower;
private final NamedParameterJdbcTemplate jdbc;
}
There is no explicit constructor in the class.
The diagnostic is therefore likely triggered during Lombok/JDT AST processing of the generated required-arguments constructor.
I am using the 1.57 pre-release because of a separate issue present in 1.56.0, so reverting to 1.56.0 is not currently a practical workaround.
Please let me know if a Java Language Server log, Lombok version, complete pom.xml, or a minimal reproducer repository would be useful.
- 主要語言
- TypeScript
- 星號
- 2.3k
- 分支
- 549
- 平均合併
- 7 小時 59 分鐘
- 30 天內合併 PR
- 5
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
redhat-developer/vscode-java 的其他 Issue
-
JDK_HOME can be sorted after lower-priority auto-detected JDK sources可能已有人在做 @shblue21 於 120 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 68/100
redhat-developer/vscode-java#4426 ·
維護者通常 1 天內回覆
-
bug
難度 3/5 1-2 天 新手友好度 45/100
redhat-developer/vscode-java#4539 ·
維護者通常 1 天內回覆
-
bug
難度 4/5 3-5 天 新手友好度 48/100
redhat-developer/vscode-java#4537 ·
維護者通常 1 天內回覆
-
bug need info
難度 4/5 3-5 天 新手友好度 35/100
redhat-developer/vscode-java#4520 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 25/100
redhat-developer/vscode-java#4517 · 1 則留言 ·
維護者通常 1 天內回覆
查看 redhat-developer/vscode-java 的全部 Issue
相似的 Issue
-
A hung CI job runs for 6 hours before it is cancelled可能已有人在做 @Olanetsoft 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
Olanetsoft/agent-lookout#110 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 90/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
thedotmack/claude-mem#4757 ·
維護者通常 1 天內回覆
-
🐛 bug 🗺️ MCP OAuth
難度 2/5 1-3 小時 新手友好度 62/100
LibreChat-AI/LibreChat#17077 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 75/100