Support for static analysis annotations

Evan Darke <[email protected]> Thu, 5 Dec 2024 17:21:14 -0800
Newsgroups gmane.comp.jakarta.lucene.user
Message-ID <CALR3qBdcS=_1+dQLma=OTOMpLaAx_A+pXNsBH6J78qapwKZ1kA@mail.gmail.com>
I'm wondering if the Lucene community would be supportive of adopting
common annotations, such a @Nullable, to enable better static analysis for
downstream projects and within Lucene as well. Lucene makes extensive use
of nulls for performance reasons, but using this code can be prone to user
error.

Since most tools nowadays (e.g. Errorprone, NullAway, Intellij) will
recognize annotations based on their simple name, rather than the fully
qualified class name, it's possible to support this analysis without
introducing any third party dependencies. I would like to propose
annotating Lucene methods with "org.apache.lucene.annotations.Nullable"
where applicable, and perhaps similar for @MustBeClosed.