LibraryModels.nullMarkedClasses() may not be checked for a class depending on when the class is first seen. Example:
class Bug {
void use(Object o) {}
void f(Object o) {
// First cause dataflow to be computed
use(o);
// then use a yet-unseen class marked by LibraryModels
use(toNull.apply(1)); // False negative - there should be a warning here but isn't
}
Function<Integer, @Nullable String> toNull = i -> null;
}
#903 added the ability for LibraryModels to make classes effectively @NullMarked, but this is not being used consistently.
CodeAnnotationInfo.get may be called with or without a Handler, and in either case it caches the result. In this example, while visiting the first use call, CodeAnnotationInfo.get is called with handler == null and so the java.util.function.Function class symbol is cached as unannotated.
Workaround: include the modeled class/package names in the NullAway:AnnotatedPackages option. In this example,
-XepOpt:NullAway:AnnotatedPackages=java.util.function.Function
would make the warning appear properly.