-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for external init annotations in constructors (#725)
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: > A list of annotations for classes that are "externally initialized." Tools like the [Cassandra Object Mapper](https://docs.datastax.com/en/developer/java-driver/3.2/manual/object_mapper/) do their own field initialization of objects with a certain annotation (like [@table](https://docs.datastax.com/en/drivers/java/3.2/com/datastax/driver/mapping/annotations/Table.html)), after invoking the zero-argument constructor. For any class annotated with an external-init annotation, we don't check that the zero-arg constructor initializes all non-null fields. 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.
- Loading branch information
1 parent
4cabc3d
commit d2e4a49
Showing
3 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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