Hi,
I would like to raise a question about ? super T where the generic parameter T is @NullMarked (therefore @NonNull) and the null-inclusiveness rule.
Do I understand correctly, that in a @NullMarked package, the following code should not issue any checker warning?
class A<V> {
void onSuccess(Consumer<? super V> consumer) {
consumer.accept(null);
}
}
And the below usage:
A<String> a = new A<>();
a.onSuccess(v -> System.out.println("Got v = " + v.toString()));
is expected to warn about v possibly being null (and clearly to throw an NPE at runtime)?
The actual context of the question is that a
similar API exists in reactor-core and I would like to best understand how it should be modelled (to be able to pass
null to the
Consumer) if any of the above assumptions that I have are incorrect.
Thank you in advance for the guidance!
Best regards,
Dariusz Jędrzejczyk