Checker Framework argument.type.incompatible commons-lang3 误报

Checker Framework argument.type.incompatible false positive with commons-lang3

这是我的错误(是的,commons-lang3 jira 上有一个未解决的错误)。

  found   : @Initialized @Nullable Console
  required: @Initialized @NonNull Console
/Users/calebcushing/IdeaProjects/ppm/scaf/src/main/java/com/xenoterracide/scaf/PebbleTemplateProcessor.java:96: error: [argument.type.incompatible] incompatible argument for parameter str of toBoolean.
        if ( BooleanUtils.toBoolean( line ) ) {

我试着制作这个 src/java/main/org/apache/commons/lang3/BooleanUtils.astub 我试着把那个文件放在 src/main/resources/

package org.apache.commons.lang3;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;


public class BooleanUtils {

  @NonNull
  public static boolean toBoolean( @Nullable final String str);
}

但我将其添加到我的 gradle 配置中

  extraJavacArgs.addAll(listOf(
    "-Werror",
    "-Astubs=BooleanUtils.astub:stubs"
  ))

但我明白了

warning: Did not find stub file BooleanUtils.astub on classpath or within current directory
warning: Did not find stub file stubs on classpath or within current directory

我该如何解决这个问题?

我弄明白了,不感谢https://checkerframework.org/manual/#stub, the gradle plugin actually has a useful example of just this https://github.com/kelloggm/checkerframework-gradle-plugin#providing-checker-specific-options-to-the-compiler

你需要提供一个项目本身的路径,我就是这样做的。

  extraJavacArgs.addAll(listOf(
    "-Werror",
    "-Astubs=${rootDir}/config/checker/stubs/BooleanUtils.astub"
  ))

我使用 ${rootDir} 因为 ./config... 正在寻找 .gradle