Skip to content

Commit 12bf71e

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
(And push a few class-level suppressions down to individual methods.) I reverted some of the changes that Error Prone suggested. I'm a little unclear on various things: - whether attempting to suppress `removal` warnings accomplishes anything under any compiler that we care about - whether extending a deprecated type produces a warning under any compiler that we care about - whether some deprecation warnings are showing up as "unnecessary" only because of builds against other sources of `java.*` classes that don't include the JDK's deprecations Hopefully all the removals that I've kept in the CL are good. RELNOTES=n/a PiperOrigin-RevId: 712957106
1 parent 4b6f871 commit 12bf71e

File tree

14 files changed

+12
-16
lines changed

14 files changed

+12
-16
lines changed

android/guava-tests/test/com/google/common/collect/ListsImplTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ private void checkLastIndexOf(List<?> toTest, int[] expected) {
243243
}
244244

245245
@SafeVarargs
246-
@SuppressWarnings("varargs")
247246
private final <T> List<T> createList(Class<T> listType, T... contents) {
248247
return getExample().createList(listType, asList(contents));
249248
}

android/guava-tests/test/com/google/common/collect/MapsTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ public void testLinkedHashMap() {
225225
assertEquals(emptyMap(), map);
226226
}
227227

228-
@SuppressWarnings("serial")
229228
public void testLinkedHashMapWithInitialMap() {
230229
Map<String, String> map =
231230
new LinkedHashMap<String, String>(
@@ -982,7 +981,6 @@ public void testUniqueIndexNullKey() {
982981

983982
@J2ktIncompatible
984983
@GwtIncompatible // Maps.fromProperties
985-
@SuppressWarnings("deprecation") // StringBufferInputStream
986984
public void testFromProperties() throws IOException {
987985
Properties testProp = new Properties();
988986

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,7 @@ public boolean matches(char c) {
18151815
return predicate.apply(c);
18161816
}
18171817

1818-
@SuppressWarnings("deprecation") // intentional; deprecation is for callers primarily
1818+
@Deprecated
18191819
@Override
18201820
public boolean apply(Character character) {
18211821
return predicate.apply(checkNotNull(character));

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2873,7 +2873,6 @@ void writeMapTo(ObjectOutputStream out) throws IOException {
28732873
out.writeObject(null); // terminate entries
28742874
}
28752875

2876-
@SuppressWarnings("deprecation") // serialization of deprecated feature
28772876
@J2ktIncompatible // java.io.ObjectInputStream
28782877
MapMaker readMapMaker(ObjectInputStream in) throws IOException {
28792878
int size = in.readInt();

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
/** An ordering that uses the natural order of the values. */
2727
@GwtCompatible(serializable = true)
28-
@SuppressWarnings({"unchecked", "rawtypes"}) // TODO(kevinb): the right way to explain this??
2928
final class NaturalOrdering extends Ordering<Comparable<?>> implements Serializable {
3029
static final NaturalOrdering INSTANCE = new NaturalOrdering();
3130

@@ -34,13 +33,15 @@ final class NaturalOrdering extends Ordering<Comparable<?>> implements Serializa
3433
@LazyInit private transient @Nullable Ordering<@Nullable Comparable<?>> nullsLast;
3534

3635
@Override
36+
@SuppressWarnings("unchecked") // TODO(kevinb): the right way to explain this??
3737
public int compare(Comparable<?> left, Comparable<?> right) {
3838
checkNotNull(left); // for GWT
3939
checkNotNull(right);
4040
return ((Comparable<Object>) left).compareTo(right);
4141
}
4242

4343
@Override
44+
@SuppressWarnings("unchecked") // TODO(kevinb): the right way to explain this??
4445
public <S extends Comparable<?>> Ordering<@Nullable S> nullsFirst() {
4546
Ordering<@Nullable Comparable<?>> result = nullsFirst;
4647
if (result == null) {
@@ -50,6 +51,7 @@ public int compare(Comparable<?> left, Comparable<?> right) {
5051
}
5152

5253
@Override
54+
@SuppressWarnings("unchecked") // TODO(kevinb): the right way to explain this??
5355
public <S extends Comparable<?>> Ordering<@Nullable S> nullsLast() {
5456
Ordering<@Nullable Comparable<?>> result = nullsLast;
5557
if (result == null) {
@@ -59,6 +61,7 @@ public int compare(Comparable<?> left, Comparable<?> right) {
5961
}
6062

6163
@Override
64+
@SuppressWarnings("unchecked") // TODO(kevinb): the right way to explain this??
6265
public <S extends Comparable<?>> Ordering<S> reverse() {
6366
return (Ordering<S>) ReverseNaturalOrdering.INSTANCE;
6467
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424

2525
/** An ordering that uses the reverse of the natural order of the values. */
2626
@GwtCompatible(serializable = true)
27-
@SuppressWarnings({"unchecked", "rawtypes"}) // TODO(kevinb): the right way to explain this??
2827
final class ReverseNaturalOrdering extends Ordering<Comparable<?>> implements Serializable {
2928
static final ReverseNaturalOrdering INSTANCE = new ReverseNaturalOrdering();
3029

3130
@Override
31+
@SuppressWarnings("unchecked") // TODO(kevinb): the right way to explain this??
3232
public int compare(Comparable<?> left, Comparable<?> right) {
3333
checkNotNull(left); // right null is caught later
3434
if (left == right) {

android/guava/src/com/google/common/math/LongMath.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,6 @@ private boolean testWitness(long base, long n) {
12411241
* is not precisely representable as a {@code double}
12421242
* @since 30.0
12431243
*/
1244-
@SuppressWarnings("deprecation")
12451244
@GwtIncompatible
12461245
public static double roundToDouble(long x, RoundingMode mode) {
12471246
// Logic adapted from ToDoubleRounder.

guava-tests/test/com/google/common/collect/ListsImplTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ private void checkLastIndexOf(List<?> toTest, int[] expected) {
243243
}
244244

245245
@SafeVarargs
246-
@SuppressWarnings("varargs")
247246
private final <T> List<T> createList(Class<T> listType, T... contents) {
248247
return getExample().createList(listType, asList(contents));
249248
}

guava-tests/test/com/google/common/collect/MapsTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ public void testLinkedHashMap() {
225225
assertEquals(emptyMap(), map);
226226
}
227227

228-
@SuppressWarnings("serial")
229228
public void testLinkedHashMapWithInitialMap() {
230229
Map<String, String> map =
231230
new LinkedHashMap<String, String>(
@@ -982,7 +981,6 @@ public void testUniqueIndexNullKey() {
982981

983982
@J2ktIncompatible
984983
@GwtIncompatible // Maps.fromProperties
985-
@SuppressWarnings("deprecation") // StringBufferInputStream
986984
public void testFromProperties() throws IOException {
987985
Properties testProp = new Properties();
988986

guava/src/com/google/common/base/CharMatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,7 @@ public boolean matches(char c) {
18151815
return predicate.apply(c);
18161816
}
18171817

1818-
@SuppressWarnings("deprecation") // intentional; deprecation is for callers primarily
1818+
@Deprecated
18191819
@Override
18201820
public boolean apply(Character character) {
18211821
return predicate.apply(checkNotNull(character));

0 commit comments

Comments
 (0)