From 1d3cbf8228a1bc30b4dcf1704c1aaae96443e79d Mon Sep 17 00:00:00 2001 From: cpovirk Date: Sat, 25 Jan 2025 08:16:13 -0800 Subject: [PATCH] Mark test-suite-builder suites and related code as `@AndroidIncompatible`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (Along the way, break out `SynchronizedSetTest.TestSet` into a top-level type `LockHeldAssertingSet`, which should also make it easier to run each test in an individual build target someday.) (I did also sneak in one change to the backport copy of `IteratorsTest`. It resolve a diff that we accidentally introduced in cl/613629330.) Such code is already not run when we run our tests under Android emulators. (The Android JUnit 3 runner just ignores `suite()` methods, I want to say?) However, it's still _built_ for them. Besides being a waste, this requires pulling in the whole suite-builder ecosystem, which is again causing problems when I try to bump various things related to Android version—quite possibly a sign that the Android runner starts actually using `suite()` methods, whose large numbers of tests (at least in `common.collect`) are just too much for that environment? By adding `@AndroidIncompatible`, I configure our Android test build to strip the code altogether. RELNOTES=n/a PiperOrigin-RevId: 719651707 --- .../collect/testing/AndroidIncompatible.java | 41 +++++ .../FeatureSpecificTestSuiteBuilderTest.java | 1 + .../testing/MapTestSuiteBuilderTests.java | 1 + .../testing/MinimalCollectionTest.java | 1 + .../collect/testing/MinimalSetTest.java | 1 + .../collect/testing/OpenJdk6ListTests.java | 1 + .../collect/testing/OpenJdk6MapTests.java | 1 + .../collect/testing/OpenJdk6QueueTests.java | 1 + .../collect/testing/OpenJdk6SetTests.java | 1 + .../common/collect/testing/OpenJdk6Tests.java | 1 + .../collect/testing/SafeTreeMapTest.java | 1 + .../collect/testing/SafeTreeSetTest.java | 1 + .../google/common/cache/LocalCacheTest.java | 2 + .../common/collect/ArrayListMultimapTest.java | 1 + .../common/collect/Collections2Test.java | 7 + .../common/collect/CompactHashMapTest.java | 1 + .../common/collect/CompactHashSetTest.java | 1 + .../collect/CompactLinkedHashMapTest.java | 1 + .../collect/CompactLinkedHashSetTest.java | 1 + .../collect/ConcurrentHashMultisetTest.java | 3 + .../common/collect/ContiguousSetTest.java | 1 + .../google/common/collect/EnumBiMapTest.java | 2 + .../common/collect/EnumHashBiMapTest.java | 2 + .../common/collect/EnumMultisetTest.java | 2 + .../collect/ForwardingCollectionTest.java | 1 + .../common/collect/ForwardingListTest.java | 1 + .../common/collect/ForwardingMapTest.java | 1 + .../collect/ForwardingMultisetTest.java | 1 + .../collect/ForwardingNavigableMapTest.java | 1 + .../collect/ForwardingNavigableSetTest.java | 1 + .../common/collect/ForwardingQueueTest.java | 1 + .../common/collect/ForwardingSetTest.java | 1 + .../collect/ForwardingSortedMapTest.java | 1 + .../collect/ForwardingSortedMultisetTest.java | 1 + .../collect/ForwardingSortedSetTest.java | 1 + .../google/common/collect/HashBiMapTest.java | 2 + .../common/collect/HashMultimapTest.java | 1 + .../common/collect/HashMultisetTest.java | 2 + .../common/collect/ImmutableBiMapTest.java | 1 + .../ImmutableClassToInstanceMapTest.java | 1 + .../common/collect/ImmutableEnumMapTest.java | 2 + .../collect/ImmutableListMultimapTest.java | 3 + .../common/collect/ImmutableListTest.java | 1 + .../common/collect/ImmutableMapTest.java | 1 + .../common/collect/ImmutableMultisetTest.java | 1 + .../common/collect/ImmutableRangeSetTest.java | 3 + .../collect/ImmutableSetMultimapTest.java | 3 + .../common/collect/ImmutableSetTest.java | 1 + .../collect/ImmutableSortedMapTest.java | 1 + .../collect/ImmutableSortedMultisetTest.java | 1 + .../collect/ImmutableSortedSetTest.java | 1 + .../google/common/collect/IteratorsTest.java | 4 +- .../collect/LinkedHashMultimapTest.java | 1 + .../collect/LinkedHashMultisetTest.java | 2 + .../collect/LinkedListMultimapTest.java | 1 + .../com/google/common/collect/ListsTest.java | 1 + .../common/collect/LockHeldAssertingSet.java | 158 ++++++++++++++++ .../common/collect/MapsCollectionTest.java | 1 + .../collect/MinMaxPriorityQueueTest.java | 1 + .../collect/MultimapsCollectionTest.java | 1 + .../collect/MultisetsCollectionTest.java | 1 + .../MutableClassToInstanceMapTest.java | 1 + .../common/collect/SetOperationsTest.java | 1 + .../com/google/common/collect/SetsTest.java | 4 + .../collect/SimpleAbstractMultisetTest.java | 1 + .../common/collect/SynchronizedBiMapTest.java | 3 + .../collect/SynchronizedMultimapTest.java | 1 + .../collect/SynchronizedNavigableMapTest.java | 1 + .../collect/SynchronizedNavigableSetTest.java | 16 +- .../common/collect/SynchronizedSetTest.java | 135 +------------- .../common/collect/TableCollectionTest.java | 1 + .../common/collect/TreeBasedTableTest.java | 1 + .../collect/TreeMultimapNaturalTest.java | 1 + .../common/collect/TreeMultisetTest.java | 1 + .../common/collect/TreeRangeMapTest.java | 1 + .../primitives/ByteArrayAsListTest.java | 1 + .../primitives/CharArrayAsListTest.java | 1 + .../primitives/DoubleArrayAsListTest.java | 1 + .../primitives/FloatArrayAsListTest.java | 1 + .../primitives/ImmutableDoubleArrayTest.java | 9 + .../primitives/ImmutableIntArrayTest.java | 1 + .../primitives/ImmutableLongArrayTest.java | 9 + .../common/primitives/IntArrayAsListTest.java | 1 + .../primitives/LongArrayAsListTest.java | 1 + .../primitives/ShortArrayAsListTest.java | 1 + .../collect/testing/AndroidIncompatible.java | 41 +++++ .../FeatureSpecificTestSuiteBuilderTest.java | 1 + .../testing/MapTestSuiteBuilderTests.java | 1 + .../testing/MinimalCollectionTest.java | 1 + .../collect/testing/MinimalSetTest.java | 1 + .../collect/testing/OpenJdk6ListTests.java | 1 + .../collect/testing/OpenJdk6MapTests.java | 1 + .../collect/testing/OpenJdk6QueueTests.java | 1 + .../collect/testing/OpenJdk6SetTests.java | 1 + .../common/collect/testing/OpenJdk6Tests.java | 1 + .../collect/testing/SafeTreeMapTest.java | 1 + .../collect/testing/SafeTreeSetTest.java | 1 + .../google/common/cache/LocalCacheTest.java | 2 + .../common/collect/ArrayListMultimapTest.java | 1 + .../common/collect/Collections2Test.java | 7 + .../common/collect/CompactHashMapTest.java | 1 + .../common/collect/CompactHashSetTest.java | 1 + .../collect/CompactLinkedHashMapTest.java | 1 + .../collect/CompactLinkedHashSetTest.java | 1 + .../collect/ConcurrentHashMultisetTest.java | 3 + .../common/collect/ContiguousSetTest.java | 1 + .../google/common/collect/EnumBiMapTest.java | 2 + .../common/collect/EnumHashBiMapTest.java | 2 + .../common/collect/EnumMultisetTest.java | 2 + .../collect/ForwardingCollectionTest.java | 1 + .../common/collect/ForwardingListTest.java | 1 + .../common/collect/ForwardingMapTest.java | 1 + .../collect/ForwardingMultisetTest.java | 1 + .../collect/ForwardingNavigableMapTest.java | 1 + .../collect/ForwardingNavigableSetTest.java | 1 + .../common/collect/ForwardingQueueTest.java | 1 + .../common/collect/ForwardingSetTest.java | 1 + .../collect/ForwardingSortedMapTest.java | 1 + .../collect/ForwardingSortedMultisetTest.java | 1 + .../collect/ForwardingSortedSetTest.java | 1 + .../google/common/collect/HashBiMapTest.java | 2 + .../common/collect/HashMultimapTest.java | 1 + .../common/collect/HashMultisetTest.java | 2 + .../common/collect/ImmutableBiMapTest.java | 1 + .../ImmutableClassToInstanceMapTest.java | 1 + .../common/collect/ImmutableEnumMapTest.java | 2 + .../collect/ImmutableListMultimapTest.java | 3 + .../common/collect/ImmutableListTest.java | 1 + .../common/collect/ImmutableMapTest.java | 1 + .../common/collect/ImmutableMultisetTest.java | 1 + .../common/collect/ImmutableRangeSetTest.java | 3 + .../collect/ImmutableSetMultimapTest.java | 3 + .../common/collect/ImmutableSetTest.java | 1 + .../collect/ImmutableSortedMapTest.java | 1 + .../collect/ImmutableSortedMultisetTest.java | 1 + .../collect/ImmutableSortedSetTest.java | 1 + .../google/common/collect/IteratorsTest.java | 2 + .../collect/LinkedHashMultimapTest.java | 1 + .../collect/LinkedHashMultisetTest.java | 2 + .../collect/LinkedListMultimapTest.java | 1 + .../com/google/common/collect/ListsTest.java | 1 + .../common/collect/LockHeldAssertingSet.java | 168 ++++++++++++++++++ .../common/collect/MapsCollectionTest.java | 1 + .../collect/MinMaxPriorityQueueTest.java | 1 + .../collect/MultimapsCollectionTest.java | 1 + .../collect/MultisetsCollectionTest.java | 1 + .../MutableClassToInstanceMapTest.java | 1 + .../common/collect/SetOperationsTest.java | 1 + .../com/google/common/collect/SetsTest.java | 4 + .../collect/SimpleAbstractMultisetTest.java | 1 + .../common/collect/SynchronizedBiMapTest.java | 3 + .../collect/SynchronizedMultimapTest.java | 1 + .../collect/SynchronizedNavigableMapTest.java | 1 + .../collect/SynchronizedNavigableSetTest.java | 16 +- .../common/collect/SynchronizedSetTest.java | 145 +-------------- .../common/collect/TableCollectionTest.java | 1 + .../common/collect/TreeBasedTableTest.java | 1 + .../collect/TreeMultimapNaturalTest.java | 1 + .../common/collect/TreeMultisetTest.java | 1 + .../common/collect/TreeRangeMapTest.java | 1 + .../primitives/ByteArrayAsListTest.java | 1 + .../primitives/CharArrayAsListTest.java | 1 + .../primitives/DoubleArrayAsListTest.java | 1 + .../primitives/FloatArrayAsListTest.java | 1 + .../primitives/ImmutableDoubleArrayTest.java | 9 + .../primitives/ImmutableIntArrayTest.java | 1 + .../primitives/ImmutableLongArrayTest.java | 9 + .../common/primitives/IntArrayAsListTest.java | 1 + .../primitives/LongArrayAsListTest.java | 1 + .../primitives/ShortArrayAsListTest.java | 1 + 170 files changed, 683 insertions(+), 289 deletions(-) create mode 100644 android/guava-testlib/test/com/google/common/collect/testing/AndroidIncompatible.java create mode 100644 android/guava-tests/test/com/google/common/collect/LockHeldAssertingSet.java create mode 100644 guava-testlib/test/com/google/common/collect/testing/AndroidIncompatible.java create mode 100644 guava-tests/test/com/google/common/collect/LockHeldAssertingSet.java diff --git a/android/guava-testlib/test/com/google/common/collect/testing/AndroidIncompatible.java b/android/guava-testlib/test/com/google/common/collect/testing/AndroidIncompatible.java new file mode 100644 index 000000000000..bbd60d7a2206 --- /dev/null +++ b/android/guava-testlib/test/com/google/common/collect/testing/AndroidIncompatible.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect.testing; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import com.google.common.annotations.GwtCompatible; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Signifies that a test should not be run under Android. This annotation is respected only by our + * Google-internal Android suite generators. Note that those generators also suppress any test + * annotated with MediumTest or LargeTest. + * + *

