So I'm getting this error from the nullness checker
> Task :compileJava
/Users/calebcushing/IdeaProjects/ppm/scaf/src/main/java/com/xenoterracide/scaf/PebbleTemplateProcessor.java:94: error: [argument.type.incompatible] incompatible argument for parameter obj of requireNonNull.
var console = Objects.requireNonNull( System.console() );
^ ^
this is complaining that System.console() could be null, which upon reading the javadoc is true. So I wrapped it in Objects.requireNonNull() now it's complaining that the argument to requireNonNull can't be null, which is obviously not true.
How do I tell NullnessChecker to ignore Objects.requireNonNull()? I'm fine with NPE's that are explicit, it's just the accidental ones I don't want. I believe checker already ships with a stub for this.
Realize I'm late to the game, but hopefully this will help others who land here after searching.
You can provide a stub file to Checker which overrides the default annotations.
For my own project, I created a new folder called checker alongside the src folder in one of my common projects, and dropped in a stub file java.util.Objects.astub with these contents:
package java.util;
import org.eclipse.jdt.annotation.Nullable;
public class Objects
{
public static <T> T requireNonNull(@Nullable T obj, String message);
}
Then I added this to our Gradle build:
checkerFramework {
extraJavacArgs = [
"-Astubs=${project(':my-project').file('checker')}"
]
}
…where my-project is the Gradle identifier for the project containing the new folder.
Checker will now load all *.astub files in that checker folder, and use the annotations provided there instead of the defaults. You can learn more at Using Stub Classes in the Checker documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With