...
In addition to those instructions you may want to tell IntelliJ inspections to "treat non-annotated members and parameters as @Nullable". This is the most conservative setting and should highlight the most bugs. Oddly, this setting is in the "Constant conditions & exceptions" panel under the Java "Probable bugs" inspection category:
You may also want to run the "Infer Nullity…" analyzer from the "Analysis" menu. You'll want to give IntelliJ lots of memory to work with (e.g. 8GiB) and it will take "a while" to complete. After that if you enable "Inferred annotations":
then you'll start to see these inferred annotations in gray in the editor. Here's an inferred @NotNull example:
Example Workflow
Here's an example. When working on SocketMessageWriter.writeHandshakeMessage
I wondered if the clientVersion
parameter could ever be null
. Here we're testing for null
. Could this null-check be eliminated?
...