For more discussion, see {@linkplain com.google.common.base.AndroidIncompatible the + * documentation on another copy of this annotation}. + */ +@Retention(CLASS) +@Target({ANNOTATION_TYPE, CONSTRUCTOR, FIELD, METHOD, TYPE}) +@GwtCompatible +@interface AndroidIncompatible {} diff --git a/android/guava-testlib/test/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilderTest.java b/android/guava-testlib/test/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilderTest.java index 72284f893bcd..682fd909d4ad 100644 --- a/android/guava-testlib/test/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilderTest.java +++ b/android/guava-testlib/test/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilderTest.java @@ -26,6 +26,7 @@ /** * @author Max Ross */ +@AndroidIncompatible // test-suite builders public class FeatureSpecificTestSuiteBuilderTest extends TestCase { private static final class MyTestSuiteBuilder extends FeatureSpecificTestSuiteBuilder { diff --git a/android/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java b/android/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java index 62724243fce2..d2e544016933 100644 --- a/android/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java +++ b/android/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java @@ -52,6 +52,7 @@ * * @author George van den Driessche */ +@AndroidIncompatible // test-suite builders public final class MapTestSuiteBuilderTests extends TestCase { private MapTestSuiteBuilderTests() {} diff --git a/android/guava-testlib/test/com/google/common/collect/testing/MinimalCollectionTest.java b/android/guava-testlib/test/com/google/common/collect/testing/MinimalCollectionTest.java index 38cadf3bff76..83489295a478 100644 --- a/android/guava-testlib/test/com/google/common/collect/testing/MinimalCollectionTest.java +++ b/android/guava-testlib/test/com/google/common/collect/testing/MinimalCollectionTest.java @@ -27,6 +27,7 @@ * * @author Kevin Bourrillion */ +@AndroidIncompatible // test-suite builders public class MinimalCollectionTest extends TestCase { public static Test suite() { return CollectionTestSuiteBuilder.using( diff --git a/android/guava-testlib/test/com/google/common/collect/testing/MinimalSetTest.java b/android/guava-testlib/test/com/google/common/collect/testing/MinimalSetTest.java index 51cc4c9561a9..037473508d83 100644 --- a/android/guava-testlib/test/com/google/common/collect/testing/MinimalSetTest.java +++ b/android/guava-testlib/test/com/google/common/collect/testing/MinimalSetTest.java @@ -27,6 +27,7 @@ * * @author Regina O'Dell */ +@AndroidIncompatible // test-suite builders public class MinimalSetTest extends TestCase { public static Test suite() { return SetTestSuiteBuilder.using( diff --git a/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6ListTests.java b/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6ListTests.java index 526cd566a627..3ba5482c4ea3 100644 --- a/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6ListTests.java +++ b/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6ListTests.java @@ -34,6 +34,7 @@ * * @author Kevin Bourrillion */ +@AndroidIncompatible // test-suite builders public class OpenJdk6ListTests extends TestsForListsInJavaUtil { public static Test suite() { return new OpenJdk6ListTests().allTests(); diff --git a/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6MapTests.java b/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6MapTests.java index 5ba946ee1cb2..54231a9def8b 100644 --- a/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6MapTests.java +++ b/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6MapTests.java @@ -41,6 +41,7 @@ * @author Kevin Bourrillion */ // TODO(cpovirk): consider renaming this class in light of our now running it under newer JDKs. +@AndroidIncompatible // test-suite builders public class OpenJdk6MapTests extends TestsForMapsInJavaUtil { public static Test suite() { return new OpenJdk6MapTests().allTests(); diff --git a/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6QueueTests.java b/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6QueueTests.java index be3e35a09e72..002b519f338a 100644 --- a/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6QueueTests.java +++ b/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6QueueTests.java @@ -31,6 +31,7 @@ * * @author Kevin Bourrillion */ +@AndroidIncompatible // test-suite builders public class OpenJdk6QueueTests extends TestsForQueuesInJavaUtil { public static Test suite() { return new OpenJdk6QueueTests().allTests(); diff --git a/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6SetTests.java b/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6SetTests.java index 39c5cf442b26..d5ccce9146bd 100644 --- a/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6SetTests.java +++ b/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6SetTests.java @@ -34,6 +34,7 @@ * * @author Kevin Bourrillion */ +@AndroidIncompatible // test-suite builders public class OpenJdk6SetTests extends TestsForSetsInJavaUtil { public static Test suite() { return new OpenJdk6SetTests().allTests(); diff --git a/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6Tests.java b/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6Tests.java index db60982ca779..c97d2bf92f92 100644 --- a/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6Tests.java +++ b/android/guava-testlib/test/com/google/common/collect/testing/OpenJdk6Tests.java @@ -27,6 +27,7 @@ * * @author Kevin Bourrillion */ +@AndroidIncompatible // test-suite builders public class OpenJdk6Tests extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-testlib/test/com/google/common/collect/testing/SafeTreeMapTest.java b/android/guava-testlib/test/com/google/common/collect/testing/SafeTreeMapTest.java index 67aa9f7f9b1f..4bd81700586a 100644 --- a/android/guava-testlib/test/com/google/common/collect/testing/SafeTreeMapTest.java +++ b/android/guava-testlib/test/com/google/common/collect/testing/SafeTreeMapTest.java @@ -42,6 +42,7 @@ * @author Louis Wasserman */ public class SafeTreeMapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SafeTreeMapTest.class); diff --git a/android/guava-testlib/test/com/google/common/collect/testing/SafeTreeSetTest.java b/android/guava-testlib/test/com/google/common/collect/testing/SafeTreeSetTest.java index 91e2e9f261e0..173e656e8016 100644 --- a/android/guava-testlib/test/com/google/common/collect/testing/SafeTreeSetTest.java +++ b/android/guava-testlib/test/com/google/common/collect/testing/SafeTreeSetTest.java @@ -37,6 +37,7 @@ import junit.framework.TestSuite; public class SafeTreeSetTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SafeTreeSetTest.class); diff --git a/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java b/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java index e5c8be9ba5cc..5a9c0961ceb1 100644 --- a/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java +++ b/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java @@ -95,6 +95,7 @@ @SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress. @NullUnmarked public class LocalCacheTest extends TestCase { + @AndroidIncompatible private static class TestStringCacheGenerator extends TestStringMapGenerator { private final CacheBuilder builder; @@ -112,6 +113,7 @@ protected Map create(Entry[] entries) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(LocalCacheTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/ArrayListMultimapTest.java b/android/guava-tests/test/com/google/common/collect/ArrayListMultimapTest.java index 37f513ae3b29..b92deb516a58 100644 --- a/android/guava-tests/test/com/google/common/collect/ArrayListMultimapTest.java +++ b/android/guava-tests/test/com/google/common/collect/ArrayListMultimapTest.java @@ -48,6 +48,7 @@ public class ArrayListMultimapTest extends TestCase { @GwtIncompatible // suite @J2ktIncompatible + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/android/guava-tests/test/com/google/common/collect/Collections2Test.java b/android/guava-tests/test/com/google/common/collect/Collections2Test.java index 221ba566f7ae..23f3ffbed87d 100644 --- a/android/guava-tests/test/com/google/common/collect/Collections2Test.java +++ b/android/guava-tests/test/com/google/common/collect/Collections2Test.java @@ -54,6 +54,7 @@ public class Collections2Test extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(Collections2Test.class.getSimpleName()); suite.addTest(testsForFilter()); @@ -73,6 +74,7 @@ public static Test suite() { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilter() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @@ -97,6 +99,7 @@ public Collection create(String[] elements) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilterAll() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @@ -119,6 +122,7 @@ public Collection create(String[] elements) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilterLinkedList() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @@ -143,6 +147,7 @@ public Collection create(String[] elements) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilterNoNulls() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @@ -167,6 +172,7 @@ public Collection create(String[] elements) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilterFiltered() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @@ -192,6 +198,7 @@ public Collection create(String[] elements) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForTransform() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { diff --git a/android/guava-tests/test/com/google/common/collect/CompactHashMapTest.java b/android/guava-tests/test/com/google/common/collect/CompactHashMapTest.java index c6b3d0c39eb7..ec8601fc52a0 100644 --- a/android/guava-tests/test/com/google/common/collect/CompactHashMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/CompactHashMapTest.java @@ -39,6 +39,7 @@ */ @NullUnmarked public class CompactHashMapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/android/guava-tests/test/com/google/common/collect/CompactHashSetTest.java b/android/guava-tests/test/com/google/common/collect/CompactHashSetTest.java index 1fe94825fecc..e472c4039357 100644 --- a/android/guava-tests/test/com/google/common/collect/CompactHashSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/CompactHashSetTest.java @@ -42,6 +42,7 @@ @GwtIncompatible // java.util.Arrays#copyOf(Object[], int), java.lang.reflect.Array @NullUnmarked public class CompactHashSetTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { List> allFeatures = Arrays.>asList( diff --git a/android/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java b/android/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java index 1b6c58c61410..fbfe0f96c13b 100644 --- a/android/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java @@ -38,6 +38,7 @@ */ @NullUnmarked public class CompactLinkedHashMapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/android/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java b/android/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java index 6996938a09f8..67853e409484 100644 --- a/android/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java @@ -42,6 +42,7 @@ @GwtIncompatible // java.util.Arrays#copyOf(Object[], int), java.lang.reflect.Array @NullUnmarked public class CompactLinkedHashSetTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { List> allFeatures = Arrays.>asList( diff --git a/android/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java b/android/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java index d211a0bed2cd..e5b0a3234ff6 100644 --- a/android/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java +++ b/android/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java @@ -51,6 +51,7 @@ @NullUnmarked public class ConcurrentHashMultisetTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( @@ -76,6 +77,7 @@ public static Test suite() { return suite; } + @AndroidIncompatible // test-suite builders private static TestStringMultisetGenerator concurrentHashMultisetGenerator() { return new TestStringMultisetGenerator() { @Override @@ -85,6 +87,7 @@ protected Multiset create(String[] elements) { }; } + @AndroidIncompatible // test-suite builders private static TestStringMultisetGenerator concurrentSkipListMultisetGenerator() { return new TestStringMultisetGenerator() { @Override diff --git a/android/guava-tests/test/com/google/common/collect/ContiguousSetTest.java b/android/guava-tests/test/com/google/common/collect/ContiguousSetTest.java index bf53d89a0dd5..b0754e40b773 100644 --- a/android/guava-tests/test/com/google/common/collect/ContiguousSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/ContiguousSetTest.java @@ -390,6 +390,7 @@ public void testAsList() { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static class BuiltTests extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/EnumBiMapTest.java b/android/guava-tests/test/com/google/common/collect/EnumBiMapTest.java index 4f5cea264617..6c869447834b 100644 --- a/android/guava-tests/test/com/google/common/collect/EnumBiMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/EnumBiMapTest.java @@ -70,6 +70,7 @@ private enum Country { UK } + @AndroidIncompatible // test-suite builders public static final class EnumBiMapGenerator implements TestBiMapGenerator { @SuppressWarnings("unchecked") @Override @@ -116,6 +117,7 @@ public Currency[] createValueArray(int length) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/android/guava-tests/test/com/google/common/collect/EnumHashBiMapTest.java b/android/guava-tests/test/com/google/common/collect/EnumHashBiMapTest.java index b0e0bab7e214..72075d05d33f 100644 --- a/android/guava-tests/test/com/google/common/collect/EnumHashBiMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/EnumHashBiMapTest.java @@ -65,6 +65,7 @@ private enum Country { UK } + @AndroidIncompatible // test-suite builders public static final class EnumHashBiMapGenerator implements TestBiMapGenerator { @SuppressWarnings("unchecked") @Override @@ -111,6 +112,7 @@ public String[] createValueArray(int length) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/android/guava-tests/test/com/google/common/collect/EnumMultisetTest.java b/android/guava-tests/test/com/google/common/collect/EnumMultisetTest.java index 3d66d0f58836..da4db3ca1e34 100644 --- a/android/guava-tests/test/com/google/common/collect/EnumMultisetTest.java +++ b/android/guava-tests/test/com/google/common/collect/EnumMultisetTest.java @@ -52,6 +52,7 @@ public class EnumMultisetTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( @@ -69,6 +70,7 @@ public static Test suite() { return suite; } + @AndroidIncompatible // test-suite builders private static TestEnumMultisetGenerator enumMultisetGenerator() { return new TestEnumMultisetGenerator() { @Override diff --git a/android/guava-tests/test/com/google/common/collect/ForwardingCollectionTest.java b/android/guava-tests/test/com/google/common/collect/ForwardingCollectionTest.java index f8b9cb02f4f8..a92edb28f458 100644 --- a/android/guava-tests/test/com/google/common/collect/ForwardingCollectionTest.java +++ b/android/guava-tests/test/com/google/common/collect/ForwardingCollectionTest.java @@ -103,6 +103,7 @@ public String toString() { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/ForwardingListTest.java b/android/guava-tests/test/com/google/common/collect/ForwardingListTest.java index ef5915545696..32b9d1f499a1 100644 --- a/android/guava-tests/test/com/google/common/collect/ForwardingListTest.java +++ b/android/guava-tests/test/com/google/common/collect/ForwardingListTest.java @@ -155,6 +155,7 @@ public List subList(int fromIndex, int toIndex) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/ForwardingMapTest.java b/android/guava-tests/test/com/google/common/collect/ForwardingMapTest.java index 908c9c9dde42..ab305710a9f0 100644 --- a/android/guava-tests/test/com/google/common/collect/ForwardingMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/ForwardingMapTest.java @@ -138,6 +138,7 @@ public boolean isEmpty() { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/ForwardingMultisetTest.java b/android/guava-tests/test/com/google/common/collect/ForwardingMultisetTest.java index ca4f28aef3ad..c3a541f758b3 100644 --- a/android/guava-tests/test/com/google/common/collect/ForwardingMultisetTest.java +++ b/android/guava-tests/test/com/google/common/collect/ForwardingMultisetTest.java @@ -159,6 +159,7 @@ public int size() { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/ForwardingNavigableMapTest.java b/android/guava-tests/test/com/google/common/collect/ForwardingNavigableMapTest.java index 170f6d5e6f02..2bcccef303c3 100644 --- a/android/guava-tests/test/com/google/common/collect/ForwardingNavigableMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/ForwardingNavigableMapTest.java @@ -250,6 +250,7 @@ protected NavigableMap delegate() { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/ForwardingNavigableSetTest.java b/android/guava-tests/test/com/google/common/collect/ForwardingNavigableSetTest.java index 6256c97f721f..537629afe38c 100644 --- a/android/guava-tests/test/com/google/common/collect/ForwardingNavigableSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/ForwardingNavigableSetTest.java @@ -163,6 +163,7 @@ public SortedSet tailSet(T fromElement) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/ForwardingQueueTest.java b/android/guava-tests/test/com/google/common/collect/ForwardingQueueTest.java index 96ad8da83690..1e645cdad84b 100644 --- a/android/guava-tests/test/com/google/common/collect/ForwardingQueueTest.java +++ b/android/guava-tests/test/com/google/common/collect/ForwardingQueueTest.java @@ -119,6 +119,7 @@ public boolean offer(T o) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/ForwardingSetTest.java b/android/guava-tests/test/com/google/common/collect/ForwardingSetTest.java index 73d6004a6058..837abe561a30 100644 --- a/android/guava-tests/test/com/google/common/collect/ForwardingSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/ForwardingSetTest.java @@ -115,6 +115,7 @@ public String toString() { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/ForwardingSortedMapTest.java b/android/guava-tests/test/com/google/common/collect/ForwardingSortedMapTest.java index 2a6777a0590a..1ae585db65af 100644 --- a/android/guava-tests/test/com/google/common/collect/ForwardingSortedMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/ForwardingSortedMapTest.java @@ -129,6 +129,7 @@ public SortedMap subMap(K fromKey, K toKey) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/ForwardingSortedMultisetTest.java b/android/guava-tests/test/com/google/common/collect/ForwardingSortedMultisetTest.java index 78711789c2fc..cf6a8d85c1b1 100644 --- a/android/guava-tests/test/com/google/common/collect/ForwardingSortedMultisetTest.java +++ b/android/guava-tests/test/com/google/common/collect/ForwardingSortedMultisetTest.java @@ -176,6 +176,7 @@ public T[] toArray(T[] array) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/ForwardingSortedSetTest.java b/android/guava-tests/test/com/google/common/collect/ForwardingSortedSetTest.java index 188a3892a027..166aaa177bfe 100644 --- a/android/guava-tests/test/com/google/common/collect/ForwardingSortedSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/ForwardingSortedSetTest.java @@ -120,6 +120,7 @@ public SortedSet subSet(T fromElement, T toElement) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/HashBiMapTest.java b/android/guava-tests/test/com/google/common/collect/HashBiMapTest.java index d000fdc5cfac..f4bee7bf9830 100644 --- a/android/guava-tests/test/com/google/common/collect/HashBiMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/HashBiMapTest.java @@ -46,6 +46,7 @@ public class HashBiMapTest extends TestCase { @J2ktIncompatible + @AndroidIncompatible // test-suite builders public static final class HashBiMapGenerator extends TestStringBiMapGenerator { @Override protected BiMap create(Entry[] entries) { @@ -59,6 +60,7 @@ protected BiMap create(Entry[] entries) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/android/guava-tests/test/com/google/common/collect/HashMultimapTest.java b/android/guava-tests/test/com/google/common/collect/HashMultimapTest.java index e4decb57c2c8..77554381bf72 100644 --- a/android/guava-tests/test/com/google/common/collect/HashMultimapTest.java +++ b/android/guava-tests/test/com/google/common/collect/HashMultimapTest.java @@ -43,6 +43,7 @@ public class HashMultimapTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/android/guava-tests/test/com/google/common/collect/HashMultisetTest.java b/android/guava-tests/test/com/google/common/collect/HashMultisetTest.java index 421ab58e3713..1c26152fe791 100644 --- a/android/guava-tests/test/com/google/common/collect/HashMultisetTest.java +++ b/android/guava-tests/test/com/google/common/collect/HashMultisetTest.java @@ -45,6 +45,7 @@ public class HashMultisetTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( @@ -63,6 +64,7 @@ public static Test suite() { } @J2ktIncompatible + @AndroidIncompatible // test-suite builders private static TestStringMultisetGenerator hashMultisetGenerator() { return new TestStringMultisetGenerator() { @Override diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java index 964be11d9790..1e4de4c798b6 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java @@ -60,6 +60,7 @@ public class ImmutableBiMapTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java index 2c855c95c7c4..c991bde6e6d4 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java @@ -46,6 +46,7 @@ */ @NullUnmarked public class ImmutableClassToInstanceMapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableClassToInstanceMapTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableEnumMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableEnumMapTest.java index b6e583163f02..8c02927ee04f 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableEnumMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableEnumMapTest.java @@ -46,6 +46,7 @@ @NullMarked public class ImmutableEnumMapTest extends TestCase { @J2ktIncompatible + @AndroidIncompatible // test-suite builders public static class ImmutableEnumMapGenerator extends TestEnumMapGenerator { @Override protected Map create(Entry[] entries) { @@ -59,6 +60,7 @@ protected Map create(Entry[] entries) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java index c4f9e661e888..40cf746ee6ef 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java @@ -54,6 +54,7 @@ @NullMarked public class ImmutableListMultimapTest extends TestCase { @J2ktIncompatible + @AndroidIncompatible // test-suite builders public static class ImmutableListMultimapGenerator extends TestStringListMultimapGenerator { @Override protected ListMultimap create(Entry[] entries) { @@ -66,6 +67,7 @@ protected ListMultimap create(Entry[] entries) { } @J2ktIncompatible + @AndroidIncompatible // test-suite builders public static class ImmutableListMultimapCopyOfEntriesGenerator extends TestStringListMultimapGenerator { @Override @@ -76,6 +78,7 @@ protected ListMultimap create(Entry[] entries) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableListTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableListTest.java index 1018f658b60f..ca538883395f 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableListTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableListTest.java @@ -68,6 +68,7 @@ public class ImmutableListTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableMapTest.java index 1a3ceea2abd3..36ee63105aca 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableMapTest.java @@ -77,6 +77,7 @@ public class ImmutableMapTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableMapTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java index 0fd2b6a0db10..3e1dfe2be9fd 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java @@ -63,6 +63,7 @@ public class ImmutableMultisetTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite // TODO(cpovirk): add to collect/gwt/suites + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableMultisetTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java index 527a3dfe8d6e..ab764372ec2a 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java @@ -40,6 +40,7 @@ @NullUnmarked public class ImmutableRangeSetTest extends AbstractRangeSetTest { + @AndroidIncompatible // test-suite builders static final class ImmutableRangeSetIntegerAsSetGenerator implements TestSetGenerator { @Override public SampleElements samples() { @@ -67,6 +68,7 @@ public Set create(Object... elements) { } } + @AndroidIncompatible // test-suite builders static final class ImmutableRangeSetBigIntegerAsSetGenerator implements TestSetGenerator { @Override @@ -100,6 +102,7 @@ public Set create(Object... elements) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableRangeSetTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java index db36f10b9a43..b7b8d6f8a2c9 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java @@ -53,6 +53,7 @@ @NullMarked public class ImmutableSetMultimapTest extends TestCase { @J2ktIncompatible + @AndroidIncompatible // test-suite builders private static final class ImmutableSetMultimapGenerator extends TestStringSetMultimapGenerator { @Override protected SetMultimap create(Entry[] entries) { @@ -65,6 +66,7 @@ protected SetMultimap create(Entry[] entries) { } @J2ktIncompatible + @AndroidIncompatible // test-suite builders private static final class ImmutableSetMultimapCopyOfEntriesGenerator extends TestStringSetMultimapGenerator { @Override @@ -75,6 +77,7 @@ protected SetMultimap create(Entry[] entries) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableSetMultimapTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java index f10585ec699c..5056e3b1f755 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java @@ -57,6 +57,7 @@ public class ImmutableSetTest extends AbstractImmutableSetTest { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java index ca9c6a564a6c..7f03e23da12a 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java @@ -68,6 +68,7 @@ public class ImmutableSortedMapTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableSortedMapTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java index fa36cbe79847..023f8877ba6a 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java @@ -51,6 +51,7 @@ */ @NullUnmarked public class ImmutableSortedMultisetTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableSortedMultisetTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java index 8d45a44e8d5d..5a8efba271e3 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java @@ -68,6 +68,7 @@ public class ImmutableSortedSetTest extends AbstractImmutableSetTest { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/IteratorsTest.java b/android/guava-tests/test/com/google/common/collect/IteratorsTest.java index 83d53f7b8f68..fd30bfe40216 100644 --- a/android/guava-tests/test/com/google/common/collect/IteratorsTest.java +++ b/android/guava-tests/test/com/google/common/collect/IteratorsTest.java @@ -88,6 +88,7 @@ public class IteratorsTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(IteratorsTest.class.getSimpleName()); suite.addTest(testsForRemoveAllAndRetainAll()); @@ -469,7 +470,7 @@ public Integer apply(String from) { } public void testNullFriendlyTransform() { - Iterator input = asList(1, 2, null, 3).iterator(); + Iterator<@Nullable Integer> input = Arrays.<@Nullable Integer>asList(1, 2, null, 3).iterator(); Iterator result = Iterators.transform( input, @@ -1436,6 +1437,7 @@ public void testRetainAll() { @J2ktIncompatible @GwtIncompatible // ListTestSuiteBuilder + @AndroidIncompatible // test-suite builders private static Test testsForRemoveAllAndRetainAll() { return ListTestSuiteBuilder.using( new TestStringListGenerator() { diff --git a/android/guava-tests/test/com/google/common/collect/LinkedHashMultimapTest.java b/android/guava-tests/test/com/google/common/collect/LinkedHashMultimapTest.java index 6b758aa13d1d..c14bad731170 100644 --- a/android/guava-tests/test/com/google/common/collect/LinkedHashMultimapTest.java +++ b/android/guava-tests/test/com/google/common/collect/LinkedHashMultimapTest.java @@ -60,6 +60,7 @@ public class LinkedHashMultimapTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/android/guava-tests/test/com/google/common/collect/LinkedHashMultisetTest.java b/android/guava-tests/test/com/google/common/collect/LinkedHashMultisetTest.java index 34d888b72361..adfbfe656341 100644 --- a/android/guava-tests/test/com/google/common/collect/LinkedHashMultisetTest.java +++ b/android/guava-tests/test/com/google/common/collect/LinkedHashMultisetTest.java @@ -44,6 +44,7 @@ public class LinkedHashMultisetTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( @@ -63,6 +64,7 @@ public static Test suite() { } @J2ktIncompatible + @AndroidIncompatible // test-suite builders private static TestStringMultisetGenerator linkedHashMultisetGenerator() { return new TestStringMultisetGenerator() { @Override diff --git a/android/guava-tests/test/com/google/common/collect/LinkedListMultimapTest.java b/android/guava-tests/test/com/google/common/collect/LinkedListMultimapTest.java index 9d6248478d86..b047eb3e650b 100644 --- a/android/guava-tests/test/com/google/common/collect/LinkedListMultimapTest.java +++ b/android/guava-tests/test/com/google/common/collect/LinkedListMultimapTest.java @@ -65,6 +65,7 @@ public class LinkedListMultimapTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/android/guava-tests/test/com/google/common/collect/ListsTest.java b/android/guava-tests/test/com/google/common/collect/ListsTest.java index f881b2c8c65b..13259e632173 100644 --- a/android/guava-tests/test/com/google/common/collect/ListsTest.java +++ b/android/guava-tests/test/com/google/common/collect/ListsTest.java @@ -113,6 +113,7 @@ public String apply(Number n) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ListsTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/LockHeldAssertingSet.java b/android/guava-tests/test/com/google/common/collect/LockHeldAssertingSet.java new file mode 100644 index 000000000000..90ce704a6661 --- /dev/null +++ b/android/guava-tests/test/com/google/common/collect/LockHeldAssertingSet.java @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2007 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect; + +import static com.google.common.base.Preconditions.checkNotNull; +import static junit.framework.Assert.assertTrue; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Set; +import org.jspecify.annotations.NullUnmarked; +import org.jspecify.annotations.Nullable; + +/** + * {@link Set} implementation that asserts that a given lock is held whenever one of its methods is + * called. + */ +@NullUnmarked +class LockHeldAssertingSet extends ForwardingSet implements Serializable { + final Set delegate; + final Object mutex; + + LockHeldAssertingSet(Set delegate, Object mutex) { + checkNotNull(mutex); + this.delegate = delegate; + this.mutex = mutex; + } + + @Override + protected Set delegate() { + return delegate; + } + + @Override + public String toString() { + assertTrue(Thread.holdsLock(mutex)); + return super.toString(); + } + + @Override + public boolean equals(@Nullable Object o) { + assertTrue(Thread.holdsLock(mutex)); + return super.equals(o); + } + + @Override + public int hashCode() { + assertTrue(Thread.holdsLock(mutex)); + return super.hashCode(); + } + + @Override + public boolean add(@Nullable E o) { + assertTrue(Thread.holdsLock(mutex)); + return super.add(o); + } + + @Override + public boolean addAll(Collection c) { + assertTrue(Thread.holdsLock(mutex)); + return super.addAll(c); + } + + @Override + public void clear() { + assertTrue(Thread.holdsLock(mutex)); + super.clear(); + } + + @Override + public boolean contains(@Nullable Object o) { + assertTrue(Thread.holdsLock(mutex)); + return super.contains(o); + } + + @Override + public boolean containsAll(Collection c) { + assertTrue(Thread.holdsLock(mutex)); + return super.containsAll(c); + } + + @Override + public boolean isEmpty() { + assertTrue(Thread.holdsLock(mutex)); + return super.isEmpty(); + } + + /* + * We don't assert that the lock is held during calls to iterator(), stream(), and spliterator: + * `Synchronized` doesn't guarantee that it will hold the mutex for those calls because callers + * are responsible for taking the mutex themselves: + * https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/Collections.html#synchronizedCollection(java.util.Collection) + * + * Similarly, we avoid having those methods *implemented* in terms of *other* TestSet methods + * that will perform holdsLock assertions: + * + * - For iterator(), we can accomplish that by not overriding iterator() at all. That way, we + * inherit an implementation that forwards to the delegate collection, which performs no + * holdsLock assertions. + * + * - For stream() and spliterator(), we have to forward to the delegate ourselves because + * ForwardingSet does not forward `default` methods, as discussed in its Javadoc. + */ + + // Currently, we don't include stream() and spliterator() for our classes in the Android flavor. + + @Override + public boolean remove(@Nullable Object o) { + assertTrue(Thread.holdsLock(mutex)); + return super.remove(o); + } + + @Override + public boolean removeAll(Collection c) { + assertTrue(Thread.holdsLock(mutex)); + return super.removeAll(c); + } + + @Override + public boolean retainAll(Collection c) { + assertTrue(Thread.holdsLock(mutex)); + return super.retainAll(c); + } + + @Override + public int size() { + assertTrue(Thread.holdsLock(mutex)); + return super.size(); + } + + @Override + public Object[] toArray() { + assertTrue(Thread.holdsLock(mutex)); + return super.toArray(); + } + + @Override + public T[] toArray(T[] a) { + assertTrue(Thread.holdsLock(mutex)); + return super.toArray(a); + } + + private static final long serialVersionUID = 0; +} diff --git a/android/guava-tests/test/com/google/common/collect/MapsCollectionTest.java b/android/guava-tests/test/com/google/common/collect/MapsCollectionTest.java index a52b7a8f50c3..bc41f318b086 100644 --- a/android/guava-tests/test/com/google/common/collect/MapsCollectionTest.java +++ b/android/guava-tests/test/com/google/common/collect/MapsCollectionTest.java @@ -61,6 +61,7 @@ * @author Louis Wasserman */ @NullUnmarked +@AndroidIncompatible // test-suite builders public class MapsCollectionTest extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/MinMaxPriorityQueueTest.java b/android/guava-tests/test/com/google/common/collect/MinMaxPriorityQueueTest.java index f3b58b220093..b5d4cf5d6331 100644 --- a/android/guava-tests/test/com/google/common/collect/MinMaxPriorityQueueTest.java +++ b/android/guava-tests/test/com/google/common/collect/MinMaxPriorityQueueTest.java @@ -68,6 +68,7 @@ public class MinMaxPriorityQueueTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(MinMaxPriorityQueueTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java b/android/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java index 27cd588bd1ff..a881b53b35bc 100644 --- a/android/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java +++ b/android/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java @@ -78,6 +78,7 @@ */ @GwtIncompatible // suite // TODO(cpovirk): set up collect/gwt/suites version @NullUnmarked +@AndroidIncompatible // test-suite builders public class MultimapsCollectionTest extends TestCase { private static final Feature[] FOR_MAP_FEATURES_ONE = { diff --git a/android/guava-tests/test/com/google/common/collect/MultisetsCollectionTest.java b/android/guava-tests/test/com/google/common/collect/MultisetsCollectionTest.java index eac7058b374b..9583f28abb58 100644 --- a/android/guava-tests/test/com/google/common/collect/MultisetsCollectionTest.java +++ b/android/guava-tests/test/com/google/common/collect/MultisetsCollectionTest.java @@ -49,6 +49,7 @@ */ @GwtIncompatible // suite // TODO(cpovirk): set up collect/gwt/suites version @NullUnmarked +@AndroidIncompatible // test-suite builders public class MultisetsCollectionTest extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java b/android/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java index f1d2e94fa302..8adb091a8f0f 100644 --- a/android/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java @@ -38,6 +38,7 @@ */ @NullUnmarked public class MutableClassToInstanceMapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(MutableClassToInstanceMapTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/SetOperationsTest.java b/android/guava-tests/test/com/google/common/collect/SetOperationsTest.java index f17d0ee3b37e..ec6daacba426 100644 --- a/android/guava-tests/test/com/google/common/collect/SetOperationsTest.java +++ b/android/guava-tests/test/com/google/common/collect/SetOperationsTest.java @@ -44,6 +44,7 @@ public class SetOperationsTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/SetsTest.java b/android/guava-tests/test/com/google/common/collect/SetsTest.java index 721e5397d5dd..54c62a2e89a1 100644 --- a/android/guava-tests/test/com/google/common/collect/SetsTest.java +++ b/android/guava-tests/test/com/google/common/collect/SetsTest.java @@ -114,6 +114,7 @@ public Iterator iterator() { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SetsTest.class); @@ -227,6 +228,7 @@ public List order(List insertionOrder) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilter() { return SetTestSuiteBuilder.using( new TestStringSetGenerator() { @@ -251,6 +253,7 @@ public Set create(String[] elements) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilterNoNulls() { TestSuite suite = new TestSuite(); suite.addTest( @@ -303,6 +306,7 @@ public List order(List insertionOrder) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilterFiltered() { return SetTestSuiteBuilder.using( new TestStringSetGenerator() { diff --git a/android/guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java b/android/guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java index e6244281876d..d568d8c7fb2e 100644 --- a/android/guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java +++ b/android/guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java @@ -48,6 +48,7 @@ public class SimpleAbstractMultisetTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SimpleAbstractMultisetTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java b/android/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java index 3f1950ccd40b..c599d10c5618 100644 --- a/android/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java @@ -40,6 +40,7 @@ @NullUnmarked public class SynchronizedBiMapTest extends SynchronizedMapTest { + @AndroidIncompatible // test-suite builders public static TestSuite suite() { TestSuite suite = new TestSuite(SynchronizedBiMapTest.class); suite.addTest( @@ -78,6 +79,7 @@ protected BiMap create() { return outer; } + @AndroidIncompatible // test-suite builders public static final class SynchronizedHashBiMapGenerator extends TestStringBiMapGenerator { @Override protected BiMap create(Entry[] entries) { @@ -90,6 +92,7 @@ protected BiMap create(Entry[] entries) { } } + @AndroidIncompatible // test-suite builders public static final class SynchTestingBiMapGenerator extends TestStringBiMapGenerator { @Override protected BiMap create(Entry[] entries) { diff --git a/android/guava-tests/test/com/google/common/collect/SynchronizedMultimapTest.java b/android/guava-tests/test/com/google/common/collect/SynchronizedMultimapTest.java index 7f7508c7155b..f5f322d202cf 100644 --- a/android/guava-tests/test/com/google/common/collect/SynchronizedMultimapTest.java +++ b/android/guava-tests/test/com/google/common/collect/SynchronizedMultimapTest.java @@ -46,6 +46,7 @@ @NullUnmarked public class SynchronizedMultimapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SynchronizedMultimapTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/SynchronizedNavigableMapTest.java b/android/guava-tests/test/com/google/common/collect/SynchronizedNavigableMapTest.java index 1a75965c8dcc..4e1f5b336e17 100644 --- a/android/guava-tests/test/com/google/common/collect/SynchronizedNavigableMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/SynchronizedNavigableMapTest.java @@ -257,6 +257,7 @@ public K lastKey() { private static final long serialVersionUID = 0; } + @AndroidIncompatible // test-suite builders public static TestSuite suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SynchronizedNavigableMapTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/SynchronizedNavigableSetTest.java b/android/guava-tests/test/com/google/common/collect/SynchronizedNavigableSetTest.java index 962e7512782c..287599ff6243 100644 --- a/android/guava-tests/test/com/google/common/collect/SynchronizedNavigableSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/SynchronizedNavigableSetTest.java @@ -44,17 +44,17 @@ public class SynchronizedNavigableSetTest extends TestCase { private static final Object MUTEX = new Object[0]; // something Serializable - @SuppressWarnings("unchecked") - protected NavigableSet create() { - TestSet inner = - new TestSet<>(new TreeSet((Comparator) Ordering.natural().nullsFirst()), MUTEX); + protected > NavigableSet create() { + LockHeldAssertingNavigableSet inner = + new LockHeldAssertingNavigableSet<>(new TreeSet<>(Ordering.natural().nullsFirst()), MUTEX); NavigableSet outer = Synchronized.navigableSet(inner, MUTEX); return outer; } - static class TestSet extends SynchronizedSetTest.TestSet implements NavigableSet { + static class LockHeldAssertingNavigableSet extends LockHeldAssertingSet + implements NavigableSet { - TestSet(NavigableSet delegate, @Nullable Object mutex) { + LockHeldAssertingNavigableSet(NavigableSet delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -164,6 +164,7 @@ public E last() { private static final long serialVersionUID = 0; } + @AndroidIncompatible // test-suite builders public static TestSuite suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SynchronizedNavigableSetTest.class); @@ -175,7 +176,8 @@ public static TestSuite suite() { protected NavigableSet create(String[] elements) { NavigableSet innermost = new SafeTreeSet<>(); Collections.addAll(innermost, elements); - TestSet inner = new TestSet<>(innermost, MUTEX); + LockHeldAssertingNavigableSet inner = + new LockHeldAssertingNavigableSet<>(innermost, MUTEX); NavigableSet outer = Synchronized.navigableSet(inner, MUTEX); return outer; } diff --git a/android/guava-tests/test/com/google/common/collect/SynchronizedSetTest.java b/android/guava-tests/test/com/google/common/collect/SynchronizedSetTest.java index bd6295f2ad2a..323480fe3f62 100644 --- a/android/guava-tests/test/com/google/common/collect/SynchronizedSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/SynchronizedSetTest.java @@ -16,21 +16,17 @@ package com.google.common.collect; -import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.testing.SetTestSuiteBuilder; import com.google.common.collect.testing.TestStringSetGenerator; import com.google.common.collect.testing.features.CollectionFeature; import com.google.common.collect.testing.features.CollectionSize; -import java.io.Serializable; -import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Set; import junit.framework.Test; import junit.framework.TestCase; import org.jspecify.annotations.NullUnmarked; -import org.jspecify.annotations.Nullable; /** * Tests for {@code Synchronized#set}. @@ -38,6 +34,7 @@ * @author Mike Bostock */ @NullUnmarked +@AndroidIncompatible // test-suite builders public class SynchronizedSetTest extends TestCase { public static final Object MUTEX = new Object[0]; // something Serializable @@ -47,7 +44,8 @@ public static Test suite() { new TestStringSetGenerator() { @Override protected Set create(String[] elements) { - TestSet inner = new TestSet<>(new HashSet(), MUTEX); + LockHeldAssertingSet inner = + new LockHeldAssertingSet<>(new HashSet(), MUTEX); Set outer = Synchronized.set(inner, inner.mutex); Collections.addAll(outer, elements); return outer; @@ -61,131 +59,4 @@ protected Set create(String[] elements) { CollectionFeature.SERIALIZABLE) .createTestSuite(); } - - static class TestSet extends ForwardingSet implements Serializable { - final Set delegate; - public final Object mutex; - - public TestSet(Set delegate, Object mutex) { - checkNotNull(mutex); - this.delegate = delegate; - this.mutex = mutex; - } - - @Override - protected Set delegate() { - return delegate; - } - - @Override - public String toString() { - assertTrue(Thread.holdsLock(mutex)); - return super.toString(); - } - - @Override - public boolean equals(@Nullable Object o) { - assertTrue(Thread.holdsLock(mutex)); - return super.equals(o); - } - - @Override - public int hashCode() { - assertTrue(Thread.holdsLock(mutex)); - return super.hashCode(); - } - - @Override - public boolean add(@Nullable E o) { - assertTrue(Thread.holdsLock(mutex)); - return super.add(o); - } - - @Override - public boolean addAll(Collection c) { - assertTrue(Thread.holdsLock(mutex)); - return super.addAll(c); - } - - @Override - public void clear() { - assertTrue(Thread.holdsLock(mutex)); - super.clear(); - } - - @Override - public boolean contains(@Nullable Object o) { - assertTrue(Thread.holdsLock(mutex)); - return super.contains(o); - } - - @Override - public boolean containsAll(Collection c) { - assertTrue(Thread.holdsLock(mutex)); - return super.containsAll(c); - } - - @Override - public boolean isEmpty() { - assertTrue(Thread.holdsLock(mutex)); - return super.isEmpty(); - } - - /* - * We don't assert that the lock is held during calls to iterator(), stream(), and spliterator: - * `Synchronized` doesn't guarantee that it will hold the mutex for those calls because callers - * are responsible for taking the mutex themselves: - * https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/Collections.html#synchronizedCollection(java.util.Collection) - * - * Similarly, we avoid having those methods *implemented* in terms of *other* TestSet methods - * that will perform holdsLock assertions: - * - * - For iterator(), we can accomplish that by not overriding iterator() at all. That way, we - * inherit an implementation that forwards to the delegate collection, which performs no - * holdsLock assertions. - * - * - For stream() and spliterator(), we have to forward to the delegate ourselves because - * ForwardingSet does not forward `default` methods, as discussed in its Javadoc. - */ - - // Currently, we don't include stream() and spliterator() for our classes in the Android flavor. - - @Override - public boolean remove(@Nullable Object o) { - assertTrue(Thread.holdsLock(mutex)); - return super.remove(o); - } - - @Override - public boolean removeAll(Collection c) { - assertTrue(Thread.holdsLock(mutex)); - return super.removeAll(c); - } - - @Override - public boolean retainAll(Collection c) { - assertTrue(Thread.holdsLock(mutex)); - return super.retainAll(c); - } - - @Override - public int size() { - assertTrue(Thread.holdsLock(mutex)); - return super.size(); - } - - @Override - public Object[] toArray() { - assertTrue(Thread.holdsLock(mutex)); - return super.toArray(); - } - - @Override - public T[] toArray(T[] a) { - assertTrue(Thread.holdsLock(mutex)); - return super.toArray(a); - } - - private static final long serialVersionUID = 0; - } } diff --git a/android/guava-tests/test/com/google/common/collect/TableCollectionTest.java b/android/guava-tests/test/com/google/common/collect/TableCollectionTest.java index 6f1d51a82c08..effc828b8d50 100644 --- a/android/guava-tests/test/com/google/common/collect/TableCollectionTest.java +++ b/android/guava-tests/test/com/google/common/collect/TableCollectionTest.java @@ -89,6 +89,7 @@ public class TableCollectionTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/android/guava-tests/test/com/google/common/collect/TreeBasedTableTest.java b/android/guava-tests/test/com/google/common/collect/TreeBasedTableTest.java index cd14b4b87359..1466bd94f5ab 100644 --- a/android/guava-tests/test/com/google/common/collect/TreeBasedTableTest.java +++ b/android/guava-tests/test/com/google/common/collect/TreeBasedTableTest.java @@ -51,6 +51,7 @@ public class TreeBasedTableTest extends AbstractTableTest { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(TreeBasedTableTest.class); diff --git a/android/guava-tests/test/com/google/common/collect/TreeMultimapNaturalTest.java b/android/guava-tests/test/com/google/common/collect/TreeMultimapNaturalTest.java index bd4f2b945a28..346ba9811e6b 100644 --- a/android/guava-tests/test/com/google/common/collect/TreeMultimapNaturalTest.java +++ b/android/guava-tests/test/com/google/common/collect/TreeMultimapNaturalTest.java @@ -65,6 +65,7 @@ public class TreeMultimapNaturalTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls? diff --git a/android/guava-tests/test/com/google/common/collect/TreeMultisetTest.java b/android/guava-tests/test/com/google/common/collect/TreeMultisetTest.java index 05453e85e279..9a7ddab9bec4 100644 --- a/android/guava-tests/test/com/google/common/collect/TreeMultisetTest.java +++ b/android/guava-tests/test/com/google/common/collect/TreeMultisetTest.java @@ -55,6 +55,7 @@ public class TreeMultisetTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java b/android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java index 198f7d542d36..ab5437caa8c5 100644 --- a/android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java @@ -43,6 +43,7 @@ @GwtIncompatible // NavigableMap @NullUnmarked public class TreeRangeMapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(TreeRangeMapTest.class); diff --git a/android/guava-tests/test/com/google/common/primitives/ByteArrayAsListTest.java b/android/guava-tests/test/com/google/common/primitives/ByteArrayAsListTest.java index 12388907e8c4..b4676078bada 100644 --- a/android/guava-tests/test/com/google/common/primitives/ByteArrayAsListTest.java +++ b/android/guava-tests/test/com/google/common/primitives/ByteArrayAsListTest.java @@ -41,6 +41,7 @@ */ @GwtCompatible(emulated = true) @NullUnmarked +@AndroidIncompatible // test-suite builders public class ByteArrayAsListTest extends TestCase { private static List asList(Byte[] values) { diff --git a/android/guava-tests/test/com/google/common/primitives/CharArrayAsListTest.java b/android/guava-tests/test/com/google/common/primitives/CharArrayAsListTest.java index 162d03358dfc..fd1dafaf1b3b 100644 --- a/android/guava-tests/test/com/google/common/primitives/CharArrayAsListTest.java +++ b/android/guava-tests/test/com/google/common/primitives/CharArrayAsListTest.java @@ -41,6 +41,7 @@ */ @GwtCompatible(emulated = true) @NullUnmarked +@AndroidIncompatible // test-suite builders public class CharArrayAsListTest extends TestCase { private static List asList(Character[] values) { diff --git a/android/guava-tests/test/com/google/common/primitives/DoubleArrayAsListTest.java b/android/guava-tests/test/com/google/common/primitives/DoubleArrayAsListTest.java index 7515073fce9b..f1b054d69d18 100644 --- a/android/guava-tests/test/com/google/common/primitives/DoubleArrayAsListTest.java +++ b/android/guava-tests/test/com/google/common/primitives/DoubleArrayAsListTest.java @@ -41,6 +41,7 @@ */ @GwtCompatible(emulated = true) @NullUnmarked +@AndroidIncompatible // test-suite builders public class DoubleArrayAsListTest extends TestCase { private static List asList(Double[] values) { diff --git a/android/guava-tests/test/com/google/common/primitives/FloatArrayAsListTest.java b/android/guava-tests/test/com/google/common/primitives/FloatArrayAsListTest.java index 9fee9033ce08..8d88e79b4a73 100644 --- a/android/guava-tests/test/com/google/common/primitives/FloatArrayAsListTest.java +++ b/android/guava-tests/test/com/google/common/primitives/FloatArrayAsListTest.java @@ -41,6 +41,7 @@ */ @GwtCompatible(emulated = true) @NullUnmarked +@AndroidIncompatible // test-suite builders public class FloatArrayAsListTest extends TestCase { private static List asList(Float[] values) { diff --git a/android/guava-tests/test/com/google/common/primitives/ImmutableDoubleArrayTest.java b/android/guava-tests/test/com/google/common/primitives/ImmutableDoubleArrayTest.java index a7ea0cfa968c..c0f7af4de727 100644 --- a/android/guava-tests/test/com/google/common/primitives/ImmutableDoubleArrayTest.java +++ b/android/guava-tests/test/com/google/common/primitives/ImmutableDoubleArrayTest.java @@ -445,6 +445,7 @@ private static void assertDoesntActuallyTrim(ImmutableDoubleArray iia) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { List> builders = ImmutableList.of( @@ -477,6 +478,7 @@ public static Test suite() { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible private static ImmutableDoubleArray makeArray(Double[] values) { return ImmutableDoubleArray.copyOf(Arrays.asList(values)); } @@ -486,6 +488,7 @@ private static ImmutableDoubleArray makeArray(Double[] values) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableDoubleArrayAsListGenerator extends TestDoubleListGenerator { @Override protected List create(Double[] elements) { @@ -495,6 +498,7 @@ protected List create(Double[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableDoubleArrayHeadSubListAsListGenerator extends TestDoubleListGenerator { @Override @@ -507,6 +511,7 @@ protected List create(Double[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableDoubleArrayTailSubListAsListGenerator extends TestDoubleListGenerator { @Override @@ -519,6 +524,7 @@ protected List create(Double[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableDoubleArrayMiddleSubListAsListGenerator extends TestDoubleListGenerator { @Override @@ -532,12 +538,14 @@ protected List create(Double[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible private static Double[] concat(Double[] a, Double[] b) { return ObjectArrays.concat(a, b, Double.class); } @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public abstract static class TestDoubleListGenerator implements TestListGenerator { @Override public SampleElements samples() { @@ -574,6 +582,7 @@ public List order(List insertionOrder) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static class SampleDoubles extends SampleElements { public SampleDoubles() { super(-0.0, Long.MAX_VALUE * 3.0, Double.MAX_VALUE, Double.POSITIVE_INFINITY, Double.NaN); diff --git a/android/guava-tests/test/com/google/common/primitives/ImmutableIntArrayTest.java b/android/guava-tests/test/com/google/common/primitives/ImmutableIntArrayTest.java index a614b441d64a..6051eead8fec 100644 --- a/android/guava-tests/test/com/google/common/primitives/ImmutableIntArrayTest.java +++ b/android/guava-tests/test/com/google/common/primitives/ImmutableIntArrayTest.java @@ -430,6 +430,7 @@ private static void assertDoesntActuallyTrim(ImmutableIntArray iia) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { List> builders = ImmutableList.of( diff --git a/android/guava-tests/test/com/google/common/primitives/ImmutableLongArrayTest.java b/android/guava-tests/test/com/google/common/primitives/ImmutableLongArrayTest.java index 9c279055c518..ec506695b6cf 100644 --- a/android/guava-tests/test/com/google/common/primitives/ImmutableLongArrayTest.java +++ b/android/guava-tests/test/com/google/common/primitives/ImmutableLongArrayTest.java @@ -433,6 +433,7 @@ private static void assertDoesntActuallyTrim(ImmutableLongArray iia) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { List> builders = ImmutableList.of( @@ -465,6 +466,7 @@ public static Test suite() { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible private static ImmutableLongArray makeArray(Long[] values) { return ImmutableLongArray.copyOf(Arrays.asList(values)); } @@ -474,6 +476,7 @@ private static ImmutableLongArray makeArray(Long[] values) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableLongArrayAsListGenerator extends TestLongListGenerator { @Override protected List create(Long[] elements) { @@ -483,6 +486,7 @@ protected List create(Long[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableLongArrayHeadSubListAsListGenerator extends TestLongListGenerator { @Override @@ -495,6 +499,7 @@ protected List create(Long[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableLongArrayTailSubListAsListGenerator extends TestLongListGenerator { @Override @@ -507,6 +512,7 @@ protected List create(Long[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableLongArrayMiddleSubListAsListGenerator extends TestLongListGenerator { @Override @@ -520,12 +526,14 @@ protected List create(Long[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible private static Long[] concat(Long[] a, Long[] b) { return ObjectArrays.concat(a, b, Long.class); } @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public abstract static class TestLongListGenerator implements TestListGenerator { @Override public SampleElements samples() { @@ -562,6 +570,7 @@ public List order(List insertionOrder) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static class SampleLongs extends SampleElements { public SampleLongs() { super(1L << 31, 1L << 33, 1L << 36, 1L << 40, 1L << 45); diff --git a/android/guava-tests/test/com/google/common/primitives/IntArrayAsListTest.java b/android/guava-tests/test/com/google/common/primitives/IntArrayAsListTest.java index 8f5732ff22c0..14ab5667bce3 100644 --- a/android/guava-tests/test/com/google/common/primitives/IntArrayAsListTest.java +++ b/android/guava-tests/test/com/google/common/primitives/IntArrayAsListTest.java @@ -42,6 +42,7 @@ @GwtCompatible(emulated = true) @SuppressWarnings("cast") // redundant casts are intentional and harmless @NullUnmarked +@AndroidIncompatible // test-suite builders public class IntArrayAsListTest extends TestCase { private static List asList(Integer[] values) { diff --git a/android/guava-tests/test/com/google/common/primitives/LongArrayAsListTest.java b/android/guava-tests/test/com/google/common/primitives/LongArrayAsListTest.java index 76c54bdbf1ba..b3657c437701 100644 --- a/android/guava-tests/test/com/google/common/primitives/LongArrayAsListTest.java +++ b/android/guava-tests/test/com/google/common/primitives/LongArrayAsListTest.java @@ -41,6 +41,7 @@ */ @GwtCompatible(emulated = true) @NullUnmarked +@AndroidIncompatible // test-suite builders public class LongArrayAsListTest extends TestCase { private static List asList(Long[] values) { diff --git a/android/guava-tests/test/com/google/common/primitives/ShortArrayAsListTest.java b/android/guava-tests/test/com/google/common/primitives/ShortArrayAsListTest.java index c6c4dea4d304..33a01b8c22c1 100644 --- a/android/guava-tests/test/com/google/common/primitives/ShortArrayAsListTest.java +++ b/android/guava-tests/test/com/google/common/primitives/ShortArrayAsListTest.java @@ -41,6 +41,7 @@ */ @GwtCompatible(emulated = true) @NullUnmarked +@AndroidIncompatible // test-suite builders public class ShortArrayAsListTest extends TestCase { private static List asList(Short[] values) { diff --git a/guava-testlib/test/com/google/common/collect/testing/AndroidIncompatible.java b/guava-testlib/test/com/google/common/collect/testing/AndroidIncompatible.java new file mode 100644 index 000000000000..bbd60d7a2206 --- /dev/null +++ b/guava-testlib/test/com/google/common/collect/testing/AndroidIncompatible.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2015 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect.testing; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import com.google.common.annotations.GwtCompatible; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Signifies that a test should not be run under Android. This annotation is respected only by our + * Google-internal Android suite generators. Note that those generators also suppress any test + * annotated with MediumTest or LargeTest. + * + *

