From 6a96d178a8ecf27b8fc48f2580824073290593ac Mon Sep 17 00:00:00 2001 From: cpovirk Date: Wed, 26 Jun 2024 10:06:58 -0700 Subject: [PATCH] Use JSpecify annotations in the public release. We've been using these internally for over a year. With JSpecify 1.0 not far off and wider adoption to gradually follow, now seems like the time to expand our public usage of the annotations. We've already been using them in a few projects, but Truth may become the mostly widely used project that users actually link against to use them. At the same time, it's a library that's used only in testing code, so the stakes remain relatively low. Most users will see no effect from this change, since most users don't use nullness checking and since we already used some nullness annotations in our public release. The main effect users are likely to see is if they pass nullable values for parameters that are now recognized as non-nullable. Under Kotlin, the effect should normally be a warning, not an error, at least until [Kotlin 2.1 or so](https://youtrack.jetbrains.com/issue/KT-55586/Handle-nullability-from-jspecify-annotations-properly#focus=Comments-27-8368666.0-0). Please still [report any problems](https://github.com/google/truth/issues/new). (progress toward JSpecify adoption in our projects in general, including https://github.com/google/guava/issues/2960) RELNOTES=Added more nullness information to our APIs (in the form of [JSpecify](https://jspecify.dev/) annotations). This could lead to additional warnings (or even errors) for users of Kotlin and other nullness checkers. Please [report any problems](https://github.com/google/truth/issues/new). PiperOrigin-RevId: 646988261 --- core/pom.xml | 4 ++-- .../java/com/google/common/truth/AbstractArraySubject.java | 4 +++- .../java/com/google/common/truth/ActualValueInference.java | 4 +++- .../com/google/common/truth/AssertionErrorWithFacts.java | 4 +++- .../java/com/google/common/truth/BigDecimalSubject.java | 4 +++- .../main/java/com/google/common/truth/BooleanSubject.java | 4 +++- .../src/main/java/com/google/common/truth/ClassSubject.java | 4 +++- .../java/com/google/common/truth/ComparableSubject.java | 4 +++- .../com/google/common/truth/ComparisonFailureWithFacts.java | 4 +++- .../java/com/google/common/truth/ComparisonFailures.java | 4 +++- .../main/java/com/google/common/truth/Correspondence.java | 4 +++- .../java/com/google/common/truth/CustomSubjectBuilder.java | 2 ++ core/src/main/java/com/google/common/truth/DiffUtils.java | 2 ++ .../main/java/com/google/common/truth/DoubleSubject.java | 4 +++- .../main/java/com/google/common/truth/ErrorWithFacts.java | 2 ++ core/src/main/java/com/google/common/truth/Expect.java | 4 +++- .../main/java/com/google/common/truth/ExpectFailure.java | 4 +++- core/src/main/java/com/google/common/truth/Fact.java | 4 +++- .../main/java/com/google/common/truth/FailureMetadata.java | 4 +++- .../main/java/com/google/common/truth/FailureStrategy.java | 2 ++ .../src/main/java/com/google/common/truth/FloatSubject.java | 4 +++- .../main/java/com/google/common/truth/GraphMatching.java | 2 ++ .../java/com/google/common/truth/GuavaOptionalSubject.java | 4 +++- .../java/com/google/common/truth/IgnoreJRERequirement.java | 2 ++ .../main/java/com/google/common/truth/IntStreamSubject.java | 2 +- .../main/java/com/google/common/truth/IntegerSubject.java | 4 +++- .../main/java/com/google/common/truth/IterableSubject.java | 4 +++- core/src/main/java/com/google/common/truth/LazyMessage.java | 4 +++- .../java/com/google/common/truth/LongStreamSubject.java | 2 +- core/src/main/java/com/google/common/truth/LongSubject.java | 4 +++- core/src/main/java/com/google/common/truth/MapSubject.java | 4 +++- core/src/main/java/com/google/common/truth/MathUtil.java | 2 ++ .../main/java/com/google/common/truth/MultimapSubject.java | 4 +++- .../main/java/com/google/common/truth/MultisetSubject.java | 4 +++- .../java/com/google/common/truth/ObjectArraySubject.java | 4 +++- .../java/com/google/common/truth/OptionalDoubleSubject.java | 2 +- .../java/com/google/common/truth/OptionalIntSubject.java | 2 +- .../java/com/google/common/truth/OptionalLongSubject.java | 2 +- .../main/java/com/google/common/truth/OptionalSubject.java | 2 +- core/src/main/java/com/google/common/truth/Ordered.java | 2 ++ core/src/main/java/com/google/common/truth/Platform.java | 4 +++- .../google/common/truth/PrimitiveBooleanArraySubject.java | 4 +++- .../com/google/common/truth/PrimitiveByteArraySubject.java | 4 +++- .../com/google/common/truth/PrimitiveCharArraySubject.java | 4 +++- .../google/common/truth/PrimitiveDoubleArraySubject.java | 4 +++- .../com/google/common/truth/PrimitiveFloatArraySubject.java | 4 +++- .../com/google/common/truth/PrimitiveIntArraySubject.java | 4 +++- .../com/google/common/truth/PrimitiveLongArraySubject.java | 4 +++- .../com/google/common/truth/PrimitiveShortArraySubject.java | 4 +++- .../java/com/google/common/truth/SimpleSubjectBuilder.java | 4 +++- .../java/com/google/common/truth/StackTraceCleaner.java | 4 +++- .../com/google/common/truth/StandardSubjectBuilder.java | 4 +++- .../main/java/com/google/common/truth/StreamSubject.java | 2 +- .../main/java/com/google/common/truth/StringSubject.java | 4 +++- core/src/main/java/com/google/common/truth/Subject.java | 4 +++- .../src/main/java/com/google/common/truth/SubjectUtils.java | 4 +++- .../src/main/java/com/google/common/truth/TableSubject.java | 4 +++- .../main/java/com/google/common/truth/ThrowableSubject.java | 4 +++- core/src/main/java/com/google/common/truth/Truth.java | 4 +++- core/src/main/java/com/google/common/truth/Truth8.java | 2 +- .../java/com/google/common/truth/TruthFailureSubject.java | 4 +++- core/src/main/java/com/google/common/truth/TruthJUnit.java | 2 ++ .../main/java/com/google/common/truth/UsedByReflection.java | 2 ++ .../truth/super/com/google/common/truth/Platform.java | 4 +++- .../java/com/google/common/truth/DoubleSubjectTest.java | 2 +- .../test/java/com/google/common/truth/FloatSubjectTest.java | 2 +- core/src/test/java/com/google/common/truth/SubjectTest.java | 2 +- .../java/com/google/common/truth/TestCorrespondences.java | 2 +- .../com/google/common/truth/extension/EmployeeSubject.java | 2 +- extensions/java8/pom.xml | 4 ++-- extensions/liteproto/pom.xml | 4 ++-- .../common/truth/extensions/proto/LiteProtoSubject.java | 2 +- .../common/truth/extensions/proto/LiteProtoTruth.java | 2 +- .../common/truth/extensions/proto/LiteProtoSubjectTest.java | 2 +- extensions/proto/pom.xml | 4 ++-- .../common/truth/extensions/proto/FluentEqualityConfig.java | 2 +- .../truth/extensions/proto/IterableOfProtosSubject.java | 2 +- .../proto/IterableOfProtosUsingCorrespondence.java | 2 +- .../extensions/proto/MapWithProtoValuesFluentAssertion.java | 2 +- .../truth/extensions/proto/MapWithProtoValuesSubject.java | 2 +- .../proto/MultimapWithProtoValuesFluentAssertion.java | 2 +- .../extensions/proto/MultimapWithProtoValuesSubject.java | 2 +- .../common/truth/extensions/proto/ProtoFluentAssertion.java | 2 +- .../google/common/truth/extensions/proto/ProtoSubject.java | 2 +- .../common/truth/extensions/proto/ProtoSubjectBuilder.java | 2 +- .../google/common/truth/extensions/proto/ProtoTruth.java | 2 +- .../extensions/proto/ProtoTruthMessageDifferencer.java | 2 +- .../common/truth/extensions/proto/ProtoSubjectTestBase.java | 2 +- .../google/common/truth/extensions/re2j/Re2jSubjects.java | 2 +- pom.xml | 6 +++--- .../refactorings/CorrespondenceSubclassToFactoryCall.java | 2 +- .../com/google/common/truth/refactorings/FailWithFacts.java | 2 +- 92 files changed, 198 insertions(+), 88 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index dfcd42af9c..a01adb66bb 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -15,8 +15,8 @@ guava - org.checkerframework - checker-qual + org.jspecify + jspecify junit diff --git a/core/src/main/java/com/google/common/truth/AbstractArraySubject.java b/core/src/main/java/com/google/common/truth/AbstractArraySubject.java index 8eff47a14e..760c18042e 100644 --- a/core/src/main/java/com/google/common/truth/AbstractArraySubject.java +++ b/core/src/main/java/com/google/common/truth/AbstractArraySubject.java @@ -20,13 +20,15 @@ import static com.google.common.truth.Fact.simpleFact; import java.lang.reflect.Array; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A common supertype for Array subjects, abstracting some common display and error infrastructure. * * @author Christian Gruber (cgruber@israfil.net) */ +@NullMarked abstract class AbstractArraySubject extends Subject { private final @Nullable Object actual; diff --git a/core/src/main/java/com/google/common/truth/ActualValueInference.java b/core/src/main/java/com/google/common/truth/ActualValueInference.java index db49c1da2c..26d813665d 100644 --- a/core/src/main/java/com/google/common/truth/ActualValueInference.java +++ b/core/src/main/java/com/google/common/truth/ActualValueInference.java @@ -33,7 +33,8 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Map.Entry; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.Handle; @@ -69,6 +70,7 @@ */ @GwtIncompatible @J2ktIncompatible +@NullMarked final class ActualValueInference { /** Call {@link Platform#inferDescription} rather than calling this directly. */ static @Nullable String describeActualValue(String className, String methodName, int lineNumber) { diff --git a/core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java b/core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java index ffdc720c61..48232c7f7a 100644 --- a/core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java +++ b/core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java @@ -19,13 +19,15 @@ import static com.google.common.truth.Fact.makeMessage; import com.google.common.collect.ImmutableList; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * An {@link AssertionError} composed of structured {@link Fact} instances and other string * messages. */ @SuppressWarnings("OverrideThrowableToString") // We intentionally hide the class name. +@NullMarked final class AssertionErrorWithFacts extends AssertionError implements ErrorWithFacts { private final ImmutableList facts; diff --git a/core/src/main/java/com/google/common/truth/BigDecimalSubject.java b/core/src/main/java/com/google/common/truth/BigDecimalSubject.java index dbba59170e..0bde0e79fb 100644 --- a/core/src/main/java/com/google/common/truth/BigDecimalSubject.java +++ b/core/src/main/java/com/google/common/truth/BigDecimalSubject.java @@ -20,13 +20,15 @@ import static com.google.common.truth.Fact.simpleFact; import java.math.BigDecimal; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link BigDecimal} typed subjects. * * @author Kurt Alfred Kluever */ +@NullMarked public final class BigDecimalSubject extends ComparableSubject { private final @Nullable BigDecimal actual; diff --git a/core/src/main/java/com/google/common/truth/BooleanSubject.java b/core/src/main/java/com/google/common/truth/BooleanSubject.java index 4e7f3da0a5..406845e8df 100644 --- a/core/src/main/java/com/google/common/truth/BooleanSubject.java +++ b/core/src/main/java/com/google/common/truth/BooleanSubject.java @@ -17,13 +17,15 @@ import static com.google.common.truth.Fact.simpleFact; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for boolean subjects. * * @author Christian Gruber (cgruber@israfil.net) */ +@NullMarked public final class BooleanSubject extends Subject { private final @Nullable Boolean actual; diff --git a/core/src/main/java/com/google/common/truth/ClassSubject.java b/core/src/main/java/com/google/common/truth/ClassSubject.java index 1ef1b9508b..2e32da77a7 100644 --- a/core/src/main/java/com/google/common/truth/ClassSubject.java +++ b/core/src/main/java/com/google/common/truth/ClassSubject.java @@ -18,13 +18,15 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.GwtIncompatible; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link Class} subjects. * * @author Kurt Alfred Kluever */ +@NullMarked @GwtIncompatible("reflection") @J2ktIncompatible public final class ClassSubject extends Subject { diff --git a/core/src/main/java/com/google/common/truth/ComparableSubject.java b/core/src/main/java/com/google/common/truth/ComparableSubject.java index 857f214955..5673330086 100644 --- a/core/src/main/java/com/google/common/truth/ComparableSubject.java +++ b/core/src/main/java/com/google/common/truth/ComparableSubject.java @@ -18,7 +18,8 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.Range; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link Comparable} typed subjects. @@ -26,6 +27,7 @@ * @author Kurt Alfred Kluever * @param the type of the object being tested by this {@code ComparableSubject} */ +@NullMarked // TODO(b/136040841): Consider further tightening this to the proper `extends Comparable` public abstract class ComparableSubject> extends Subject { /** diff --git a/core/src/main/java/com/google/common/truth/ComparisonFailureWithFacts.java b/core/src/main/java/com/google/common/truth/ComparisonFailureWithFacts.java index 47608db2c1..bf49932a28 100644 --- a/core/src/main/java/com/google/common/truth/ComparisonFailureWithFacts.java +++ b/core/src/main/java/com/google/common/truth/ComparisonFailureWithFacts.java @@ -21,12 +21,14 @@ import com.google.common.collect.ImmutableList; import com.google.common.truth.Platform.PlatformComparisonFailure; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * An {@link AssertionError} (usually a JUnit {@code ComparisonFailure}, but not under GWT) composed * of structured {@link Fact} instances and other string messages. */ +@NullMarked final class ComparisonFailureWithFacts extends PlatformComparisonFailure implements ErrorWithFacts { private final ImmutableList facts; diff --git a/core/src/main/java/com/google/common/truth/ComparisonFailures.java b/core/src/main/java/com/google/common/truth/ComparisonFailures.java index 1e50f49c56..c1cdf5a621 100644 --- a/core/src/main/java/com/google/common/truth/ComparisonFailures.java +++ b/core/src/main/java/com/google/common/truth/ComparisonFailures.java @@ -26,7 +26,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Contains part of the code responsible for creating a JUnit {@code ComparisonFailure} (if @@ -42,6 +43,7 @@ * different implementation under GWT/j2cl, where {@code ComparisonFailure} is also unavailable but * we can't just recover from that at runtime. */ +@NullMarked final class ComparisonFailures { static ImmutableList makeComparisonFailureFacts( ImmutableList headFacts, diff --git a/core/src/main/java/com/google/common/truth/Correspondence.java b/core/src/main/java/com/google/common/truth/Correspondence.java index 8059779e69..bedb35ae3b 100644 --- a/core/src/main/java/com/google/common/truth/Correspondence.java +++ b/core/src/main/java/com/google/common/truth/Correspondence.java @@ -31,7 +31,8 @@ import com.google.common.collect.ImmutableList; import java.util.Arrays; import java.util.List; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Determines whether an instance of type {@code A} corresponds in some way to an instance of type @@ -65,6 +66,7 @@ * * @author Pete Gillin */ +@NullMarked public abstract class Correspondence { /** diff --git a/core/src/main/java/com/google/common/truth/CustomSubjectBuilder.java b/core/src/main/java/com/google/common/truth/CustomSubjectBuilder.java index 0b84ef88c6..20a130e066 100644 --- a/core/src/main/java/com/google/common/truth/CustomSubjectBuilder.java +++ b/core/src/main/java/com/google/common/truth/CustomSubjectBuilder.java @@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkNotNull; +import org.jspecify.annotations.NullMarked; /** * In a fluent assertion chain, exposes one or more "custom" {@code that} methods, which accept a @@ -35,6 +36,7 @@ * extensions. It explains the cases in which {@code CustomSubjectBuilder} is necessary, and it * links to further instructions. */ +@NullMarked public abstract class CustomSubjectBuilder { /** * In a fluent assertion chain, the argument to the "custom" overload of {@link diff --git a/core/src/main/java/com/google/common/truth/DiffUtils.java b/core/src/main/java/com/google/common/truth/DiffUtils.java index b8b4122e5a..c90d3a19db 100644 --- a/core/src/main/java/com/google/common/truth/DiffUtils.java +++ b/core/src/main/java/com/google/common/truth/DiffUtils.java @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.jspecify.annotations.NullMarked; /** * A custom implementation of the diff algorithm based on the solution described at @@ -30,6 +31,7 @@ * * @author Yun Peng (pcloudy@google.com) */ +@NullMarked final class DiffUtils { // A list of unique strings appeared in compared texts. // The index of each string is its incremental Id. diff --git a/core/src/main/java/com/google/common/truth/DoubleSubject.java b/core/src/main/java/com/google/common/truth/DoubleSubject.java index 58cd50d610..4da26c149f 100644 --- a/core/src/main/java/com/google/common/truth/DoubleSubject.java +++ b/core/src/main/java/com/google/common/truth/DoubleSubject.java @@ -26,13 +26,15 @@ import static java.lang.Double.NaN; import static java.lang.Double.doubleToLongBits; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link Double} subjects. * * @author Kurt Alfred Kluever */ +@NullMarked public final class DoubleSubject extends ComparableSubject { private static final long NEG_ZERO_BITS = doubleToLongBits(-0.0); diff --git a/core/src/main/java/com/google/common/truth/ErrorWithFacts.java b/core/src/main/java/com/google/common/truth/ErrorWithFacts.java index 61f404b60c..9c9e71c85c 100644 --- a/core/src/main/java/com/google/common/truth/ErrorWithFacts.java +++ b/core/src/main/java/com/google/common/truth/ErrorWithFacts.java @@ -17,11 +17,13 @@ package com.google.common.truth; import com.google.common.collect.ImmutableList; +import org.jspecify.annotations.NullMarked; /** * Supertype of Truth's {@link AssertionError} subclasses that are created from a list of {@link * Fact} instances. */ +@NullMarked interface ErrorWithFacts { ImmutableList facts(); } diff --git a/core/src/main/java/com/google/common/truth/Expect.java b/core/src/main/java/com/google/common/truth/Expect.java index c5f61010bc..b495cebeb5 100644 --- a/core/src/main/java/com/google/common/truth/Expect.java +++ b/core/src/main/java/com/google/common/truth/Expect.java @@ -30,7 +30,8 @@ import com.google.errorprone.annotations.concurrent.GuardedBy; import java.util.ArrayList; import java.util.List; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import org.junit.internal.AssumptionViolatedException; import org.junit.rules.ErrorCollector; import org.junit.rules.TestRule; @@ -83,6 +84,7 @@ */ @GwtIncompatible("JUnit4") @J2ktIncompatible +@NullMarked public final class Expect extends StandardSubjectBuilder implements TestRule { private static final class ExpectationGatherer implements FailureStrategy { diff --git a/core/src/main/java/com/google/common/truth/ExpectFailure.java b/core/src/main/java/com/google/common/truth/ExpectFailure.java index 5b03608575..9625886cce 100644 --- a/core/src/main/java/com/google/common/truth/ExpectFailure.java +++ b/core/src/main/java/com/google/common/truth/ExpectFailure.java @@ -24,7 +24,8 @@ import com.google.common.annotations.GwtIncompatible; import com.google.common.truth.Truth.SimpleAssertionError; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import org.junit.runner.Description; import org.junit.runners.model.Statement; @@ -66,6 +67,7 @@ * also checks that the assertion you're testing uses the supplied {@link FailureStrategy} and calls * {@link FailureStrategy#fail} only once. */ +@NullMarked public final class ExpectFailure implements Platform.JUnitTestRule { private boolean inRuleContext = false; private boolean failureExpected = false; diff --git a/core/src/main/java/com/google/common/truth/Fact.java b/core/src/main/java/com/google/common/truth/Fact.java index b2dadad2db..173a929dbf 100644 --- a/core/src/main/java/com/google/common/truth/Fact.java +++ b/core/src/main/java/com/google/common/truth/Fact.java @@ -22,7 +22,8 @@ import com.google.common.collect.ImmutableList; import java.io.Serializable; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A string key-value pair in a failure message, such as "expected: abc" or "but was: xyz." @@ -34,6 +35,7 @@ *

If you are writing a custom {@code Subject}, see our tips on writing failure messages. */ +@NullMarked public final class Fact implements Serializable { /** * Creates a fact with the given key and value, which will be printed in a format like "key: diff --git a/core/src/main/java/com/google/common/truth/FailureMetadata.java b/core/src/main/java/com/google/common/truth/FailureMetadata.java index e6d86a7408..df13c7db33 100644 --- a/core/src/main/java/com/google/common/truth/FailureMetadata.java +++ b/core/src/main/java/com/google/common/truth/FailureMetadata.java @@ -29,7 +29,8 @@ import com.google.common.base.Function; import com.google.common.collect.ImmutableList; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * An opaque, immutable object containing state from the previous calls in the fluent assertion @@ -51,6 +52,7 @@ * using their {@link CustomSubjectBuilder#metadata()} method to get an instance to pass to the * constructor.) */ +@NullMarked public final class FailureMetadata { static FailureMetadata forFailureStrategy(FailureStrategy failureStrategy) { return new FailureMetadata( diff --git a/core/src/main/java/com/google/common/truth/FailureStrategy.java b/core/src/main/java/com/google/common/truth/FailureStrategy.java index b10d5509a7..b1cbd225f7 100644 --- a/core/src/main/java/com/google/common/truth/FailureStrategy.java +++ b/core/src/main/java/com/google/common/truth/FailureStrategy.java @@ -15,6 +15,7 @@ */ package com.google.common.truth; +import org.jspecify.annotations.NullMarked; /** * Defines what to do when a check fails. @@ -53,6 +54,7 @@ * StandardSubjectBuilder#forCustomFailureStrategy * StandardSubjectBuilder.forCustomFailureStrategy(STRATEGY)}. */ +@NullMarked public interface FailureStrategy { /** * Handles a failure. The parameter is an {@code AssertionError} or subclass thereof, and it diff --git a/core/src/main/java/com/google/common/truth/FloatSubject.java b/core/src/main/java/com/google/common/truth/FloatSubject.java index 19dff124bd..47a5db2c12 100644 --- a/core/src/main/java/com/google/common/truth/FloatSubject.java +++ b/core/src/main/java/com/google/common/truth/FloatSubject.java @@ -26,13 +26,15 @@ import static java.lang.Float.NaN; import static java.lang.Float.floatToIntBits; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link Float} subjects. * * @author Kurt Alfred Kluever */ +@NullMarked public final class FloatSubject extends ComparableSubject { private static final int NEG_ZERO_BITS = floatToIntBits(-0.0f); diff --git a/core/src/main/java/com/google/common/truth/GraphMatching.java b/core/src/main/java/com/google/common/truth/GraphMatching.java index ef21fef5ba..58f37f68d4 100644 --- a/core/src/main/java/com/google/common/truth/GraphMatching.java +++ b/core/src/main/java/com/google/common/truth/GraphMatching.java @@ -27,6 +27,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Queue; +import org.jspecify.annotations.NullMarked; /** * Helper routines related to graph @@ -34,6 +35,7 @@ * * @author Pete Gillin */ +@NullMarked final class GraphMatching { /** diff --git a/core/src/main/java/com/google/common/truth/GuavaOptionalSubject.java b/core/src/main/java/com/google/common/truth/GuavaOptionalSubject.java index 86a7f2c9c2..fb530b2fd3 100644 --- a/core/src/main/java/com/google/common/truth/GuavaOptionalSubject.java +++ b/core/src/main/java/com/google/common/truth/GuavaOptionalSubject.java @@ -19,7 +19,8 @@ import static com.google.common.truth.Fact.simpleFact; import com.google.common.base.Optional; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for Guava {@link Optional} subjects. @@ -28,6 +29,7 @@ * * @author Christian Gruber */ +@NullMarked public final class GuavaOptionalSubject extends Subject { @SuppressWarnings("NullableOptional") // Truth always accepts nulls, no matter the type private final @Nullable Optional actual; diff --git a/core/src/main/java/com/google/common/truth/IgnoreJRERequirement.java b/core/src/main/java/com/google/common/truth/IgnoreJRERequirement.java index a2d4842727..96f0b7b7d5 100644 --- a/core/src/main/java/com/google/common/truth/IgnoreJRERequirement.java +++ b/core/src/main/java/com/google/common/truth/IgnoreJRERequirement.java @@ -21,9 +21,11 @@ import static java.lang.annotation.ElementType.TYPE; import java.lang.annotation.Target; +import org.jspecify.annotations.NullMarked; /** * Disables Animal Sniffer's checking of compatibility with older versions of Java/Android. */ @Target({METHOD, CONSTRUCTOR, TYPE}) +@NullMarked @interface IgnoreJRERequirement {} diff --git a/core/src/main/java/com/google/common/truth/IntStreamSubject.java b/core/src/main/java/com/google/common/truth/IntStreamSubject.java index 9503747c82..1c1a6f6a75 100644 --- a/core/src/main/java/com/google/common/truth/IntStreamSubject.java +++ b/core/src/main/java/com/google/common/truth/IntStreamSubject.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.stream.IntStream; import java.util.stream.Stream; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link IntStream} subjects. diff --git a/core/src/main/java/com/google/common/truth/IntegerSubject.java b/core/src/main/java/com/google/common/truth/IntegerSubject.java index ba3119c2de..2ceca9179a 100644 --- a/core/src/main/java/com/google/common/truth/IntegerSubject.java +++ b/core/src/main/java/com/google/common/truth/IntegerSubject.java @@ -20,7 +20,8 @@ import static com.google.common.truth.Fact.fact; import static com.google.common.truth.MathUtil.equalWithinTolerance; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link Integer} subjects. @@ -29,6 +30,7 @@ * @author Christian Gruber (cgruber@israfil.net) * @author Kurt Alfred Kluever */ +@NullMarked public class IntegerSubject extends ComparableSubject { private final @Nullable Integer actual; diff --git a/core/src/main/java/com/google/common/truth/IterableSubject.java b/core/src/main/java/com/google/common/truth/IterableSubject.java index 1f5a64270d..312655837a 100644 --- a/core/src/main/java/com/google/common/truth/IterableSubject.java +++ b/core/src/main/java/com/google/common/truth/IterableSubject.java @@ -67,7 +67,8 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link Iterable} subjects. @@ -88,6 +89,7 @@ * @author Pete Gillin */ // Can't be final since MultisetSubject and SortedSetSubject extend it +@NullMarked public class IterableSubject extends Subject { private final @Nullable Iterable actual; diff --git a/core/src/main/java/com/google/common/truth/LazyMessage.java b/core/src/main/java/com/google/common/truth/LazyMessage.java index 2e6861a76c..a70e94da1f 100644 --- a/core/src/main/java/com/google/common/truth/LazyMessage.java +++ b/core/src/main/java/com/google/common/truth/LazyMessage.java @@ -20,8 +20,10 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +@NullMarked final class LazyMessage { private final String format; private final @Nullable Object[] args; diff --git a/core/src/main/java/com/google/common/truth/LongStreamSubject.java b/core/src/main/java/com/google/common/truth/LongStreamSubject.java index 073c2d8477..01e680ca75 100644 --- a/core/src/main/java/com/google/common/truth/LongStreamSubject.java +++ b/core/src/main/java/com/google/common/truth/LongStreamSubject.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.stream.LongStream; import java.util.stream.Stream; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link LongStream} subjects. diff --git a/core/src/main/java/com/google/common/truth/LongSubject.java b/core/src/main/java/com/google/common/truth/LongSubject.java index 32ca51593b..4b0ae7bb80 100644 --- a/core/src/main/java/com/google/common/truth/LongSubject.java +++ b/core/src/main/java/com/google/common/truth/LongSubject.java @@ -20,7 +20,8 @@ import static com.google.common.truth.Fact.fact; import static com.google.common.truth.MathUtil.equalWithinTolerance; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for {@code long} subjects. @@ -29,6 +30,7 @@ * @author Christian Gruber (cgruber@israfil.net) * @author Kurt Alfred Kluever */ +@NullMarked public class LongSubject extends ComparableSubject { private final @Nullable Long actual; diff --git a/core/src/main/java/com/google/common/truth/MapSubject.java b/core/src/main/java/com/google/common/truth/MapSubject.java index 0f8db9d5e2..b1009de9cd 100644 --- a/core/src/main/java/com/google/common/truth/MapSubject.java +++ b/core/src/main/java/com/google/common/truth/MapSubject.java @@ -42,7 +42,8 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link Map} subjects. @@ -50,6 +51,7 @@ * @author Christian Gruber * @author Kurt Alfred Kluever */ +@NullMarked public class MapSubject extends Subject { private final @Nullable Map actual; diff --git a/core/src/main/java/com/google/common/truth/MathUtil.java b/core/src/main/java/com/google/common/truth/MathUtil.java index 2fb44da5cc..986cd1e5c5 100644 --- a/core/src/main/java/com/google/common/truth/MathUtil.java +++ b/core/src/main/java/com/google/common/truth/MathUtil.java @@ -19,8 +19,10 @@ import static java.lang.Math.subtractExact; import com.google.common.primitives.Doubles; +import org.jspecify.annotations.NullMarked; /** Math utilities to be shared by numeric subjects. */ +@NullMarked final class MathUtil { private MathUtil() {} diff --git a/core/src/main/java/com/google/common/truth/MultimapSubject.java b/core/src/main/java/com/google/common/truth/MultimapSubject.java index 4a02216fc2..4f767350eb 100644 --- a/core/src/main/java/com/google/common/truth/MultimapSubject.java +++ b/core/src/main/java/com/google/common/truth/MultimapSubject.java @@ -46,7 +46,8 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link Multimap} subjects. @@ -54,6 +55,7 @@ * @author Daniel Ploch * @author Kurt Alfred Kluever */ +@NullMarked public class MultimapSubject extends Subject { /** Ordered implementation that does nothing because an earlier check already caused a failure. */ diff --git a/core/src/main/java/com/google/common/truth/MultisetSubject.java b/core/src/main/java/com/google/common/truth/MultisetSubject.java index da1be35858..0ab2450c0b 100644 --- a/core/src/main/java/com/google/common/truth/MultisetSubject.java +++ b/core/src/main/java/com/google/common/truth/MultisetSubject.java @@ -19,13 +19,15 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.Multiset; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link Multiset} subjects. * * @author Kurt Alfred Kluever */ +@NullMarked public final class MultisetSubject extends IterableSubject { private final @Nullable Multiset actual; diff --git a/core/src/main/java/com/google/common/truth/ObjectArraySubject.java b/core/src/main/java/com/google/common/truth/ObjectArraySubject.java index bfba314764..b50caac567 100644 --- a/core/src/main/java/com/google/common/truth/ObjectArraySubject.java +++ b/core/src/main/java/com/google/common/truth/ObjectArraySubject.java @@ -18,13 +18,15 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Arrays; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A Subject for {@code Object[]} and more generically {@code T[]}. * * @author Christian Gruber */ +@NullMarked public final class ObjectArraySubject extends AbstractArraySubject { private final T @Nullable [] actual; diff --git a/core/src/main/java/com/google/common/truth/OptionalDoubleSubject.java b/core/src/main/java/com/google/common/truth/OptionalDoubleSubject.java index fa9d940255..2aefa170fa 100644 --- a/core/src/main/java/com/google/common/truth/OptionalDoubleSubject.java +++ b/core/src/main/java/com/google/common/truth/OptionalDoubleSubject.java @@ -19,7 +19,7 @@ import static com.google.common.truth.Fact.simpleFact; import java.util.OptionalDouble; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Propositions for Java 8 {@link OptionalDouble} subjects. diff --git a/core/src/main/java/com/google/common/truth/OptionalIntSubject.java b/core/src/main/java/com/google/common/truth/OptionalIntSubject.java index b4350536cc..12d0ed9325 100644 --- a/core/src/main/java/com/google/common/truth/OptionalIntSubject.java +++ b/core/src/main/java/com/google/common/truth/OptionalIntSubject.java @@ -19,7 +19,7 @@ import static com.google.common.truth.Fact.simpleFact; import java.util.OptionalInt; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Propositions for Java 8 {@link OptionalInt} subjects. diff --git a/core/src/main/java/com/google/common/truth/OptionalLongSubject.java b/core/src/main/java/com/google/common/truth/OptionalLongSubject.java index 535fd1b3b1..ddf51066ae 100644 --- a/core/src/main/java/com/google/common/truth/OptionalLongSubject.java +++ b/core/src/main/java/com/google/common/truth/OptionalLongSubject.java @@ -19,7 +19,7 @@ import static com.google.common.truth.Fact.simpleFact; import java.util.OptionalLong; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Propositions for Java 8 {@link OptionalLong} subjects. diff --git a/core/src/main/java/com/google/common/truth/OptionalSubject.java b/core/src/main/java/com/google/common/truth/OptionalSubject.java index f6cac1ef59..246888041e 100644 --- a/core/src/main/java/com/google/common/truth/OptionalSubject.java +++ b/core/src/main/java/com/google/common/truth/OptionalSubject.java @@ -19,7 +19,7 @@ import static com.google.common.truth.Fact.simpleFact; import java.util.Optional; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Propositions for Java 8 {@link Optional} subjects. diff --git a/core/src/main/java/com/google/common/truth/Ordered.java b/core/src/main/java/com/google/common/truth/Ordered.java index 2f7efed383..2eb1f0d181 100644 --- a/core/src/main/java/com/google/common/truth/Ordered.java +++ b/core/src/main/java/com/google/common/truth/Ordered.java @@ -15,6 +15,7 @@ */ package com.google.common.truth; +import org.jspecify.annotations.NullMarked; /** * Returned by calls like {@link IterableSubject#containsExactly}, {@code Ordered} lets the caller @@ -26,6 +27,7 @@ * assertThat(supportedCharsets).containsExactly("UTF-8", "US-ASCII").inOrder(); // does check order * } */ +@NullMarked public interface Ordered { /** diff --git a/core/src/main/java/com/google/common/truth/Platform.java b/core/src/main/java/com/google/common/truth/Platform.java index 30f7277dd3..69944c1e4c 100644 --- a/core/src/main/java/com/google/common/truth/Platform.java +++ b/core/src/main/java/com/google/common/truth/Platform.java @@ -32,7 +32,8 @@ import java.lang.reflect.Method; import java.util.List; import java.util.regex.Pattern; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import org.junit.ComparisonFailure; import org.junit.rules.TestRule; @@ -42,6 +43,7 @@ * * @author Christian Gruber (cgruber@google.com) */ +@NullMarked final class Platform { private Platform() {} diff --git a/core/src/main/java/com/google/common/truth/PrimitiveBooleanArraySubject.java b/core/src/main/java/com/google/common/truth/PrimitiveBooleanArraySubject.java index 33ff6d8952..30e221d9c1 100644 --- a/core/src/main/java/com/google/common/truth/PrimitiveBooleanArraySubject.java +++ b/core/src/main/java/com/google/common/truth/PrimitiveBooleanArraySubject.java @@ -18,13 +18,15 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.primitives.Booleans; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A Subject for {@code boolean[]}. * * @author Christian Gruber (cgruber@israfil.net) */ +@NullMarked public final class PrimitiveBooleanArraySubject extends AbstractArraySubject { private final boolean @Nullable [] actual; diff --git a/core/src/main/java/com/google/common/truth/PrimitiveByteArraySubject.java b/core/src/main/java/com/google/common/truth/PrimitiveByteArraySubject.java index f8169ca4df..510d953d6a 100644 --- a/core/src/main/java/com/google/common/truth/PrimitiveByteArraySubject.java +++ b/core/src/main/java/com/google/common/truth/PrimitiveByteArraySubject.java @@ -18,13 +18,15 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.primitives.Bytes; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A Subject for {@code byte[]}. * * @author Kurt Alfred Kluever */ +@NullMarked public final class PrimitiveByteArraySubject extends AbstractArraySubject { private final byte @Nullable [] actual; diff --git a/core/src/main/java/com/google/common/truth/PrimitiveCharArraySubject.java b/core/src/main/java/com/google/common/truth/PrimitiveCharArraySubject.java index 79e6f12ebf..bfeceea065 100644 --- a/core/src/main/java/com/google/common/truth/PrimitiveCharArraySubject.java +++ b/core/src/main/java/com/google/common/truth/PrimitiveCharArraySubject.java @@ -18,13 +18,15 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.primitives.Chars; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A Subject for {@code char[]}. * * @author Christian Gruber (cgruber@israfil.net) */ +@NullMarked public final class PrimitiveCharArraySubject extends AbstractArraySubject { private final char @Nullable [] actual; diff --git a/core/src/main/java/com/google/common/truth/PrimitiveDoubleArraySubject.java b/core/src/main/java/com/google/common/truth/PrimitiveDoubleArraySubject.java index 6fdb27507b..840b6f7042 100644 --- a/core/src/main/java/com/google/common/truth/PrimitiveDoubleArraySubject.java +++ b/core/src/main/java/com/google/common/truth/PrimitiveDoubleArraySubject.java @@ -23,13 +23,15 @@ import com.google.common.primitives.Doubles; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Arrays; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A Subject for {@code double[]}. * * @author Christian Gruber (cgruber@israfil.net) */ +@NullMarked public final class PrimitiveDoubleArraySubject extends AbstractArraySubject { private final double @Nullable [] actual; diff --git a/core/src/main/java/com/google/common/truth/PrimitiveFloatArraySubject.java b/core/src/main/java/com/google/common/truth/PrimitiveFloatArraySubject.java index 339a4d5be6..c53267d0fc 100644 --- a/core/src/main/java/com/google/common/truth/PrimitiveFloatArraySubject.java +++ b/core/src/main/java/com/google/common/truth/PrimitiveFloatArraySubject.java @@ -23,13 +23,15 @@ import com.google.common.primitives.Floats; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Arrays; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A Subject for {@code float[]}. * * @author Christian Gruber (cgruber@israfil.net) */ +@NullMarked public final class PrimitiveFloatArraySubject extends AbstractArraySubject { private final float @Nullable [] actual; diff --git a/core/src/main/java/com/google/common/truth/PrimitiveIntArraySubject.java b/core/src/main/java/com/google/common/truth/PrimitiveIntArraySubject.java index b6c64634de..f2458b88cc 100644 --- a/core/src/main/java/com/google/common/truth/PrimitiveIntArraySubject.java +++ b/core/src/main/java/com/google/common/truth/PrimitiveIntArraySubject.java @@ -18,13 +18,15 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.primitives.Ints; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A Subject for {@code int[]}. * * @author Christian Gruber (cgruber@israfil.net) */ +@NullMarked public final class PrimitiveIntArraySubject extends AbstractArraySubject { private final int @Nullable [] actual; diff --git a/core/src/main/java/com/google/common/truth/PrimitiveLongArraySubject.java b/core/src/main/java/com/google/common/truth/PrimitiveLongArraySubject.java index 0744108633..4b5ed5ebe1 100644 --- a/core/src/main/java/com/google/common/truth/PrimitiveLongArraySubject.java +++ b/core/src/main/java/com/google/common/truth/PrimitiveLongArraySubject.java @@ -18,13 +18,15 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.primitives.Longs; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A Subject for {@code long[]}. * * @author Christian Gruber (cgruber@israfil.net) */ +@NullMarked public final class PrimitiveLongArraySubject extends AbstractArraySubject { private final long @Nullable [] actual; diff --git a/core/src/main/java/com/google/common/truth/PrimitiveShortArraySubject.java b/core/src/main/java/com/google/common/truth/PrimitiveShortArraySubject.java index dcefab4784..ff36a947ef 100644 --- a/core/src/main/java/com/google/common/truth/PrimitiveShortArraySubject.java +++ b/core/src/main/java/com/google/common/truth/PrimitiveShortArraySubject.java @@ -18,13 +18,15 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.primitives.Shorts; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * A Subject for {@code short[]}. * * @author Christian Gruber (cgruber@israfil.net) */ +@NullMarked public final class PrimitiveShortArraySubject extends AbstractArraySubject { private final short @Nullable [] actual; diff --git a/core/src/main/java/com/google/common/truth/SimpleSubjectBuilder.java b/core/src/main/java/com/google/common/truth/SimpleSubjectBuilder.java index 80caa364c6..7bae5be04c 100644 --- a/core/src/main/java/com/google/common/truth/SimpleSubjectBuilder.java +++ b/core/src/main/java/com/google/common/truth/SimpleSubjectBuilder.java @@ -17,7 +17,8 @@ import static com.google.common.base.Preconditions.checkNotNull; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * In a fluent assertion chain, exposes the most common {@code that} method, which accepts a value @@ -31,6 +32,7 @@ *

You won't extend this type. When you write a custom subject, see our doc on extensions. */ +@NullMarked public final class SimpleSubjectBuilder { private final FailureMetadata metadata; private final Subject.Factory subjectFactory; diff --git a/core/src/main/java/com/google/common/truth/StackTraceCleaner.java b/core/src/main/java/com/google/common/truth/StackTraceCleaner.java index 5efc43a0fa..290aea0d1e 100644 --- a/core/src/main/java/com/google/common/truth/StackTraceCleaner.java +++ b/core/src/main/java/com/google/common/truth/StackTraceCleaner.java @@ -27,11 +27,13 @@ import java.util.List; import java.util.ListIterator; import java.util.Set; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** Utility that cleans stack traces to remove noise from common frameworks. */ @GwtIncompatible @J2ktIncompatible +@NullMarked final class StackTraceCleaner { static final String CLEANER_LINK = "https://goo.gl/aH3UyP"; diff --git a/core/src/main/java/com/google/common/truth/StandardSubjectBuilder.java b/core/src/main/java/com/google/common/truth/StandardSubjectBuilder.java index 5413182f76..7a450367d1 100644 --- a/core/src/main/java/com/google/common/truth/StandardSubjectBuilder.java +++ b/core/src/main/java/com/google/common/truth/StandardSubjectBuilder.java @@ -33,7 +33,8 @@ import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.Stream; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * In a fluent assertion chain, an object with which you can do any of the following: @@ -53,6 +54,7 @@ *

You won't extend this type. When you write a custom subject, see our doc on extensions. */ +@NullMarked public class StandardSubjectBuilder { /** * Returns a new instance that invokes the given {@code FailureStrategy} when a check fails. Most diff --git a/core/src/main/java/com/google/common/truth/StreamSubject.java b/core/src/main/java/com/google/common/truth/StreamSubject.java index a774cc994b..2baed2ccd5 100644 --- a/core/src/main/java/com/google/common/truth/StreamSubject.java +++ b/core/src/main/java/com/google/common/truth/StreamSubject.java @@ -25,7 +25,7 @@ import java.util.Comparator; import java.util.List; import java.util.stream.Stream; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link Stream} subjects. diff --git a/core/src/main/java/com/google/common/truth/StringSubject.java b/core/src/main/java/com/google/common/truth/StringSubject.java index 597bcd9bbd..8e71cc1137 100644 --- a/core/src/main/java/com/google/common/truth/StringSubject.java +++ b/core/src/main/java/com/google/common/truth/StringSubject.java @@ -23,7 +23,8 @@ import com.google.common.annotations.GwtIncompatible; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for string subjects. @@ -31,6 +32,7 @@ * @author David Saff * @author Christian Gruber (cgruber@israfil.net) */ +@NullMarked public class StringSubject extends ComparableSubject { private final @Nullable String actual; diff --git a/core/src/main/java/com/google/common/truth/Subject.java b/core/src/main/java/com/google/common/truth/Subject.java index bcb8e4d0d0..d97f3791be 100644 --- a/core/src/main/java/com/google/common/truth/Subject.java +++ b/core/src/main/java/com/google/common/truth/Subject.java @@ -53,7 +53,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * An object that lets you perform checks on the value under test. For example, {@code Subject} @@ -72,6 +73,7 @@ * @author David Saff * @author Christian Gruber */ +@NullMarked public class Subject { /** * In a fluent assertion chain, the argument to the common overload of {@link diff --git a/core/src/main/java/com/google/common/truth/SubjectUtils.java b/core/src/main/java/com/google/common/truth/SubjectUtils.java index 7668beb52d..20fe72e152 100644 --- a/core/src/main/java/com/google/common/truth/SubjectUtils.java +++ b/core/src/main/java/com/google/common/truth/SubjectUtils.java @@ -36,7 +36,8 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Utility methods used in {@code Subject} implementors. @@ -44,6 +45,7 @@ * @author Christian Gruber * @author Jens Nyman */ +@NullMarked final class SubjectUtils { private SubjectUtils() {} diff --git a/core/src/main/java/com/google/common/truth/TableSubject.java b/core/src/main/java/com/google/common/truth/TableSubject.java index 9ab8f5c3ef..21e9e10412 100644 --- a/core/src/main/java/com/google/common/truth/TableSubject.java +++ b/core/src/main/java/com/google/common/truth/TableSubject.java @@ -23,13 +23,15 @@ import com.google.common.collect.Table; import com.google.common.collect.Table.Cell; import com.google.common.collect.Tables; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link Table} subjects. * * @author Kurt Alfred Kluever */ +@NullMarked public final class TableSubject extends Subject { private final @Nullable Table actual; diff --git a/core/src/main/java/com/google/common/truth/ThrowableSubject.java b/core/src/main/java/com/google/common/truth/ThrowableSubject.java index 08306bcb2b..8566dbd70c 100644 --- a/core/src/main/java/com/google/common/truth/ThrowableSubject.java +++ b/core/src/main/java/com/google/common/truth/ThrowableSubject.java @@ -17,7 +17,8 @@ import static com.google.common.base.Preconditions.checkNotNull; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Propositions for {@link Throwable} subjects. @@ -38,6 +39,7 @@ * * @author Kurt Alfred Kluever */ +@NullMarked public class ThrowableSubject extends Subject { private final @Nullable Throwable actual; diff --git a/core/src/main/java/com/google/common/truth/Truth.java b/core/src/main/java/com/google/common/truth/Truth.java index 8b16b6c448..7ece562cfd 100644 --- a/core/src/main/java/com/google/common/truth/Truth.java +++ b/core/src/main/java/com/google/common/truth/Truth.java @@ -32,7 +32,8 @@ import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.Stream; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * The primary entry point for Truth, a library for fluent test @@ -78,6 +79,7 @@ * @author David Saff * @author Christian Gruber (cgruber@israfil.net) */ +@NullMarked public final class Truth { private Truth() {} diff --git a/core/src/main/java/com/google/common/truth/Truth8.java b/core/src/main/java/com/google/common/truth/Truth8.java index 23bd46764b..e28ad49e08 100644 --- a/core/src/main/java/com/google/common/truth/Truth8.java +++ b/core/src/main/java/com/google/common/truth/Truth8.java @@ -25,7 +25,7 @@ import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.Stream; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * The obsolete entry point for assertions about Java 8 types. diff --git a/core/src/main/java/com/google/common/truth/TruthFailureSubject.java b/core/src/main/java/com/google/common/truth/TruthFailureSubject.java index eb9f93878c..d4b6d60668 100644 --- a/core/src/main/java/com/google/common/truth/TruthFailureSubject.java +++ b/core/src/main/java/com/google/common/truth/TruthFailureSubject.java @@ -23,7 +23,8 @@ import static com.google.common.truth.Fact.simpleFact; import com.google.common.collect.ImmutableList; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** * Subject for {@link AssertionError} objects thrown by Truth. {@code TruthFailureSubject} contains @@ -38,6 +39,7 @@ *

This class accepts any {@code AssertionError} value, but it will throw an exception if a * caller tries to access the facts of an error that wasn't produced by Truth. */ +@NullMarked public final class TruthFailureSubject extends ThrowableSubject { static final Fact HOW_TO_TEST_KEYS_WITHOUT_VALUES = simpleFact( diff --git a/core/src/main/java/com/google/common/truth/TruthJUnit.java b/core/src/main/java/com/google/common/truth/TruthJUnit.java index 648d51236c..94f47cb754 100644 --- a/core/src/main/java/com/google/common/truth/TruthJUnit.java +++ b/core/src/main/java/com/google/common/truth/TruthJUnit.java @@ -15,6 +15,7 @@ */ package com.google.common.truth; +import org.jspecify.annotations.NullMarked; import org.junit.AssumptionViolatedException; /** @@ -39,6 +40,7 @@ * @author David Saff * @author Christian Gruber (cgruber@israfil.net) */ +@NullMarked @com.google.common.annotations.GwtIncompatible("JUnit4") public final class TruthJUnit { @SuppressWarnings("ConstantCaseForConstants") // Despite the "Builder" name, it's not mutable. diff --git a/core/src/main/java/com/google/common/truth/UsedByReflection.java b/core/src/main/java/com/google/common/truth/UsedByReflection.java index ce41dfd8df..50713931ed 100644 --- a/core/src/main/java/com/google/common/truth/UsedByReflection.java +++ b/core/src/main/java/com/google/common/truth/UsedByReflection.java @@ -20,6 +20,8 @@ import static java.lang.annotation.ElementType.METHOD; import java.lang.annotation.Target; +import org.jspecify.annotations.NullMarked; @Target({METHOD, FIELD, CONSTRUCTOR}) +@NullMarked @interface UsedByReflection {} diff --git a/core/src/main/java/com/google/common/truth/super/com/google/common/truth/Platform.java b/core/src/main/java/com/google/common/truth/super/com/google/common/truth/Platform.java index 3bb24af2e7..e50bd28ea4 100644 --- a/core/src/main/java/com/google/common/truth/super/com/google/common/truth/Platform.java +++ b/core/src/main/java/com/google/common/truth/super/com/google/common/truth/Platform.java @@ -23,7 +23,8 @@ import jsinterop.annotations.JsMethod; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; /** @@ -32,6 +33,7 @@ * * @author Christian Gruber (cgruber@google.com) */ +@NullMarked final class Platform { private Platform() {} diff --git a/core/src/test/java/com/google/common/truth/DoubleSubjectTest.java b/core/src/test/java/com/google/common/truth/DoubleSubjectTest.java index e6535584d2..f65e2603ca 100644 --- a/core/src/test/java/com/google/common/truth/DoubleSubjectTest.java +++ b/core/src/test/java/com/google/common/truth/DoubleSubjectTest.java @@ -23,7 +23,7 @@ import com.google.common.annotations.GwtIncompatible; import com.google.common.truth.ExpectFailure.SimpleSubjectBuilderCallback; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; diff --git a/core/src/test/java/com/google/common/truth/FloatSubjectTest.java b/core/src/test/java/com/google/common/truth/FloatSubjectTest.java index b528ab0908..b14da38fc4 100644 --- a/core/src/test/java/com/google/common/truth/FloatSubjectTest.java +++ b/core/src/test/java/com/google/common/truth/FloatSubjectTest.java @@ -23,7 +23,7 @@ import com.google.common.annotations.GwtIncompatible; import com.google.common.truth.ExpectFailure.SimpleSubjectBuilderCallback; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; diff --git a/core/src/test/java/com/google/common/truth/SubjectTest.java b/core/src/test/java/com/google/common/truth/SubjectTest.java index 9544f52f45..48b74b3dcc 100644 --- a/core/src/test/java/com/google/common/truth/SubjectTest.java +++ b/core/src/test/java/com/google/common/truth/SubjectTest.java @@ -42,7 +42,7 @@ import java.math.BigDecimal; import java.util.Arrays; import java.util.Iterator; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; diff --git a/core/src/test/java/com/google/common/truth/TestCorrespondences.java b/core/src/test/java/com/google/common/truth/TestCorrespondences.java index d2488d5caa..0c5c3af7c2 100644 --- a/core/src/test/java/com/google/common/truth/TestCorrespondences.java +++ b/core/src/test/java/com/google/common/truth/TestCorrespondences.java @@ -23,7 +23,7 @@ import com.google.common.base.Splitter; import com.google.common.primitives.Ints; import java.util.List; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** {@link Correspondence} implementations for testing purposes. */ final class TestCorrespondences { diff --git a/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java b/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java index 224bf65397..72c6a1778f 100644 --- a/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java +++ b/core/src/test/java/com/google/common/truth/extension/EmployeeSubject.java @@ -23,7 +23,7 @@ import com.google.common.truth.LongSubject; import com.google.common.truth.StringSubject; import com.google.common.truth.Subject; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * A Truth subject for {@link Employee}. diff --git a/extensions/java8/pom.xml b/extensions/java8/pom.xml index 951dc43a8e..95fb6505a7 100644 --- a/extensions/java8/pom.xml +++ b/extensions/java8/pom.xml @@ -20,8 +20,8 @@ truth - org.checkerframework - checker-qual + org.jspecify + jspecify diff --git a/extensions/liteproto/pom.xml b/extensions/liteproto/pom.xml index 7474ee5a4d..a70faa5d81 100644 --- a/extensions/liteproto/pom.xml +++ b/extensions/liteproto/pom.xml @@ -25,8 +25,8 @@ guava - org.checkerframework - checker-qual + org.jspecify + jspecify com.google.auto.value diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java index 3a0774eed2..0fcea474fd 100644 --- a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoSubject.java @@ -27,7 +27,7 @@ import com.google.errorprone.annotations.CheckReturnValue; import com.google.protobuf.MessageLite; import java.util.regex.Pattern; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Truth subjects for the Lite version of Protocol Buffers. diff --git a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java index 94895d9316..d3179b5888 100644 --- a/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java +++ b/extensions/liteproto/src/main/java/com/google/common/truth/extensions/proto/LiteProtoTruth.java @@ -21,7 +21,7 @@ import com.google.common.truth.Subject; import com.google.errorprone.annotations.CheckReturnValue; import com.google.protobuf.MessageLite; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * A set of static methods to begin a Truth assertion chain for the lite version of protocol diff --git a/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java b/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java index 372100e450..eba52260cb 100644 --- a/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java +++ b/extensions/liteproto/src/test/java/com/google/common/truth/extensions/proto/LiteProtoSubjectTest.java @@ -30,7 +30,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.regex.Pattern; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/extensions/proto/pom.xml b/extensions/proto/pom.xml index 7c07acc58e..d52855799a 100644 --- a/extensions/proto/pom.xml +++ b/extensions/proto/pom.xml @@ -29,8 +29,8 @@ guava - org.checkerframework - checker-qual + org.jspecify + jspecify com.google.auto.value diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FluentEqualityConfig.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FluentEqualityConfig.java index 1c425bd468..b3c994a4e9 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FluentEqualityConfig.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/FluentEqualityConfig.java @@ -34,7 +34,7 @@ import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.Message; import com.google.protobuf.TypeRegistry; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * A specification for a {@link ProtoTruthMessageDifferencer} for comparing two individual diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosSubject.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosSubject.java index b5f342bb76..427fe4b9f5 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosSubject.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosSubject.java @@ -34,7 +34,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Comparator; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Truth subject for the iterables of protocol buffers. diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosUsingCorrespondence.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosUsingCorrespondence.java index 9c366f588a..f7a15b35ec 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosUsingCorrespondence.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/IterableOfProtosUsingCorrespondence.java @@ -19,7 +19,7 @@ import com.google.common.truth.Ordered; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.protobuf.Message; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Comparison methods, which enforce the rules set in prior calls to {@link diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesFluentAssertion.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesFluentAssertion.java index f1aa7af105..f0ff0bed68 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesFluentAssertion.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesFluentAssertion.java @@ -22,7 +22,7 @@ import com.google.protobuf.Message; import com.google.protobuf.TypeRegistry; import java.util.Map; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Fluent API to perform detailed, customizable comparison of maps containing protocol buffers as diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java index 9248843e92..662ddb0d9a 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MapWithProtoValuesSubject.java @@ -32,7 +32,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Truth subject for maps with protocol buffers for values. diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesFluentAssertion.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesFluentAssertion.java index 838389b4ed..937bed8c3f 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesFluentAssertion.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesFluentAssertion.java @@ -22,7 +22,7 @@ import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.Message; import com.google.protobuf.TypeRegistry; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Fluent API to perform detailed, customizable comparison of {@link Multimap}s containing protocol diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubject.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubject.java index 8b37ee95f2..00bf560508 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubject.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/MultimapWithProtoValuesSubject.java @@ -35,7 +35,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Truth subject for {@link Multimap}s with protocol buffers for values. diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoFluentAssertion.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoFluentAssertion.java index 3047caba0d..6b5624f9c9 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoFluentAssertion.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoFluentAssertion.java @@ -19,7 +19,7 @@ import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.Message; import com.google.protobuf.TypeRegistry; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Fluent API to perform detailed, customizable comparison of Protocol buffers. diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubject.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubject.java index ba96333d97..1388f90042 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubject.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubject.java @@ -29,7 +29,7 @@ import com.google.protobuf.Message; import com.google.protobuf.TypeRegistry; import java.util.Arrays; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Truth subject for the full version of Protocol Buffers. diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java index 0d813aa20a..e7015c1897 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java @@ -22,7 +22,7 @@ import com.google.protobuf.Message; import com.google.protobuf.MessageLite; import java.util.Map; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * {@link CustomSubjectBuilder} which aggregates all Proto-related {@link diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java index fbdaa9e015..7daa0d1dcb 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java @@ -27,7 +27,7 @@ import com.google.protobuf.Message; import com.google.protobuf.MessageLite; import java.util.Map; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * A set of static methods to begin a Truth assertion chain for protocol buffers. diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruthMessageDifferencer.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruthMessageDifferencer.java index 8ecfe0b455..d5ec1a8030 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruthMessageDifferencer.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruthMessageDifferencer.java @@ -49,7 +49,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Tool to differentiate two messages with the same {@link Descriptor}, subject to the rules set out diff --git a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java index cc7fd0a3ef..e686a4f4ad 100644 --- a/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java +++ b/extensions/proto/src/test/java/com/google/common/truth/extensions/proto/ProtoSubjectTestBase.java @@ -45,7 +45,7 @@ import java.util.Map; import java.util.Set; import java.util.regex.Pattern; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; import org.junit.Rule; /** Base class for testing {@link ProtoSubject} methods. */ diff --git a/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java b/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java index 1dc387f5d9..ecaa6a61d1 100644 --- a/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java +++ b/extensions/re2j/src/main/java/com/google/common/truth/extensions/re2j/Re2jSubjects.java @@ -21,7 +21,7 @@ import com.google.common.truth.FailureMetadata; import com.google.common.truth.Subject; import com.google.re2j.Pattern; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Truth subjects for re2j regular expressions. diff --git a/pom.xml b/pom.xml index 26067bf641..c502b7ad99 100644 --- a/pom.xml +++ b/pom.xml @@ -71,9 +71,9 @@ ${guava.android.version} - org.checkerframework - checker-qual - 3.44.0 + org.jspecify + jspecify + 0.3.0 junit diff --git a/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java b/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java index 8b298f351d..7bd0076cd3 100644 --- a/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java +++ b/refactorings/src/main/java/com/google/common/truth/refactorings/CorrespondenceSubclassToFactoryCall.java @@ -83,7 +83,7 @@ import java.util.Optional; import java.util.Set; import javax.lang.model.element.Modifier; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Refactors some subclasses of {@code Correspondence} to instead call {@code Correspondence.from}. diff --git a/refactorings/src/main/java/com/google/common/truth/refactorings/FailWithFacts.java b/refactorings/src/main/java/com/google/common/truth/refactorings/FailWithFacts.java index 30cb5207dd..f2fa8506a0 100644 --- a/refactorings/src/main/java/com/google/common/truth/refactorings/FailWithFacts.java +++ b/refactorings/src/main/java/com/google/common/truth/refactorings/FailWithFacts.java @@ -40,7 +40,7 @@ import com.sun.source.tree.MemberSelectTree; import com.sun.source.tree.MethodInvocationTree; import java.util.List; -import org.checkerframework.checker.nullness.qual.Nullable; +import org.jspecify.annotations.Nullable; /** * Migrates Truth subjects from the old {@code fail(String, Object)} to the new {@code