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

前端 未结 4 615
闹比i
闹比i 2020-12-29 09:52

I really like the code inspection functionalities which are now able with either JSR 305 or Jetbrains\' proprietary annotations for IntelliJ. Unfortunately both implementati

相关标签:
4条回答
  • 2020-12-29 10:18

    This has been made possible with the 10.5 of IntelliJ: http://blogs.jetbrains.com/idea/2011/03/more-flexible-and-configurable-nullublenotnull-annotations/

    0 讨论(0)
  • 2020-12-29 10:18

    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.

    0 讨论(0)
  • 2020-12-29 10:20

    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)
    0 讨论(0)
  • 2020-12-29 10:21

    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:

    0 讨论(0)
提交回复
热议问题