## Why is this an issue?

Fields, parameters and return values marked `@NotNull`, `@NonNull`, or `@Nonnull` are assumed to have non-null values and are not typically null-checked before use. Therefore setting one of these values to `null`, or failing to set such a class field in a constructor, could cause `NullPointerException`s at runtime.

### Noncompliant code example

    public class MainClass {

      @Nonnull
      private String primary;
      private String secondary;

      public MainClass(String color) {
        if (color != null) {
          secondary = null;
        }
        primary = color;  // Noncompliant; "primary" is Nonnull but could be set to null here
      }

      public MainClass() { // Noncompliant; "primary" is Nonnull but is not initialized
      }

      @Nonnull
      public String indirectMix() {
        String mix = null;
        return mix;  // Noncompliant; return value is Nonnull, but null is returned.
      }

## Resources

### Standards

- CERT - EXP34-C. Do not dereference null pointers
- CERT - EXP01-J. Do not use a null in a case where an object is required
- CWE - CWE-476 NULL Pointer Dereference