diff --git a/android/guava/src/com/google/common/collect/ImmutableCollection.java b/android/guava/src/com/google/common/collect/ImmutableCollection.java index 1da069a2f19b..c8167e8f61cc 100644 --- a/android/guava/src/com/google/common/collect/ImmutableCollection.java +++ b/android/guava/src/com/google/common/collect/ImmutableCollection.java @@ -36,6 +36,8 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Spliterator; +import java.util.Spliterators; import javax.annotation.CheckForNull; import org.checkerframework.checker.nullness.qual.Nullable; @@ -176,6 +178,11 @@ public abstract class ImmutableCollection extends AbstractCollection imple * These are properties of the collection as a whole; SIZED and SUBSIZED are more properties of * the spliterator implementation. */ + @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"}) + // @IgnoreJRERequirement is not necessary because this compiles down to a constant. + // (which is fortunate because Animal Sniffer doesn't look for @IgnoreJRERequirement on fields) + static final int SPLITERATOR_CHARACTERISTICS = + Spliterator.IMMUTABLE | Spliterator.NONNULL | Spliterator.ORDERED; ImmutableCollection() {} @@ -183,6 +190,14 @@ public abstract class ImmutableCollection extends AbstractCollection imple @Override public abstract UnmodifiableIterator iterator(); + @Override + @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"}) + @IgnoreJRERequirement // used only from APIs with Java 8 types in them + // (not used within guava-android as of this writing, but we include it in the jar as a test) + public Spliterator spliterator() { + return Spliterators.spliterator(this, SPLITERATOR_CHARACTERISTICS); + } + private static final Object[] EMPTY_ARRAY = {}; @Override