Skip to content

Commit

Permalink
Prepare to make ImmutableMultimap collectors available in guava-and…
Browse files Browse the repository at this point in the history
…roid (but don't do so yet).

This CL also includes updates to avoid problems with reflection when Java 8+ APIs are not present. That means adding a `serialVersionUID` (so that Java/Android reflection doesn't try to compute one with reflection) and skipping `NullPointerTester` (compare cl/550872250) and some `FauxveridesTest` tests (compare cl/576629272) under Android.

This CL is further progress toward #6567

RELNOTES=n/a
PiperOrigin-RevId: 577951171
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Oct 31, 2023
1 parent c61f415 commit 05cc6e4
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ public void testImmutableBiMap() {
doHasAllFauxveridesTest(ImmutableBiMap.class, ImmutableMap.class);
}

@AndroidIncompatible // similar to ImmutableTableTest.testNullPointerInstance
public void testImmutableListMultimap() {
doHasAllFauxveridesTest(ImmutableListMultimap.class, ImmutableMultimap.class);
}

@AndroidIncompatible // similar to ImmutableTableTest.testNullPointerInstance
public void testImmutableSetMultimap() {
doHasAllFauxveridesTest(ImmutableSetMultimap.class, ImmutableMultimap.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ public void testEmptySerialization() {
}

@GwtIncompatible // reflection
@AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableListMultimap.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public void testEquals() {
}

@GwtIncompatible // reflection
@AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableMultimap.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ private ImmutableSetMultimap<String, Integer> createMultimap() {
}

@GwtIncompatible // reflection
@AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableSetMultimap.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ public void testNullGet() {
}

@GwtIncompatible // NullPointerTester
@AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableSortedMap.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,4 +591,6 @@ Object writeReplace() {
private void readObject(ObjectInputStream stream) throws InvalidObjectException {
throw new InvalidObjectException("Use SerializedForm");
}

private static final long serialVersionUID = 0xdecaf;
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ public Builder<K, V> putAll(Multimap<? extends K, ? extends V> multimap) {
return this;
}

@CanIgnoreReturnValue
@Override
Builder<K, V> combine(ImmutableMultimap.Builder<K, V> other) {
super.combine(other);
return this;
}

/**
* {@inheritDoc}
*
Expand All @@ -220,13 +227,6 @@ public Builder<K, V> orderValuesBy(Comparator<? super V> valueComparator) {
return this;
}

@CanIgnoreReturnValue
@Override
Builder<K, V> combine(ImmutableMultimap.Builder<K, V> other) {
super.combine(other);
return this;
}

/** Returns a newly-created immutable list multimap. */
@Override
public ImmutableListMultimap<K, V> build() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ public void testImmutableBiMap() {
doHasAllFauxveridesTest(ImmutableBiMap.class, ImmutableMap.class);
}

@AndroidIncompatible // similar to ImmutableTableTest.testNullPointerInstance
public void testImmutableListMultimap() {
doHasAllFauxveridesTest(ImmutableListMultimap.class, ImmutableMultimap.class);
}

@AndroidIncompatible // similar to ImmutableTableTest.testNullPointerInstance
public void testImmutableSetMultimap() {
doHasAllFauxveridesTest(ImmutableSetMultimap.class, ImmutableMultimap.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ public void testEmptySerialization() {
}

@GwtIncompatible // reflection
@AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableListMultimap.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public void testEquals() {
}

@GwtIncompatible // reflection
@AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableMultimap.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ private ImmutableSetMultimap<String, Integer> createMultimap() {
}

@GwtIncompatible // reflection
@AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableSetMultimap.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ public void testNullGet() {
}

@GwtIncompatible // NullPointerTester
@AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableSortedMap.class);
Expand Down
2 changes: 2 additions & 0 deletions guava/src/com/google/common/collect/ImmutableBiMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -676,4 +676,6 @@ private void readObject(ObjectInputStream stream) throws InvalidObjectException
BinaryOperator<V> mergeFunction) {
throw new UnsupportedOperationException();
}

private static final long serialVersionUID = 0xcafebabe;
}

0 comments on commit 05cc6e4

Please sign in to comment.