0

这是我的错误(是的,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

我该如何解决这个问题?

4

1 回答 1

0

我想通了,不感谢https://checkerframework.org/manual/#stub,gradle 插件实际上有一个有用的例子就是这个https://github.com/kelloggm/checkerframework-gradle-plugin#providing-检查器特定选项到编译器

您需要提供项目本身的路径,这就是我所做的。

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

我用过${rootDir},因为./config...在看.gradle

于 2020-12-11T04:46:21.493 回答