我参考了文档中的空值示例(检查器框架版本2.1.14
:)
当我按照建议运行示例以检查NullnessExampleWithWarnings.java 时:
javac -processor org.checkerframework.checker.nullness.NullnessChecker docs/examples/NullnessExampleWithWarnings.java
我得到预期的错误:
..\..\docs\examples\NullnessExampleWithWarnings.java:23: error: [assignment.type.incompatible] incompatible types in assignment.
foo = bar;
^
found : @FBCBottom @Nullable String
required: @UnknownInitialization @NonNull String
..\..\docs\examples\NullnessExampleWithWarnings.java:33: error: [argument.type.incompatible] incompatible types in argument.
foo.add(quux);
^
found : @FBCBottom @Nullable String
required: @Initialized @NonNull String
2 errors
现在我禁用初始化检查器:使用AsuppressWarnings=initialization
.
javac -processor org.checkerframework.checker.nullness.NullnessChecker -AsuppressWarnings=initialization docs/examples/NullnessExampleWithWarnings.java
但这也禁用了空检查,并且构建不再报告错误。
如何禁用Initialization checker,但保留 Null 检查?