NullAway
NullAway copied to clipboard
No error with `List<@Nullable String>`
Sorry if I miss something obvious, but I am not sure why NullAway 0.12.4 with Java 23, JSpecify mode enabled, and @NullMarked at package level does not report any error for this simple use case:
List<@Nullable String> listOfNullable = new ArrayList<>();
listOfNullable.add("foo");
listOfNullable.add(null);
listOfNullable.add("bar");
for (String element : listOfNullable) {
System.out.println(element.toLowerCase());
}
You can find a related repro on https://github.com/sdeleuze/jspecify-nullway-demo/tree/generics-with-list, where ./gradlew clean build does not report any error. I see the same behavior with Supplier<@Nullable T>. IDEA reports a warning as expected.
@sdeleuze can you show the example that uses Supplier<@Nullable T>? That might be a different issue. This could all be due to missing JDK models (#950) but I'm not sure yet.
See https://github.com/sdeleuze/jspecify-nullway-demo/tree/generics-with-supplier.
After further investigation this is in fact #950. That one is high on our priority list and I'll try to prioritize it even more, but it will take some time to address properly. I'm going to leave this issue open just to ensure we come back and test these specific scenarios.