Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cannot find symbol errors when migrating to Spring Boot 3 due to @ConstrutorBinding changes #3331

Open
mwisnicki opened this issue Jan 16, 2023 · 12 comments

Comments

@mwisnicki
Copy link

mwisnicki commented Jan 16, 2023

Describe the bug
Lombok breaks silently if annotation without ElementType.TYPE is used on a type.
This results in "cannot find symbol" on every usage of lombok-generated symbols.
It's very hard to find the cause when hit with this bug.

To Reproduce

Spring Boot 3 dropped ElementType.TYPE from @ContructorBinding:
spring-projects/spring-boot@44b88cc#diff-b777c5786f45759cb351f1d367175439ee177f65a14bc6677886c1cf93e6e582

It's easy to hit this bug when migrating Spring Boot 2.x codebase that has code like

@Data
@ContructorBinding
@ConfigurationProperties("foo")
class Foo {
  int bar;
}

To fix, @ConstructorBinding should be replaced with @RequiredArgsConstructor(onConstructor_={@ConstructorBinding}) or removed altogether.

Expected behavior
Lombok should fail fast and log root cause of the problem.

Version info (please complete the following information):

  • Lombok version: 1.8.24
  • Platform: azul-jdk 17.0.5
@mrDoctorWho
Copy link

I actually faced this issue too, using lombok 1.8.26, Java 17 and Spring Boot 3.0.4. Lombok just wouldn't work and the compiler just complained "cannot find symbol".

@saschakr
Copy link

saschakr commented Apr 5, 2023

Same issue here

openjdk 17.0.6 2023-01-17 LTS
OpenJDK Runtime Environment Zulu17.40+19-CA (build 17.0.6+10-LTS)
OpenJDK 64-Bit Server VM Zulu17.40+19-CA (build 17.0.6+10-LTS, mixed mode, sharing)

Lombok: 1.18.26
Spring Boot: 3.0.4

@Rawi01
Copy link
Collaborator

Rawi01 commented May 2, 2023

This is a javac problem. For some reason the compiler does not call annotation processors like lombok if unrecoverable errors occour. One of these errors are annotations on the wrong element. A different example is a static import for non-existing methods (see #2044).

As an annotation processor lombok can not handle these cases but it is possible for a compiler plugin. I created a PoC yesterday to test if that works and it looks good so far. As this is also useful for other annotation processors I might publish it as standalone plugin too.

@janrieke
Copy link
Contributor

janrieke commented May 3, 2023

Let me know if you need some beta testers. I'll try getting a few of my colleagues on board then.

@joecotton-wk
Copy link

Also seeing this, would love to see it fixed.

@Rawi01
Copy link
Collaborator

Rawi01 commented May 10, 2023

It is still WIP but if you want to try it you can download the current build here and add -Xplugin:Lombok as compiler argument.

@healthy-interac
Copy link

Is there any progress on this? Effectively it blocks us from migrating to SpringBoot 3.0.x, but maybe there is some workaround lombok team can offer?

@dstango
Copy link

dstango commented Sep 8, 2023

Is there any progress on this? Effectively it blocks us from migrating to SpringBoot 3.0.x, but maybe there is some workaround lombok team can offer?

Did you try the wip compiler plugin?

@Rawi01
Copy link
Collaborator

Rawi01 commented Sep 8, 2023

As far as I know lombok works fine with Spring Boot 3, I use it in multiple projects without any problems.

The compiler plugin only change how the compiler handles annotation processing if an unrecoverable error occurs.

@adnangul
Copy link

adnangul commented Oct 4, 2023

I actually faced this issue too, using lombok 1.8.26, Java 17 and Spring Boot 3.0.4. Lombok just wouldn't work and the compiler just complained "cannot find symbol".

were you able to find any fix?

@dtsukinovsky
Copy link

I actually faced this issue too, using lombok 1.8.26, Java 17 and Spring Boot 3.0.4. Lombok just wouldn't work and the compiler just complained "cannot find symbol".

were you able to find any fix?

Try this: find all the not-annotation-related problems (e.g. compilation errors or jakarta/javax dependency names to be updated) and fix them first. It seems lombok just "fails fast" if any issue in your application exists and does not process any annotation until there is a clean compilation can be passed. This is the reason you see a lot of "cannot find symbol" errors.

@adnangul
Copy link

adnangul commented Oct 5, 2023

@dtsukinovsky First of all thanks for responding, I do agree with you and I know the problem could be somewhere else, and trying to figure it out from all possible perspectives. I'm able to finish all the compilation errors, the only two kinds of problems left, related to "cannot find symbol".

  1. JPA metamodels are not being generated
  2. Lombok related

I have been trying log of things, and now my IDEA and mvn are showing different errors. MVN is still showing both errors above but IntelliJ IDEA only complaining about JPA-related stuff

java: Error generating JPA metamodel: begin 14, end -1, length 30

However, unless MVN problem doesn't resolves, I can't move with deployment pipelines etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants