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
Property names are not available with Lombok and constructor binding #18730
Comments
@andrebraitc thanks for the report, I was able to reproduce it. I've debugged things a bit and I can see the model Lombok gives us contain When a |
I wonder if it's worth raising a Lombok enhancement request to generate parameter names that are more meaningful than |
Something else to mention is that if any property requires a default value, you'll have to generate the constructor anyway to provide it using |
@wilkinsona I agree but that suggestion would only work if Lombok ran before us. Our lombok support doesn't have that assumption at the moment, it reads the lombok annotations and infer what lombok will do, ignoring whether the actual bytcode has been produced or not. This very example is a bit more involved unfortunately as we'd have to infer what the constructor would look like. |
That seems like a reasonable requirement for us to introduce in a new minor release. As I understand it, it would remove a lot of complexity from the annotation processor and also remove the risk of our understanding of what Lombok will do getting out of sync with what Lombok actually does. |
I deleted my other GitHub account. Contact this account if you need. However, I'm not sure you can do an annotation processor that assumes another has already run before it, can you? Perhaps something that would attach itself to a different build phase than the other annotation processor? |
I've created projectlombok/lombok#2275 |
This has hopefully been addressed in Lombok by a combination of projectlombok/lombok#2497 and projectlombok/lombok#2556. The changes aren't in a release yet. |
I've tested a snapshot of the lombok build and I confirm that the issue is fixed. |
I case anyone else stumbles upon this - I updated lombok to 1.18.16 and still faced issues, spring now didn't output any field data at all when I had my class annotated with
Turns out the order in which annotation processors are defined (in my case in build.gradle) is important.
but if I switch the order like this, everything works fine
|
The output of the spring-boot-configuration-processor looks like below. It can't determine the names of any arguments. Those classes are standard classes with all final fields, annotated with lombok's
@Data
.The issue only happens if the constructor is created by lombok and the class is annotated with
@ConstructorBinding
. If I create the constructor by hand, then it all works just fine. If I make the class mutable and remove@ConstructorBinding
, it also works fine, even with a lombok-generated constructor.The text was updated successfully, but these errors were encountered: