False positive "Flexible Constructor Bodies is only available with source level 25 and above" with Lombok @RequiredArgsConstructor on Java 21
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 52/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 2.3k
- Forks
- 549
- Ø Merge
- 8 Std. 20 Min.
- Gemergte PRs (30 T.)
- 6
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus redhat-developer/vscode-java
-
JDK_HOME can be sorted after lower-priority auto-detected JDK sourcesEvtl. vergeben @shblue21 hat das vor 115 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
redhat-developer/vscode-java#4426 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
redhat-developer/vscode-java#4537 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug need info
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
redhat-developer/vscode-java#4520 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
redhat-developer/vscode-java#4517 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Red Hat Not ActivatingOffenbug documentation
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 25/100
redhat-developer/vscode-java#4516 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in redhat-developer/vscode-java
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
siyuan-note/siyuan#20313 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 92/100
alunduil/projects-v2-sync#14 ·
-
Service process inherits the caller's cwd at first use, holding that folder open on Windows (EBUSY)Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
-
DevTools page styles leak into the host app in developmentEvtl. vergeben @onmax hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
nuxt-modules/better-auth#567 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag