projectlombok / lombok

Very spicy additions to the Java programming language.
https://projectlombok.org/
Other
12.83k stars 2.37k forks source link

[BUG] Missing generated annotation on record #3339

Closed carlphilipp closed 1 year ago

carlphilipp commented 1 year ago

Describe the bug When using:

lombok.addLombokGeneratedAnnotation = true

and:

@Builder
public record UserRecord(String name) {}

I would expect that the generated code contains the @Generated annotation on the method:

public String name() {
   return this.name;
}

Now, I guess this is debatable, as this is a method part of the record. I'm not too sure how that works internally, but maybe the other solution would be to not have that method at all in the generated record?

The root of the issue here is that by switching from normal class with @Builder to record with @Builder, we end-up having some code not covered with JaCoCo. At first sight it did not make a lot of sense why.

To Reproduce I have created a sample project here. Just run

./gradlew clean build 

And you can check the generated classes and also jacoco report.

Version info (please complete the following information):

Rawi01 commented 1 year ago

Lombok marks everything it generates with this annotation. Why should it do the same for record components? This is a problem in JaCoCo and will also happen without lombok.

pzygielo commented 1 year ago
carlphilipp commented 1 year ago

Thanks @pzygielo I bumped jacoco to latest snapshot and it seems that the report is correct now!