Add @Nullable annotations and NullAway profile for Maven 4 API#11818
Open
gnodet wants to merge 1 commit intoapache:masterfrom
Open
Add @Nullable annotations and NullAway profile for Maven 4 API#11818gnodet wants to merge 1 commit intoapache:masterfrom
gnodet wants to merge 1 commit intoapache:masterfrom
Conversation
ffcc698 to
b603fc4
Compare
…ile-time null checks - 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 to fields, method parameters, and return types across the Maven 4 API where values can genuinely be null - Add @nullable to Velocity model template (model.vm) for generated model classes: non-primitive, non-collection fields and their getters - Add @nullable to hand-written template files: InputLocation, InputSource, InputLocationTracker, ImmutableCollections - Add @nullable to XmlNode builder, XmlService merge methods, XmlReaderRequest, XmlWriterRequest - Add @nullable to builder fields in request classes (fields start null before builder methods are called) - Add requireNonNull() validation in builder build() methods for parameters that must be non-null, preserving existing @nonnull API contracts - Fix InputLocation.locations field: not nullable (always initialized via ImmutableCollections which returns empty map for null input) - Fix Sources.BuildPathSource.resolve() null safety for Path.getParent() - Add @nullable to Nullable annotation itself (meta-annotation for NullAway) - Fix Phase.getEffectiveId() return annotation in lifecycle.mdo Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b603fc4 to
7a89764
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-Pnullaway) using Error Prone 2.36.0 + NullAway 0.12.6 for compile-time null safety checking onorg.apache.maven.apipackages@Nullableannotations across the Maven 4 API where values can genuinely be null: fields, method parameters, return types, builder fields, generated model code (via Velocity template)requireNonNull()validation in builderbuild()methods to preserve existing@NonnullAPI contracts — no@Nonnullannotations were changed to@NullableInputLocation.locationsfield: was incorrectly annotated@Nullablebut is never null (always initialized viaImmutableCollectionswhich returns empty map for null input)Sources.BuildPathSource.resolve()null safety forPath.getParent()which can return nullDetails
The NullAway profile runs at
WARNlevel with-XepDisableAllChecksso 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@Nullableand@Nonnullannotations.Files changed fall into these categories:
@Nullableto genuinely nullable fields, params, and return types@Nullableto builder fields (which start null) andrequireNonNull()inbuild()methods for non-null paramsmodel.vm): Added@Nullableto non-primitive, non-collection generated fields and their gettersInputLocation.java,InputSource.java, etc.): Added@Nullableannotations.mdomodel files: Added@Nullableto code segments where neededTest plan
mvn clean test -f api)mvn clean compile -f api)mvn clean compile -f api -Pnullaway)🤖 Generated with Claude Code