@Nullable/@NotNull with IntelliJ IDEA, Maven & JSR 305

自作多情 提交于 2019-11-30 04:57:41

I'm late to the party, but for future readers this might be interesting.

As of IntelliJ 15.0.2, you may natively use other annotations than the JetBrains ones:

  • go to the settings
  • go to the Editor > Inspections tab
  • go to Java > Probable Bugs > "@NotNull/@Nullable problems"
  • at the end of the options panel (you might need to scroll), there is a Configure annotations button, leading to this dialog where you can select from a list of well-known annotations:

According to IntelliJ issue IDEA-64677:

  • support for arbitrary @Nullable/@NotNull annotations should be available in IDEA 10.0.3
  • there will probably some a manual configuration step(s) to enable support for the non-proprietary annotations (see Anna's comments on that page)

As this question is IntelliJ specific it is perhaps best asked on an IntelliJ forum. You might find this thread interesting http://devnet.jetbrains.net/message/5262800. The downside of using Findbugs is that it doesn't provide code injection for runtime checks and JSR-305 doesn't appear likely to be approved anytime soon.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!