You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False positive "Flexible Constructor Bodies is only available with source level 25 and above" with Lombok @RequiredArgsConstructor on Java 21 #4521
I managed to replicate this. It's also filed upstream in lombok: projectlombok/lombok#4084 . vscode-java reuses parts of Eclipse. Lombok support in Eclipse relies on a bunch of hacks to the internals of Eclipse's Java compiler (ECJ), so sometimes when there's new features, fixes or refactorings in that compiler, it breaks Lombok.
From my past experience, lombok is slow to address these things, but it seems like one of the committers someone who contributes to the project frequently has assigned themselves, so maybe it'll be addressed at some point.
I managed to replicate this. It's also filed upstream in lombok: projectlombok/lombok#4084 . vscode-java reuses parts of Eclipse. Lombok support in Eclipse relies on a bunch of hacks to the internals of Eclipse's Java compiler (ECJ), so sometimes when there's new features, fixes or refactorings in that compiler, it breaks Lombok.
From my past experience, lombok is slow to address these things, but it seems like one of the committers someone who contributes to the project frequently has assigned themselves, so maybe it'll be addressed at some point.
Tried without success: restarting the language server, cleaning the Java workspace, reinstalling the Java Extension Pack, upgrading Lombok.
Disabling built-in Lombok support and pointing -javaagent at lombok-1.18.42.jar removed the Flexible Constructor Bodies error, but Lombok then didn't take effect ("The blank final field ... may not have been initialized").
I had the same issue with Java 21 and Lombok 1.18.46. Gradle compiled fine, but VS Code kept showing this error. Downgrading the Java extension to 1.56.0 fixed it for me. Thanks for sharing the workaround!
Apparently, 1.57 only supports java25 or above. Our project is java21, we had to downgrade to 1.56. NOTE, java21 is an LTS, it should be available for a few more years at least. Furthermore, it is a requirement imposed upon us by the (big-big corporate) client, we are unable to change it in any reasonably short time frame.
I’m using Java 21 and everything was good until I updated, and now I’m getting the same error as everyone here. Will have to downgrade to 1.56.0 for what i see.
It’s very likely that Cursor and VS Code have shipped or automatically updated to Red Hat Java 1.57.0. You might want to try rolling back to version 1.56.0.
How to roll back to version 1.56.0:
1-) Open Extensions: Click the Extensions icon (four squares).
2-) Find the Java extension: Type @installed redhat java or Language Support for Java(TM) by Red Hat in the search box. The publisher should be Red Hat.
3-) Open its detail page: Click the extension itself (not just the list row) to view its full description, version number, and other details.
4-) Install another version: Click the gear ⚙️ icon on the extension entry (sometimes located in the detail page header). Select Install Another Version… from the menu.
5-) Select version 1.56.0: Choose 1.56.0 and avoid 1.57.x. Confirm the installation and reload Cursor if prompted.
Apparently, 1.57 only supports java25 or above. Our project is java21, we had to downgrade to 1.56. NOTE, java21 is an LTS, it should be available for a few more years at least. Furthermore, it is a requirement imposed upon us by the (big-big corporate) client, we are unable to change it in any reasonably short time frame.
I'm using Java 25 and I had to downgrade to 1.56 too :(
I'm using Java 25 and I had to downgrade to 1.56 too :(
Well, the specific error seems to affect both java versions. The version limitation in 1.57 is then strange coincidence :) But still a problem for a lot of projects in itself.
Well, the specific error seems to affect both java versions. The version limitation in 1.57 is then strange coincidence :) But still a problem for a lot of projects in itself.
jdtls, the language server that powers vscode-java's features, requires Java 25 to run as of the latest version. vscode-java bundles a copy of the JRE it needs to run jdtls (i.e. 1.57.0 bundles a copy of Java 25), so you shouldn't need to install it yourself for the extension to work. You should still be able to work on projects as old as Java 8 with vscode-java.
My understanding is that the problems being reported here are caused by lombok; lombok doesn't support the latest version of Eclipse's internal compiler, which this extension makes use of.
I think downgrading to 1.56.0 is the best path forward if you're working with lombok. There's not much we can do on our end to address this until this is fixed upstream lombok. Lombok has been fairly slow to adopt to the latest release of Eclipse's internal compiler, so this might take a while.
...
You should still be able to work on projects as old as Java 8 with vscode-java.
...
There's not much we can do on our end to address this until this is fixed upstream lombok. Lombok has been fairly slow to adopt to the latest release of Eclipse's internal compiler, so this might take a while.
23. > Well, the specific error seems to affect both java versions. The version limitation in 1.57 is then strange coincidence :) But still a problem for a lot of projects in itself.
jdtls, the language server that powers vscode-java's features, requires Java 25 to run as of the latest version. vscode-java bundles a copy of the JRE it needs to run jdtls (i.e. 1.57.0 bundles a copy of Java 25), so you shouldn't need to install it yourself for the extension to work. You should still be able to work on projects as old as Java 8 with vscode-java.
My understanding is that the problems being reported here are caused by lombok; lombok doesn't support the latest version of Eclipse's internal compiler, which this extension makes use of.
I think downgrading to 1.56.0 is the best path forward if you're working with lombok. There's not much we can do on our end to address this until this is fixed upstream lombok. Lombok has been fairly slow to adopt to the latest release of Eclipse's internal compiler, so this might take a while.
There has been some progress upstream: eclipse-jdt/eclipse.jdt.core#5489 identified the underlying Lombok/ECJ compatibility issue, and a backward-compatibility fix has already been merged in PR #5490.
While Lombok is also working on adapting to the new ECJ AST structure, upgrading Lombok may not be feasible for projects with pinned dependencies. Currently, we having to downgrade vscode-java to 1.56.0 as a workaround.
Could the next vscode-java release include a JDT Core/ECJ build containing this compatibility fix? This would help restore compatibility with existing Lombok versions without requiring changes to project dependencies.
I can confirm this issue with redhat.java 1.57.0 on Java 17 and Lombok 1.18.36. In our case the problem is more severe than an incorrect diagnostic: the Eclipse/JDT compilation performed by VS Code actually produces an invalid .class file for a Lombok-generated builder.
We get:
java.lang.ClassFormatError: Invalid method Code length 0 in class file
nl/rivm/dvp/rvp/machine/model/ComponentPlanning$ComponentPlanningBuilder
Inspecting the generated class with javap -v shows that with redhat.java 1.57.0 the Lombok-generated constructor has an empty Code attribute:
We isolated this from Maven compilation. After deleting the generated builder .class, merely touching ComponentPlanning.java while VS Code is running causes the Java language server to regenerate the invalid class.
Downgrading only redhat.java from 1.57.0 to 1.56.0 and repeating exactly the same test produces valid bytecode:
Activity
datho7561 commentedon Oct 5, 2026
I managed to replicate this. It's also filed upstream in lombok: projectlombok/lombok#4084 . vscode-java reuses parts of Eclipse. Lombok support in Eclipse relies on a bunch of hacks to the internals of Eclipse's Java compiler (ECJ), so sometimes when there's new features, fixes or refactorings in that compiler, it breaks Lombok.
From my past experience, lombok is slow to address these things, but it seems like
one of the committerssomeone who contributes to the project frequently has assigned themselves, so maybe it'll be addressed at some point.tomas-bucki-pds commentedon Oct 5, 2026
@datho7561 thanks, in the meantime we downgraded to 1.55 where no such problem appears.
acarcher commentedon Oct 13, 2026
Same issue on the stable release.
Environment
Notes
-javaagentat lombok-1.18.42.jar removed the Flexible Constructor Bodies error, but Lombok then didn't take effect ("The blank final field ... may not have been initialized").Kerbores commentedon Oct 14, 2026
me too!
danrriv commentedon Oct 14, 2026
I had the same issue with Java 21 and Lombok 1.18.46. Gradle compiled fine, but VS Code kept showing this error. Downgrading the Java extension to 1.56.0 fixed it for me. Thanks for sharing the workaround!
chrispyleLAC commentedon Oct 14, 2026
Seeing the same thing, but on Java 17 and with other Lombok annotations, so it doesn't look specific to
@RequiredArgsConstructoror Java 21.Environment
lombok-1.18.39-4050.jarJavaLanguageVersion.of(17), Lombok 1.18.30Symptoms
~250 errors across 56 files:
The Java feature 'Flexible Constructor Bodies' is only available with source level 25 and aboveEvery error is reported on a Lombok annotation (
@Getter/@Builder/@Jacksonized). Example:maomaoke commentedon Oct 14, 2026
germandsantana commentedon Oct 14, 2026
similar issue, java 25 project with lombok
all lombok SuperBuilder don't compile
Cannot read field xxx in an early construction context
zhaiang commentedon Oct 14, 2026
same question in java17 project
TotoShampoin commentedon Oct 14, 2026
Welp, this bug forced me to downgrade back to 1.56.0
zhaiang commentedon Oct 14, 2026
yes, back to 1.56.0
chrispyleLAC commentedon Oct 14, 2026
Yup, I downgraded the extension back to 1.56.0 too!
JimmyRampage commentedon Oct 14, 2026
Same problem here, and downgrading solve the problem...
javobalazs commentedon Oct 14, 2026
Apparently, 1.57 only supports java25 or above. Our project is java21, we had to downgrade to 1.56. NOTE, java21 is an LTS, it should be available for a few more years at least. Furthermore, it is a requirement imposed upon us by the (big-big corporate) client, we are unable to change it in any reasonably short time frame.
MrItzreal commentedon Oct 14, 2026
I’m using Java 21 and everything was good until I updated, and now I’m getting the same error as everyone here. Will have to downgrade to 1.56.0 for what i see.
It’s very likely that Cursor and VS Code have shipped or automatically updated to Red Hat Java 1.57.0. You might want to try rolling back to version 1.56.0.
How to roll back to version 1.56.0:
1-) Open Extensions: Click the Extensions icon (four squares).
2-) Find the Java extension: Type @installed redhat java or Language Support for Java(TM) by Red Hat in the search box. The publisher should be Red Hat.
3-) Open its detail page: Click the extension itself (not just the list row) to view its full description, version number, and other details.
4-) Install another version: Click the gear ⚙️ icon on the extension entry (sometimes located in the detail page header). Select Install Another Version… from the menu.
5-) Select version 1.56.0: Choose 1.56.0 and avoid 1.57.x. Confirm the installation and reload Cursor if prompted.
TIS-liuz commentedon Oct 14, 2026
I encountered the same issue, and downgrading to version 1.56.0 fixed it for me.
JimmyRampage commentedon Oct 14, 2026
I'm using Java 25 and I had to downgrade to 1.56 too :(
javobalazs commentedon Oct 14, 2026
Well, the specific error seems to affect both java versions. The version limitation in 1.57 is then strange coincidence :) But still a problem for a lot of projects in itself.
2buisson commentedon Oct 14, 2026
Here is what worked for me:
datho7561 commentedon Oct 14, 2026
jdtls, the language server that powers vscode-java's features, requires Java 25 to run as of the latest version. vscode-java bundles a copy of the JRE it needs to run jdtls (i.e. 1.57.0 bundles a copy of Java 25), so you shouldn't need to install it yourself for the extension to work. You should still be able to work on projects as old as Java 8 with vscode-java.
My understanding is that the problems being reported here are caused by lombok; lombok doesn't support the latest version of Eclipse's internal compiler, which this extension makes use of.
I think downgrading to 1.56.0 is the best path forward if you're working with lombok. There's not much we can do on our end to address this until this is fixed upstream lombok. Lombok has been fairly slow to adopt to the latest release of Eclipse's internal compiler, so this might take a while.
javobalazs commentedon Oct 14, 2026
Got it, thx.
Hou-Xiaoxuan commentedon Oct 14, 2026
There has been some progress upstream: eclipse-jdt/eclipse.jdt.core#5489 identified the underlying Lombok/ECJ compatibility issue, and a backward-compatibility fix has already been merged in PR #5490.
While Lombok is also working on adapting to the new ECJ AST structure, upgrading Lombok may not be feasible for projects with pinned dependencies. Currently, we having to downgrade vscode-java to 1.56.0 as a workaround.
Could the next vscode-java release include a JDT Core/ECJ build containing this compatibility fix? This would help restore compatibility with existing Lombok versions without requiring changes to project dependencies.
hanjoosten commentedon Oct 14, 2026
I can confirm this issue with
redhat.java1.57.0 on Java 17 and Lombok 1.18.36. In our case the problem is more severe than an incorrect diagnostic: the Eclipse/JDT compilation performed by VS Code actually produces an invalid.classfile for a Lombok-generated builder.We get:
Inspecting the generated class with
javap -vshows that withredhat.java1.57.0 the Lombok-generated constructor has an emptyCodeattribute:We isolated this from Maven compilation. After deleting the generated builder
.class, merely touchingComponentPlanning.javawhile VS Code is running causes the Java language server to regenerate the invalid class.Downgrading only
redhat.javafrom 1.57.0 to 1.56.0 and repeating exactly the same test produces valid bytecode:After the downgrade, the
ClassFormatErrordisappears and the affected Cucumber tests run normally from VS Code Testing.Environment:
So this issue can affect not only editor diagnostics, but also the bytecode emitted by the incremental Eclipse/JDT compilation.