Add support for external init annotations in constructors #725
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.
NullAway has existing support for
-XepOpt:NullAway:ExternalInitAnnotations=...
as configuration option.Before this PR, that option allows listing a set of class-level annotations with the following semantics:
This PR extends that configuration option to also allow annotations that are added directly to the zero-arguments
constructor of such an externally initialized class. The reason for this is that it's often desired to document why
the empty constructor exists, and doing so at the declaration site for the constructor makes code more readable than
doing so at the class declaration level.
The canonical example here is GSON serialization, which requires classes to have a private zero-arguments constructor
which is called for deserialization, in addition to their normal initializing constructors.
As a follow up to this PR landing, we will update the Wiki docs accordingly.