`AddNullMarkedToPackageInfo` should also report absent packages
Problem
There is an experimental AddNullMarkedToPackageInfo bug pattern which reports package-info.java files which do not have @NullMarked applied to them.
It does help detect the issue of forgetting to add @NullMarked to the package, but in our experience a more common problem is forgetting to create package-info itself and thus marking it with @NullMarked which is currently not caught by the checker.
Solution
The suggestion is to also handle this scenario, probably also allowing the package to be explicitly @NullUnmarked so that there still is an escape hatch for unannotated packages.
Pseudo-code
Currently:
if (thePackage.exists()) {
if (!thePackage.isAnnotated(NullMarked.class)) {
reportError("No @NullMarked on packages %s", thePackage);
}
}
Suggested:
if (thePackage.exists()) {
if (!thePackage.isAnnotated(NullMarked.class)
&& !thePackage.isAnnotated(NullUnmarked.class)) {
reportError("No @NullMarked or @NullUnmarked on packages %s", thePackage);
}
} else {
reportError("No package info %s", thePackage);
}
FYI: NullAway have implemented their own equivalent with the described semantic aka RequireExplicitNullMarking
@JarvisCraft nice, so leaving AddNullMarkedToPackageInfo the way it works would allow us to expect annotations in case package-info exists and NullAway's RequireExpliciteNullMarking allows us to expect everything to be null marked. NullAway does not care whether it's module, package or class annotations. Personally, I no longer want the behavior of AddNullMarkedToPackageInfo to be changed.