IntelliJ IDEA 2022.1 Help

Inferred annotations

IntelliJ IDEA scans bytecode from SDKs and libraries and infers annotations automatically. These annotations can help you better understand code contacts and make code analysis more efficient.

IntelliJ IDEA infers the @Nullable and @NotNull annotations that you can use to analyze your source code to spot places where you overlooked null. For methods with more complex behavior, IntelliJ IDEA has the method contracts (@Contract). The IDE also infers @Unmodifiable and @UnmodifiableView annotations.

In the editor, inferred annotations are marked with the Inferred annotation icon icon in the gutter.

Inferred annotation in the editor

Show inferred annotations inline

You can configure the IDE to show inferred annotations right in your code.

  1. Press Ctrl+Alt+S to open the IDE settings and select Editor | Inlay Hints | Annotations | Java.

  2. Select the Inferred annotations checkbox.

  3. Apply the changes and close the dialog.

Inferred annotation shown inline with the code
Last modified: 10 August 2022