vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

1.42.0 with Lombok @Builder does not work with records

Open tienipia opened this issue 6 months ago • 18 comments
trafficstars

Hi. I've got jsut update vscode-java 1.41.1 to 1.42.0

before update, it's okay,

Image

import io.tienipia.model.Template;
import java.util.List;
import lombok.Builder;

@Builder
record TemplateResponse(List<Template> templates) {}

but after upgrade to 1.42.0

Image

The constructor TemplateResponse() is undefinedJava(134217858)

It occurs every vscode with 1.42.0

of course, manual build with maven works fine.

mvn clean compile

tienipia avatar May 16 '25 06:05 tienipia

lombok version does not affect to this issue.

    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <!-- <version>1.18.38/version> NOT WORKING -->
      <!-- <version>1.18.36</version> NOT WORKING  -->
      <!-- <version>1.18.34</version> NOT WORKING  -->
      <scope>provided</scope>
    </dependency>

1.18.38 1.18.36 1.18.34

tienipia avatar May 16 '25 09:05 tienipia

Is the issue specifically with annotating records or does it occur on other type declarations as well ?

Update: I can confirm it seems to be an issue with records. @Builder on other type declarations worked.

rgrunber avatar May 16 '25 13:05 rgrunber

+1 same issue spotted in the v1.42.0

pastouret avatar May 16 '25 15:05 pastouret

I've the same issue in v1.42.0

jdgc12 avatar May 16 '25 17:05 jdgc12

I wish I found this before completely uninstalling and reinstalling vs code. I rolled back the extension to the previous stable and things are back to normal.

philipfong avatar May 16 '25 23:05 philipfong

Seems to be there in prerelease 1.43.2025051708 as well. In previous 1.41.1 the problem does not appear.

linusbrimstedtellos avatar May 17 '25 20:05 linusbrimstedtellos

The same problem happens to me after updating vscode from 1.98 to 1.100.2 in Kali linux.

logslie avatar May 19 '25 09:05 logslie

I have the same issue v1.42.0

shalska avatar May 19 '25 10:05 shalska

Same is happening for me. I am using VSCode Version: 1.100.2 (Universal). I also tried providing my own lombok.jar using java.jdt.ls.vmargs but it did not work.

This broke my entire workflow, have to resort to using IntelliJ.

ankurkesharwani avatar May 19 '25 15:05 ankurkesharwani

Same is happening for me. I am using VSCode Version: 1.100.2 (Universal). I also tried providing my own lombok.jar using java.jdt.ls.vmargs but it did not work.

This broke my entire workflow, have to resort to using IntelliJ.

FYI @ankurkesharwani You can force the red-hat extension version to 1.41.1 to avoid switching to IntelliJ

Image

pastouret avatar May 19 '25 15:05 pastouret

Same issue here. Rolled back to 1.41.1 fixed it.

adolfo-cia avatar May 19 '25 20:05 adolfo-cia

We were using @With with records and it also broke with 1.42.0. Rollback to 1.41.1 worked.

danedb avatar May 21 '25 07:05 danedb

Thanks a bunch @pastouret !

DylanMerigaud avatar May 21 '25 07:05 DylanMerigaud

thanks a lot! @pastouret. Downgrading to 1.41.1 solved the issue!

sebadere avatar May 25 '25 22:05 sebadere

Same here, have to downgrade to make it work. PLZ fix it

JamesChen407 avatar Jun 05 '25 20:06 JamesChen407

Same here; also couldn't use any of the ide tools to compile, run unit or integration tests. rolling back to 1.41.1 fixed the linter, compile, and test explorer runner.

okeylanders avatar Jun 06 '25 15:06 okeylanders

I've built Lombok from their development branch, with the PR from https://github.com/projectlombok/lombok/pull/3888 applied. It can be accessed at https://github.com/rgrunber/lombok/releases/download/pull-3888/lombok-1.18.39.jar ( https://github.com/rgrunber/lombok/releases/tag/pull-3888 ) . From what I can tell, it should solve the issue. People are free to try it out and confirm. There's a few ways to do this, after updating to vscode-java 1.42.0 :

Option 1 : Use in place of your existing project's Lombok library.

