Annotate the rest of the main package (basically just the Java 8 subjects) for nullness.
And move the @NullMarked annotation from individual classes up to the package.
Motivation:
The annotating is about potentially making things nicer for callers (or any future J2KT use?).
Moving @NullMarked to the package is about saving Truth users from a warning when running Error Prone with --release 8: When @NullMarked appears on a class, Error Prone processes the entire NullMarked class in order to check whether NullMarked is @Inherited. This leads to warning: unknown enum constant ElementType.MODULE because NullMarked has @Target(MODULE, ...) but MODULE isn't available until Java 9. We'll also be fixing this on the Error Prone side, but we might as well work around it on the Truth side, too—and annotate the rest of Truth while we're at it.
(In principle, I should now add @NullUnmarked to all of Truth's test classes, since they haven't been annotated. But doing so would have little to no effect in practice unless maybe IntelliJ recognizes @NullUnmarked (probably not now?) or we improve our nullness offerings in Error Prone. I'm planning to not bother, but let me know if I'm being overly lazy.)
Note that this CL applies @Nullable to some assertion methods' parameters even though those assertions would always fail if the callers passed null. This follows a principle that we'd applied (albeit incompletely) in cl/516515683, which showed that such changes avoided producing build errors in existing, working code. The principle is the same as that discussed for EqualsTester in cl/578260904.
RELNOTES=Annotated the rest of the main package for nullness, and moved the @NullMarked annotation from individual classes up to the package to avoid a warning under --release 8.
Annotate the rest of the main package (basically just the Java 8 subjects) for nullness.
And move the
@NullMarked
annotation from individual classes up to the package.Motivation:
@NullMarked
to the package is about saving Truth users from a warning when running Error Prone with--release 8
: When@NullMarked
appears on a class, Error Prone processes the entireNullMarked
class in order to check whetherNullMarked
is@Inherited
. This leads towarning: unknown enum constant ElementType.MODULE
becauseNullMarked
has@Target(MODULE, ...)
butMODULE
isn't available until Java 9. We'll also be fixing this on the Error Prone side, but we might as well work around it on the Truth side, too—and annotate the rest of Truth while we're at it.(In principle, I should now add
@NullUnmarked
to all of Truth's test classes, since they haven't been annotated. But doing so would have little to no effect in practice unless maybe IntelliJ recognizes@NullUnmarked
(probably not now?) or we improve our nullness offerings in Error Prone. I'm planning to not bother, but let me know if I'm being overly lazy.)Note that this CL applies
@Nullable
to some assertion methods' parameters even though those assertions would always fail if the callers passednull
. This follows a principle that we'd applied (albeit incompletely) in cl/516515683, which showed that such changes avoided producing build errors in existing, working code. The principle is the same as that discussed forEqualsTester
in cl/578260904.Fixes https://github.com/google/truth/issues/1320
RELNOTES=Annotated the rest of the main package for nullness, and moved the
@NullMarked
annotation from individual classes up to the package to avoid a warning under--release 8
.