检查框架,有什么方法可以消除/禁用 type.anno.before.modifier 警告吗?

xen*_*ide 5 java checker-framework

我想我应该尝试一下检查框架,但我得到了很多这样的东西

/Users/calebcushing/IdeaProjects/ppm/scaf/src/main/java/com/xenoterracide/scaf/Config.java:22: warning: [type.anno.before.modifier] write type annotation @NonNull() immediately before type, after modifiers [abstract]
  abstract Map<String, SkeletonConfiguration> getTemplates();
Run Code Online (Sandbox Code Playgroud)

对于这段代码

/Users/calebcushing/IdeaProjects/ppm/scaf/src/main/java/com/xenoterracide/scaf/Config.java:22: warning: [type.anno.before.modifier] write type annotation @NonNull() immediately before type, after modifiers [abstract]
  abstract Map<String, SkeletonConfiguration> getTemplates();
Run Code Online (Sandbox Code Playgroud)

这似乎是我应该写的建议

  @Nullable
  abstract String getWorkdir();
Run Code Online (Sandbox Code Playgroud)

但这违背了JLS,有什么办法可以禁用它吗?

mer*_*nst 5

  1. 你说“这违背了 JLS”,但事实并非如此。它是合法的Java,而且是更好的风格。

  2. Checker框架手册描述了如何抑制警告,例如通过@SuppressWarning("type.anno.before.modifier")注释或-AsuppressWarnings=type.anno.before.modifier命令行参数。