If Lombok is referenced in the configuration of your build tools (eg. pom.xml, build.gradle), you'll have to install it first so your build system can detect it.

For a Maven project :

$ mvn install:install-file -Dfile=/home/user/Downloads/lombok-1.18.39.jar -DgroupId=org.projectlombok -DartifactId=lombok -Dversion=1.18.39 -Dpackaging=jar

After that you can update your pom file(s) to refer to Lombok 1.18.39. Finally, when you load your project, you just need to make sure to "Use Project's Version" over the extension's and reload the project.

Image

Image

Option 2 : Replace vscode-java's embedded lombok library

vscode-java provides a version of Lombok and it is used when Lombok is detected on the classpath. You can always switch to your own project's Lombok version (see above), but this is the default one.

~/.vscode/extensions/redhat.java-1.42.0-${platform}/lombok/lombok-1.18.36.jar

If you move the new jar into this location :

rm ~/.vscode/extensions/redhat.java-1.42.0-linux-x64/lombok/lombok-1.18.36.jar
mv ~/Downloads/lombok-1.18.39.jar ~/.vscode/extensions/redhat.java-1.42.0-linux-x64/lombok/

then your vscode-java extension will now use that by default which should fix any issues. You would just need to confirm your project is set to "Use Extension's Version" and not the project's version.

rgrunber avatar Jun 09 '25 13:06 rgrunber

I can confirm the @rgrunber fix is working fine in Eclipse 2025-06. My installation steps also were:

  1. Copy lombok-1.18.39.jar into eclipse directory.
  2. Replace in eclipse.ini the entry: -javaagent:/opt/apps/eclipse/plugins/org.projectlombok.agent_1.18.38/lombok.jar for the line -javaagent:/opt/apps/eclipse/lombok-1.18.39.jar
  3. Restart eclipse

Thank you

barrenaedu avatar Jun 14 '25 16:06 barrenaedu

I've embedded the development version of Lombok (towards 1.18.39) along with the PR that fixes this issue into vscode-java, rather than using a released (1.18.38) version that lacks the fix. This should resolve the issue in pre-releases and the upcoming 1.43.0 release without needing to perform any of the steps at https://github.com/redhat-developer/vscode-java/issues/4050#issuecomment-2955782487 .

rgrunber avatar Jun 24 '25 15:06 rgrunber

This must come as a huge relief for many developers who either struggled with this issue or weren’t even aware of the cause. Thank you for resolving it — your work is truly appreciated. @rgrunber

tienipia avatar Jun 25 '25 08:06 tienipia

Can there be some kind of lombok interoperability testing establish before releasing a plugin update? This happens ever so often.

stefanrybacki avatar Jun 27 '25 06:06 stefanrybacki

Hi! I've just upgraded to 1.43.0 released yesterday, but I'm still experiencing similar issues with Lombok. I tried two Lombok versions - the extension's one and the one from my project. I'm getting similar compilation errors again. Can anyone confirm 1.43.0 resolved the issue? 🤔

dsokal avatar Jun 27 '25 07:06 dsokal

It's OK for me with 1.43 version (I was using pre-release until today and switch to release this morning).

Image

Maze-fr avatar Jun 27 '25 08:06 Maze-fr

Can there be some kind of lombok interoperability testing establish before releasing a plugin update? This happens ever so often.

This is the responsibility of the Lombok project. Lombok uses internal Eclipse JDT APIs which change from time to time, when using such internal code it is important to monitor changes upstream and adapt to them proactively. The fact that a PR fixing this issue in Lombok itself has remained un-merged for a month points to a larger issue of inactive maintenance from Lombok's side.

ericwill avatar Jun 27 '25 13:06 ericwill

@ericwill as I understood the comment from rgrunder lombok is also shipped with vscode-java in a version that is causing this issue.

stefanrybacki avatar Jul 04 '25 12:07 stefanrybacki

That was done as one-time effort to resolve user complaints because the Lombok project maintainers are slow to react (the PR to fix the issue in Lombok is still open!). VS Code Java does not maintain Lombok.

ericwill avatar Jul 04 '25 13:07 ericwill

@ericwill got you, if there just would exist a lombok alternative

stefanrybacki avatar Jul 06 '25 09:07 stefanrybacki