Checker Framework参数.type.incompatible与commons-lang3的误报 [英] Checker Framework argument.type.incompatible false positive with commons-lang3
问题描述
这是我的错误(是的,commons-lang3 jira中有一个打开的错误).
Here's my error (and yes there is an open bug on 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/
I tried making this src/java/main/org/apache/commons/lang3/BooleanUtils.astub
and I tried putting that file in 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配置中
but I and adding this to my gradle config
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 ,gradle插件实际上有一个有用的示例,说明了
I figured it out, no thanks to 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
您需要提供项目本身的路径,这就是我所做的.
you need to provide a path from the project itself, this is what I did.
extraJavacArgs.addAll(listOf(
"-Werror",
"-Astubs=${rootDir}/config/checker/stubs/BooleanUtils.astub"
))
我使用 $ {rootDir}
是因为 ./config ...
正在查找 .gradle
I used ${rootDir}
because ./config...
was looking in .gradle
这篇关于Checker Framework参数.type.incompatible与commons-lang3的误报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!