0

I like the feature where IntelliJ can automatically generate code to check at runtime for null on each argument/parameter passed to a method.

This feature is enabled in Preferences > Build, Execution, Deployment > Compiler > Add runtime assertions for notnull-annotated methods and parameters (checkbox). The neighboring Configure annotations button configures which annotation package.

I am trying to set my not-null annotation at the package level. Example:

@ParametersAreNonnullByDefault
package work.basil.ticktock.backend.data;

import javax.annotation.ParametersAreNonnullByDefault;

My question is: Which, if any, of these "Configure annotations" work the generate code for the @ParametersAreNonnullByDefault annotation discussed here and found here?

The null-checks are indeed working within the code editor, generating warnings. But I want runtime-checking as provided by the checkbox shown in this screenshot.

Screenshot of IntelliJ Preferences > Build, Execution, Deployment > Compiler > Add runtime assertions for notnull-annotated methods and parameters (checkbox)

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
  • Related: [*Set findbugs NotNull as default for all classes under a package*](https://stackoverflow.com/q/13310994/642706) – Basil Bourque Sep 11 '19 at 00:35

1 Answers1

1

Please follow/comment the duplicated feature request already created at YouTrack, but not yet implemented: https://youtrack.jetbrains.com/issue/IDEA-164347. Thank you.

Olga Klisho
  • 1,206
  • 5
  • 7