For more discussion, see {@linkplain com.google.common.base.AndroidIncompatible the + * documentation on another copy of this annotation}. + */ +@Retention(CLASS) +@Target({ANNOTATION_TYPE, CONSTRUCTOR, FIELD, METHOD, TYPE}) +@GwtCompatible +@interface AndroidIncompatible {} diff --git a/guava-testlib/test/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilderTest.java b/guava-testlib/test/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilderTest.java index 72284f893bcd..682fd909d4ad 100644 --- a/guava-testlib/test/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilderTest.java +++ b/guava-testlib/test/com/google/common/collect/testing/FeatureSpecificTestSuiteBuilderTest.java @@ -26,6 +26,7 @@ /** * @author Max Ross */ +@AndroidIncompatible // test-suite builders public class FeatureSpecificTestSuiteBuilderTest extends TestCase { private static final class MyTestSuiteBuilder extends FeatureSpecificTestSuiteBuilder { diff --git a/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java b/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java index b0ed1a7788b7..008cecd98562 100644 --- a/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java +++ b/guava-testlib/test/com/google/common/collect/testing/MapTestSuiteBuilderTests.java @@ -53,6 +53,7 @@ * * @author George van den Driessche */ +@AndroidIncompatible // test-suite builders public final class MapTestSuiteBuilderTests extends TestCase { private MapTestSuiteBuilderTests() {} diff --git a/guava-testlib/test/com/google/common/collect/testing/MinimalCollectionTest.java b/guava-testlib/test/com/google/common/collect/testing/MinimalCollectionTest.java index 38cadf3bff76..83489295a478 100644 --- a/guava-testlib/test/com/google/common/collect/testing/MinimalCollectionTest.java +++ b/guava-testlib/test/com/google/common/collect/testing/MinimalCollectionTest.java @@ -27,6 +27,7 @@ * * @author Kevin Bourrillion */ +@AndroidIncompatible // test-suite builders public class MinimalCollectionTest extends TestCase { public static Test suite() { return CollectionTestSuiteBuilder.using( diff --git a/guava-testlib/test/com/google/common/collect/testing/MinimalSetTest.java b/guava-testlib/test/com/google/common/collect/testing/MinimalSetTest.java index 51cc4c9561a9..037473508d83 100644 --- a/guava-testlib/test/com/google/common/collect/testing/MinimalSetTest.java +++ b/guava-testlib/test/com/google/common/collect/testing/MinimalSetTest.java @@ -27,6 +27,7 @@ * * @author Regina O'Dell */ +@AndroidIncompatible // test-suite builders public class MinimalSetTest extends TestCase { public static Test suite() { return SetTestSuiteBuilder.using( diff --git a/guava-testlib/test/com/google/common/collect/testing/OpenJdk6ListTests.java b/guava-testlib/test/com/google/common/collect/testing/OpenJdk6ListTests.java index 526cd566a627..3ba5482c4ea3 100644 --- a/guava-testlib/test/com/google/common/collect/testing/OpenJdk6ListTests.java +++ b/guava-testlib/test/com/google/common/collect/testing/OpenJdk6ListTests.java @@ -34,6 +34,7 @@ * * @author Kevin Bourrillion */ +@AndroidIncompatible // test-suite builders public class OpenJdk6ListTests extends TestsForListsInJavaUtil { public static Test suite() { return new OpenJdk6ListTests().allTests(); diff --git a/guava-testlib/test/com/google/common/collect/testing/OpenJdk6MapTests.java b/guava-testlib/test/com/google/common/collect/testing/OpenJdk6MapTests.java index 5a146e9472a1..b89040dac390 100644 --- a/guava-testlib/test/com/google/common/collect/testing/OpenJdk6MapTests.java +++ b/guava-testlib/test/com/google/common/collect/testing/OpenJdk6MapTests.java @@ -42,6 +42,7 @@ * @author Kevin Bourrillion */ // TODO(cpovirk): consider renaming this class in light of our now running it under newer JDKs. +@AndroidIncompatible // test-suite builders public class OpenJdk6MapTests extends TestsForMapsInJavaUtil { public static Test suite() { return new OpenJdk6MapTests().allTests(); diff --git a/guava-testlib/test/com/google/common/collect/testing/OpenJdk6QueueTests.java b/guava-testlib/test/com/google/common/collect/testing/OpenJdk6QueueTests.java index be3e35a09e72..002b519f338a 100644 --- a/guava-testlib/test/com/google/common/collect/testing/OpenJdk6QueueTests.java +++ b/guava-testlib/test/com/google/common/collect/testing/OpenJdk6QueueTests.java @@ -31,6 +31,7 @@ * * @author Kevin Bourrillion */ +@AndroidIncompatible // test-suite builders public class OpenJdk6QueueTests extends TestsForQueuesInJavaUtil { public static Test suite() { return new OpenJdk6QueueTests().allTests(); diff --git a/guava-testlib/test/com/google/common/collect/testing/OpenJdk6SetTests.java b/guava-testlib/test/com/google/common/collect/testing/OpenJdk6SetTests.java index 39c5cf442b26..d5ccce9146bd 100644 --- a/guava-testlib/test/com/google/common/collect/testing/OpenJdk6SetTests.java +++ b/guava-testlib/test/com/google/common/collect/testing/OpenJdk6SetTests.java @@ -34,6 +34,7 @@ * * @author Kevin Bourrillion */ +@AndroidIncompatible // test-suite builders public class OpenJdk6SetTests extends TestsForSetsInJavaUtil { public static Test suite() { return new OpenJdk6SetTests().allTests(); diff --git a/guava-testlib/test/com/google/common/collect/testing/OpenJdk6Tests.java b/guava-testlib/test/com/google/common/collect/testing/OpenJdk6Tests.java index db60982ca779..c97d2bf92f92 100644 --- a/guava-testlib/test/com/google/common/collect/testing/OpenJdk6Tests.java +++ b/guava-testlib/test/com/google/common/collect/testing/OpenJdk6Tests.java @@ -27,6 +27,7 @@ * * @author Kevin Bourrillion */ +@AndroidIncompatible // test-suite builders public class OpenJdk6Tests extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-testlib/test/com/google/common/collect/testing/SafeTreeMapTest.java b/guava-testlib/test/com/google/common/collect/testing/SafeTreeMapTest.java index 67aa9f7f9b1f..4bd81700586a 100644 --- a/guava-testlib/test/com/google/common/collect/testing/SafeTreeMapTest.java +++ b/guava-testlib/test/com/google/common/collect/testing/SafeTreeMapTest.java @@ -42,6 +42,7 @@ * @author Louis Wasserman */ public class SafeTreeMapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SafeTreeMapTest.class); diff --git a/guava-testlib/test/com/google/common/collect/testing/SafeTreeSetTest.java b/guava-testlib/test/com/google/common/collect/testing/SafeTreeSetTest.java index 91e2e9f261e0..173e656e8016 100644 --- a/guava-testlib/test/com/google/common/collect/testing/SafeTreeSetTest.java +++ b/guava-testlib/test/com/google/common/collect/testing/SafeTreeSetTest.java @@ -37,6 +37,7 @@ import junit.framework.TestSuite; public class SafeTreeSetTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SafeTreeSetTest.class); diff --git a/guava-tests/test/com/google/common/cache/LocalCacheTest.java b/guava-tests/test/com/google/common/cache/LocalCacheTest.java index 9ade4ccf4f7a..5152b20b8933 100644 --- a/guava-tests/test/com/google/common/cache/LocalCacheTest.java +++ b/guava-tests/test/com/google/common/cache/LocalCacheTest.java @@ -95,6 +95,7 @@ @SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress. @NullUnmarked public class LocalCacheTest extends TestCase { + @AndroidIncompatible private static class TestStringCacheGenerator extends TestStringMapGenerator { private final CacheBuilder builder; @@ -112,6 +113,7 @@ protected Map create(Entry[] entries) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(LocalCacheTest.class); diff --git a/guava-tests/test/com/google/common/collect/ArrayListMultimapTest.java b/guava-tests/test/com/google/common/collect/ArrayListMultimapTest.java index 37f513ae3b29..b92deb516a58 100644 --- a/guava-tests/test/com/google/common/collect/ArrayListMultimapTest.java +++ b/guava-tests/test/com/google/common/collect/ArrayListMultimapTest.java @@ -48,6 +48,7 @@ public class ArrayListMultimapTest extends TestCase { @GwtIncompatible // suite @J2ktIncompatible + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/guava-tests/test/com/google/common/collect/Collections2Test.java b/guava-tests/test/com/google/common/collect/Collections2Test.java index 221ba566f7ae..23f3ffbed87d 100644 --- a/guava-tests/test/com/google/common/collect/Collections2Test.java +++ b/guava-tests/test/com/google/common/collect/Collections2Test.java @@ -54,6 +54,7 @@ public class Collections2Test extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(Collections2Test.class.getSimpleName()); suite.addTest(testsForFilter()); @@ -73,6 +74,7 @@ public static Test suite() { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilter() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @@ -97,6 +99,7 @@ public Collection create(String[] elements) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilterAll() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @@ -119,6 +122,7 @@ public Collection create(String[] elements) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilterLinkedList() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @@ -143,6 +147,7 @@ public Collection create(String[] elements) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilterNoNulls() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @@ -167,6 +172,7 @@ public Collection create(String[] elements) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilterFiltered() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { @@ -192,6 +198,7 @@ public Collection create(String[] elements) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForTransform() { return CollectionTestSuiteBuilder.using( new TestStringCollectionGenerator() { diff --git a/guava-tests/test/com/google/common/collect/CompactHashMapTest.java b/guava-tests/test/com/google/common/collect/CompactHashMapTest.java index 570815c53fc5..f1baeba9dccb 100644 --- a/guava-tests/test/com/google/common/collect/CompactHashMapTest.java +++ b/guava-tests/test/com/google/common/collect/CompactHashMapTest.java @@ -39,6 +39,7 @@ */ @NullUnmarked public class CompactHashMapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/guava-tests/test/com/google/common/collect/CompactHashSetTest.java b/guava-tests/test/com/google/common/collect/CompactHashSetTest.java index bef00fbc12de..7145ef1ceaed 100644 --- a/guava-tests/test/com/google/common/collect/CompactHashSetTest.java +++ b/guava-tests/test/com/google/common/collect/CompactHashSetTest.java @@ -43,6 +43,7 @@ @GwtIncompatible // java.util.Arrays#copyOf(Object[], int), java.lang.reflect.Array @NullUnmarked public class CompactHashSetTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { List> allFeatures = Arrays.>asList( diff --git a/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java b/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java index e9648953e345..1d6a5361675d 100644 --- a/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java +++ b/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java @@ -38,6 +38,7 @@ */ @NullUnmarked public class CompactLinkedHashMapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java b/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java index e0d9a00586e0..6b0ceee7e9cd 100644 --- a/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java +++ b/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java @@ -43,6 +43,7 @@ @GwtIncompatible // java.util.Arrays#copyOf(Object[], int), java.lang.reflect.Array @NullUnmarked public class CompactLinkedHashSetTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { List> allFeatures = Arrays.>asList( diff --git a/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java b/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java index d211a0bed2cd..e5b0a3234ff6 100644 --- a/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java +++ b/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java @@ -51,6 +51,7 @@ @NullUnmarked public class ConcurrentHashMultisetTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( @@ -76,6 +77,7 @@ public static Test suite() { return suite; } + @AndroidIncompatible // test-suite builders private static TestStringMultisetGenerator concurrentHashMultisetGenerator() { return new TestStringMultisetGenerator() { @Override @@ -85,6 +87,7 @@ protected Multiset create(String[] elements) { }; } + @AndroidIncompatible // test-suite builders private static TestStringMultisetGenerator concurrentSkipListMultisetGenerator() { return new TestStringMultisetGenerator() { @Override diff --git a/guava-tests/test/com/google/common/collect/ContiguousSetTest.java b/guava-tests/test/com/google/common/collect/ContiguousSetTest.java index bf53d89a0dd5..b0754e40b773 100644 --- a/guava-tests/test/com/google/common/collect/ContiguousSetTest.java +++ b/guava-tests/test/com/google/common/collect/ContiguousSetTest.java @@ -390,6 +390,7 @@ public void testAsList() { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static class BuiltTests extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/EnumBiMapTest.java b/guava-tests/test/com/google/common/collect/EnumBiMapTest.java index 4f5cea264617..6c869447834b 100644 --- a/guava-tests/test/com/google/common/collect/EnumBiMapTest.java +++ b/guava-tests/test/com/google/common/collect/EnumBiMapTest.java @@ -70,6 +70,7 @@ private enum Country { UK } + @AndroidIncompatible // test-suite builders public static final class EnumBiMapGenerator implements TestBiMapGenerator { @SuppressWarnings("unchecked") @Override @@ -116,6 +117,7 @@ public Currency[] createValueArray(int length) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/guava-tests/test/com/google/common/collect/EnumHashBiMapTest.java b/guava-tests/test/com/google/common/collect/EnumHashBiMapTest.java index b0e0bab7e214..72075d05d33f 100644 --- a/guava-tests/test/com/google/common/collect/EnumHashBiMapTest.java +++ b/guava-tests/test/com/google/common/collect/EnumHashBiMapTest.java @@ -65,6 +65,7 @@ private enum Country { UK } + @AndroidIncompatible // test-suite builders public static final class EnumHashBiMapGenerator implements TestBiMapGenerator { @SuppressWarnings("unchecked") @Override @@ -111,6 +112,7 @@ public String[] createValueArray(int length) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/guava-tests/test/com/google/common/collect/EnumMultisetTest.java b/guava-tests/test/com/google/common/collect/EnumMultisetTest.java index 3d66d0f58836..da4db3ca1e34 100644 --- a/guava-tests/test/com/google/common/collect/EnumMultisetTest.java +++ b/guava-tests/test/com/google/common/collect/EnumMultisetTest.java @@ -52,6 +52,7 @@ public class EnumMultisetTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( @@ -69,6 +70,7 @@ public static Test suite() { return suite; } + @AndroidIncompatible // test-suite builders private static TestEnumMultisetGenerator enumMultisetGenerator() { return new TestEnumMultisetGenerator() { @Override diff --git a/guava-tests/test/com/google/common/collect/ForwardingCollectionTest.java b/guava-tests/test/com/google/common/collect/ForwardingCollectionTest.java index f8b9cb02f4f8..a92edb28f458 100644 --- a/guava-tests/test/com/google/common/collect/ForwardingCollectionTest.java +++ b/guava-tests/test/com/google/common/collect/ForwardingCollectionTest.java @@ -103,6 +103,7 @@ public String toString() { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/ForwardingListTest.java b/guava-tests/test/com/google/common/collect/ForwardingListTest.java index ef5915545696..32b9d1f499a1 100644 --- a/guava-tests/test/com/google/common/collect/ForwardingListTest.java +++ b/guava-tests/test/com/google/common/collect/ForwardingListTest.java @@ -155,6 +155,7 @@ public List subList(int fromIndex, int toIndex) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/ForwardingMapTest.java b/guava-tests/test/com/google/common/collect/ForwardingMapTest.java index 908c9c9dde42..ab305710a9f0 100644 --- a/guava-tests/test/com/google/common/collect/ForwardingMapTest.java +++ b/guava-tests/test/com/google/common/collect/ForwardingMapTest.java @@ -138,6 +138,7 @@ public boolean isEmpty() { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/ForwardingMultisetTest.java b/guava-tests/test/com/google/common/collect/ForwardingMultisetTest.java index ca4f28aef3ad..c3a541f758b3 100644 --- a/guava-tests/test/com/google/common/collect/ForwardingMultisetTest.java +++ b/guava-tests/test/com/google/common/collect/ForwardingMultisetTest.java @@ -159,6 +159,7 @@ public int size() { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/ForwardingNavigableMapTest.java b/guava-tests/test/com/google/common/collect/ForwardingNavigableMapTest.java index 170f6d5e6f02..2bcccef303c3 100644 --- a/guava-tests/test/com/google/common/collect/ForwardingNavigableMapTest.java +++ b/guava-tests/test/com/google/common/collect/ForwardingNavigableMapTest.java @@ -250,6 +250,7 @@ protected NavigableMap delegate() { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/ForwardingNavigableSetTest.java b/guava-tests/test/com/google/common/collect/ForwardingNavigableSetTest.java index 6256c97f721f..537629afe38c 100644 --- a/guava-tests/test/com/google/common/collect/ForwardingNavigableSetTest.java +++ b/guava-tests/test/com/google/common/collect/ForwardingNavigableSetTest.java @@ -163,6 +163,7 @@ public SortedSet tailSet(T fromElement) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/ForwardingQueueTest.java b/guava-tests/test/com/google/common/collect/ForwardingQueueTest.java index 96ad8da83690..1e645cdad84b 100644 --- a/guava-tests/test/com/google/common/collect/ForwardingQueueTest.java +++ b/guava-tests/test/com/google/common/collect/ForwardingQueueTest.java @@ -119,6 +119,7 @@ public boolean offer(T o) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/ForwardingSetTest.java b/guava-tests/test/com/google/common/collect/ForwardingSetTest.java index 73d6004a6058..837abe561a30 100644 --- a/guava-tests/test/com/google/common/collect/ForwardingSetTest.java +++ b/guava-tests/test/com/google/common/collect/ForwardingSetTest.java @@ -115,6 +115,7 @@ public String toString() { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/ForwardingSortedMapTest.java b/guava-tests/test/com/google/common/collect/ForwardingSortedMapTest.java index 2a6777a0590a..1ae585db65af 100644 --- a/guava-tests/test/com/google/common/collect/ForwardingSortedMapTest.java +++ b/guava-tests/test/com/google/common/collect/ForwardingSortedMapTest.java @@ -129,6 +129,7 @@ public SortedMap subMap(K fromKey, K toKey) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/ForwardingSortedMultisetTest.java b/guava-tests/test/com/google/common/collect/ForwardingSortedMultisetTest.java index 78711789c2fc..cf6a8d85c1b1 100644 --- a/guava-tests/test/com/google/common/collect/ForwardingSortedMultisetTest.java +++ b/guava-tests/test/com/google/common/collect/ForwardingSortedMultisetTest.java @@ -176,6 +176,7 @@ public T[] toArray(T[] array) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/ForwardingSortedSetTest.java b/guava-tests/test/com/google/common/collect/ForwardingSortedSetTest.java index 188a3892a027..166aaa177bfe 100644 --- a/guava-tests/test/com/google/common/collect/ForwardingSortedSetTest.java +++ b/guava-tests/test/com/google/common/collect/ForwardingSortedSetTest.java @@ -120,6 +120,7 @@ public SortedSet subSet(T fromElement, T toElement) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/HashBiMapTest.java b/guava-tests/test/com/google/common/collect/HashBiMapTest.java index d000fdc5cfac..f4bee7bf9830 100644 --- a/guava-tests/test/com/google/common/collect/HashBiMapTest.java +++ b/guava-tests/test/com/google/common/collect/HashBiMapTest.java @@ -46,6 +46,7 @@ public class HashBiMapTest extends TestCase { @J2ktIncompatible + @AndroidIncompatible // test-suite builders public static final class HashBiMapGenerator extends TestStringBiMapGenerator { @Override protected BiMap create(Entry[] entries) { @@ -59,6 +60,7 @@ protected BiMap create(Entry[] entries) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/guava-tests/test/com/google/common/collect/HashMultimapTest.java b/guava-tests/test/com/google/common/collect/HashMultimapTest.java index e4decb57c2c8..77554381bf72 100644 --- a/guava-tests/test/com/google/common/collect/HashMultimapTest.java +++ b/guava-tests/test/com/google/common/collect/HashMultimapTest.java @@ -43,6 +43,7 @@ public class HashMultimapTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/guava-tests/test/com/google/common/collect/HashMultisetTest.java b/guava-tests/test/com/google/common/collect/HashMultisetTest.java index 421ab58e3713..1c26152fe791 100644 --- a/guava-tests/test/com/google/common/collect/HashMultisetTest.java +++ b/guava-tests/test/com/google/common/collect/HashMultisetTest.java @@ -45,6 +45,7 @@ public class HashMultisetTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( @@ -63,6 +64,7 @@ public static Test suite() { } @J2ktIncompatible + @AndroidIncompatible // test-suite builders private static TestStringMultisetGenerator hashMultisetGenerator() { return new TestStringMultisetGenerator() { @Override diff --git a/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java index c3347aa39353..d69bbb12824b 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java @@ -68,6 +68,7 @@ public class ImmutableBiMapTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java index 2c855c95c7c4..c991bde6e6d4 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java @@ -46,6 +46,7 @@ */ @NullUnmarked public class ImmutableClassToInstanceMapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableClassToInstanceMapTest.class); diff --git a/guava-tests/test/com/google/common/collect/ImmutableEnumMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableEnumMapTest.java index 37d4cefebff2..f0f132fd7cf6 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableEnumMapTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableEnumMapTest.java @@ -52,6 +52,7 @@ @NullMarked public class ImmutableEnumMapTest extends TestCase { @J2ktIncompatible + @AndroidIncompatible // test-suite builders public static class ImmutableEnumMapGenerator extends TestEnumMapGenerator { @Override protected Map create(Entry[] entries) { @@ -65,6 +66,7 @@ protected Map create(Entry[] entries) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java b/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java index ea074f572d22..aaa2f2a46bdb 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java @@ -62,6 +62,7 @@ @NullMarked public class ImmutableListMultimapTest extends TestCase { @J2ktIncompatible + @AndroidIncompatible // test-suite builders public static class ImmutableListMultimapGenerator extends TestStringListMultimapGenerator { @Override protected ListMultimap create(Entry[] entries) { @@ -74,6 +75,7 @@ protected ListMultimap create(Entry[] entries) { } @J2ktIncompatible + @AndroidIncompatible // test-suite builders public static class ImmutableListMultimapCopyOfEntriesGenerator extends TestStringListMultimapGenerator { @Override @@ -84,6 +86,7 @@ protected ListMultimap create(Entry[] entries) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/guava-tests/test/com/google/common/collect/ImmutableListTest.java b/guava-tests/test/com/google/common/collect/ImmutableListTest.java index 3083c77b8978..a57f0c300279 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableListTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableListTest.java @@ -69,6 +69,7 @@ public class ImmutableListTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/guava-tests/test/com/google/common/collect/ImmutableMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableMapTest.java index 182bb9ba7b5d..e313889b6dca 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableMapTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableMapTest.java @@ -86,6 +86,7 @@ public class ImmutableMapTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableMapTest.class); diff --git a/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java b/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java index b949a21234f9..c38624d0be68 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java @@ -67,6 +67,7 @@ public class ImmutableMultisetTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite // TODO(cpovirk): add to collect/gwt/suites + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableMultisetTest.class); diff --git a/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java b/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java index 55f834481f15..b450e87f9993 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java @@ -41,6 +41,7 @@ @NullUnmarked public class ImmutableRangeSetTest extends AbstractRangeSetTest { + @AndroidIncompatible // test-suite builders static final class ImmutableRangeSetIntegerAsSetGenerator implements TestSetGenerator { @Override public SampleElements samples() { @@ -68,6 +69,7 @@ public Set create(Object... elements) { } } + @AndroidIncompatible // test-suite builders static final class ImmutableRangeSetBigIntegerAsSetGenerator implements TestSetGenerator { @Override @@ -101,6 +103,7 @@ public Set create(Object... elements) { } } + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableRangeSetTest.class); diff --git a/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java b/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java index 19587243b107..dee49acf6d39 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java @@ -61,6 +61,7 @@ @NullMarked public class ImmutableSetMultimapTest extends TestCase { @J2ktIncompatible + @AndroidIncompatible // test-suite builders private static final class ImmutableSetMultimapGenerator extends TestStringSetMultimapGenerator { @Override protected SetMultimap create(Entry[] entries) { @@ -73,6 +74,7 @@ protected SetMultimap create(Entry[] entries) { } @J2ktIncompatible + @AndroidIncompatible // test-suite builders private static final class ImmutableSetMultimapCopyOfEntriesGenerator extends TestStringSetMultimapGenerator { @Override @@ -83,6 +85,7 @@ protected SetMultimap create(Entry[] entries) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableSetMultimapTest.class); diff --git a/guava-tests/test/com/google/common/collect/ImmutableSetTest.java b/guava-tests/test/com/google/common/collect/ImmutableSetTest.java index 59591ee65f0a..3a830cdf7d44 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableSetTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableSetTest.java @@ -64,6 +64,7 @@ public class ImmutableSetTest extends AbstractImmutableSetTest { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java index 72092806711b..977fdbfc94b9 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java @@ -76,6 +76,7 @@ public class ImmutableSortedMapTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableSortedMapTest.class); diff --git a/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java b/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java index cae1354e3096..0bb1d8684986 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java @@ -57,6 +57,7 @@ */ @NullUnmarked public class ImmutableSortedMultisetTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ImmutableSortedMultisetTest.class); diff --git a/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java b/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java index 26574d6f6f50..43d4056f3008 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java @@ -74,6 +74,7 @@ public class ImmutableSortedSetTest extends AbstractImmutableSetTest { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/IteratorsTest.java b/guava-tests/test/com/google/common/collect/IteratorsTest.java index 5cbc63ac1569..fd30bfe40216 100644 --- a/guava-tests/test/com/google/common/collect/IteratorsTest.java +++ b/guava-tests/test/com/google/common/collect/IteratorsTest.java @@ -88,6 +88,7 @@ public class IteratorsTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(IteratorsTest.class.getSimpleName()); suite.addTest(testsForRemoveAllAndRetainAll()); @@ -1436,6 +1437,7 @@ public void testRetainAll() { @J2ktIncompatible @GwtIncompatible // ListTestSuiteBuilder + @AndroidIncompatible // test-suite builders private static Test testsForRemoveAllAndRetainAll() { return ListTestSuiteBuilder.using( new TestStringListGenerator() { diff --git a/guava-tests/test/com/google/common/collect/LinkedHashMultimapTest.java b/guava-tests/test/com/google/common/collect/LinkedHashMultimapTest.java index 870d27fff58f..869b735c3f1e 100644 --- a/guava-tests/test/com/google/common/collect/LinkedHashMultimapTest.java +++ b/guava-tests/test/com/google/common/collect/LinkedHashMultimapTest.java @@ -62,6 +62,7 @@ public class LinkedHashMultimapTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/guava-tests/test/com/google/common/collect/LinkedHashMultisetTest.java b/guava-tests/test/com/google/common/collect/LinkedHashMultisetTest.java index 34d888b72361..adfbfe656341 100644 --- a/guava-tests/test/com/google/common/collect/LinkedHashMultisetTest.java +++ b/guava-tests/test/com/google/common/collect/LinkedHashMultisetTest.java @@ -44,6 +44,7 @@ public class LinkedHashMultisetTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( @@ -63,6 +64,7 @@ public static Test suite() { } @J2ktIncompatible + @AndroidIncompatible // test-suite builders private static TestStringMultisetGenerator linkedHashMultisetGenerator() { return new TestStringMultisetGenerator() { @Override diff --git a/guava-tests/test/com/google/common/collect/LinkedListMultimapTest.java b/guava-tests/test/com/google/common/collect/LinkedListMultimapTest.java index caea53de70c4..25c6cf344ff4 100644 --- a/guava-tests/test/com/google/common/collect/LinkedListMultimapTest.java +++ b/guava-tests/test/com/google/common/collect/LinkedListMultimapTest.java @@ -64,6 +64,7 @@ public class LinkedListMultimapTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/guava-tests/test/com/google/common/collect/ListsTest.java b/guava-tests/test/com/google/common/collect/ListsTest.java index f881b2c8c65b..13259e632173 100644 --- a/guava-tests/test/com/google/common/collect/ListsTest.java +++ b/guava-tests/test/com/google/common/collect/ListsTest.java @@ -113,6 +113,7 @@ public String apply(Number n) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(ListsTest.class); diff --git a/guava-tests/test/com/google/common/collect/LockHeldAssertingSet.java b/guava-tests/test/com/google/common/collect/LockHeldAssertingSet.java new file mode 100644 index 000000000000..09ebb271d424 --- /dev/null +++ b/guava-tests/test/com/google/common/collect/LockHeldAssertingSet.java @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2007 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.common.collect; + +import static com.google.common.base.Preconditions.checkNotNull; +import static junit.framework.Assert.assertTrue; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Set; +import java.util.Spliterator; +import java.util.stream.Stream; +import org.jspecify.annotations.NullUnmarked; +import org.jspecify.annotations.Nullable; + +/** + * {@link Set} implementation that asserts that a given lock is held whenever one of its methods is + * called. + */ +@NullUnmarked +class LockHeldAssertingSet extends ForwardingSet implements Serializable { + final Set delegate; + final Object mutex; + + LockHeldAssertingSet(Set delegate, Object mutex) { + checkNotNull(mutex); + this.delegate = delegate; + this.mutex = mutex; + } + + @Override + protected Set delegate() { + return delegate; + } + + @Override + public String toString() { + assertTrue(Thread.holdsLock(mutex)); + return super.toString(); + } + + @Override + public boolean equals(@Nullable Object o) { + assertTrue(Thread.holdsLock(mutex)); + return super.equals(o); + } + + @Override + public int hashCode() { + assertTrue(Thread.holdsLock(mutex)); + return super.hashCode(); + } + + @Override + public boolean add(@Nullable E o) { + assertTrue(Thread.holdsLock(mutex)); + return super.add(o); + } + + @Override + public boolean addAll(Collection c) { + assertTrue(Thread.holdsLock(mutex)); + return super.addAll(c); + } + + @Override + public void clear() { + assertTrue(Thread.holdsLock(mutex)); + super.clear(); + } + + @Override + public boolean contains(@Nullable Object o) { + assertTrue(Thread.holdsLock(mutex)); + return super.contains(o); + } + + @Override + public boolean containsAll(Collection c) { + assertTrue(Thread.holdsLock(mutex)); + return super.containsAll(c); + } + + @Override + public boolean isEmpty() { + assertTrue(Thread.holdsLock(mutex)); + return super.isEmpty(); + } + + /* + * We don't assert that the lock is held during calls to iterator(), stream(), and spliterator: + * `Synchronized` doesn't guarantee that it will hold the mutex for those calls because callers + * are responsible for taking the mutex themselves: + * https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/Collections.html#synchronizedCollection(java.util.Collection) + * + * Similarly, we avoid having those methods *implemented* in terms of *other* TestSet methods + * that will perform holdsLock assertions: + * + * - For iterator(), we can accomplish that by not overriding iterator() at all. That way, we + * inherit an implementation that forwards to the delegate collection, which performs no + * holdsLock assertions. + * + * - For stream() and spliterator(), we have to forward to the delegate ourselves because + * ForwardingSet does not forward `default` methods, as discussed in its Javadoc. + */ + + @Override + public Stream stream() { + return delegate.stream(); + } + + @Override + public Spliterator spliterator() { + return delegate.spliterator(); + } + + @Override + public boolean remove(@Nullable Object o) { + assertTrue(Thread.holdsLock(mutex)); + return super.remove(o); + } + + @Override + public boolean removeAll(Collection c) { + assertTrue(Thread.holdsLock(mutex)); + return super.removeAll(c); + } + + @Override + public boolean retainAll(Collection c) { + assertTrue(Thread.holdsLock(mutex)); + return super.retainAll(c); + } + + @Override + public int size() { + assertTrue(Thread.holdsLock(mutex)); + return super.size(); + } + + @Override + public Object[] toArray() { + assertTrue(Thread.holdsLock(mutex)); + return super.toArray(); + } + + @Override + public T[] toArray(T[] a) { + assertTrue(Thread.holdsLock(mutex)); + return super.toArray(a); + } + + private static final long serialVersionUID = 0; +} diff --git a/guava-tests/test/com/google/common/collect/MapsCollectionTest.java b/guava-tests/test/com/google/common/collect/MapsCollectionTest.java index a52b7a8f50c3..bc41f318b086 100644 --- a/guava-tests/test/com/google/common/collect/MapsCollectionTest.java +++ b/guava-tests/test/com/google/common/collect/MapsCollectionTest.java @@ -61,6 +61,7 @@ * @author Louis Wasserman */ @NullUnmarked +@AndroidIncompatible // test-suite builders public class MapsCollectionTest extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/MinMaxPriorityQueueTest.java b/guava-tests/test/com/google/common/collect/MinMaxPriorityQueueTest.java index f3b58b220093..b5d4cf5d6331 100644 --- a/guava-tests/test/com/google/common/collect/MinMaxPriorityQueueTest.java +++ b/guava-tests/test/com/google/common/collect/MinMaxPriorityQueueTest.java @@ -68,6 +68,7 @@ public class MinMaxPriorityQueueTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(MinMaxPriorityQueueTest.class); diff --git a/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java b/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java index c0c40596eac5..a2de6237dea9 100644 --- a/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java +++ b/guava-tests/test/com/google/common/collect/MultimapsCollectionTest.java @@ -79,6 +79,7 @@ */ @GwtIncompatible // suite // TODO(cpovirk): set up collect/gwt/suites version @NullUnmarked +@AndroidIncompatible // test-suite builders public class MultimapsCollectionTest extends TestCase { private static final Feature[] FOR_MAP_FEATURES_ONE = { diff --git a/guava-tests/test/com/google/common/collect/MultisetsCollectionTest.java b/guava-tests/test/com/google/common/collect/MultisetsCollectionTest.java index eac7058b374b..9583f28abb58 100644 --- a/guava-tests/test/com/google/common/collect/MultisetsCollectionTest.java +++ b/guava-tests/test/com/google/common/collect/MultisetsCollectionTest.java @@ -49,6 +49,7 @@ */ @GwtIncompatible // suite // TODO(cpovirk): set up collect/gwt/suites version @NullUnmarked +@AndroidIncompatible // test-suite builders public class MultisetsCollectionTest extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java b/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java index f1d2e94fa302..8adb091a8f0f 100644 --- a/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java +++ b/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java @@ -38,6 +38,7 @@ */ @NullUnmarked public class MutableClassToInstanceMapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(MutableClassToInstanceMapTest.class); diff --git a/guava-tests/test/com/google/common/collect/SetOperationsTest.java b/guava-tests/test/com/google/common/collect/SetOperationsTest.java index f17d0ee3b37e..ec6daacba426 100644 --- a/guava-tests/test/com/google/common/collect/SetOperationsTest.java +++ b/guava-tests/test/com/google/common/collect/SetOperationsTest.java @@ -44,6 +44,7 @@ public class SetOperationsTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/SetsTest.java b/guava-tests/test/com/google/common/collect/SetsTest.java index 2dba31fb2bf6..e348078e9f2e 100644 --- a/guava-tests/test/com/google/common/collect/SetsTest.java +++ b/guava-tests/test/com/google/common/collect/SetsTest.java @@ -118,6 +118,7 @@ public Iterator iterator() { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SetsTest.class); @@ -231,6 +232,7 @@ public List order(List insertionOrder) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilter() { return SetTestSuiteBuilder.using( new TestStringSetGenerator() { @@ -255,6 +257,7 @@ public Set create(String[] elements) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilterNoNulls() { TestSuite suite = new TestSuite(); suite.addTest( @@ -307,6 +310,7 @@ public List order(List insertionOrder) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders private static Test testsForFilterFiltered() { return SetTestSuiteBuilder.using( new TestStringSetGenerator() { diff --git a/guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java b/guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java index e6244281876d..d568d8c7fb2e 100644 --- a/guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java +++ b/guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java @@ -48,6 +48,7 @@ public class SimpleAbstractMultisetTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SimpleAbstractMultisetTest.class); diff --git a/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java b/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java index 7e4ac851dd07..fffb346966de 100644 --- a/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java +++ b/guava-tests/test/com/google/common/collect/SynchronizedBiMapTest.java @@ -41,6 +41,7 @@ @NullUnmarked public class SynchronizedBiMapTest extends SynchronizedMapTest { + @AndroidIncompatible // test-suite builders public static TestSuite suite() { TestSuite suite = new TestSuite(SynchronizedBiMapTest.class); suite.addTest( @@ -79,6 +80,7 @@ protected BiMap create() { return outer; } + @AndroidIncompatible // test-suite builders public static final class SynchronizedHashBiMapGenerator extends TestStringBiMapGenerator { @Override protected BiMap create(Entry[] entries) { @@ -91,6 +93,7 @@ protected BiMap create(Entry[] entries) { } } + @AndroidIncompatible // test-suite builders public static final class SynchTestingBiMapGenerator extends TestStringBiMapGenerator { @Override protected BiMap create(Entry[] entries) { diff --git a/guava-tests/test/com/google/common/collect/SynchronizedMultimapTest.java b/guava-tests/test/com/google/common/collect/SynchronizedMultimapTest.java index 7f7508c7155b..f5f322d202cf 100644 --- a/guava-tests/test/com/google/common/collect/SynchronizedMultimapTest.java +++ b/guava-tests/test/com/google/common/collect/SynchronizedMultimapTest.java @@ -46,6 +46,7 @@ @NullUnmarked public class SynchronizedMultimapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SynchronizedMultimapTest.class); diff --git a/guava-tests/test/com/google/common/collect/SynchronizedNavigableMapTest.java b/guava-tests/test/com/google/common/collect/SynchronizedNavigableMapTest.java index 1a75965c8dcc..4e1f5b336e17 100644 --- a/guava-tests/test/com/google/common/collect/SynchronizedNavigableMapTest.java +++ b/guava-tests/test/com/google/common/collect/SynchronizedNavigableMapTest.java @@ -257,6 +257,7 @@ public K lastKey() { private static final long serialVersionUID = 0; } + @AndroidIncompatible // test-suite builders public static TestSuite suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SynchronizedNavigableMapTest.class); diff --git a/guava-tests/test/com/google/common/collect/SynchronizedNavigableSetTest.java b/guava-tests/test/com/google/common/collect/SynchronizedNavigableSetTest.java index 962e7512782c..287599ff6243 100644 --- a/guava-tests/test/com/google/common/collect/SynchronizedNavigableSetTest.java +++ b/guava-tests/test/com/google/common/collect/SynchronizedNavigableSetTest.java @@ -44,17 +44,17 @@ public class SynchronizedNavigableSetTest extends TestCase { private static final Object MUTEX = new Object[0]; // something Serializable - @SuppressWarnings("unchecked") - protected NavigableSet create() { - TestSet inner = - new TestSet<>(new TreeSet((Comparator) Ordering.natural().nullsFirst()), MUTEX); + protected > NavigableSet create() { + LockHeldAssertingNavigableSet inner = + new LockHeldAssertingNavigableSet<>(new TreeSet<>(Ordering.natural().nullsFirst()), MUTEX); NavigableSet outer = Synchronized.navigableSet(inner, MUTEX); return outer; } - static class TestSet extends SynchronizedSetTest.TestSet implements NavigableSet { + static class LockHeldAssertingNavigableSet extends LockHeldAssertingSet + implements NavigableSet { - TestSet(NavigableSet delegate, @Nullable Object mutex) { + LockHeldAssertingNavigableSet(NavigableSet delegate, @Nullable Object mutex) { super(delegate, mutex); } @@ -164,6 +164,7 @@ public E last() { private static final long serialVersionUID = 0; } + @AndroidIncompatible // test-suite builders public static TestSuite suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(SynchronizedNavigableSetTest.class); @@ -175,7 +176,8 @@ public static TestSuite suite() { protected NavigableSet create(String[] elements) { NavigableSet innermost = new SafeTreeSet<>(); Collections.addAll(innermost, elements); - TestSet inner = new TestSet<>(innermost, MUTEX); + LockHeldAssertingNavigableSet inner = + new LockHeldAssertingNavigableSet<>(innermost, MUTEX); NavigableSet outer = Synchronized.navigableSet(inner, MUTEX); return outer; } diff --git a/guava-tests/test/com/google/common/collect/SynchronizedSetTest.java b/guava-tests/test/com/google/common/collect/SynchronizedSetTest.java index dd7073579359..323480fe3f62 100644 --- a/guava-tests/test/com/google/common/collect/SynchronizedSetTest.java +++ b/guava-tests/test/com/google/common/collect/SynchronizedSetTest.java @@ -16,23 +16,17 @@ package com.google.common.collect; -import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.collect.testing.SetTestSuiteBuilder; import com.google.common.collect.testing.TestStringSetGenerator; import com.google.common.collect.testing.features.CollectionFeature; import com.google.common.collect.testing.features.CollectionSize; -import java.io.Serializable; -import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Set; -import java.util.Spliterator; -import java.util.stream.Stream; import junit.framework.Test; import junit.framework.TestCase; import org.jspecify.annotations.NullUnmarked; -import org.jspecify.annotations.Nullable; /** * Tests for {@code Synchronized#set}. @@ -40,6 +34,7 @@ * @author Mike Bostock */ @NullUnmarked +@AndroidIncompatible // test-suite builders public class SynchronizedSetTest extends TestCase { public static final Object MUTEX = new Object[0]; // something Serializable @@ -49,7 +44,8 @@ public static Test suite() { new TestStringSetGenerator() { @Override protected Set create(String[] elements) { - TestSet inner = new TestSet<>(new HashSet(), MUTEX); + LockHeldAssertingSet inner = + new LockHeldAssertingSet<>(new HashSet(), MUTEX); Set outer = Synchronized.set(inner, inner.mutex); Collections.addAll(outer, elements); return outer; @@ -63,139 +59,4 @@ protected Set create(String[] elements) { CollectionFeature.SERIALIZABLE) .createTestSuite(); } - - static class TestSet extends ForwardingSet implements Serializable { - final Set delegate; - public final Object mutex; - - public TestSet(Set delegate, Object mutex) { - checkNotNull(mutex); - this.delegate = delegate; - this.mutex = mutex; - } - - @Override - protected Set delegate() { - return delegate; - } - - @Override - public String toString() { - assertTrue(Thread.holdsLock(mutex)); - return super.toString(); - } - - @Override - public boolean equals(@Nullable Object o) { - assertTrue(Thread.holdsLock(mutex)); - return super.equals(o); - } - - @Override - public int hashCode() { - assertTrue(Thread.holdsLock(mutex)); - return super.hashCode(); - } - - @Override - public boolean add(@Nullable E o) { - assertTrue(Thread.holdsLock(mutex)); - return super.add(o); - } - - @Override - public boolean addAll(Collection c) { - assertTrue(Thread.holdsLock(mutex)); - return super.addAll(c); - } - - @Override - public void clear() { - assertTrue(Thread.holdsLock(mutex)); - super.clear(); - } - - @Override - public boolean contains(@Nullable Object o) { - assertTrue(Thread.holdsLock(mutex)); - return super.contains(o); - } - - @Override - public boolean containsAll(Collection c) { - assertTrue(Thread.holdsLock(mutex)); - return super.containsAll(c); - } - - @Override - public boolean isEmpty() { - assertTrue(Thread.holdsLock(mutex)); - return super.isEmpty(); - } - - /* - * We don't assert that the lock is held during calls to iterator(), stream(), and spliterator: - * `Synchronized` doesn't guarantee that it will hold the mutex for those calls because callers - * are responsible for taking the mutex themselves: - * https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/util/Collections.html#synchronizedCollection(java.util.Collection) - * - * Similarly, we avoid having those methods *implemented* in terms of *other* TestSet methods - * that will perform holdsLock assertions: - * - * - For iterator(), we can accomplish that by not overriding iterator() at all. That way, we - * inherit an implementation that forwards to the delegate collection, which performs no - * holdsLock assertions. - * - * - For stream() and spliterator(), we have to forward to the delegate ourselves because - * ForwardingSet does not forward `default` methods, as discussed in its Javadoc. - */ - - @Override - public Stream stream() { - return delegate.stream(); - } - - @Override - public Spliterator spliterator() { - return delegate.spliterator(); - } - - @Override - public boolean remove(@Nullable Object o) { - assertTrue(Thread.holdsLock(mutex)); - return super.remove(o); - } - - @Override - public boolean removeAll(Collection c) { - assertTrue(Thread.holdsLock(mutex)); - return super.removeAll(c); - } - - @Override - public boolean retainAll(Collection c) { - assertTrue(Thread.holdsLock(mutex)); - return super.retainAll(c); - } - - @Override - public int size() { - assertTrue(Thread.holdsLock(mutex)); - return super.size(); - } - - @Override - public Object[] toArray() { - assertTrue(Thread.holdsLock(mutex)); - return super.toArray(); - } - - @Override - public T[] toArray(T[] a) { - assertTrue(Thread.holdsLock(mutex)); - return super.toArray(a); - } - - private static final long serialVersionUID = 0; - } } diff --git a/guava-tests/test/com/google/common/collect/TableCollectionTest.java b/guava-tests/test/com/google/common/collect/TableCollectionTest.java index 6f1d51a82c08..effc828b8d50 100644 --- a/guava-tests/test/com/google/common/collect/TableCollectionTest.java +++ b/guava-tests/test/com/google/common/collect/TableCollectionTest.java @@ -89,6 +89,7 @@ public class TableCollectionTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); diff --git a/guava-tests/test/com/google/common/collect/TreeBasedTableTest.java b/guava-tests/test/com/google/common/collect/TreeBasedTableTest.java index cd14b4b87359..1466bd94f5ab 100644 --- a/guava-tests/test/com/google/common/collect/TreeBasedTableTest.java +++ b/guava-tests/test/com/google/common/collect/TreeBasedTableTest.java @@ -51,6 +51,7 @@ public class TreeBasedTableTest extends AbstractTableTest { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(TreeBasedTableTest.class); diff --git a/guava-tests/test/com/google/common/collect/TreeMultimapNaturalTest.java b/guava-tests/test/com/google/common/collect/TreeMultimapNaturalTest.java index bd4f2b945a28..346ba9811e6b 100644 --- a/guava-tests/test/com/google/common/collect/TreeMultimapNaturalTest.java +++ b/guava-tests/test/com/google/common/collect/TreeMultimapNaturalTest.java @@ -65,6 +65,7 @@ public class TreeMultimapNaturalTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); // TODO(lowasser): should we force TreeMultimap to be more thorough about checking nulls? diff --git a/guava-tests/test/com/google/common/collect/TreeMultisetTest.java b/guava-tests/test/com/google/common/collect/TreeMultisetTest.java index 05453e85e279..9a7ddab9bec4 100644 --- a/guava-tests/test/com/google/common/collect/TreeMultisetTest.java +++ b/guava-tests/test/com/google/common/collect/TreeMultisetTest.java @@ -55,6 +55,7 @@ public class TreeMultisetTest extends TestCase { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTest( diff --git a/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java b/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java index 6b884467f91b..baadf5c9af45 100644 --- a/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java +++ b/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java @@ -44,6 +44,7 @@ @GwtIncompatible // NavigableMap @NullUnmarked public class TreeRangeMapTest extends TestCase { + @AndroidIncompatible // test-suite builders public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(TreeRangeMapTest.class); diff --git a/guava-tests/test/com/google/common/primitives/ByteArrayAsListTest.java b/guava-tests/test/com/google/common/primitives/ByteArrayAsListTest.java index 12388907e8c4..b4676078bada 100644 --- a/guava-tests/test/com/google/common/primitives/ByteArrayAsListTest.java +++ b/guava-tests/test/com/google/common/primitives/ByteArrayAsListTest.java @@ -41,6 +41,7 @@ */ @GwtCompatible(emulated = true) @NullUnmarked +@AndroidIncompatible // test-suite builders public class ByteArrayAsListTest extends TestCase { private static List asList(Byte[] values) { diff --git a/guava-tests/test/com/google/common/primitives/CharArrayAsListTest.java b/guava-tests/test/com/google/common/primitives/CharArrayAsListTest.java index 162d03358dfc..fd1dafaf1b3b 100644 --- a/guava-tests/test/com/google/common/primitives/CharArrayAsListTest.java +++ b/guava-tests/test/com/google/common/primitives/CharArrayAsListTest.java @@ -41,6 +41,7 @@ */ @GwtCompatible(emulated = true) @NullUnmarked +@AndroidIncompatible // test-suite builders public class CharArrayAsListTest extends TestCase { private static List asList(Character[] values) { diff --git a/guava-tests/test/com/google/common/primitives/DoubleArrayAsListTest.java b/guava-tests/test/com/google/common/primitives/DoubleArrayAsListTest.java index 7515073fce9b..f1b054d69d18 100644 --- a/guava-tests/test/com/google/common/primitives/DoubleArrayAsListTest.java +++ b/guava-tests/test/com/google/common/primitives/DoubleArrayAsListTest.java @@ -41,6 +41,7 @@ */ @GwtCompatible(emulated = true) @NullUnmarked +@AndroidIncompatible // test-suite builders public class DoubleArrayAsListTest extends TestCase { private static List asList(Double[] values) { diff --git a/guava-tests/test/com/google/common/primitives/FloatArrayAsListTest.java b/guava-tests/test/com/google/common/primitives/FloatArrayAsListTest.java index 9fee9033ce08..8d88e79b4a73 100644 --- a/guava-tests/test/com/google/common/primitives/FloatArrayAsListTest.java +++ b/guava-tests/test/com/google/common/primitives/FloatArrayAsListTest.java @@ -41,6 +41,7 @@ */ @GwtCompatible(emulated = true) @NullUnmarked +@AndroidIncompatible // test-suite builders public class FloatArrayAsListTest extends TestCase { private static List asList(Float[] values) { diff --git a/guava-tests/test/com/google/common/primitives/ImmutableDoubleArrayTest.java b/guava-tests/test/com/google/common/primitives/ImmutableDoubleArrayTest.java index a7ea0cfa968c..c0f7af4de727 100644 --- a/guava-tests/test/com/google/common/primitives/ImmutableDoubleArrayTest.java +++ b/guava-tests/test/com/google/common/primitives/ImmutableDoubleArrayTest.java @@ -445,6 +445,7 @@ private static void assertDoesntActuallyTrim(ImmutableDoubleArray iia) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { List> builders = ImmutableList.of( @@ -477,6 +478,7 @@ public static Test suite() { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible private static ImmutableDoubleArray makeArray(Double[] values) { return ImmutableDoubleArray.copyOf(Arrays.asList(values)); } @@ -486,6 +488,7 @@ private static ImmutableDoubleArray makeArray(Double[] values) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableDoubleArrayAsListGenerator extends TestDoubleListGenerator { @Override protected List create(Double[] elements) { @@ -495,6 +498,7 @@ protected List create(Double[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableDoubleArrayHeadSubListAsListGenerator extends TestDoubleListGenerator { @Override @@ -507,6 +511,7 @@ protected List create(Double[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableDoubleArrayTailSubListAsListGenerator extends TestDoubleListGenerator { @Override @@ -519,6 +524,7 @@ protected List create(Double[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableDoubleArrayMiddleSubListAsListGenerator extends TestDoubleListGenerator { @Override @@ -532,12 +538,14 @@ protected List create(Double[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible private static Double[] concat(Double[] a, Double[] b) { return ObjectArrays.concat(a, b, Double.class); } @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public abstract static class TestDoubleListGenerator implements TestListGenerator { @Override public SampleElements samples() { @@ -574,6 +582,7 @@ public List order(List insertionOrder) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static class SampleDoubles extends SampleElements { public SampleDoubles() { super(-0.0, Long.MAX_VALUE * 3.0, Double.MAX_VALUE, Double.POSITIVE_INFINITY, Double.NaN); diff --git a/guava-tests/test/com/google/common/primitives/ImmutableIntArrayTest.java b/guava-tests/test/com/google/common/primitives/ImmutableIntArrayTest.java index a614b441d64a..6051eead8fec 100644 --- a/guava-tests/test/com/google/common/primitives/ImmutableIntArrayTest.java +++ b/guava-tests/test/com/google/common/primitives/ImmutableIntArrayTest.java @@ -430,6 +430,7 @@ private static void assertDoesntActuallyTrim(ImmutableIntArray iia) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { List> builders = ImmutableList.of( diff --git a/guava-tests/test/com/google/common/primitives/ImmutableLongArrayTest.java b/guava-tests/test/com/google/common/primitives/ImmutableLongArrayTest.java index 9c279055c518..ec506695b6cf 100644 --- a/guava-tests/test/com/google/common/primitives/ImmutableLongArrayTest.java +++ b/guava-tests/test/com/google/common/primitives/ImmutableLongArrayTest.java @@ -433,6 +433,7 @@ private static void assertDoesntActuallyTrim(ImmutableLongArray iia) { @J2ktIncompatible @GwtIncompatible // suite + @AndroidIncompatible // test-suite builders public static Test suite() { List> builders = ImmutableList.of( @@ -465,6 +466,7 @@ public static Test suite() { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible private static ImmutableLongArray makeArray(Long[] values) { return ImmutableLongArray.copyOf(Arrays.asList(values)); } @@ -474,6 +476,7 @@ private static ImmutableLongArray makeArray(Long[] values) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableLongArrayAsListGenerator extends TestLongListGenerator { @Override protected List create(Long[] elements) { @@ -483,6 +486,7 @@ protected List create(Long[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableLongArrayHeadSubListAsListGenerator extends TestLongListGenerator { @Override @@ -495,6 +499,7 @@ protected List create(Long[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableLongArrayTailSubListAsListGenerator extends TestLongListGenerator { @Override @@ -507,6 +512,7 @@ protected List create(Long[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static final class ImmutableLongArrayMiddleSubListAsListGenerator extends TestLongListGenerator { @Override @@ -520,12 +526,14 @@ protected List create(Long[] elements) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible private static Long[] concat(Long[] a, Long[] b) { return ObjectArrays.concat(a, b, Long.class); } @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public abstract static class TestLongListGenerator implements TestListGenerator { @Override public SampleElements samples() { @@ -562,6 +570,7 @@ public List order(List insertionOrder) { @J2ktIncompatible @GwtIncompatible // used only from suite + @AndroidIncompatible public static class SampleLongs extends SampleElements { public SampleLongs() { super(1L << 31, 1L << 33, 1L << 36, 1L << 40, 1L << 45); diff --git a/guava-tests/test/com/google/common/primitives/IntArrayAsListTest.java b/guava-tests/test/com/google/common/primitives/IntArrayAsListTest.java index 8f5732ff22c0..14ab5667bce3 100644 --- a/guava-tests/test/com/google/common/primitives/IntArrayAsListTest.java +++ b/guava-tests/test/com/google/common/primitives/IntArrayAsListTest.java @@ -42,6 +42,7 @@ @GwtCompatible(emulated = true) @SuppressWarnings("cast") // redundant casts are intentional and harmless @NullUnmarked +@AndroidIncompatible // test-suite builders public class IntArrayAsListTest extends TestCase { private static List asList(Integer[] values) { diff --git a/guava-tests/test/com/google/common/primitives/LongArrayAsListTest.java b/guava-tests/test/com/google/common/primitives/LongArrayAsListTest.java index 76c54bdbf1ba..b3657c437701 100644 --- a/guava-tests/test/com/google/common/primitives/LongArrayAsListTest.java +++ b/guava-tests/test/com/google/common/primitives/LongArrayAsListTest.java @@ -41,6 +41,7 @@ */ @GwtCompatible(emulated = true) @NullUnmarked +@AndroidIncompatible // test-suite builders public class LongArrayAsListTest extends TestCase { private static List asList(Long[] values) { diff --git a/guava-tests/test/com/google/common/primitives/ShortArrayAsListTest.java b/guava-tests/test/com/google/common/primitives/ShortArrayAsListTest.java index c6c4dea4d304..33a01b8c22c1 100644 --- a/guava-tests/test/com/google/common/primitives/ShortArrayAsListTest.java +++ b/guava-tests/test/com/google/common/primitives/ShortArrayAsListTest.java @@ -41,6 +41,7 @@ */ @GwtCompatible(emulated = true) @NullUnmarked +@AndroidIncompatible // test-suite builders public class ShortArrayAsListTest extends TestCase { private static List asList(Short[] values) {