checker framework argument.type.与commons-lang3不兼容误报

to94eoyn  于 2021-07-06  发布在  Java
关注(0)|答案(1)|浏览(588)

这是我的错误(是的,commons-lang3jira上有一个开放的bug)。

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

如何解决此问题?
rpppsulh

rpppsulh1#

我想出来了,不,多亏了你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

相关问题