Spring Boot 4 and Spring Framework 7 introduce first-class null safety via JSpecify annotations. By adding @NullMarked at the package level, all types default to non-null, and developers must explicitly annotate nullable return types, parameters, fields, and collection elements with @Nullable. Combined with the NullAway compiler plugin and Error Prone, this catches NullPointerExceptions at compile time rather than in production. The walkthrough covers practical scenarios: nullable return types in services, nullable constructor/method parameters, nullable fields in records, and nullable elements inside collections and arrays.

25m watch time

Sort: