Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

With GEODE-8882 we have introduced a compile-time dependency (in the geode-core subproject only) on the JetBrains annotations package. This makes the JetBrains @NotNull and @Nullable annotations available in classes in that subproject. If you need those annotations in other subprojects, just add this to the pertinent build.gradle:

...

Here is the home page for the JetBrains annotations Maven project: https://github.com/JetBrains/java-annotations

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:

Image Added


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":

Image Added

then you'll start to see these inferred annotations in gray in the editor. Here's an inferred @NotNull example:


Image Added


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?

...

…where I find this call-site passing a null for clientVersion:

image

So that null-check in SocketMessageWriter.writeHandshakeMessage was needed after all! Since I didn't want to change that null-sending call-site, and I didn't want to squander my analysis work, I marked the parameter @Nullable:

...