Skip to content

No error with List<@Nullable String> #1161

@sdeleuze

Description

@sdeleuze

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions