Skip to content

Commit 9892c31

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
Remove @GwtCompatible from methods and non-visible classes.
Since members of `@GwtCompatible` classes are assumed to be GWT-compatible by default, there is no need for the annotation except on classes. Arguably, it's not necessary even on public nested classes, since those have annotations on their enclosing classes. But there is value in having the annotation in the generated Javadoc for the class itself, so I've kept the occurrences that I've seen. (There was one on [`FutureCombiner`](https://guava.dev/FutureCombiner), at least. I rather doubt that we're being consistent about including it on all such types, though.) Most (all?) such existing annotations on methods are left over from when we were saying something meaningful, `@GwtCompatible(serializable = ...)`. If I'd been fully on the ball, I would have removed them back in cl/767108998 and cl/767189860. Along the way, I also noticed a couple static imports of members of the current class. I think I removed them all (just `Maps` and `Helpers`). RELNOTES=n/a PiperOrigin-RevId: 778311761
1 parent f51883f commit 9892c31

File tree

32 files changed

+0
-89
lines changed

32 files changed

+0
-89
lines changed

android/guava-testlib/src/com/google/common/collect/testing/Helpers.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.common.collect.testing;
1818

19-
import static com.google.common.collect.testing.Helpers.entryComparator;
2019
import static java.lang.Math.max;
2120
import static java.util.Arrays.asList;
2221
import static java.util.Collections.singletonMap;

