NonNullApi
NonNullApi is a package-level annotation in the Spring Framework (org.springframework.lang.NonNullApi) that marks all public API elements within a package as non-null by default. This means that method parameters and return values are considered non-null unless explicitly annotated otherwise. The annotation helps formalize null-safety contracts across a codebase and reduces the need to annotate every member individually.
Usage typically involves placing the annotation on a package via a package-info.java file, so that all types
Impact and tooling: NonNullApi is not enforced at runtime; it is intended as a compile-time and tooling
Related concepts include @Nullable, and the NonNullFields annotation for fields. These annotations are part of Spring’s