Skip to content

Commit 702e4b2

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
Disable Java7ApiChecker for our *tests*, removing most of its suppressions and also most AndroidJdkLibsChecker suppressions.
(`AndroidJdkLibsChecker` (albeit in "desugaring mode") and Animal Sniffer will continue to run.) It's not clear that `Java7ApiChecker` is useful even for our *prod* code at this point, as discussed in b/336133887. Let's at least start by disabling it for tests, where it's one of the remaining annoyances when adding support for Java 8 APIs to our Android branch. (The actual immediate motivation for this CL is cl/686562711.) The _`AndroidJdkLibsChecker`_ suppressions can be removed now that the standard configuration inside Google enables opt-in library desugaring, which signals to `AndroidJdkLibsChecker` not to warn about the methods that we're using. (Again, we still have checking from Animal Sniffer.) RELNOTES=n/a PiperOrigin-RevId: 686638643
1 parent 98d5528 commit 702e4b2

28 files changed

+43
-63
lines changed

android/guava-testlib/test/com/google/common/testing/FakeTickerTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public void testNullPointerExceptions() {
4444
}
4545

4646
@GwtIncompatible // java.time.Duration
47-
@SuppressWarnings("Java7ApiChecker") // guava-android can rely on library desugaring now.
4847
@IgnoreJRERequirement // TODO: b/288085449 - Remove this once we use library-desugaring scents.
4948
public void testAdvance() {
5049
FakeTicker ticker = new FakeTicker();
@@ -84,7 +83,6 @@ public void testAutoIncrementStep_seconds() {
8483
}
8584

8685
@GwtIncompatible // java.time.Duration
87-
@SuppressWarnings("Java7ApiChecker") // guava-android can rely on library desugaring now.
8886
@IgnoreJRERequirement // TODO: b/288085449 - Remove this once we use library-desugaring scents.
8987
public void testAutoIncrementStep_duration() {
9088
FakeTicker ticker = new FakeTicker().setAutoIncrementStep(Duration.ofMillis(1));

android/guava-tests/test/com/google/common/base/SuppliersTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ public void testMemoizeWithExpiration_longTimeUnit() throws InterruptedException
231231

232232
@J2ktIncompatible
233233
@GwtIncompatible // Thread.sleep
234-
@SuppressWarnings("Java7ApiChecker") // test of Java 8+ API
235234
public void testMemoizeWithExpiration_duration() throws InterruptedException {
236235
CountingSupplier countingSupplier = new CountingSupplier();
237236

@@ -252,7 +251,6 @@ public void testMemoizeWithExpiration_longTimeUnitNegative() throws InterruptedE
252251
() -> Suppliers.memoizeWithExpiration(() -> "", -1, TimeUnit.MILLISECONDS));
253252
}
254253

255-
@SuppressWarnings("Java7ApiChecker") // test of Java 8+ API
256254
@J2ktIncompatible // Duration
257255
@GwtIncompatible // Duration
258256
public void testMemoizeWithExpiration_durationNegative() throws InterruptedException {
@@ -496,7 +494,6 @@ public void testSerialization() {
496494

497495
@J2ktIncompatible
498496
@GwtIncompatible // reflection
499-
@SuppressWarnings("Java7ApiChecker") // includes test of Java 8+ API
500497
public void testSuppliersNullChecks() throws Exception {
501498
new ClassSanityTester()
502499
.setDefault(Duration.class, Duration.ofSeconds(1))
@@ -507,7 +504,6 @@ public void testSuppliersNullChecks() throws Exception {
507504
@J2ktIncompatible
508505
@GwtIncompatible // reflection
509506
@AndroidIncompatible // TODO(cpovirk): ClassNotFoundException: com.google.common.base.Function
510-
@SuppressWarnings("Java7ApiChecker") // includes test of Java 8+ API
511507
public void testSuppliersSerializable() throws Exception {
512508
new ClassSanityTester()
513509
.setDefault(Duration.class, Duration.ofSeconds(1))

android/guava-tests/test/com/google/common/cache/CacheBuilderTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ public void testValueStrengthSetTwice() {
230230
}
231231

232232
@GwtIncompatible // Duration
233-
@SuppressWarnings("Java7ApiChecker")
234233
@IgnoreJRERequirement // No more dangerous than wherever the caller got the Duration from
235234
public void testLargeDurationsAreOk() {
236235
Duration threeHundredYears = Duration.ofDays(365 * 300);
@@ -251,7 +250,6 @@ public void testTimeToLive_negative() {
251250
}
252251

253252
@GwtIncompatible // Duration
254-
@SuppressWarnings("Java7ApiChecker")
255253
public void testTimeToLive_negative_duration() {
256254
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
257255
assertThrows(
@@ -276,7 +274,6 @@ public void testTimeToLive_setTwice() {
276274
}
277275

278276
@GwtIncompatible // Duration
279-
@SuppressWarnings("Java7ApiChecker")
280277
public void testTimeToLive_setTwice_duration() {
281278
CacheBuilder<Object, Object> builder =
282279
CacheBuilder.newBuilder().expireAfterWrite(Duration.ofHours(1));
@@ -293,7 +290,6 @@ public void testTimeToIdle_negative() {
293290
}
294291

295292
@GwtIncompatible // Duration
296-
@SuppressWarnings("Java7ApiChecker")
297293
public void testTimeToIdle_negative_duration() {
298294
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
299295
assertThrows(
@@ -318,14 +314,12 @@ public void testTimeToIdle_setTwice() {
318314
}
319315

320316
@GwtIncompatible // Duration
321-
@SuppressWarnings("Java7ApiChecker")
322317
public void testTimeToIdle_setTwice_duration() {
323318
CacheBuilder<Object, Object> builder =
324319
CacheBuilder.newBuilder().expireAfterAccess(Duration.ofHours(1));
325320
assertThrows(IllegalStateException.class, () -> builder.expireAfterAccess(Duration.ofHours(1)));
326321
}
327322

328-
@SuppressWarnings("Java7ApiChecker")
329323
public void testTimeToIdleAndToLive() {
330324
LoadingCache<?, ?> unused =
331325
CacheBuilder.newBuilder()
@@ -342,7 +336,6 @@ public void testRefresh_zero() {
342336
}
343337

344338
@GwtIncompatible // Duration
345-
@SuppressWarnings("Java7ApiChecker")
346339
public void testRefresh_zero_duration() {
347340
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
348341
assertThrows(IllegalArgumentException.class, () -> builder.refreshAfterWrite(Duration.ZERO));
@@ -356,7 +349,6 @@ public void testRefresh_setTwice() {
356349
}
357350

358351
@GwtIncompatible // Duration
359-
@SuppressWarnings("Java7ApiChecker")
360352
public void testRefresh_setTwice_duration() {
361353
CacheBuilder<Object, Object> builder =
362354
CacheBuilder.newBuilder().refreshAfterWrite(Duration.ofHours(1));

android/guava/src/com/google/common/collect/CollectCollectors.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
/** Collectors utilities for {@code common.collect} internals. */
4343
@GwtCompatible
4444
@ElementTypesAreNonnullByDefault
45-
@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
45+
@SuppressWarnings("Java7ApiChecker")
4646
@IgnoreJRERequirement // used only from APIs with Java 8 types in them
4747
// (not used publicly by guava-android as of this writing, but we include it in the jar as a test)
4848
final class CollectCollectors {

android/guava/src/com/google/common/collect/Comparators.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private Comparators() {}
129129
* @throws IllegalArgumentException if {@code k < 0}
130130
* @since 33.2.0 (available since 22.0 in guava-jre)
131131
*/
132-
@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
132+
@SuppressWarnings("Java7ApiChecker")
133133
@IgnoreJRERequirement // Users will use this only if they're already using streams.
134134
public static <T extends @Nullable Object> Collector<T, ?, List<T>> least(
135135
int k, Comparator<? super T> comparator) {
@@ -163,7 +163,7 @@ private Comparators() {}
163163
* @throws IllegalArgumentException if {@code k < 0}
164164
* @since 33.2.0 (available since 22.0 in guava-jre)
165165
*/
166-
@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
166+
@SuppressWarnings("Java7ApiChecker")
167167
@IgnoreJRERequirement // Users will use this only if they're already using streams.
168168
public static <T extends @Nullable Object> Collector<T, ?, List<T>> greatest(
169169
int k, Comparator<? super T> comparator) {

android/guava/src/com/google/common/collect/ImmutableBiMap.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public abstract class ImmutableBiMap<K, V> extends ImmutableMap<K, V> implements
5959
*
6060
* @since 33.2.0 (available since 21.0 in guava-jre)
6161
*/
62-
@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
62+
@SuppressWarnings("Java7ApiChecker")
6363
@IgnoreJRERequirement // Users will use this only if they're already using streams.
6464
public static <T extends @Nullable Object, K, V>
6565
Collector<T, ?, ImmutableBiMap<K, V>> toImmutableBiMap(
@@ -628,7 +628,7 @@ private void readObject(ObjectInputStream stream) throws InvalidObjectException
628628
*/
629629
@Deprecated
630630
@DoNotCall("Use toImmutableBiMap")
631-
@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
631+
@SuppressWarnings("Java7ApiChecker")
632632
@IgnoreJRERequirement // Users will use this only if they're already using streams.
633633
public static <T extends @Nullable Object, K, V>
634634
Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
@@ -648,7 +648,7 @@ private void readObject(ObjectInputStream stream) throws InvalidObjectException
648648
*/
649649
@Deprecated
650650
@DoNotCall("Use toImmutableBiMap")
651-
@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
651+
@SuppressWarnings("Java7ApiChecker")
652652
@IgnoreJRERequirement // Users will use this only if they're already using streams.
653653
public static <T extends @Nullable Object, K, V>
654654
Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(

android/guava/src/com/google/common/collect/ImmutableCollection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public abstract class ImmutableCollection<E> extends AbstractCollection<E> imple
178178
* These are properties of the collection as a whole; SIZED and SUBSIZED are more properties of
179179
* the spliterator implementation.
180180
*/
181-
@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
181+
@SuppressWarnings("Java7ApiChecker")
182182
// @IgnoreJRERequirement is not necessary because this compiles down to a constant.
183183
// (which is fortunate because Animal Sniffer doesn't look for @IgnoreJRERequirement on fields)
184184
static final int SPLITERATOR_CHARACTERISTICS =
@@ -191,7 +191,7 @@ public abstract class ImmutableCollection<E> extends AbstractCollection<E> imple
191191
public abstract UnmodifiableIterator<E> iterator();
192192

193193
@Override
194-
@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
194+
@SuppressWarnings("Java7ApiChecker")
195195
@IgnoreJRERequirement // used only from APIs with Java 8 types in them
196196
// (not used within guava-android as of this writing, but we include it in the jar as a test)
197197
public Spliterator<E> spliterator() {

android/guava/src/com/google/common/collect/ImmutableList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public abstract class ImmutableList<E> extends ImmutableCollection<E>
6969
*
7070
* @since 33.2.0 (available since 21.0 in guava-jre)
7171
*/
72-
@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
72+
@SuppressWarnings("Java7ApiChecker")
7373
@IgnoreJRERequirement // Users will use this only if they're already using streams.
7474
public static <E> Collector<E, ?, ImmutableList<E>> toImmutableList() {
7575
return CollectCollectors.toImmutableList();

android/guava/src/com/google/common/collect/ImmutableListMultimap.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V>
8282
*
8383
* @since 33.2.0 (available since 21.0 in guava-jre)
8484
*/
85-
@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
85+
@SuppressWarnings("Java7ApiChecker")
8686
@IgnoreJRERequirement // Users will use this only if they're already using streams.
8787
public static <T extends @Nullable Object, K, V>
8888
Collector<T, ?, ImmutableListMultimap<K, V>> toImmutableListMultimap(
@@ -122,7 +122,7 @@ public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V>
122122
*
123123
* @since 33.2.0 (available since 21.0 in guava-jre)
124124
*/
125-
@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
125+
@SuppressWarnings("Java7ApiChecker")
126126
@IgnoreJRERequirement // Users will use this only if they're already using streams.
127127
public static <T extends @Nullable Object, K, V>
128128
Collector<T, ?, ImmutableListMultimap<K, V>> flatteningToImmutableListMultimap(

android/guava/src/com/google/common/collect/ImmutableMap.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
8282
*
8383
* @since 33.2.0 (available since 21.0 in guava-jre)
8484
*/
85-
@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
85+
@SuppressWarnings("Java7ApiChecker")
8686
@IgnoreJRERequirement // Users will use this only if they're already using streams.
8787
public static <T extends @Nullable Object, K, V>
8888
Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
@@ -104,7 +104,7 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
104104
*
105105
* @since 33.2.0 (available since 21.0 in guava-jre)
106106
*/
107-
@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
107+
@SuppressWarnings("Java7ApiChecker")
108108
@IgnoreJRERequirement // Users will use this only if they're already using streams.
109109
public static <T extends @Nullable Object, K, V>
110110
Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(

0 commit comments

Comments
 (0)