gnodet opened a new pull request, #11818: URL: https://github.com/apache/maven/pull/11818
## Summary - Add opt-in NullAway profile (`-Pnullaway`) using Error Prone 2.36.0 + NullAway 0.12.6 for compile-time null safety checking on `org.apache.maven.api` packages - Add `@Nullable` annotations across the Maven 4 API where values can genuinely be null: fields, method parameters, return types, builder fields, generated model code (via Velocity template) - Add `requireNonNull()` validation in builder `build()` methods to preserve existing `@Nonnull` API contracts — no `@Nonnull` annotations were changed to `@Nullable` - Fix `InputLocation.locations` field: was incorrectly annotated `@Nullable` but is never null (always initialized via `ImmutableCollections` which returns empty map for null input) - Fix `Sources.BuildPathSource.resolve()` null safety for `Path.getParent()` which can return null ### Details The NullAway profile runs at `WARN` level with `-XepDisableAllChecks` so only NullAway warnings are reported. It is designed as an opt-in quality check, not a build gate. The profile configures NullAway to recognize Maven's custom `@Nullable` and `@Nonnull` annotations. Files changed fall into these categories: - **Hand-written API classes**: Added `@Nullable` to genuinely nullable fields, params, and return types - **Builder classes**: Added `@Nullable` to builder fields (which start null) and `requireNonNull()` in `build()` methods for non-null params - **Velocity template** (`model.vm`): Added `@Nullable` to non-primitive, non-collection generated fields and their getters - **Template source files** (`InputLocation.java`, `InputSource.java`, etc.): Added `@Nullable` annotations - **`.mdo` model files**: Added `@Nullable` to code segments where needed ## Test plan - [x] All existing tests pass (`mvn clean test -f api`) - [x] Clean compile without NullAway profile (`mvn clean compile -f api`) - [x] Zero NullAway warnings with profile enabled (`mvn clean compile -f api -Pnullaway`) - [ ] Verify no downstream breakage in maven-core modules 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
