Skip to content

[CQ] ☂ fix nullability problems #8291

Open
Open
@pq

Description

@pq

A tracking issue for fixing nullability problems, where possible with @NotNull and @Nullable annotations.

Motivation

Null Pointer Exceptions are a significant issue in Java and the plugin in particular. While Java doesn't have native, compile-time null safety like Kotlin (or Dart), Jetbrains provides @NotNull and @Nullable annotations to document nullability contracts with static and runtime enforcement. Static enforcement gives code authors feedback in the editor if they pass a possibly null value where a non-null one is expected. In addition, the compiler adds assertions to all code elements annotated with @NotNull, providing a runtime check and making any explicit null-checks redundant and unnecessary. @NotNull and @nullable are in use already (2297 and 857 times respectively) but not consistently and the question of whether to use them on new code has come up in code review (e.g., pull#8247).

Approach

Detecting code is easy with the built-in inspection:

Image

To ensure we don't regress, it would be great to update the plugin verify to flag new nullability problems (#8292).

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions