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] delomboked class is missing @Builder.Default initialization in no args constructor #3053

Closed
Alexey007gold opened this issue Dec 1, 2021 · 3 comments · Fixed by #3103
Assignees
Milestone

Comments

@Alexey007gold
Copy link

Alexey007gold commented Dec 1, 2021

Describe the bug
There is a parent class

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class DTOParent {
    private String a;
}

and a child, using @SuperBuilder and @Builder.Default

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class DTO extends DTOParent {
    @Builder.Default
    private Integer number = 5;
}

The problem is that lombok and delombok generate different result.
Lombok on the left and delombok+compile on the right
image

Expected behavior
Lombok initializes the field annotated with @Builder.Default in no-args constructor, as I believe is expected
Delomboked code is missing that step

Version info (please complete the following information):

  • Lombok 1.18.22
@janrieke
Copy link
Contributor

janrieke commented Dec 2, 2021

How do you delombok? It looks like delombok uses Lombok <= 1.18.0.

@Alexey007gold
Copy link
Author

Alexey007gold commented Dec 2, 2021

How do you delombok? It looks like delombok uses Lombok <= 1.18.0.

> java -jar lombok.jar version
 v1.18.22 "Envious Ferret"
> java -jar lombok.jar delombok src/main/java -d src-delomboked

image

Screenshot in the issue description is showing two .class files, decompiled with Intellij. First one was compiled directly using lombok, the second one compiled from delomboked sources.

@Rawi01
Copy link
Collaborator

Rawi01 commented Jan 30, 2022

I still don't know how you managed to generate the code on the left side but I think that you actually found a bug. In 3987f54 support for @Builder.Default in @NoArgsConstructor was added. This works with javac if you use @Builder but not if you use @SuperBuilder. In ecj both annotations generate the initialization in the constructor so it most likely is an javac specific problem.

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

Successfully merging a pull request may close this issue.

4 participants