Inferred annotations
Last modified: 10 August 2022IntelliJ 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 icon in the gutter.

Show inferred annotations inline
You can configure the IDE to show inferred annotations right in your code.
Press Ctrl+Alt+S to open the IDE settings and select Editor | Inlay Hints | Annotations | Java.
Select the Inferred annotations checkbox.
Apply the changes and close the dialog.

Thanks for your feedback!