-
-
Notifications
You must be signed in to change notification settings - Fork 274
Description
The widely used but aging Findbugs annotations are not compatible with Java 9 due to split package (Findbugs choose to use the same package as an existing package in the JDK). The Findbug annotations were never made official and as the RFC died (dormant), there's no hope of fixing this with JSR-305 (which never defined annotations).
The solution is to move to an alternative, which begs the question: which alternative is still maintained, compatible with Java 9 and also has runtime retention, actually has all the annotations currently used, doesn't bring transitive baggage and is supported by analyses tools and on top of all that supports a compatible license?
Currently, nobody has a clear answer:
- Migrate off of jsr305 google/guava#2960
- JDK9: Don't use JSR-305 dependency rsocket/rsocket-java#423
- https://blog.codefx.org/java/jsr-305-java-9/
- https://lists.apache.org/thread.html/%[email protected]%3E
- https://stackoverflow.com/questions/4963300/which-notnull-java-annotation-should-i-use
To make some sense out of all the options available to use, here's an aspect matrix for the main contenders to help us decide:
Library | Purpose | License | Compiles in Java 9? | Runteim Ret.? | Active? | Clean dependency | Robust null support | Tool support |
---|---|---|---|---|---|---|---|---|
javax Findbugs | Static analyses | LGPL | ❌ | ✔️ | ❌ | ✔️ | ✔️ | ✔️ |
Spotbugs | Static analyses | LGPL | ✔️ | ❌ | ✔️ | ✔️ | ➖ | ? |
JetBrains | Static analyses | Apache | ✔️ | ❌ | ✔️ | ✔️ | ❌ | ✔️ |
Checker framework | Static analyses | MIT | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Eclipse JDT | Static analyses | EPL | ✔️ | ? | ✔️ | ✔️ | ➖ | ✔️ |
Google's ErrorProne | Static analyses | Apache | ✔️ | ? | ✔️ | ✔️ | ➖ | ? |
Lombok | Code generation | MIT | ✔️ | ? | ✔️ | ❌ | ❌ | ➖ |
Java Bean Validation* | Runtime integrity | Apache | ✔️ | ? | ✔️ | ❌ | ➖ | ➖ |
edu.umd.cs Findbugs | Static analyses | LGPL | ✔️ | ❌ | ❌ | ✔️ | ✔️ | ? |
Android | Static analyses | ➖ | ? | ✔️ | ➖ | ❌ | ✔️ | |
Netbeans | ? | ? | ? | ? | ? | ? | ? | ? |
Spring | based on findbugs | ➖ | ➖ | ? | ➖ | ❌ | ➖ | ➖ |
*Java Bean Validation (JSR-380) is implemented by Hibernate Validator under Apache v2
*Checker framework (and probably other) supports Lombok's null annotations
Other alternatives are switching to strict non-null Option types using some variation of Optional or the Null-object pattern, or even force Java 9 to work with Findbugs with some hackery.
Since Simple Java Mail only uses @NonNull
and @Nullable
, I'm thinking the Jetbrains annotations would be a comfortable transition.