Describe the bug
In my project and libs I use custom nullability annotations that are almost one-to-one copies of spring ones, the purpose is to avoid depending on spring-core. I wanted to configure lombok to add them from fields to constructors and methods (getters/setters) for Value/Data annotated classes, but for some reason annotations are not added.
At the same time, when lombok is configured to use spring
or checkerframework
annotations they are added correctly.
In other words, sample class
@Value
public class Sample {
@Nullable
String prop1;
String prop2;
}
Produce different results depending on Nullable
annotation.
For spring with (lombok.addLombokGeneratedAnnotation=true, lombok.addNullAnnotations=spring
)
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
public final class Sample {
@Nullable
private final String prop1;
private final String prop2;
@Generated
public Sample(@Nullable String prop1, String prop2) {
this.prop1 = prop1;
this.prop2 = prop2;
}
@Nullable
@Generated
public String getProp1() {
return this.prop1;
}
For custom (lombok.addLombokGeneratedAnnotation=true, lombok.addNullAnnotations=CUSTOM:com.example.annotations.NonNull:com.example.annotations.Nullable
)
import com.example.annotations.NonNull;
import com.example.annotations.Nullable;
import lombok.Generated;
public final class Sample {
@Nullable
private final String prop1;
private final String prop2;
@Generated
public Sample(String prop1, String prop2) {
this.prop1 = prop1;
this.prop2 = prop2;
}
@Generated
public String getProp1() {
return this.prop1;
}
To Reproduce
I've prepared a sample project that shows the problem: https://github.com/zeldigas/lombok-custom-nullable-problem. In spring
module you can find usage of spring annotations and in custom
- custom ones that are defined in this module as well (for simplicity)
Expected behavior
Both modules in sample project are working the same way.
Version info (please complete the following information):
- Lombok version -
1.18.24
- Platform - javac temurin-11.0.17 on Windows 10