15

I really like the code inspection functionalities which are now able with either JSR 305 or Jetbrains' proprietary annotations for IntelliJ. Unfortunately both implementations (JSR 305 and Jetbrains') do not mix well:

  • IntelliJ obviously only understands its own proprietary set of annotations and integrates them quite well.
  • Using Findbugs in my Maven Build, it only supports JSR-305 annotations.

The only possible workaround might be to go for JSR-305 and use the Findbugs plugin in IntelliJ. Has anybody a better idea? (please don't say change your IDE ;) ).

Thanks Thomas

Riduidel
  • 22,052
  • 14
  • 85
  • 185
Thomas
  • 1,119
  • 9
  • 24
  • Stack Overflow tip: when asking a question specific to a particular programming language, add that language as a tag. (I added the java tag for you.) – Laurence Gonsalves Dec 17 '10 at 07:58
  • JetBrains annotations are Apache2 license open source (eg org.jetbrains.annotations.NotNull/Nullable). As for mixing them with FindBugs see answer below (IntelliJ supports any annotation you define for IDE NotNull/Nullable support) – osundblad May 25 '12 at 10:35

4 Answers4

19

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

Wim Deblauwe
  • 25,113
  • 20
  • 133
  • 211
7

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:

enter image description here

Joffrey
  • 32,348
  • 6
  • 68
  • 100
2

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.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • Peter, thanks for the link. Posted it here because I think it's more than just IntelliJ ;) It seems that once again Java lacks a unified solution. Maybe I'll just patch Findbugs to take Jetbrains annotations into account and switch to JSR-305 once it's approved (if ever). – Thomas Dec 22 '10 at 07:48
2

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)
mattbh
  • 5,230
  • 2
  • 27
  • 27