-
Notifications
You must be signed in to change notification settings - Fork 317
Closed
Description
Background
Originally, I was using JSR 305 for @Nullable
annotation and was recently trying to migrate to JSpecify, but with JSpecify's @Nullable
annotation, Lombok handling of NullAway written in the README does not seem to work well. I thought it was quite possible that this was intentional JSpecify support in NullAway, but it makes the transition to JSpecify for projects using NullAway very difficult.
So I would like to know about the following:
- Is this behavior of JSpecify intentional? or bug?
- Is there a workaround for the combination of NullAway + JSpecify + Lombok?
Reproducer
Below is a sample code that I have tried. (The following code is committed to my github repo as reproducer)
public final class NullableWithLombok {
public void jsr305() {
new JSR305NullableValue(null);
}
public void jakartaAnnotation() {
new JakartaAnnotationNullableValue(null);
}
public void jetbrains() {
new JetbrainsNullableValue(null);
}
public void checkerframework() {
new CheckerframeworkNullableValue(null);
}
public void jspecify() {
new JSpecifyNullableValue(null);
}
@lombok.Value
private static class JSR305NullableValue {
@javax.annotation.Nullable
Object value;
}
@lombok.Value
private static class JakartaAnnotationNullableValue {
@jakarta.annotation.Nullable
Object value;
}
@lombok.Value
private static class JetbrainsNullableValue {
@org.jetbrains.annotations.Nullable
Object value;
}
@lombok.Value
private static class CheckerframeworkNullableValue {
@org.checkerframework.checker.nullness.qual.Nullable
Object value;
}
@lombok.Value
private static class JSpecifyNullableValue {
@org.jspecify.annotations.Nullable
Object value;
}
This code will make the . /gradlew check
will report an error due to NullAway as shown below.
$ ./g check
> Task :nullaway-lombok:compileJava FAILED
/Users/keiji.muraishi/workspace/smartnews/kjim/nullaway-example/nullaway-lombok/src/main/java/org/example/NullableWithLombok.java:22: error: [NullAway] passing @Nullable parameter 'null' where @NonNull is required
new JSpecifyNullableValue(null);
^
(see http://t.uber.com/nullaway )
1 error
FAILURE: Build failed with an exception.
Metadata
Metadata
Assignees
Labels
No labels