diff --git a/android/guava-testlib/test/com/google/common/testing/EquivalenceTesterTest.java b/android/guava-testlib/test/com/google/common/testing/EquivalenceTesterTest.java index 00bdb2aa4457..77a35d04ece2 100644 --- a/android/guava-testlib/test/com/google/common/testing/EquivalenceTesterTest.java +++ b/android/guava-testlib/test/com/google/common/testing/EquivalenceTesterTest.java @@ -238,7 +238,7 @@ void expectHash(Object object, int hash) { void replay() { checkRecording(); - equivalentExpectations = equivalentExpectationsBuilder.build(); + equivalentExpectations = equivalentExpectationsBuilder.buildOrThrow(); hashExpectations = hashExpectationsBuilder.buildOrThrow(); } diff --git a/android/guava-tests/benchmark/com/google/common/base/JoinerBenchmark.java b/android/guava-tests/benchmark/com/google/common/base/JoinerBenchmark.java index 8b3b5afd02d3..1d53f79f00af 100644 --- a/android/guava-tests/benchmark/com/google/common/base/JoinerBenchmark.java +++ b/android/guava-tests/benchmark/com/google/common/base/JoinerBenchmark.java @@ -46,6 +46,7 @@ public class JoinerBenchmark { private Iterable components; @BeforeExperiment + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 void setUp() { String component = Strings.repeat("a", componentLength); String[] raw = new String[count]; diff --git a/android/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java b/android/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java index 4d23cc20fc68..d1c0d38a62be 100644 --- a/android/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java +++ b/android/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java @@ -42,6 +42,7 @@ public class SplitterBenchmark { private static final Splitter STRING_SPLITTER = Splitter.on("X"); @BeforeExperiment + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 void setUp() { input = Strings.repeat(text, length); } diff --git a/android/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java b/android/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java index 9f350cf68c78..3750ca53f9c2 100644 --- a/android/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java +++ b/android/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java @@ -37,6 +37,7 @@ public class StringsRepeatBenchmark { private String originalString; @BeforeExperiment + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 void setUp() { originalString = Strings.repeat("x", length); } diff --git a/android/guava-tests/test/com/google/common/base/CharMatcherTest.java b/android/guava-tests/test/com/google/common/base/CharMatcherTest.java index 1d47a3dc8a85..248e4bbca070 100644 --- a/android/guava-tests/test/com/google/common/base/CharMatcherTest.java +++ b/android/guava-tests/test/com/google/common/base/CharMatcherTest.java @@ -293,6 +293,7 @@ private void reallyTestNoMatches(CharMatcher matcher, CharSequence s) { assertEquals(0, matcher.countIn(s)); } + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 private void reallyTestAllMatches(CharMatcher matcher, CharSequence s) { assertTrue(matcher.matches(s.charAt(0))); assertEquals(0, matcher.indexIn(s)); diff --git a/android/guava-tests/test/com/google/common/base/ConverterTest.java b/android/guava-tests/test/com/google/common/base/ConverterTest.java index d566dcba0ceb..e8817ab32e27 100644 --- a/android/guava-tests/test/com/google/common/base/ConverterTest.java +++ b/android/guava-tests/test/com/google/common/base/ConverterTest.java @@ -103,6 +103,8 @@ public void testReverseReverse() { assertEquals(converter, converter.reverse().reverse()); } + // We need to test that apply() does in fact behave like convert(). + @SuppressWarnings("InlineMeInliner") public void testApply() { assertEquals(LONG_VAL, STR_TO_LONG.apply(STR_VAL)); } diff --git a/android/guava-tests/test/com/google/common/collect/FluentIterableTest.java b/android/guava-tests/test/com/google/common/collect/FluentIterableTest.java index 9bfb1e2f5f3a..049dae5b2760 100644 --- a/android/guava-tests/test/com/google/common/collect/FluentIterableTest.java +++ b/android/guava-tests/test/com/google/common/collect/FluentIterableTest.java @@ -82,7 +82,11 @@ public void testFrom() { Lists.newArrayList(FluentIterable.from(ImmutableList.of(1, 2, 3, 4)))); } - @SuppressWarnings("deprecation") // test of deprecated method + @SuppressWarnings({ + "deprecation", // test of deprecated method + // We need to test that from(FluentIterable) really is just a null check. + "InlineMeInliner", + }) public void testFrom_alreadyFluentIterable() { FluentIterable iterable = FluentIterable.from(asList(1)); assertSame(iterable, FluentIterable.from(iterable)); 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 4b3d18d9edbc..f5b6880a193b 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableListTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableListTest.java @@ -598,6 +598,8 @@ public void testBuilderAddAllHandlesNullsCorrectly() { } } + // We need to test that asList() really does return the original list. + @SuppressWarnings("InlineMeInliner") public void testAsList() { ImmutableList list = ImmutableList.of("a", "b"); assertSame(list, list.asList()); diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableTableTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableTableTest.java index 7054ff7559e3..b194d2abcd05 100644 --- a/android/guava-tests/test/com/google/common/collect/ImmutableTableTest.java +++ b/android/guava-tests/test/com/google/common/collect/ImmutableTableTest.java @@ -41,7 +41,7 @@ protected Table create(@Nullable Object... data) { for (int i = 0; i < data.length; i = i + 3) { builder.put((String) data[i], (Integer) data[i + 1], (Character) data[i + 2]); } - return builder.build(); + return builder.buildOrThrow(); } // TODO(b/172823566): Use mainline testToImmutableMap once CollectorTester is usable to java7. @@ -65,8 +65,8 @@ public void testToImmutableTable_java7_combine() { public void testBuilder() { ImmutableTable.Builder builder = new ImmutableTable.Builder<>(); - assertEquals(ImmutableTable.of(), builder.build()); - assertEquals(ImmutableTable.of('a', 1, "foo"), builder.put('a', 1, "foo").build()); + assertEquals(ImmutableTable.of(), builder.buildOrThrow()); + assertEquals(ImmutableTable.of('a', 1, "foo"), builder.put('a', 1, "foo").buildOrThrow()); Table expectedTable = HashBasedTable.create(); expectedTable.put('a', 1, "foo"); expectedTable.put('b', 1, "bar"); @@ -74,13 +74,13 @@ public void testBuilder() { Table otherTable = HashBasedTable.create(); otherTable.put('b', 1, "bar"); otherTable.put('a', 2, "baz"); - assertEquals(expectedTable, builder.putAll(otherTable).build()); + assertEquals(expectedTable, builder.putAll(otherTable).buildOrThrow()); } public void testBuilder_withImmutableCell() { ImmutableTable.Builder builder = new ImmutableTable.Builder<>(); assertEquals( - ImmutableTable.of('a', 1, "foo"), builder.put(immutableCell('a', 1, "foo")).build()); + ImmutableTable.of('a', 1, "foo"), builder.put(immutableCell('a', 1, "foo")).buildOrThrow()); } public void testBuilder_withImmutableCellAndNullContents() { @@ -127,7 +127,7 @@ public String getValue() { holder.string = "bar"; // Make sure it uses the original value. - assertEquals(ImmutableTable.of('K', 42, "foo"), builder.build()); + assertEquals(ImmutableTable.of('K', 42, "foo"), builder.buildOrThrow()); } public void testBuilder_noDuplicates() { @@ -135,7 +135,7 @@ public void testBuilder_noDuplicates() { new ImmutableTable.Builder() .put('a', 1, "foo") .put('a', 1, "bar"); - assertThrows(IllegalArgumentException.class, () -> builder.build()); + assertThrows(IllegalArgumentException.class, () -> builder.buildOrThrow()); } public void testBuilder_noNulls() { @@ -150,7 +150,7 @@ private static void validateTableCopies(Table original) { assertEquals(original, copy); validateViewOrdering(original, copy); - Table built = ImmutableTable.builder().putAll(original).build(); + Table built = ImmutableTable.builder().putAll(original).buildOrThrow(); assertEquals(original, built); validateViewOrdering(original, built); } @@ -213,7 +213,7 @@ public void testBuilder_orderRowsAndColumnsBy_putAll() { .orderRowsBy(Ordering.natural()) .orderColumnsBy(Ordering.natural()) .putAll(table) - .build(); + .buildOrThrow(); assertThat(copy.rowKeySet()).containsExactly('a', 'b').inOrder(); assertThat(copy.columnKeySet()).containsExactly(1, 2).inOrder(); assertThat(copy.values()).containsExactly("baz", "bar", "foo").inOrder(); @@ -233,7 +233,7 @@ public void testBuilder_orderRowsAndColumnsBy_sparse() { builder.put('e', 3, "tub"); builder.put('r', 4, "foo"); builder.put('x', 5, "bar"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table.rowKeySet()).containsExactly('b', 'c', 'e', 'r', 'x').inOrder(); assertThat(table.columnKeySet()).containsExactly(0, 1, 2, 3, 4, 5, 7).inOrder(); assertThat(table.values()) @@ -255,7 +255,7 @@ public void testBuilder_orderRowsAndColumnsBy_dense() { builder.put('a', 3, "foo"); builder.put('a', 2, "bar"); builder.put('a', 1, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table.rowKeySet()).containsExactly('a', 'b', 'c').inOrder(); assertThat(table.columnKeySet()).containsExactly(1, 2, 3).inOrder(); assertThat(table.values()) @@ -277,7 +277,7 @@ public void testBuilder_orderRowsBy_sparse() { builder.put('e', 3, "tub"); builder.put('r', 4, "foo"); builder.put('x', 5, "bar"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table.rowKeySet()).containsExactly('b', 'c', 'e', 'r', 'x').inOrder(); assertThat(table.column(5).keySet()).containsExactly('e', 'x').inOrder(); } @@ -293,7 +293,7 @@ public void testBuilder_orderRowsBy_dense() { builder.put('a', 3, "foo"); builder.put('a', 2, "bar"); builder.put('a', 1, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table.rowKeySet()).containsExactly('a', 'b', 'c').inOrder(); assertThat(table.column(1).keySet()).containsExactly('a', 'b', 'c').inOrder(); } @@ -310,7 +310,7 @@ public void testBuilder_orderColumnsBy_sparse() { builder.put('e', 3, "tub"); builder.put('r', 4, "foo"); builder.put('x', 5, "bar"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table.columnKeySet()).containsExactly(0, 1, 2, 3, 4, 5, 7).inOrder(); assertThat(table.row('c').keySet()).containsExactly(0, 3).inOrder(); } @@ -326,7 +326,7 @@ public void testBuilder_orderColumnsBy_dense() { builder.put('a', 3, "foo"); builder.put('a', 2, "bar"); builder.put('a', 1, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table.columnKeySet()).containsExactly(1, 2, 3).inOrder(); assertThat(table.row('c').keySet()).containsExactly(1, 2, 3).inOrder(); } @@ -344,7 +344,7 @@ public void testDenseSerialization_manualOrder() { builder.put('b', 2, "foo"); builder.put('b', 1, "bar"); builder.put('a', 2, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(DenseImmutableTable.class); validateReserialization(table); } @@ -355,7 +355,7 @@ public void testDenseSerialization_rowOrder() { builder.put('b', 2, "foo"); builder.put('b', 1, "bar"); builder.put('a', 2, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(DenseImmutableTable.class); validateReserialization(table); } @@ -366,7 +366,7 @@ public void testDenseSerialization_columnOrder() { builder.put('b', 2, "foo"); builder.put('b', 1, "bar"); builder.put('a', 2, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(DenseImmutableTable.class); validateReserialization(table); } @@ -378,7 +378,7 @@ public void testDenseSerialization_bothOrders() { builder.put('b', 2, "foo"); builder.put('b', 1, "bar"); builder.put('a', 2, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(DenseImmutableTable.class); validateReserialization(table); } @@ -390,7 +390,7 @@ public void testSparseSerialization_manualOrder() { builder.put('a', 2, "baz"); builder.put('c', 3, "cat"); builder.put('d', 4, "dog"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(SparseImmutableTable.class); validateReserialization(table); } @@ -403,7 +403,7 @@ public void testSparseSerialization_rowOrder() { builder.put('a', 2, "baz"); builder.put('c', 3, "cat"); builder.put('d', 4, "dog"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(SparseImmutableTable.class); validateReserialization(table); } @@ -416,7 +416,7 @@ public void testSparseSerialization_columnOrder() { builder.put('a', 2, "baz"); builder.put('c', 3, "cat"); builder.put('d', 4, "dog"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(SparseImmutableTable.class); validateReserialization(table); } @@ -430,7 +430,7 @@ public void testSparseSerialization_bothOrders() { builder.put('a', 2, "baz"); builder.put('c', 3, "cat"); builder.put('d', 4, "dog"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(SparseImmutableTable.class); validateReserialization(table); } @@ -452,6 +452,6 @@ public void testOverflowCondition() { builder.put(i, 0, "foo"); builder.put(0, i, "bar"); } - assertTrue(builder.build() instanceof SparseImmutableTable); + assertTrue(builder.buildOrThrow() instanceof SparseImmutableTable); } } diff --git a/android/guava-tests/test/com/google/common/hash/FarmHashFingerprint64Test.java b/android/guava-tests/test/com/google/common/hash/FarmHashFingerprint64Test.java index ec7023a16cd7..4f6987f645fe 100644 --- a/android/guava-tests/test/com/google/common/hash/FarmHashFingerprint64Test.java +++ b/android/guava-tests/test/com/google/common/hash/FarmHashFingerprint64Test.java @@ -37,6 +37,7 @@ public class FarmHashFingerprint64Test extends TestCase { private static final HashFunction HASH_FN = Hashing.farmHashFingerprint64(); // If this test fails, all bets are off + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 public void testReallySimpleFingerprints() { assertEquals(8581389452482819506L, fingerprint("test".getBytes(UTF_8))); // 32 characters long diff --git a/android/guava-tests/test/com/google/common/hash/Fingerprint2011Test.java b/android/guava-tests/test/com/google/common/hash/Fingerprint2011Test.java index d8db779ceda9..a764a0af527f 100644 --- a/android/guava-tests/test/com/google/common/hash/Fingerprint2011Test.java +++ b/android/guava-tests/test/com/google/common/hash/Fingerprint2011Test.java @@ -60,6 +60,7 @@ public class Fingerprint2011Test extends TestCase { private static final HashFunction HASH_FN = Hashing.fingerprint2011(); // If this test fails, all bets are off + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 public void testReallySimpleFingerprints() { assertEquals(8473225671271759044L, fingerprint("test".getBytes(UTF_8))); // 32 characters long diff --git a/android/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java b/android/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java index cc54edad90fb..9bfe7af85a99 100644 --- a/android/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java +++ b/android/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java @@ -61,7 +61,7 @@ public class MacHashFunctionTest extends TestCase { .put("HmacSHA1", SHA1_KEY, Hashing.hmacSha1(SHA1_KEY)) .put("HmacSHA256", SHA256_KEY, Hashing.hmacSha256(SHA256_KEY)) .put("HmacSHA512", SHA512_KEY, Hashing.hmacSha512(SHA512_KEY)) - .build(); + .buildOrThrow(); public void testNulls() { NullPointerTester tester = diff --git a/android/guava-tests/test/com/google/common/io/CharStreamsTest.java b/android/guava-tests/test/com/google/common/io/CharStreamsTest.java index f36a1dcc74a4..023542225976 100644 --- a/android/guava-tests/test/com/google/common/io/CharStreamsTest.java +++ b/android/guava-tests/test/com/google/common/io/CharStreamsTest.java @@ -226,6 +226,7 @@ public void testCopy_toWriter_fromReadable() throws IOException { * is permanently reduced, but with certain Reader implementations it could also cause the buffer * size to reach 0, causing an infinite loop. */ + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 public void testCopyWithReaderThatDoesNotFillBuffer() throws IOException { // need a long enough string for the buffer to hit 0 remaining before the copy completes String string = Strings.repeat("0123456789", 100); diff --git a/android/guava-tests/test/com/google/common/net/InternetDomainNameTest.java b/android/guava-tests/test/com/google/common/net/InternetDomainNameTest.java index aece7235ebb7..eb75b1e5104c 100644 --- a/android/guava-tests/test/com/google/common/net/InternetDomainNameTest.java +++ b/android/guava-tests/test/com/google/common/net/InternetDomainNameTest.java @@ -47,10 +47,13 @@ public final class InternetDomainNameTest extends TestCase { private static final String DELTA = "\u0394"; /** A domain part which is valid under lenient validation, but invalid under strict validation. */ + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 static final String LOTS_OF_DELTAS = Strings.repeat(DELTA, 62); + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 private static final String ALMOST_TOO_MANY_LEVELS = Strings.repeat("a.", 127); + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 private static final String ALMOST_TOO_LONG = Strings.repeat("aaaaa.", 40) + "1234567890.c"; private static final ImmutableSet VALID_NAME = diff --git a/android/guava-tests/test/com/google/common/primitives/BooleansTest.java b/android/guava-tests/test/com/google/common/primitives/BooleansTest.java index 7d081054102c..e6e907062059 100644 --- a/android/guava-tests/test/com/google/common/primitives/BooleansTest.java +++ b/android/guava-tests/test/com/google/common/primitives/BooleansTest.java @@ -70,6 +70,8 @@ public void testFalseFirst() { assertThat(Booleans.falseFirst().compare(true, false)).isGreaterThan(0); } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (boolean x : VALUES) { for (boolean y : VALUES) { diff --git a/android/guava-tests/test/com/google/common/primitives/CharsTest.java b/android/guava-tests/test/com/google/common/primitives/CharsTest.java index c8e861ff940c..30e1c3990395 100644 --- a/android/guava-tests/test/com/google/common/primitives/CharsTest.java +++ b/android/guava-tests/test/com/google/common/primitives/CharsTest.java @@ -92,6 +92,8 @@ private void assertCastFails(long value) { } } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (char x : VALUES) { for (char y : VALUES) { diff --git a/android/guava-tests/test/com/google/common/primitives/DoublesTest.java b/android/guava-tests/test/com/google/common/primitives/DoublesTest.java index c5b00d688268..e0bb4a8736b3 100644 --- a/android/guava-tests/test/com/google/common/primitives/DoublesTest.java +++ b/android/guava-tests/test/com/google/common/primitives/DoublesTest.java @@ -95,6 +95,8 @@ public void testIsFinite() { } } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (double x : VALUES) { for (double y : VALUES) { diff --git a/android/guava-tests/test/com/google/common/primitives/FloatsTest.java b/android/guava-tests/test/com/google/common/primitives/FloatsTest.java index 3adaf8d15bf3..0423cf46599e 100644 --- a/android/guava-tests/test/com/google/common/primitives/FloatsTest.java +++ b/android/guava-tests/test/com/google/common/primitives/FloatsTest.java @@ -90,6 +90,8 @@ public void testIsFinite() { } } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (float x : VALUES) { for (float y : VALUES) { diff --git a/android/guava-tests/test/com/google/common/primitives/IntsTest.java b/android/guava-tests/test/com/google/common/primitives/IntsTest.java index 9e267a36f4ff..f5a2b557c6d7 100644 --- a/android/guava-tests/test/com/google/common/primitives/IntsTest.java +++ b/android/guava-tests/test/com/google/common/primitives/IntsTest.java @@ -94,6 +94,8 @@ private static void assertCastFails(long value) { } } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (int x : VALUES) { for (int y : VALUES) { diff --git a/android/guava-tests/test/com/google/common/primitives/LongsTest.java b/android/guava-tests/test/com/google/common/primitives/LongsTest.java index 9f4bfd562e56..d09ba263af89 100644 --- a/android/guava-tests/test/com/google/common/primitives/LongsTest.java +++ b/android/guava-tests/test/com/google/common/primitives/LongsTest.java @@ -65,6 +65,8 @@ public void testHashCode() { } } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (long x : VALUES) { for (long y : VALUES) { diff --git a/android/guava-tests/test/com/google/common/primitives/ShortsTest.java b/android/guava-tests/test/com/google/common/primitives/ShortsTest.java index dc44f39ac83c..7fdc4d646920 100644 --- a/android/guava-tests/test/com/google/common/primitives/ShortsTest.java +++ b/android/guava-tests/test/com/google/common/primitives/ShortsTest.java @@ -93,6 +93,8 @@ private static void assertCastFails(long value) { } } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (short x : VALUES) { for (short y : VALUES) { diff --git a/android/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java b/android/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java index bd2376afc3cc..b2bfd3bfbf81 100644 --- a/android/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java +++ b/android/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java @@ -94,7 +94,7 @@ public void testToLong() { public void testCompare() { for (long a : UNSIGNED_INTS) { for (long b : UNSIGNED_INTS) { - int cmpAsLongs = Longs.compare(a, b); + int cmpAsLongs = Long.compare(a, b); int cmpAsUInt = UnsignedInts.compare((int) a, (int) b); assertThat(Integer.signum(cmpAsUInt)).isEqualTo(Integer.signum(cmpAsLongs)); } diff --git a/android/guava/src/com/google/common/collect/ImmutableTable.java b/android/guava/src/com/google/common/collect/ImmutableTable.java index 6c0d60981821..234fb40afca1 100644 --- a/android/guava/src/com/google/common/collect/ImmutableTable.java +++ b/android/guava/src/com/google/common/collect/ImmutableTable.java @@ -141,7 +141,7 @@ static ImmutableTable copyOf( for (Cell cell : cells) { builder.put(cell); } - return builder.build(); + return builder.buildOrThrow(); } /** diff --git a/android/guava/src/com/google/common/collect/TableCollectors.java b/android/guava/src/com/google/common/collect/TableCollectors.java index bcbf41451e8f..ed199dde9510 100644 --- a/android/guava/src/com/google/common/collect/TableCollectors.java +++ b/android/guava/src/com/google/common/collect/TableCollectors.java @@ -48,7 +48,7 @@ final class TableCollectors { (builder, t) -> builder.put(rowFunction.apply(t), columnFunction.apply(t), valueFunction.apply(t)), ImmutableTable.Builder::combine, - ImmutableTable.Builder::build); + ImmutableTable.Builder::buildOrThrow); } static diff --git a/android/guava/src/com/google/common/primitives/UnsignedInts.java b/android/guava/src/com/google/common/primitives/UnsignedInts.java index 513a633d425b..644ef2da75c1 100644 --- a/android/guava/src/com/google/common/primitives/UnsignedInts.java +++ b/android/guava/src/com/google/common/primitives/UnsignedInts.java @@ -66,6 +66,7 @@ static int flip(int value) { * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ + @SuppressWarnings("InlineMeInliner") // Integer.compare unavailable under GWT+J2CL public static int compare(int a, int b) { return Ints.compare(flip(a), flip(b)); } diff --git a/android/guava/src/com/google/common/primitives/UnsignedLongs.java b/android/guava/src/com/google/common/primitives/UnsignedLongs.java index 96f4628d4d76..ac9b2c5c750d 100644 --- a/android/guava/src/com/google/common/primitives/UnsignedLongs.java +++ b/android/guava/src/com/google/common/primitives/UnsignedLongs.java @@ -74,6 +74,7 @@ private static long flip(long a) { * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ + @SuppressWarnings("InlineMeInliner") // Integer.compare unavailable under GWT+J2CL public static int compare(long a, long b) { return Longs.compare(flip(a), flip(b)); } diff --git a/guava-testlib/test/com/google/common/testing/EquivalenceTesterTest.java b/guava-testlib/test/com/google/common/testing/EquivalenceTesterTest.java index 00bdb2aa4457..77a35d04ece2 100644 --- a/guava-testlib/test/com/google/common/testing/EquivalenceTesterTest.java +++ b/guava-testlib/test/com/google/common/testing/EquivalenceTesterTest.java @@ -238,7 +238,7 @@ void expectHash(Object object, int hash) { void replay() { checkRecording(); - equivalentExpectations = equivalentExpectationsBuilder.build(); + equivalentExpectations = equivalentExpectationsBuilder.buildOrThrow(); hashExpectations = hashExpectationsBuilder.buildOrThrow(); } diff --git a/guava-tests/benchmark/com/google/common/base/JoinerBenchmark.java b/guava-tests/benchmark/com/google/common/base/JoinerBenchmark.java index 8b3b5afd02d3..1d53f79f00af 100644 --- a/guava-tests/benchmark/com/google/common/base/JoinerBenchmark.java +++ b/guava-tests/benchmark/com/google/common/base/JoinerBenchmark.java @@ -46,6 +46,7 @@ public class JoinerBenchmark { private Iterable components; @BeforeExperiment + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 void setUp() { String component = Strings.repeat("a", componentLength); String[] raw = new String[count]; diff --git a/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java b/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java index 4d23cc20fc68..d1c0d38a62be 100644 --- a/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java +++ b/guava-tests/benchmark/com/google/common/base/SplitterBenchmark.java @@ -42,6 +42,7 @@ public class SplitterBenchmark { private static final Splitter STRING_SPLITTER = Splitter.on("X"); @BeforeExperiment + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 void setUp() { input = Strings.repeat(text, length); } diff --git a/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java b/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java index 9f350cf68c78..3750ca53f9c2 100644 --- a/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java +++ b/guava-tests/benchmark/com/google/common/base/StringsRepeatBenchmark.java @@ -37,6 +37,7 @@ public class StringsRepeatBenchmark { private String originalString; @BeforeExperiment + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 void setUp() { originalString = Strings.repeat("x", length); } diff --git a/guava-tests/test/com/google/common/base/CharMatcherTest.java b/guava-tests/test/com/google/common/base/CharMatcherTest.java index 1d47a3dc8a85..248e4bbca070 100644 --- a/guava-tests/test/com/google/common/base/CharMatcherTest.java +++ b/guava-tests/test/com/google/common/base/CharMatcherTest.java @@ -293,6 +293,7 @@ private void reallyTestNoMatches(CharMatcher matcher, CharSequence s) { assertEquals(0, matcher.countIn(s)); } + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 private void reallyTestAllMatches(CharMatcher matcher, CharSequence s) { assertTrue(matcher.matches(s.charAt(0))); assertEquals(0, matcher.indexIn(s)); diff --git a/guava-tests/test/com/google/common/base/ConverterTest.java b/guava-tests/test/com/google/common/base/ConverterTest.java index d566dcba0ceb..e8817ab32e27 100644 --- a/guava-tests/test/com/google/common/base/ConverterTest.java +++ b/guava-tests/test/com/google/common/base/ConverterTest.java @@ -103,6 +103,8 @@ public void testReverseReverse() { assertEquals(converter, converter.reverse().reverse()); } + // We need to test that apply() does in fact behave like convert(). + @SuppressWarnings("InlineMeInliner") public void testApply() { assertEquals(LONG_VAL, STR_TO_LONG.apply(STR_VAL)); } diff --git a/guava-tests/test/com/google/common/collect/FluentIterableTest.java b/guava-tests/test/com/google/common/collect/FluentIterableTest.java index 1019453cca0f..fc8601bca382 100644 --- a/guava-tests/test/com/google/common/collect/FluentIterableTest.java +++ b/guava-tests/test/com/google/common/collect/FluentIterableTest.java @@ -82,7 +82,11 @@ public void testFrom() { Lists.newArrayList(FluentIterable.from(ImmutableList.of(1, 2, 3, 4)))); } - @SuppressWarnings("deprecation") // test of deprecated method + @SuppressWarnings({ + "deprecation", // test of deprecated method + // We need to test that from(FluentIterable) really is just a null check. + "InlineMeInliner", + }) public void testFrom_alreadyFluentIterable() { FluentIterable iterable = FluentIterable.from(asList(1)); assertSame(iterable, FluentIterable.from(iterable)); diff --git a/guava-tests/test/com/google/common/collect/ImmutableListTest.java b/guava-tests/test/com/google/common/collect/ImmutableListTest.java index 0599ea79fe71..a3f1cccd887e 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableListTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableListTest.java @@ -596,6 +596,8 @@ public void testBuilderAddAllHandlesNullsCorrectly() { } } + // We need to test that asList() really does return the original list. + @SuppressWarnings("InlineMeInliner") public void testAsList() { ImmutableList list = ImmutableList.of("a", "b"); assertSame(list, list.asList()); diff --git a/guava-tests/test/com/google/common/collect/ImmutableTableTest.java b/guava-tests/test/com/google/common/collect/ImmutableTableTest.java index ffeb15c239dc..cf4ae6d91d12 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableTableTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableTableTest.java @@ -45,7 +45,7 @@ protected Table create(@Nullable Object... data) { for (int i = 0; i < data.length; i = i + 3) { builder.put((String) data[i], (Integer) data[i + 1], (Character) data[i + 2]); } - return builder.build(); + return builder.buildOrThrow(); } // The bulk of the toImmutableTable tests can be found in TableCollectorsTest. @@ -71,8 +71,8 @@ public void testToImmutableTableMergingSanityTest() { public void testBuilder() { ImmutableTable.Builder builder = new ImmutableTable.Builder<>(); - assertEquals(ImmutableTable.of(), builder.build()); - assertEquals(ImmutableTable.of('a', 1, "foo"), builder.put('a', 1, "foo").build()); + assertEquals(ImmutableTable.of(), builder.buildOrThrow()); + assertEquals(ImmutableTable.of('a', 1, "foo"), builder.put('a', 1, "foo").buildOrThrow()); Table expectedTable = HashBasedTable.create(); expectedTable.put('a', 1, "foo"); expectedTable.put('b', 1, "bar"); @@ -80,13 +80,13 @@ public void testBuilder() { Table otherTable = HashBasedTable.create(); otherTable.put('b', 1, "bar"); otherTable.put('a', 2, "baz"); - assertEquals(expectedTable, builder.putAll(otherTable).build()); + assertEquals(expectedTable, builder.putAll(otherTable).buildOrThrow()); } public void testBuilder_withImmutableCell() { ImmutableTable.Builder builder = new ImmutableTable.Builder<>(); assertEquals( - ImmutableTable.of('a', 1, "foo"), builder.put(immutableCell('a', 1, "foo")).build()); + ImmutableTable.of('a', 1, "foo"), builder.put(immutableCell('a', 1, "foo")).buildOrThrow()); } public void testBuilder_withImmutableCellAndNullContents() { @@ -133,7 +133,7 @@ public String getValue() { holder.string = "bar"; // Make sure it uses the original value. - assertEquals(ImmutableTable.of('K', 42, "foo"), builder.build()); + assertEquals(ImmutableTable.of('K', 42, "foo"), builder.buildOrThrow()); } public void testBuilder_noDuplicates() { @@ -141,7 +141,7 @@ public void testBuilder_noDuplicates() { new ImmutableTable.Builder() .put('a', 1, "foo") .put('a', 1, "bar"); - assertThrows(IllegalArgumentException.class, () -> builder.build()); + assertThrows(IllegalArgumentException.class, () -> builder.buildOrThrow()); } public void testBuilder_noNulls() { @@ -156,7 +156,7 @@ private static void validateTableCopies(Table original) { assertEquals(original, copy); validateViewOrdering(original, copy); - Table built = ImmutableTable.builder().putAll(original).build(); + Table built = ImmutableTable.builder().putAll(original).buildOrThrow(); assertEquals(original, built); validateViewOrdering(original, built); } @@ -219,7 +219,7 @@ public void testBuilder_orderRowsAndColumnsBy_putAll() { .orderRowsBy(Ordering.natural()) .orderColumnsBy(Ordering.natural()) .putAll(table) - .build(); + .buildOrThrow(); assertThat(copy.rowKeySet()).containsExactly('a', 'b').inOrder(); assertThat(copy.columnKeySet()).containsExactly(1, 2).inOrder(); assertThat(copy.values()).containsExactly("baz", "bar", "foo").inOrder(); @@ -239,7 +239,7 @@ public void testBuilder_orderRowsAndColumnsBy_sparse() { builder.put('e', 3, "tub"); builder.put('r', 4, "foo"); builder.put('x', 5, "bar"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table.rowKeySet()).containsExactly('b', 'c', 'e', 'r', 'x').inOrder(); assertThat(table.columnKeySet()).containsExactly(0, 1, 2, 3, 4, 5, 7).inOrder(); assertThat(table.values()) @@ -261,7 +261,7 @@ public void testBuilder_orderRowsAndColumnsBy_dense() { builder.put('a', 3, "foo"); builder.put('a', 2, "bar"); builder.put('a', 1, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table.rowKeySet()).containsExactly('a', 'b', 'c').inOrder(); assertThat(table.columnKeySet()).containsExactly(1, 2, 3).inOrder(); assertThat(table.values()) @@ -283,7 +283,7 @@ public void testBuilder_orderRowsBy_sparse() { builder.put('e', 3, "tub"); builder.put('r', 4, "foo"); builder.put('x', 5, "bar"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table.rowKeySet()).containsExactly('b', 'c', 'e', 'r', 'x').inOrder(); assertThat(table.column(5).keySet()).containsExactly('e', 'x').inOrder(); } @@ -299,7 +299,7 @@ public void testBuilder_orderRowsBy_dense() { builder.put('a', 3, "foo"); builder.put('a', 2, "bar"); builder.put('a', 1, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table.rowKeySet()).containsExactly('a', 'b', 'c').inOrder(); assertThat(table.column(1).keySet()).containsExactly('a', 'b', 'c').inOrder(); } @@ -316,7 +316,7 @@ public void testBuilder_orderColumnsBy_sparse() { builder.put('e', 3, "tub"); builder.put('r', 4, "foo"); builder.put('x', 5, "bar"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table.columnKeySet()).containsExactly(0, 1, 2, 3, 4, 5, 7).inOrder(); assertThat(table.row('c').keySet()).containsExactly(0, 3).inOrder(); } @@ -332,7 +332,7 @@ public void testBuilder_orderColumnsBy_dense() { builder.put('a', 3, "foo"); builder.put('a', 2, "bar"); builder.put('a', 1, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table.columnKeySet()).containsExactly(1, 2, 3).inOrder(); assertThat(table.row('c').keySet()).containsExactly(1, 2, 3).inOrder(); } @@ -350,7 +350,7 @@ public void testDenseSerialization_manualOrder() { builder.put('b', 2, "foo"); builder.put('b', 1, "bar"); builder.put('a', 2, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(DenseImmutableTable.class); validateReserialization(table); } @@ -361,7 +361,7 @@ public void testDenseSerialization_rowOrder() { builder.put('b', 2, "foo"); builder.put('b', 1, "bar"); builder.put('a', 2, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(DenseImmutableTable.class); validateReserialization(table); } @@ -372,7 +372,7 @@ public void testDenseSerialization_columnOrder() { builder.put('b', 2, "foo"); builder.put('b', 1, "bar"); builder.put('a', 2, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(DenseImmutableTable.class); validateReserialization(table); } @@ -384,7 +384,7 @@ public void testDenseSerialization_bothOrders() { builder.put('b', 2, "foo"); builder.put('b', 1, "bar"); builder.put('a', 2, "baz"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(DenseImmutableTable.class); validateReserialization(table); } @@ -396,7 +396,7 @@ public void testSparseSerialization_manualOrder() { builder.put('a', 2, "baz"); builder.put('c', 3, "cat"); builder.put('d', 4, "dog"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(SparseImmutableTable.class); validateReserialization(table); } @@ -409,7 +409,7 @@ public void testSparseSerialization_rowOrder() { builder.put('a', 2, "baz"); builder.put('c', 3, "cat"); builder.put('d', 4, "dog"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(SparseImmutableTable.class); validateReserialization(table); } @@ -422,7 +422,7 @@ public void testSparseSerialization_columnOrder() { builder.put('a', 2, "baz"); builder.put('c', 3, "cat"); builder.put('d', 4, "dog"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(SparseImmutableTable.class); validateReserialization(table); } @@ -436,7 +436,7 @@ public void testSparseSerialization_bothOrders() { builder.put('a', 2, "baz"); builder.put('c', 3, "cat"); builder.put('d', 4, "dog"); - Table table = builder.build(); + Table table = builder.buildOrThrow(); assertThat(table).isInstanceOf(SparseImmutableTable.class); validateReserialization(table); } @@ -458,6 +458,6 @@ public void testOverflowCondition() { builder.put(i, 0, "foo"); builder.put(0, i, "bar"); } - assertTrue(builder.build() instanceof SparseImmutableTable); + assertTrue(builder.buildOrThrow() instanceof SparseImmutableTable); } } diff --git a/guava-tests/test/com/google/common/collect/StreamsTest.java b/guava-tests/test/com/google/common/collect/StreamsTest.java index 0c77151badcb..9fb842c10807 100644 --- a/guava-tests/test/com/google/common/collect/StreamsTest.java +++ b/guava-tests/test/com/google/common/collect/StreamsTest.java @@ -58,7 +58,11 @@ public void testStream_nonCollection() { assertThat(stream(FluentIterable.of(1, 2, 3)).filter(n -> n > 1)).containsExactly(2, 3); } - @SuppressWarnings("deprecation") + @SuppressWarnings({ + "deprecation", // test of a deprecated method + // We need to test that our methods really do behave like collection.stream(). + "InlineMeInliner", + }) public void testStream_collection() { assertThat(stream(asList())).isEmpty(); assertThat(stream(asList("a"))).containsExactly("a"); @@ -76,6 +80,8 @@ public void testStream_googleOptional() { assertThat(stream(com.google.common.base.Optional.of("a"))).containsExactly("a"); } + // We need to test that our methods really do behave like optional.stream(). + @SuppressWarnings("InlineMeInliner") public void testStream_javaOptional() { assertThat(stream(java.util.Optional.empty())).isEmpty(); assertThat(stream(java.util.Optional.of("a"))).containsExactly("a"); @@ -243,16 +249,22 @@ public void testConcat_doubleStream() { .inOrder(); } + // We need to test that our methods really do behave like optional.stream(). + @SuppressWarnings("InlineMeInliner") public void testStream_optionalInt() { assertThat(stream(OptionalInt.empty())).isEmpty(); assertThat(stream(OptionalInt.of(5))).containsExactly(5); } + // We need to test that our methods really do behave like optional.stream(). + @SuppressWarnings("InlineMeInliner") public void testStream_optionalLong() { assertThat(stream(OptionalLong.empty())).isEmpty(); assertThat(stream(OptionalLong.of(5L))).containsExactly(5L); } + // We need to test that our methods really do behave like optional.stream(). + @SuppressWarnings("InlineMeInliner") public void testStream_optionalDouble() { assertThatDoubleStream(stream(OptionalDouble.empty())).isEmpty(); assertThatDoubleStream(stream(OptionalDouble.of(5.0))).containsExactly(5.0); diff --git a/guava-tests/test/com/google/common/collect/TableCollectorsTest.java b/guava-tests/test/com/google/common/collect/TableCollectorsTest.java index 18f3041bab4b..70cd90cfdd49 100644 --- a/guava-tests/test/com/google/common/collect/TableCollectorsTest.java +++ b/guava-tests/test/com/google/common/collect/TableCollectorsTest.java @@ -50,7 +50,7 @@ public void testToImmutableTable() { .put("one", "uno", 1) .put("two", "dos", 2) .put("three", "tres", 3) - .build(), + .buildOrThrow(), immutableCell("one", "uno", 1), immutableCell("two", "dos", 2), immutableCell("three", "tres", 3)); @@ -112,7 +112,7 @@ public void testToImmutableTableMerging() { .put("one", "uno", 1) .put("two", "dos", 6) .put("three", "tres", 3) - .build(), + .buildOrThrow(), immutableCell("one", "uno", 1), immutableCell("two", "dos", 2), immutableCell("three", "tres", 3), @@ -182,7 +182,7 @@ public void testToTable() { .put("one", "uno", 1) .put("two", "dos", 2) .put("three", "tres", 3) - .build(), + .buildOrThrow(), immutableCell("one", "uno", 1), immutableCell("two", "dos", 2), immutableCell("three", "tres", 3)); @@ -252,7 +252,7 @@ public void testToTableMerging() { .put("one", "uno", 1) .put("two", "dos", 6) .put("three", "tres", 3) - .build(), + .buildOrThrow(), immutableCell("one", "uno", 1), immutableCell("two", "dos", 2), immutableCell("three", "tres", 3), diff --git a/guava-tests/test/com/google/common/hash/FarmHashFingerprint64Test.java b/guava-tests/test/com/google/common/hash/FarmHashFingerprint64Test.java index ec7023a16cd7..4f6987f645fe 100644 --- a/guava-tests/test/com/google/common/hash/FarmHashFingerprint64Test.java +++ b/guava-tests/test/com/google/common/hash/FarmHashFingerprint64Test.java @@ -37,6 +37,7 @@ public class FarmHashFingerprint64Test extends TestCase { private static final HashFunction HASH_FN = Hashing.farmHashFingerprint64(); // If this test fails, all bets are off + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 public void testReallySimpleFingerprints() { assertEquals(8581389452482819506L, fingerprint("test".getBytes(UTF_8))); // 32 characters long diff --git a/guava-tests/test/com/google/common/hash/Fingerprint2011Test.java b/guava-tests/test/com/google/common/hash/Fingerprint2011Test.java index d8db779ceda9..a764a0af527f 100644 --- a/guava-tests/test/com/google/common/hash/Fingerprint2011Test.java +++ b/guava-tests/test/com/google/common/hash/Fingerprint2011Test.java @@ -60,6 +60,7 @@ public class Fingerprint2011Test extends TestCase { private static final HashFunction HASH_FN = Hashing.fingerprint2011(); // If this test fails, all bets are off + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 public void testReallySimpleFingerprints() { assertEquals(8473225671271759044L, fingerprint("test".getBytes(UTF_8))); // 32 characters long diff --git a/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java b/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java index cc54edad90fb..9bfe7af85a99 100644 --- a/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java +++ b/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java @@ -61,7 +61,7 @@ public class MacHashFunctionTest extends TestCase { .put("HmacSHA1", SHA1_KEY, Hashing.hmacSha1(SHA1_KEY)) .put("HmacSHA256", SHA256_KEY, Hashing.hmacSha256(SHA256_KEY)) .put("HmacSHA512", SHA512_KEY, Hashing.hmacSha512(SHA512_KEY)) - .build(); + .buildOrThrow(); public void testNulls() { NullPointerTester tester = diff --git a/guava-tests/test/com/google/common/io/CharStreamsTest.java b/guava-tests/test/com/google/common/io/CharStreamsTest.java index f36a1dcc74a4..023542225976 100644 --- a/guava-tests/test/com/google/common/io/CharStreamsTest.java +++ b/guava-tests/test/com/google/common/io/CharStreamsTest.java @@ -226,6 +226,7 @@ public void testCopy_toWriter_fromReadable() throws IOException { * is permanently reduced, but with certain Reader implementations it could also cause the buffer * size to reach 0, causing an infinite loop. */ + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 public void testCopyWithReaderThatDoesNotFillBuffer() throws IOException { // need a long enough string for the buffer to hit 0 remaining before the copy completes String string = Strings.repeat("0123456789", 100); diff --git a/guava-tests/test/com/google/common/net/InternetDomainNameTest.java b/guava-tests/test/com/google/common/net/InternetDomainNameTest.java index aece7235ebb7..eb75b1e5104c 100644 --- a/guava-tests/test/com/google/common/net/InternetDomainNameTest.java +++ b/guava-tests/test/com/google/common/net/InternetDomainNameTest.java @@ -47,10 +47,13 @@ public final class InternetDomainNameTest extends TestCase { private static final String DELTA = "\u0394"; /** A domain part which is valid under lenient validation, but invalid under strict validation. */ + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 static final String LOTS_OF_DELTAS = Strings.repeat(DELTA, 62); + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 private static final String ALMOST_TOO_MANY_LEVELS = Strings.repeat("a.", 127); + @SuppressWarnings("InlineMeInliner") // String.repeat unavailable under Java 8 private static final String ALMOST_TOO_LONG = Strings.repeat("aaaaa.", 40) + "1234567890.c"; private static final ImmutableSet VALID_NAME = diff --git a/guava-tests/test/com/google/common/primitives/BooleansTest.java b/guava-tests/test/com/google/common/primitives/BooleansTest.java index 7d081054102c..e6e907062059 100644 --- a/guava-tests/test/com/google/common/primitives/BooleansTest.java +++ b/guava-tests/test/com/google/common/primitives/BooleansTest.java @@ -70,6 +70,8 @@ public void testFalseFirst() { assertThat(Booleans.falseFirst().compare(true, false)).isGreaterThan(0); } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (boolean x : VALUES) { for (boolean y : VALUES) { diff --git a/guava-tests/test/com/google/common/primitives/CharsTest.java b/guava-tests/test/com/google/common/primitives/CharsTest.java index c8e861ff940c..30e1c3990395 100644 --- a/guava-tests/test/com/google/common/primitives/CharsTest.java +++ b/guava-tests/test/com/google/common/primitives/CharsTest.java @@ -92,6 +92,8 @@ private void assertCastFails(long value) { } } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (char x : VALUES) { for (char y : VALUES) { diff --git a/guava-tests/test/com/google/common/primitives/DoublesTest.java b/guava-tests/test/com/google/common/primitives/DoublesTest.java index c5b00d688268..e0bb4a8736b3 100644 --- a/guava-tests/test/com/google/common/primitives/DoublesTest.java +++ b/guava-tests/test/com/google/common/primitives/DoublesTest.java @@ -95,6 +95,8 @@ public void testIsFinite() { } } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (double x : VALUES) { for (double y : VALUES) { diff --git a/guava-tests/test/com/google/common/primitives/FloatsTest.java b/guava-tests/test/com/google/common/primitives/FloatsTest.java index 3adaf8d15bf3..0423cf46599e 100644 --- a/guava-tests/test/com/google/common/primitives/FloatsTest.java +++ b/guava-tests/test/com/google/common/primitives/FloatsTest.java @@ -90,6 +90,8 @@ public void testIsFinite() { } } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (float x : VALUES) { for (float y : VALUES) { diff --git a/guava-tests/test/com/google/common/primitives/IntsTest.java b/guava-tests/test/com/google/common/primitives/IntsTest.java index 9e267a36f4ff..f5a2b557c6d7 100644 --- a/guava-tests/test/com/google/common/primitives/IntsTest.java +++ b/guava-tests/test/com/google/common/primitives/IntsTest.java @@ -94,6 +94,8 @@ private static void assertCastFails(long value) { } } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (int x : VALUES) { for (int y : VALUES) { diff --git a/guava-tests/test/com/google/common/primitives/LongsTest.java b/guava-tests/test/com/google/common/primitives/LongsTest.java index 9f4bfd562e56..d09ba263af89 100644 --- a/guava-tests/test/com/google/common/primitives/LongsTest.java +++ b/guava-tests/test/com/google/common/primitives/LongsTest.java @@ -65,6 +65,8 @@ public void testHashCode() { } } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (long x : VALUES) { for (long y : VALUES) { diff --git a/guava-tests/test/com/google/common/primitives/ShortsTest.java b/guava-tests/test/com/google/common/primitives/ShortsTest.java index dc44f39ac83c..7fdc4d646920 100644 --- a/guava-tests/test/com/google/common/primitives/ShortsTest.java +++ b/guava-tests/test/com/google/common/primitives/ShortsTest.java @@ -93,6 +93,8 @@ private static void assertCastFails(long value) { } } + // We need to test that our method behaves like the JDK method. + @SuppressWarnings("InlineMeInliner") public void testCompare() { for (short x : VALUES) { for (short y : VALUES) { diff --git a/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java b/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java index bd2376afc3cc..b2bfd3bfbf81 100644 --- a/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java +++ b/guava-tests/test/com/google/common/primitives/UnsignedIntsTest.java @@ -94,7 +94,7 @@ public void testToLong() { public void testCompare() { for (long a : UNSIGNED_INTS) { for (long b : UNSIGNED_INTS) { - int cmpAsLongs = Longs.compare(a, b); + int cmpAsLongs = Long.compare(a, b); int cmpAsUInt = UnsignedInts.compare((int) a, (int) b); assertThat(Integer.signum(cmpAsUInt)).isEqualTo(Integer.signum(cmpAsLongs)); } diff --git a/guava/src/com/google/common/collect/ImmutableTable.java b/guava/src/com/google/common/collect/ImmutableTable.java index 7131c6c0f887..199577679fdd 100644 --- a/guava/src/com/google/common/collect/ImmutableTable.java +++ b/guava/src/com/google/common/collect/ImmutableTable.java @@ -138,7 +138,7 @@ static ImmutableTable copyOf( for (Cell cell : cells) { builder.put(cell); } - return builder.build(); + return builder.buildOrThrow(); } /** diff --git a/guava/src/com/google/common/collect/TableCollectors.java b/guava/src/com/google/common/collect/TableCollectors.java index 723a01a3d9bc..e6e68042f1c7 100644 --- a/guava/src/com/google/common/collect/TableCollectors.java +++ b/guava/src/com/google/common/collect/TableCollectors.java @@ -45,7 +45,7 @@ final class TableCollectors { (builder, t) -> builder.put(rowFunction.apply(t), columnFunction.apply(t), valueFunction.apply(t)), ImmutableTable.Builder::combine, - ImmutableTable.Builder::build); + ImmutableTable.Builder::buildOrThrow); } static diff --git a/guava/src/com/google/common/primitives/UnsignedInts.java b/guava/src/com/google/common/primitives/UnsignedInts.java index 513a633d425b..644ef2da75c1 100644 --- a/guava/src/com/google/common/primitives/UnsignedInts.java +++ b/guava/src/com/google/common/primitives/UnsignedInts.java @@ -66,6 +66,7 @@ static int flip(int value) { * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ + @SuppressWarnings("InlineMeInliner") // Integer.compare unavailable under GWT+J2CL public static int compare(int a, int b) { return Ints.compare(flip(a), flip(b)); } diff --git a/guava/src/com/google/common/primitives/UnsignedLongs.java b/guava/src/com/google/common/primitives/UnsignedLongs.java index 96f4628d4d76..ac9b2c5c750d 100644 --- a/guava/src/com/google/common/primitives/UnsignedLongs.java +++ b/guava/src/com/google/common/primitives/UnsignedLongs.java @@ -74,6 +74,7 @@ private static long flip(long a) { * @return a negative value if {@code a} is less than {@code b}; a positive value if {@code a} is * greater than {@code b}; or zero if they are equal */ + @SuppressWarnings("InlineMeInliner") // Integer.compare unavailable under GWT+J2CL public static int compare(long a, long b) { return Longs.compare(flip(a), flip(b)); }