I have a problem when I try to use @Nullable and AtomicReferenceFieldUpdater , this snippet:
class A {
static final AtomicReferenceFieldUpdater<A, @Nullable Object> RESULT_UPDATER =
AtomicReferenceFieldUpdater.newUpdater(A.class, Object.class, "result");
volatile @Nullable Object result;
A() {
System.out.println("Set operation result " + RESULT_UPDATER.compareAndSet(this, null, new Object()));
}
}
Gives the following error:
/nullaway-mismatched-nullability/src/main/java/org/example/A.java:8: error: [NullAway] Cannot assign from type AtomicReferenceFieldUpdater<A, Object> to type AtomicReferenceFieldUpdater<A, @Nullable Object> due to mismatched nullability of type parameters
static final AtomicReferenceFieldUpdater<A, @Nullable Object> RESULT_UPDATER =
^
The repository with the reproducible example can be found here
https://github.com/violetagg/nullaway-mismatched-nullability