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 2aefa170f..96403a4bc 100644
--- a/core/src/main/java/com/google/common/truth/OptionalDoubleSubject.java
+++ b/core/src/main/java/com/google/common/truth/OptionalDoubleSubject.java
@@ -31,7 +31,7 @@
@IgnoreJRERequirement
public final class OptionalDoubleSubject extends Subject {
- private final OptionalDouble actual;
+ private final @Nullable OptionalDouble actual;
OptionalDoubleSubject(
FailureMetadata failureMetadata,
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 12d0ed932..37921f8b4 100644
--- a/core/src/main/java/com/google/common/truth/OptionalIntSubject.java
+++ b/core/src/main/java/com/google/common/truth/OptionalIntSubject.java
@@ -30,7 +30,7 @@
@SuppressWarnings("Java7ApiChecker") // used only from APIs with Java 8 in their signatures
@IgnoreJRERequirement
public final class OptionalIntSubject extends Subject {
- private final OptionalInt actual;
+ private final @Nullable OptionalInt actual;
OptionalIntSubject(
FailureMetadata failureMetadata,
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 ddf51066a..237706b6c 100644
--- a/core/src/main/java/com/google/common/truth/OptionalLongSubject.java
+++ b/core/src/main/java/com/google/common/truth/OptionalLongSubject.java
@@ -30,7 +30,7 @@
@SuppressWarnings("Java7ApiChecker") // used only from APIs with Java 8 in their signatures
@IgnoreJRERequirement
public final class OptionalLongSubject extends Subject {
- private final OptionalLong actual;
+ private final @Nullable OptionalLong actual;
OptionalLongSubject(
FailureMetadata failureMetadata,
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 2eb1f0d18..2f7efed38 100644
--- a/core/src/main/java/com/google/common/truth/Ordered.java
+++ b/core/src/main/java/com/google/common/truth/Ordered.java
@@ -15,7 +15,6 @@
*/
package com.google.common.truth;
-import org.jspecify.annotations.NullMarked;
/**
* Returned by calls like {@link IterableSubject#containsExactly}, {@code Ordered} lets the caller
@@ -27,7 +26,6 @@
* 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/PathSubject.java b/core/src/main/java/com/google/common/truth/PathSubject.java
index d470c8656..5957779d1 100644
--- a/core/src/main/java/com/google/common/truth/PathSubject.java
+++ b/core/src/main/java/com/google/common/truth/PathSubject.java
@@ -18,6 +18,7 @@
import com.google.common.annotations.GwtIncompatible;
import com.google.j2objc.annotations.J2ObjCIncompatible;
import java.nio.file.Path;
+import org.jspecify.annotations.Nullable;
/**
* Assertions for {@link Path} instances.
@@ -28,7 +29,7 @@
@J2ObjCIncompatible
@J2ktIncompatible
public final class PathSubject extends Subject {
- PathSubject(FailureMetadata failureMetadata, Path actual) {
+ PathSubject(FailureMetadata failureMetadata, @Nullable Path actual) {
super(failureMetadata, actual);
}
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 59e47c37d..f3e9059f6 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,6 @@
import java.lang.reflect.Method;
import java.util.List;
import java.util.regex.Pattern;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import org.junit.ComparisonFailure;
import org.junit.rules.TestRule;
@@ -43,7 +42,6 @@
*
* @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 30e221d9c..925ea571f 100644
--- a/core/src/main/java/com/google/common/truth/PrimitiveBooleanArraySubject.java
+++ b/core/src/main/java/com/google/common/truth/PrimitiveBooleanArraySubject.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.primitives.Booleans;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -26,7 +25,6 @@
*
* @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 510d953d6..1f649c6e3 100644
--- a/core/src/main/java/com/google/common/truth/PrimitiveByteArraySubject.java
+++ b/core/src/main/java/com/google/common/truth/PrimitiveByteArraySubject.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.primitives.Bytes;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -26,7 +25,6 @@
*
* @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 bfeceea06..0ee8c0577 100644
--- a/core/src/main/java/com/google/common/truth/PrimitiveCharArraySubject.java
+++ b/core/src/main/java/com/google/common/truth/PrimitiveCharArraySubject.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.primitives.Chars;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -26,7 +25,6 @@
*
* @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 840b6f704..ce22539f9 100644
--- a/core/src/main/java/com/google/common/truth/PrimitiveDoubleArraySubject.java
+++ b/core/src/main/java/com/google/common/truth/PrimitiveDoubleArraySubject.java
@@ -23,7 +23,6 @@
import com.google.common.primitives.Doubles;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Arrays;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -31,7 +30,6 @@
*
* @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 c53267d0f..9ce5a2894 100644
--- a/core/src/main/java/com/google/common/truth/PrimitiveFloatArraySubject.java
+++ b/core/src/main/java/com/google/common/truth/PrimitiveFloatArraySubject.java
@@ -23,7 +23,6 @@
import com.google.common.primitives.Floats;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Arrays;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -31,7 +30,6 @@
*
* @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 f2458b88c..b8ee605a1 100644
--- a/core/src/main/java/com/google/common/truth/PrimitiveIntArraySubject.java
+++ b/core/src/main/java/com/google/common/truth/PrimitiveIntArraySubject.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.primitives.Ints;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -26,7 +25,6 @@
*
* @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 4b5ed5ebe..8b34ddd4e 100644
--- a/core/src/main/java/com/google/common/truth/PrimitiveLongArraySubject.java
+++ b/core/src/main/java/com/google/common/truth/PrimitiveLongArraySubject.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.primitives.Longs;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -26,7 +25,6 @@
*
* @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 ff36a947e..147eeb102 100644
--- a/core/src/main/java/com/google/common/truth/PrimitiveShortArraySubject.java
+++ b/core/src/main/java/com/google/common/truth/PrimitiveShortArraySubject.java
@@ -18,7 +18,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.primitives.Shorts;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -26,7 +25,6 @@
*
* @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 7bae5be04..1bb1b2c5e 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,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -32,7 +31,6 @@
* 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 290aea0d1..6284a0168 100644
--- a/core/src/main/java/com/google/common/truth/StackTraceCleaner.java
+++ b/core/src/main/java/com/google/common/truth/StackTraceCleaner.java
@@ -27,13 +27,11 @@
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
-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 7a450367d..288662afe 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,6 @@
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.Stream;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -54,7 +53,6 @@
* 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 2baed2ccd..0140d6dcd 100644
--- a/core/src/main/java/com/google/common/truth/StreamSubject.java
+++ b/core/src/main/java/com/google/common/truth/StreamSubject.java
@@ -50,7 +50,7 @@
public final class StreamSubject extends Subject {
// Storing the FailureMetadata instance is not usually advisable.
private final FailureMetadata metadata;
- private final Stream> actual;
+ private final @Nullable Stream> actual;
private final Supplier<@Nullable List>> listSupplier;
StreamSubject(
@@ -145,7 +145,7 @@ public void containsAnyOf(
}
/** Fails if the subject does not contain at least one of the given elements. */
- public void containsAnyIn(Iterable> expected) {
+ public void containsAnyIn(@Nullable Iterable> expected) {
checkThatContentsList().containsAnyIn(expected);
}
@@ -174,7 +174,7 @@ public Ordered containsAtLeast(
* within the actual elements, but they are not required to be consecutive.
*/
@CanIgnoreReturnValue
- public Ordered containsAtLeastElementsIn(Iterable> expected) {
+ public Ordered containsAtLeastElementsIn(@Nullable Iterable> expected) {
return checkThatContentsList().containsAtLeastElementsIn(expected);
}
@@ -209,7 +209,7 @@ public Ordered containsExactly(@Nullable Object @Nullable ... varargs) {
* on the object returned by this method.
*/
@CanIgnoreReturnValue
- public Ordered containsExactlyElementsIn(Iterable> expected) {
+ public Ordered containsExactlyElementsIn(@Nullable Iterable> expected) {
return checkThatContentsList().containsExactlyElementsIn(expected);
}
@@ -226,7 +226,7 @@ public void containsNoneOf(
* Fails if the subject contains any of the given elements. (Duplicates are irrelevant to this
* test, which fails if any of the actual elements equal any of the excluded.)
*/
- public void containsNoneIn(Iterable> excluded) {
+ public void containsNoneIn(@Nullable Iterable> excluded) {
checkThatContentsList().containsNoneIn(excluded);
}
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 bfd55f10d..8819c9218 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,6 @@
import com.google.common.annotations.GwtIncompatible;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -32,7 +31,6 @@
* @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 d97f3791b..08e14bb93 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,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -73,7 +72,6 @@
* @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 20fe72e15..84cf1f6ef 100644
--- a/core/src/main/java/com/google/common/truth/SubjectUtils.java
+++ b/core/src/main/java/com/google/common/truth/SubjectUtils.java
@@ -15,6 +15,7 @@
*/
package com.google.common.truth;
+import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Strings.lenientFormat;
import static com.google.common.collect.Iterables.isEmpty;
import static com.google.common.collect.Iterables.transform;
@@ -36,7 +37,6 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -45,7 +45,6 @@
* @author Christian Gruber
* @author Jens Nyman
*/
-@NullMarked
final class SubjectUtils {
private SubjectUtils() {}
@@ -343,7 +342,10 @@ private static List addTypeInfoToEveryItem(Iterable> items) {
return itemsWithTypeInfo;
}
- static Collection iterableToCollection(Iterable iterable) {
+ static Collection iterableToCollection(
+ @Nullable Iterable iterable) {
+ // TODO(cpovirk): For null inputs, produce a better exception message (ideally in callers).
+ checkNotNull(iterable);
if (iterable instanceof Collection) {
// Should be safe to assume that any Iterable implementing Collection isn't a one-shot
// iterable, right? I sure hope so.
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 21e9e1041..61e2c2f0c 100644
--- a/core/src/main/java/com/google/common/truth/TableSubject.java
+++ b/core/src/main/java/com/google/common/truth/TableSubject.java
@@ -23,7 +23,6 @@
import com.google.common.collect.Table;
import com.google.common.collect.Table.Cell;
import com.google.common.collect.Tables;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -31,7 +30,6 @@
*
* @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 8566dbd70..7a03a67a6 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,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -39,7 +38,6 @@
*
* @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 7ece562cf..407f6df63 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,6 @@
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.Stream;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -79,7 +78,6 @@
* @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/TruthFailureSubject.java b/core/src/main/java/com/google/common/truth/TruthFailureSubject.java
index d4b6d6066..6439cf7d8 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,6 @@
import static com.google.common.truth.Fact.simpleFact;
import com.google.common.collect.ImmutableList;
-import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
@@ -39,7 +38,6 @@
* 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 94f47cb75..648d51236 100644
--- a/core/src/main/java/com/google/common/truth/TruthJUnit.java
+++ b/core/src/main/java/com/google/common/truth/TruthJUnit.java
@@ -15,7 +15,6 @@
*/
package com.google.common.truth;
-import org.jspecify.annotations.NullMarked;
import org.junit.AssumptionViolatedException;
/**
@@ -40,7 +39,6 @@
* @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 50713931e..ce41dfd8d 100644
--- a/core/src/main/java/com/google/common/truth/UsedByReflection.java
+++ b/core/src/main/java/com/google/common/truth/UsedByReflection.java
@@ -20,8 +20,6 @@
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/package-info.java b/core/src/main/java/com/google/common/truth/package-info.java
index 89839f730..99ee86a05 100644
--- a/core/src/main/java/com/google/common/truth/package-info.java
+++ b/core/src/main/java/com/google/common/truth/package-info.java
@@ -29,6 +29,8 @@
* other docs.
*/
@CheckReturnValue
+@NullMarked
package com.google.common.truth;
import com.google.errorprone.annotations.CheckReturnValue;
+import org.jspecify.annotations.NullMarked;