Skip to content

Move away from Findbugs (unofficial JSR-305) annotations #165

@bbottema

Description

@bbottema

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions