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] SuperBuilder can cause non-reproducible builds #3655

Open
Kidlike opened this issue Apr 16, 2024 · 4 comments
Open

[BUG] SuperBuilder can cause non-reproducible builds #3655

Kidlike opened this issue Apr 16, 2024 · 4 comments

Comments

@Kidlike
Copy link

Kidlike commented Apr 16, 2024

Describe the bug
When using @SuperBuilder in my project, there is some random behavior introduced, on the generated bytecode of classes annotated with @SuperBuilder, which causes the builds to be non-reproducible

To Reproduce
I have tried to create sample projects, but I can't pinpoint the root cause of the issue...

Here is the diffoscope output: diffoscope.txt

From what I have observed, there (at least) 2 key differences:

  1. Sometimes Lombok inserts a checkcast instruction, but not always.
  2. Sometimes the number/id of the target class is plus or minus 2 between builds (e.g. for invokevirtual)

Version info (please complete the following information):

  • Lombok version: 1.18.30
  • Platform: Linux, java 17.0.4.1 (but same results with 21.0.1)

Additional context

@Kidlike Kidlike changed the title [BUG] SuperBuilder causes non-reproducible builds [BUG] SuperBuilder can cause non-reproducible builds Apr 16, 2024
@janrieke
Copy link
Contributor

janrieke commented Apr 17, 2024

This seems to me like a compiler issue. The checkcast diff (in Placement$PlacementBuilder.class) is within the bridge self method. That method is not generated by lombok, but injected by javac to bridge the gap between overridden methods with different return types (covariant return types). In your case, it bridges between protected abstract B self(); and protected BasicCardSuper$BasicCardSuperBuilder self();.

When I compile similar @SuperBuilder classes, I only get the version without checkcast.

Could it be that you are accidently using different compilers?

@janrieke
Copy link
Contributor

Are there any other annotation processors involved?

@janrieke
Copy link
Contributor

There is another weird thing going on: In the lombok-generated constructor Placement(PlacementBuilder<?, ?> b) there also is an additional checkcast before the actual call to the super-constructor. That's weird because it should be statically known to the compiler that this checkcast can never fail. (That additional checkcast is also the reason for the diff in the constant pool.) It seems that the compiler somehow lost the information that PlacementBuilder extends BasicCardSuperBuilder.

@Kidlike
Copy link
Author

Kidlike commented Apr 21, 2024

hey @janrieke, thanks for your interest!

Could it be that you are accidently using different compilers?

Not that I'm aware of. I run this from command line with maven.

Are there any other annotation processors involved?

Yes:

  1. lombok
  2. mapstruct-processor
  3. lombok-mapstruct-binding

Everything is latest version.

I would expect that Mapstruct would not modify my DTOs though... Is that a wrong assumption?

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

2 participants