android/guava/src/com/google/common/base/Equivalence.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ public String toString() {
277277
*
278278
* @since 10.0
279279
*/
280-
@GwtCompatible
281280
public final <S extends @Nullable T> Equivalence<Iterable<S>> pairwise() {
282281
// Ideally, the returned equivalence would support Iterable<? extends T>. However,
283282
// the need for this is so rare that it's not worth making callers deal with the ugly wildcard.

android/guava/src/com/google/common/base/Predicates.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public final class Predicates {
4747
* <p><b>Discouraged:</b> Prefer using {@code x -> true}, but note that lambdas do not have
4848
* human-readable {@link #toString()} representations and are not serializable.
4949
*/
50-
@GwtCompatible
5150
public static <T extends @Nullable Object> Predicate<T> alwaysTrue() {
5251
return ObjectPredicate.ALWAYS_TRUE.withNarrowedType();
5352
}
@@ -58,7 +57,6 @@ public final class Predicates {
5857
* <p><b>Discouraged:</b> Prefer using {@code x -> false}, but note that lambdas do not have
5958
* human-readable {@link #toString()} representations and are not serializable.
6059
*/
61-
@GwtCompatible
6260
public static <T extends @Nullable Object> Predicate<T> alwaysFalse() {
6361
return ObjectPredicate.ALWAYS_FALSE.withNarrowedType();
6462
}
@@ -71,7 +69,6 @@ public final class Predicates {
7169
* but note that lambdas and method references do not have human-readable {@link #toString()}
7270
* representations and are not serializable.
7371
*/
74-
@GwtCompatible
7572
public static <T extends @Nullable Object> Predicate<T> isNull() {
7673
return ObjectPredicate.IS_NULL.withNarrowedType();
7774
}
@@ -84,7 +81,6 @@ public final class Predicates {
8481
* but note that lambdas and method references do not have human-readable {@link #toString()}
8582
* representations and are not serializable.
8683
*/
87-
@GwtCompatible
8884
public static <T extends @Nullable Object> Predicate<T> notNull() {
8985
return ObjectPredicate.NOT_NULL.withNarrowedType();
9086
}

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ private Lists() {}
8181
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
8282
* syntax</a>.
8383
*/
84-
@GwtCompatible
8584
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
8685
public static <E extends @Nullable Object> ArrayList<E> newArrayList() {
8786
return new ArrayList<>();
@@ -102,7 +101,6 @@ private Lists() {}
102101
* not actually very useful and will likely be deprecated in the future.
103102
*/
104103
@SafeVarargs
105-
@GwtCompatible
106104
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
107105
public static <E extends @Nullable Object> ArrayList<E> newArrayList(E... elements) {
108106
checkNotNull(elements); // for GWT
@@ -127,7 +125,6 @@ private Lists() {}
127125
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
128126
* syntax</a>.
129127
*/
130-
@GwtCompatible
131128
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
132129
public static <E extends @Nullable Object> ArrayList<E> newArrayList(
133130
Iterable<? extends E> elements) {
@@ -145,7 +142,6 @@ private Lists() {}
145142
* <p><b>Note:</b> if mutability is not required and the elements are non-null, use {@link
146143
* ImmutableList#copyOf(Iterator)} instead.
147144
*/
148-
@GwtCompatible
149145
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
150146
public static <E extends @Nullable Object> ArrayList<E> newArrayList(
151147
Iterator<? extends E> elements) {
@@ -179,7 +175,6 @@ static int computeArrayListCapacity(int arraySize) {
179175
* reaches {@code initialArraySize + 1}
180176
* @throws IllegalArgumentException if {@code initialArraySize} is negative
181177
*/
182-
@GwtCompatible
183178
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
184179
public static <E extends @Nullable Object> ArrayList<E> newArrayListWithCapacity(
185180
int initialArraySize) {
@@ -200,7 +195,6 @@ static int computeArrayListCapacity(int arraySize) {
200195
* elements
201196
* @throws IllegalArgumentException if {@code estimatedSize} is negative
202197
*/
203-
@GwtCompatible
204198
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
205199
public static <E extends @Nullable Object> ArrayList<E> newArrayListWithExpectedSize(
206200
int estimatedSize) {
@@ -225,7 +219,6 @@ static int computeArrayListCapacity(int arraySize) {
225219
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
226220
* syntax</a>.
227221
*/
228-
@GwtCompatible
229222
@SuppressWarnings({
230223
"NonApiType", // acts as a direct substitute for a constructor call
231224
"JdkObsolete", // We recommend against this method but need to keep it for compatibility.
@@ -252,7 +245,6 @@ static int computeArrayListCapacity(int arraySize) {
252245
* href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html#type-inference-instantiation">"diamond"
253246
* syntax</a>.
254247
*/
255-
@GwtCompatible
256248
@SuppressWarnings("NonApiType") // acts as a direct substitute for a constructor call
257249
public static <E extends @Nullable Object> LinkedList<E> newLinkedList(
258250
Iterable<? extends E> elements) {

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import static com.google.common.base.Predicates.compose;
2222
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
2323
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
24-
import static com.google.common.collect.Maps.immutableEntry;
2524
import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
2625
import static java.lang.Math.ceil;
2726
import static java.util.Collections.singletonMap;
@@ -150,7 +149,6 @@ V transform(Entry<K, V> entry) {
150149
* @return an immutable map containing those entries
151150
* @since 14.0
152151
*/
153-
@GwtCompatible
154152
public static <K extends Enum<K>, V> ImmutableMap<K, V> immutableEnumMap(
155153
Map<K, ? extends V> map) {
156154
if (map instanceof ImmutableEnumMap) {
@@ -1438,7 +1436,6 @@ public static ImmutableMap<String, String> fromProperties(Properties properties)
14381436
* @param key the key to be associated with the returned entry
14391437
* @param value the value to be associated with the returned entry
14401438
*/
1441-
@GwtCompatible
14421439
public static <K extends @Nullable Object, V extends @Nullable Object> Entry<K, V> immutableEntry(
14431440
@ParametricNullness K key, @ParametricNullness V value) {
14441441
return new SimpleImmutableEntry<>(key, value);
@@ -3539,7 +3536,6 @@ NavigableMap<K, V> synchronizedNavigableMap(NavigableMap<K, V> navigableMap) {
35393536
* {@code AbstractMap} extension that makes it easy to cache customized keySet, values, and
35403537
* entrySet views.
35413538
*/
3542-
@GwtCompatible
35433539
abstract static class ViewCachingAbstractMap<
35443540
K extends @Nullable Object, V extends @Nullable Object>
35453541
extends AbstractMap<K, V> {

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ public abstract class Ordering<T extends @Nullable Object> implements Comparator
165165
*
166166
* <p><b>Java 8+ users:</b> use {@link Comparator#naturalOrder} instead.
167167
*/
168-
@GwtCompatible
169168
@SuppressWarnings({"unchecked", "rawtypes"})
170169
// TODO(kevinb): right way to explain this??
171170
// plus https://github.com/google/guava/issues/989
@@ -190,7 +189,6 @@ public static <C extends Comparable> Ordering<C> natural() {
190189
* @return comparator itself if it is already an {@code Ordering}; otherwise an ordering that
191190
* wraps that comparator
192191
*/
193-
@GwtCompatible
194192
public static <T extends @Nullable Object> Ordering<T> from(Comparator<T> comparator) {
195193
return (comparator instanceof Ordering)
196194
? (Ordering<T>) comparator
@@ -205,7 +203,6 @@ public static <C extends Comparable> Ordering<C> natural() {
205203
@InlineMe(
206204
replacement = "checkNotNull(ordering)",
207205
staticImports = "com.google.common.base.Preconditions.checkNotNull")
208-
@GwtCompatible
209206
@Deprecated
210207
public static <T extends @Nullable Object> Ordering<T> from(Ordering<T> ordering) {
211208
return checkNotNull(ordering);
@@ -231,7 +228,6 @@ public static <C extends Comparable> Ordering<C> natural() {
231228
* (according to {@link Object#equals})
232229
*/
233230
// TODO(kevinb): provide replacement
234-
@GwtCompatible
235231
public static <T> Ordering<T> explicit(List<T> valuesInOrder) {
236232
return new ExplicitOrdering<>(valuesInOrder);
237233
}
@@ -257,7 +253,6 @@ public static <T> Ordering<T> explicit(List<T> valuesInOrder) {
257253
* Object#equals(Object)}) are present among the method arguments
258254
*/
259255
// TODO(kevinb): provide replacement
260-
@GwtCompatible
261256
public static <T> Ordering<T> explicit(T leastValue, T... remainingValuesInOrder) {
262257
return explicit(Lists.asList(leastValue, remainingValuesInOrder));
263258
}
@@ -292,7 +287,6 @@ public static <T> Ordering<T> explicit(T leastValue, T... remainingValuesInOrder
292287
*
293288
* @since 13.0
294289
*/
295-
@GwtCompatible
296290
public static Ordering<@Nullable Object> allEqual() {
297291
return AllEqualOrdering.INSTANCE;
298292
}
@@ -305,7 +299,6 @@ public static <T> Ordering<T> explicit(T leastValue, T... remainingValuesInOrder
305299
*
306300
* <p><b>Java 8+ users:</b> Use {@code Comparator.comparing(Object::toString)} instead.
307301
*/
308-
@GwtCompatible
309302
public static Ordering<Object> usingToString() {
310303
return UsingToStringOrdering.INSTANCE;
311304
}
@@ -418,7 +411,6 @@ protected Ordering() {}
418411
*/
419412
// type parameter <S> lets us avoid the extra <String> in statements like:
420413
// Ordering<String> o = Ordering.<String>natural().reverse();
421-
@GwtCompatible
422414
public <S extends T> Ordering<S> reverse() {
423415
return new ReverseOrdering<>(this);
424416
}
@@ -433,7 +425,6 @@ public <S extends T> Ordering<S> reverse() {
433425
*/
434426
// type parameter <S> lets us avoid the extra <String> in statements like:
435427
// Ordering<String> o = Ordering.<String>natural().nullsFirst();
436-
@GwtCompatible
437428
public <S extends T> Ordering<@Nullable S> nullsFirst() {
438429
return new NullsFirstOrdering<S>(this);
439430
}
@@ -448,7 +439,6 @@ public <S extends T> Ordering<S> reverse() {
448439
*/
449440
// type parameter <S> lets us avoid the extra <String> in statements like:
450441
// Ordering<String> o = Ordering.<String>natural().nullsLast();
451-
@GwtCompatible
452442
public <S extends T> Ordering<@Nullable S> nullsLast() {
453443
return new NullsLastOrdering<S>(this);
454444
}
@@ -466,7 +456,6 @@ public <S extends T> Ordering<S> reverse() {
466456
* <p><b>Java 8+ users:</b> Use {@code Comparator.comparing(function, thisComparator)} instead
467457
* (you can omit the comparator if it is the natural order).
468458
*/
469-
@GwtCompatible
470459
public <F extends @Nullable Object> Ordering<F> onResultOf(Function<F, ? extends T> function) {
471460
return new ByFunctionOrdering<>(function, this);
472461
}
@@ -491,7 +480,6 @@ public <S extends T> Ordering<S> reverse() {
491480
* Depending on what {@code secondaryComparator} is, one of the other overloads of {@code
492481
* thenComparing} may be even more useful.
493482
*/
494-
@GwtCompatible
495483
public <U extends T> Ordering<U> compound(Comparator<? super U> secondaryComparator) {
496484
return new CompoundOrdering<>(this, checkNotNull(secondaryComparator));
497485
}
@@ -517,7 +505,6 @@ public <U extends T> Ordering<U> compound(Comparator<? super U> secondaryCompara
517505
*
518506
* @param comparators the comparators to try in order
519507
*/
520-
@GwtCompatible
521508
public static <T extends @Nullable Object> Ordering<T> compound(
522509
Iterable<? extends Comparator<? super T>> comparators) {
523510
return new CompoundOrdering<>(comparators);
@@ -538,7 +525,6 @@ public <U extends T> Ordering<U> compound(Comparator<? super U> secondaryCompara
538525
*
539526
* @since 2.0
540527
*/
541-
@GwtCompatible
542528
// type parameter <S> lets us avoid the extra <String> in statements like:
543529
// Ordering<Iterable<String>> o =
544530
// Ordering.<String>natural().lexicographical();

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ public boolean retainAll(Collection<?> c) {
101101
* @param otherElements the rest of the elements the set should contain
102102
* @return an immutable set containing those elements, minus duplicates
103103
*/
104-
@GwtCompatible
105104
public static <E extends Enum<E>> ImmutableSet<E> immutableEnumSet(
106105
E anElement, E... otherElements) {
107106
return ImmutableEnumSet.asImmutable(EnumSet.of(anElement, otherElements));
@@ -117,7 +116,6 @@ public static <E extends Enum<E>> ImmutableSet<E> immutableEnumSet(
117116
* @param elements the elements, all of the same {@code enum} type, that the set should contain
118117
* @return an immutable set containing those elements, minus duplicates
119118
*/
120-
@GwtCompatible
121119
public static <E extends Enum<E>> ImmutableSet<E> immutableEnumSet(Iterable<E> elements) {
122120
if (elements instanceof ImmutableEnumSet) {
123121
return (ImmutableEnumSet<E>) elements;
@@ -1627,7 +1625,6 @@ public int hashCode() {
16271625
* @see <a href="http://en.wikipedia.org/wiki/Power_set">Power set article at Wikipedia</a>
16281626
* @since 4.0
16291627
*/
1630-
@GwtCompatible
16311628
public static <E> Set<Set<E>> powerSet(Set<E> set) {
16321629
return new PowerSet<E>(set);
16331630
}

android/guava/src/com/google/common/primitives/Booleans.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ public static List<Boolean> asList(boolean... backingArray) {
386386
return new BooleanArrayAsList(backingArray);
387387
}
388388

389-
@GwtCompatible
390389
private static class BooleanArrayAsList extends AbstractList<Boolean>
391390
implements RandomAccess, Serializable {
392391
final boolean[] array;

android/guava/src/com/google/common/primitives/Bytes.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ public static List<Byte> asList(byte... backingArray) {
253253
return new ByteArrayAsList(backingArray);
254254
}
255255

256-
@GwtCompatible
257256
private static class ByteArrayAsList extends AbstractList<Byte>
258257
implements RandomAccess, Serializable {
259258
final byte[] array;

android/guava/src/com/google/common/primitives/Chars.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,6 @@ public static List<Character> asList(char... backingArray) {
573573
return new CharArrayAsList(backingArray);
574574
}
575575

576-
@GwtCompatible
577576
private static class CharArrayAsList extends AbstractList<Character>
578577
implements RandomAccess, Serializable {
579578
final char[] array;

0 commit comments

Comments
 (0)