这是我的错误
found : @Initialized @Nullable String
required: @Initialized @NonNull String
/Users/calebcushing/IdeaProjects/ppm/scaf/src/main/java/com/xenoterracide/scaf/Application.java:21: error: [initialization.fields.uninitialized] the constructor does not initialize fields: arg, args, dir
public final class Application implements Runnable {
^
3 errors
这些都是由picocli初始化的,所以我添加了suppresswarnings,不知道为什么它仍然在发生。
@SuppressWarnings({ "NullAway.Init", "initialization.fields.uninitialize" })
@CommandLine.Parameters( index = "0", description = "first configuration directory" )
private String arg;
@SuppressWarnings({ "NullAway.Init", "initialization.fields.uninitialize" })
@CommandLine.Parameters(
index = "1..*",
description = "path to configuration directories separated by space"
)
private List<String> args;
@SuppressWarnings({ "NullAway.Init", "initialization.fields.uninitialize" })
@CommandLine.Option(
names = {"-d", "--dir"},
defaultValue = ".config/scaf",
showDefaultValue = CommandLine.Help.Visibility.ALWAYS,
description = "Directory path from the current working directory. " +
"Templates and configs are looked up relative to here"
)
private Path dir;
我试过
@SuppressWarnings({ "NullAway.Init", "initialization.fields.uninitialize"})
在类、构造函数和字段上。如何使checkerframework快乐?
这里是完整的源代码检查器框架,目前还没有启用,因为事实上这不会编译,如果我这样做了。
1条答案
按热度按时间dba5bblo1#
checker框架正在抱怨,因为
main
方法不初始化示例字段arg
,args
以及dir
. 如果没有显式地对字段进行注解,则从checker框架的Angular 来看,该字段被认为是@NotNull
.请尝试用
@Nullable
:尽管您配置了
picocli
为了提供默认值,checker框架只知道main
方法调用这些字段没有初始化,没有这样的初始化代码,picocli
将提供您指定的默认值,但checker framework没有意识到这一点,这就是为什么它会抱怨它。话虽如此,如果您希望抑制警告,请注意checker framework指示必须抑制的警告类型,
initialization.fields.uninitialized
,似乎你的密码有误:请注意要求值之间的差异,
initialization.fields.uninitialized
,还有你提供的,initialization.fields.uninitialize
.