aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadaf Ebrahimi <sadafebrahimi@google.com>2024-01-03 17:59:28 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2024-01-03 17:59:28 +0000
commit422eb80feae2e73eda9678ecaacbd087d4b7020b (patch)
treecbc7e4894708533a0ddc4e61da1d74e64393e0e1
parenteec82bd5ace8fd2c4ba647f153c4c03e1bb41268 (diff)
parent0be00b5218b69852777cab76ff89457211904bc9 (diff)
downloadguava-422eb80feae2e73eda9678ecaacbd087d4b7020b.tar.gz
Merge "Upgrade guava to v33.0.0" into main am: fcb6827395 am: 0be00b5218
Original change: https://android-review.googlesource.com/c/platform/external/guava/+/2894060 Change-Id: I8deb731e9d2b4cc35b6760f190c9e7583e91b271 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.yaml83
-rw-r--r--.github/ISSUE_TEMPLATE/feature_addition_request.yaml156
-rw-r--r--.github/ISSUE_TEMPLATE/feature_enhancement_request.yaml108
-rw-r--r--.github/pull_request_template.md10
-rw-r--r--.github/workflows/ci.yml18
-rw-r--r--.github/workflows/gradle-wrapper-validation.yml2
-rw-r--r--.github/workflows/scorecard.yml8
-rw-r--r--.gitignore1
-rw-r--r--.mvn/wrapper/maven-wrapper.properties21
-rw-r--r--CONTRIBUTING.md12
-rw-r--r--METADATA25
-rw-r--r--README.md29
-rw-r--r--android/guava-testlib/src/com/google/common/collect/testing/AbstractIteratorTester.java20
-rw-r--r--android/guava-testlib/src/com/google/common/collect/testing/AbstractTester.java5
-rw-r--r--android/guava-testlib/src/com/google/common/collect/testing/IteratorFeature.java11
-rw-r--r--android/guava-testlib/src/com/google/common/collect/testing/MapInterfaceTest.java12
-rw-r--r--android/guava-testlib/src/com/google/common/collect/testing/google/AbstractMultisetSetCountTester.java16
-rw-r--r--android/guava-testlib/src/com/google/common/collect/testing/testers/NavigableMapNavigationTester.java13
-rw-r--r--android/guava-testlib/src/com/google/common/collect/testing/testers/NavigableSetNavigationTester.java13
-rw-r--r--android/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java4
-rw-r--r--android/guava-testlib/src/com/google/common/testing/ClassSanityTester.java6
-rw-r--r--android/guava-testlib/src/com/google/common/testing/EqualsTester.java10
-rw-r--r--android/guava-testlib/src/com/google/common/testing/NullPointerTester.java43
-rw-r--r--android/guava-testlib/src/com/google/common/testing/Platform.java3
-rw-r--r--android/guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java47
-rw-r--r--android/guava-testlib/test/com/google/common/collect/testing/features/FeatureUtilTest.java34
-rw-r--r--android/guava-testlib/test/com/google/common/testing/ArbitraryInstancesTest.java7
-rw-r--r--android/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java1351
-rw-r--r--android/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java51
-rw-r--r--android/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java1438
-rw-r--r--android/guava-testlib/test/com/google/common/testing/anotherpackage/ForwardingWrapperTesterTest.java12
-rw-r--r--android/guava-testlib/test/com/google/common/util/concurrent/testing/TestingExecutorsTest.java16
-rw-r--r--android/guava-tests/pom.xml2
-rw-r--r--android/guava-tests/test/com/google/common/base/ConverterTest.java6
-rw-r--r--android/guava-tests/test/com/google/common/base/DefaultsTest.java2
-rw-r--r--android/guava-tests/test/com/google/common/base/EnumsTest.java7
-rw-r--r--android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java2
-rw-r--r--android/guava-tests/test/com/google/common/base/PackageSanityTests.java2
-rw-r--r--android/guava-tests/test/com/google/common/base/PreconditionsTest.java34
-rw-r--r--android/guava-tests/test/com/google/common/base/PredicatesTest.java7
-rw-r--r--android/guava-tests/test/com/google/common/base/SplitterTest.java7
-rw-r--r--android/guava-tests/test/com/google/common/base/StandardSystemPropertyTest.java2
-rw-r--r--android/guava-tests/test/com/google/common/base/SuppliersTest.java9
-rw-r--r--android/guava-tests/test/com/google/common/base/ThrowablesTest.java129
-rw-r--r--android/guava-tests/test/com/google/common/base/UnannotatedJavaClass.java26
-rw-r--r--android/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java37
-rw-r--r--android/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java145
-rw-r--r--android/guava-tests/test/com/google/common/cache/CacheBuilderTest.java97
-rw-r--r--android/guava-tests/test/com/google/common/cache/CacheLoadingTest.java306
-rw-r--r--android/guava-tests/test/com/google/common/cache/EmptyCachesTest.java79
-rw-r--r--android/guava-tests/test/com/google/common/cache/LocalCacheTest.java79
-rw-r--r--android/guava-tests/test/com/google/common/cache/NullCacheTest.java17
-rw-r--r--android/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java7
-rw-r--r--android/guava-tests/test/com/google/common/collect/AbstractFilteredMapTest.java212
-rw-r--r--android/guava-tests/test/com/google/common/collect/AbstractMapsTransformValuesTest.java275
-rw-r--r--android/guava-tests/test/com/google/common/collect/Base.java54
-rw-r--r--android/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java13
-rw-r--r--android/guava-tests/test/com/google/common/collect/ContiguousSetTest.java26
-rw-r--r--android/guava-tests/test/com/google/common/collect/Derived.java29
-rw-r--r--android/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java49
-rw-r--r--android/guava-tests/test/com/google/common/collect/FauxveridesTest.java25
-rw-r--r--android/guava-tests/test/com/google/common/collect/FilteredBiMapTest.java2
-rw-r--r--android/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java19
-rw-r--r--android/guava-tests/test/com/google/common/collect/FilteredMapTest.java186
-rw-r--r--android/guava-tests/test/com/google/common/collect/FilteredSortedMapTest.java4
-rw-r--r--android/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java13
-rw-r--r--android/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java1
-rw-r--r--android/guava-tests/test/com/google/common/collect/ImmutableListTest.java1
-rw-r--r--android/guava-tests/test/com/google/common/collect/ImmutableMapTest.java1
-rw-r--r--android/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java1
-rw-r--r--android/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java1
-rw-r--r--android/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java21
-rw-r--r--android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java52
-rw-r--r--android/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java1
-rw-r--r--android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java7
-rw-r--r--android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java1
-rw-r--r--android/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java84
-rw-r--r--android/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java1
-rw-r--r--android/guava-tests/test/com/google/common/collect/InternersTest.java26
-rw-r--r--android/guava-tests/test/com/google/common/collect/IterablesTest.java1
-rw-r--r--android/guava-tests/test/com/google/common/collect/IteratorsTest.java40
-rw-r--r--android/guava-tests/test/com/google/common/collect/ListsImplTest.java2
-rw-r--r--android/guava-tests/test/com/google/common/collect/MapsSortedTransformValuesTest.java3
-rw-r--r--android/guava-tests/test/com/google/common/collect/MapsTest.java36
-rw-r--r--android/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java270
-rw-r--r--android/guava-tests/test/com/google/common/collect/MultimapsTest.java1
-rw-r--r--android/guava-tests/test/com/google/common/collect/MultisetsTest.java1
-rw-r--r--android/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java14
-rw-r--r--android/guava-tests/test/com/google/common/collect/OrderingTest.java13
-rw-r--r--android/guava-tests/test/com/google/common/collect/QueuesTest.java15
-rw-r--r--android/guava-tests/test/com/google/common/collect/RangeTest.java2
-rw-r--r--android/guava-tests/test/com/google/common/collect/SetsTest.java58
-rw-r--r--android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java17
-rw-r--r--android/guava-tests/test/com/google/common/collect/WriteReplaceOverridesTest.java118
-rw-r--r--android/guava-tests/test/com/google/common/eventbus/EventBusTest.java22
-rw-r--r--android/guava-tests/test/com/google/common/eventbus/SubscriberRegistryTest.java21
-rw-r--r--android/guava-tests/test/com/google/common/eventbus/SubscriberTest.java18
-rw-r--r--android/guava-tests/test/com/google/common/graph/AbstractGraphTest.java84
-rw-r--r--android/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java138
-rw-r--r--android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java87
-rw-r--r--android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java240
-rw-r--r--android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java68
-rw-r--r--android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java220
-rw-r--r--android/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java48
-rw-r--r--android/guava-tests/test/com/google/common/graph/EndpointPairTest.java15
-rw-r--r--android/guava-tests/test/com/google/common/graph/GraphsTest.java78
-rw-r--r--android/guava-tests/test/com/google/common/graph/PackageSanityTests.java6
-rw-r--r--android/guava-tests/test/com/google/common/graph/TraverserTest.java120
-rw-r--r--android/guava-tests/test/com/google/common/graph/ValueGraphTest.java98
-rw-r--r--android/guava-tests/test/com/google/common/hash/AbstractByteHasherTest.java19
-rw-r--r--android/guava-tests/test/com/google/common/hash/AbstractStreamingHasherTest.java19
-rw-r--r--android/guava-tests/test/com/google/common/hash/BloomFilterTest.java103
-rw-r--r--android/guava-tests/test/com/google/common/hash/HashCodeTest.java43
-rw-r--r--android/guava-tests/test/com/google/common/hash/HashingTest.java49
-rw-r--r--android/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java13
-rw-r--r--android/guava-tests/test/com/google/common/hash/MessageDigestHashFunctionTest.java14
-rw-r--r--android/guava-tests/test/com/google/common/io/AppendableWriterTest.java14
-rw-r--r--android/guava-tests/test/com/google/common/io/ByteSinkTest.java23
-rw-r--r--android/guava-tests/test/com/google/common/io/ByteSourceTest.java35
-rw-r--r--android/guava-tests/test/com/google/common/io/ByteSourceTester.java21
-rw-r--r--android/guava-tests/test/com/google/common/io/ByteStreamsTest.java150
-rw-r--r--android/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java98
-rw-r--r--android/guava-tests/test/com/google/common/io/CharSinkTest.java19
-rw-r--r--android/guava-tests/test/com/google/common/io/CharSourceTest.java23
-rw-r--r--android/guava-tests/test/com/google/common/io/CharStreamsTest.java22
-rw-r--r--android/guava-tests/test/com/google/common/io/CountingInputStreamTest.java17
-rw-r--r--android/guava-tests/test/com/google/common/io/CountingOutputStreamTest.java8
-rw-r--r--android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java6
-rw-r--r--android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java43
-rw-r--r--android/guava-tests/test/com/google/common/io/FilesTest.java94
-rw-r--r--android/guava-tests/test/com/google/common/io/LittleEndianDataInputStreamTest.java22
-rw-r--r--android/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java8
-rw-r--r--android/guava-tests/test/com/google/common/io/ResourcesTest.java42
-rw-r--r--android/guava-tests/test/com/google/common/math/BigDecimalMathTest.java11
-rw-r--r--android/guava-tests/test/com/google/common/math/DoubleUtilsTest.java7
-rw-r--r--android/guava-tests/test/com/google/common/math/LinearTransformationTest.java115
-rw-r--r--android/guava-tests/test/com/google/common/math/PairedStatsAccumulatorTest.java169
-rw-r--r--android/guava-tests/test/com/google/common/math/PairedStatsTest.java116
-rw-r--r--android/guava-tests/test/com/google/common/math/QuantilesTest.java123
-rw-r--r--android/guava-tests/test/com/google/common/math/StatsAccumulatorTest.java167
-rw-r--r--android/guava-tests/test/com/google/common/math/StatsTest.java135
-rw-r--r--android/guava-tests/test/com/google/common/math/StatsTesting.java9
-rw-r--r--android/guava-tests/test/com/google/common/net/InetAddressesTest.java219
-rw-r--r--android/guava-tests/test/com/google/common/net/MediaTypeTest.java21
-rw-r--r--android/guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java35
-rw-r--r--android/guava-tests/test/com/google/common/reflect/ImmutableTypeToInstanceMapTest.java16
-rw-r--r--android/guava-tests/test/com/google/common/reflect/InvokableTest.java23
-rw-r--r--android/guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java58
-rw-r--r--android/guava-tests/test/com/google/common/reflect/ReflectionTest.java9
-rw-r--r--android/guava-tests/test/com/google/common/reflect/TypeParameterTest.java8
-rw-r--r--android/guava-tests/test/com/google/common/reflect/TypeResolverTest.java112
-rw-r--r--android/guava-tests/test/com/google/common/reflect/TypeTokenResolutionTest.java7
-rw-r--r--android/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java17
-rw-r--r--android/guava-tests/test/com/google/common/reflect/TypeTokenTest.java78
-rw-r--r--android/guava-tests/test/com/google/common/reflect/TypesTest.java55
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/AbstractChainedListenableFutureTest.java7
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/AbstractClosingFutureTest.java13
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java63
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java27
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java66
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/AbstractIdleServiceTest.java52
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java67
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java129
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java62
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/AtomicsTest.java26
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToFutureTest.java21
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToValueAndCloserTest.java23
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java187
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/FakeTimeLimiterTest.java54
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java9
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedInputs.java42
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java294
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java49
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java13
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java10
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java7
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java21
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/RateLimiterTest.java61
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java28
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java69
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java56
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/SimpleTimeLimiterTest.java95
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/SupplementalMonitorTest.java25
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java15
-rw-r--r--android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java19
-rw-r--r--android/guava/pom.xml12
-rw-r--r--android/guava/src/com/google/common/base/CharMatcher.java28
-rw-r--r--android/guava/src/com/google/common/base/Converter.java2
-rw-r--r--android/guava/src/com/google/common/base/Joiner.java13
-rw-r--r--android/guava/src/com/google/common/base/MoreObjects.java2
-rw-r--r--android/guava/src/com/google/common/base/PatternCompiler.java7
-rw-r--r--android/guava/src/com/google/common/base/Platform.java8
-rw-r--r--android/guava/src/com/google/common/base/Splitter.java7
-rw-r--r--android/guava/src/com/google/common/base/Throwables.java44
-rw-r--r--android/guava/src/com/google/common/base/internal/Finalizer.java65
-rw-r--r--android/guava/src/com/google/common/cache/CacheBuilder.java4
-rw-r--r--android/guava/src/com/google/common/cache/LocalCache.java39
-rw-r--r--android/guava/src/com/google/common/collect/AbstractBiMap.java3
-rw-r--r--android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java4
-rw-r--r--android/guava/src/com/google/common/collect/CartesianList.java11
-rw-r--r--android/guava/src/com/google/common/collect/CollectCollectors.java473
-rw-r--r--android/guava/src/com/google/common/collect/Comparators.java62
-rw-r--r--android/guava/src/com/google/common/collect/ConcurrentHashMultiset.java3
-rw-r--r--android/guava/src/com/google/common/collect/ContiguousSet.java10
-rw-r--r--android/guava/src/com/google/common/collect/DenseImmutableTable.java51
-rw-r--r--android/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java9
-rw-r--r--android/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java9
-rw-r--r--android/guava/src/com/google/common/collect/EnumBiMap.java5
-rw-r--r--android/guava/src/com/google/common/collect/EnumHashBiMap.java3
-rw-r--r--android/guava/src/com/google/common/collect/EnumMultiset.java3
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableBiMap.java61
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableCollection.java9
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableList.java40
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableListMultimap.java96
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableMap.java72
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java9
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableMapKeySet.java3
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableMapValues.java9
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableMultimap.java18
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableMultiset.java33
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableRangeMap.java32
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableRangeSet.java30
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableSet.java16
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableSetMultimap.java99
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableSortedMap.java353
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java285
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableSortedMultiset.java225
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java177
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableSortedSet.java167
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java193
-rw-r--r--android/guava/src/com/google/common/collect/ImmutableTable.java52
-rw-r--r--android/guava/src/com/google/common/collect/IndexedImmutableSet.java19
-rw-r--r--android/guava/src/com/google/common/collect/Iterators.java81
-rw-r--r--android/guava/src/com/google/common/collect/LinkedHashMultimap.java8
-rw-r--r--android/guava/src/com/google/common/collect/LinkedListMultimap.java2
-rw-r--r--android/guava/src/com/google/common/collect/Lists.java9
-rw-r--r--android/guava/src/com/google/common/collect/Maps.java44
-rw-r--r--android/guava/src/com/google/common/collect/MinMaxPriorityQueue.java2
-rw-r--r--android/guava/src/com/google/common/collect/MoreCollectors.java175
-rw-r--r--android/guava/src/com/google/common/collect/Multimaps.java112
-rw-r--r--android/guava/src/com/google/common/collect/Multisets.java31
-rw-r--r--android/guava/src/com/google/common/collect/RegularContiguousSet.java9
-rw-r--r--android/guava/src/com/google/common/collect/RegularImmutableAsList.java10
-rw-r--r--android/guava/src/com/google/common/collect/RegularImmutableBiMap.java11
-rw-r--r--android/guava/src/com/google/common/collect/RegularImmutableList.java11
-rw-r--r--android/guava/src/com/google/common/collect/RegularImmutableMap.java43
-rw-r--r--android/guava/src/com/google/common/collect/RegularImmutableMultiset.java13
-rw-r--r--android/guava/src/com/google/common/collect/RegularImmutableSet.java11
-rw-r--r--android/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java9
-rw-r--r--android/guava/src/com/google/common/collect/RegularImmutableSortedSet.java10
-rw-r--r--android/guava/src/com/google/common/collect/RegularImmutableTable.java26
-rw-r--r--android/guava/src/com/google/common/collect/Sets.java28
-rw-r--r--android/guava/src/com/google/common/collect/SingletonImmutableSet.java11
-rw-r--r--android/guava/src/com/google/common/collect/SingletonImmutableTable.java6
-rw-r--r--android/guava/src/com/google/common/collect/SparseImmutableTable.java6
-rw-r--r--android/guava/src/com/google/common/collect/StandardTable.java4
-rw-r--r--android/guava/src/com/google/common/collect/Synchronized.java47
-rw-r--r--android/guava/src/com/google/common/collect/TableCollectors.java2
-rw-r--r--android/guava/src/com/google/common/collect/Tables.java61
-rw-r--r--android/guava/src/com/google/common/collect/TopKSelector.java7
-rw-r--r--android/guava/src/com/google/common/collect/TransformedListIterator.java2
-rw-r--r--android/guava/src/com/google/common/collect/TreeMultiset.java2
-rw-r--r--android/guava/src/com/google/common/escape/Platform.java5
-rw-r--r--android/guava/src/com/google/common/eventbus/Dispatcher.java4
-rw-r--r--android/guava/src/com/google/common/graph/StandardMutableValueGraph.java9
-rw-r--r--android/guava/src/com/google/common/hash/BloomFilter.java7
-rw-r--r--android/guava/src/com/google/common/io/BaseEncoding.java2
-rw-r--r--android/guava/src/com/google/common/io/TempFileCreator.java77
-rw-r--r--android/guava/src/com/google/common/net/HostAndPort.java2
-rw-r--r--android/guava/src/com/google/common/net/HttpHeaders.java19
-rw-r--r--android/guava/src/com/google/common/net/InetAddresses.java4
-rw-r--r--android/guava/src/com/google/common/net/MediaType.java14
-rw-r--r--android/guava/src/com/google/common/primitives/Doubles.java2
-rw-r--r--android/guava/src/com/google/common/primitives/Floats.java2
-rw-r--r--android/guava/src/com/google/common/primitives/Ints.java2
-rw-r--r--android/guava/src/com/google/common/primitives/Longs.java2
-rw-r--r--android/guava/src/com/google/common/primitives/Shorts.java2
-rw-r--r--android/guava/src/com/google/common/reflect/Invokable.java58
-rw-r--r--android/guava/src/com/google/common/reflect/Parameter.java24
-rw-r--r--android/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java4
-rw-r--r--android/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java14
-rw-r--r--android/guava/src/com/google/common/util/concurrent/AbstractFuture.java56
-rw-r--r--android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java17
-rw-r--r--android/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java3
-rw-r--r--android/guava/src/com/google/common/util/concurrent/AggregateFuture.java7
-rw-r--r--android/guava/src/com/google/common/util/concurrent/AggregateFutureState.java11
-rw-r--r--android/guava/src/com/google/common/util/concurrent/ClosingFuture.java48
-rw-r--r--android/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java11
-rw-r--r--android/guava/src/com/google/common/util/concurrent/ExecutionList.java18
-rw-r--r--android/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java3
-rw-r--r--android/guava/src/com/google/common/util/concurrent/Futures.java22
-rw-r--r--android/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java22
-rw-r--r--android/guava/src/com/google/common/util/concurrent/ImmediateFuture.java18
-rw-r--r--android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java2
-rw-r--r--android/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java8
-rw-r--r--android/guava/src/com/google/common/util/concurrent/LazyLogger.java56
-rw-r--r--android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java29
-rw-r--r--android/guava/src/com/google/common/util/concurrent/Monitor.java3
-rw-r--r--android/guava/src/com/google/common/util/concurrent/MoreExecutors.java12
-rw-r--r--android/guava/src/com/google/common/util/concurrent/SequentialExecutor.java11
-rw-r--r--android/guava/src/com/google/common/util/concurrent/ServiceManager.java40
-rw-r--r--android/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java13
-rw-r--r--android/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java16
-rw-r--r--android/pom.xml87
-rw-r--r--futures/failureaccess/pom.xml34
-rw-r--r--guava-gwt/pom.xml4
-rw-r--r--guava-gwt/src-super/com/google/common/base/super/com/google/common/base/ExtraObjectsMethodsForWeb.java2
-rw-r--r--guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableCollection.java9
-rw-r--r--guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableList.java4
-rw-r--r--guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableMap.java3
-rw-r--r--guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/RegularImmutableList.java4
-rw-r--r--guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/RegularImmutableMap.java2
-rw-r--r--guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/DoublesMethodsForWeb.java2
-rw-r--r--guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/FloatsMethodsForWeb.java2
-rw-r--r--guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/IntsMethodsForWeb.java2
-rw-r--r--guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/ShortsMethodsForWeb.java2
-rw-r--r--guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/ListenableFuture.java12
-rw-r--r--guava-gwt/test-super/com/google/common/collect/testing/super/com/google/common/collect/testing/testers/Platform.java7
-rw-r--r--guava-testlib/README.md12
-rw-r--r--guava-testlib/src/com/google/common/collect/testing/AbstractIteratorTester.java20
-rw-r--r--guava-testlib/src/com/google/common/collect/testing/AbstractTester.java5
-rw-r--r--guava-testlib/src/com/google/common/collect/testing/IteratorFeature.java11
-rw-r--r--guava-testlib/src/com/google/common/collect/testing/MapInterfaceTest.java12
-rw-r--r--guava-testlib/src/com/google/common/collect/testing/SpliteratorTester.java10
-rw-r--r--guava-testlib/src/com/google/common/collect/testing/google/AbstractMultisetSetCountTester.java16
-rw-r--r--guava-testlib/src/com/google/common/collect/testing/google/UnmodifiableCollectionTests.java5
-rw-r--r--guava-testlib/src/com/google/common/collect/testing/testers/NavigableMapNavigationTester.java13
-rw-r--r--guava-testlib/src/com/google/common/collect/testing/testers/NavigableSetNavigationTester.java13
-rw-r--r--guava-testlib/src/com/google/common/testing/ArbitraryInstances.java4
-rw-r--r--guava-testlib/src/com/google/common/testing/ClassSanityTester.java6
-rw-r--r--guava-testlib/src/com/google/common/testing/CollectorTester.java1
-rw-r--r--guava-testlib/src/com/google/common/testing/EqualsTester.java10
-rw-r--r--guava-testlib/src/com/google/common/testing/NullPointerTester.java24
-rw-r--r--guava-testlib/src/com/google/common/testing/Platform.java3
-rw-r--r--guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java47
-rw-r--r--guava-testlib/test/com/google/common/collect/testing/features/FeatureUtilTest.java34
-rw-r--r--guava-testlib/test/com/google/common/testing/ArbitraryInstancesTest.java7
-rw-r--r--guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java98
-rw-r--r--guava-testlib/test/com/google/common/testing/GcFinalizationTest.java52
-rw-r--r--guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java13
-rw-r--r--guava-testlib/test/com/google/common/testing/anotherpackage/ForwardingWrapperTesterTest.java12
-rw-r--r--guava-testlib/test/com/google/common/util/concurrent/testing/TestingExecutorsTest.java16
-rw-r--r--guava-tests/pom.xml2
-rw-r--r--guava-tests/test/com/google/common/base/ConverterTest.java6
-rw-r--r--guava-tests/test/com/google/common/base/DefaultsTest.java2
-rw-r--r--guava-tests/test/com/google/common/base/EnumsTest.java7
-rw-r--r--guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java2
-rw-r--r--guava-tests/test/com/google/common/base/PackageSanityTests.java2
-rw-r--r--guava-tests/test/com/google/common/base/PreconditionsTest.java34
-rw-r--r--guava-tests/test/com/google/common/base/PredicatesTest.java7
-rw-r--r--guava-tests/test/com/google/common/base/SplitterTest.java7
-rw-r--r--guava-tests/test/com/google/common/base/StandardSystemPropertyTest.java2
-rw-r--r--guava-tests/test/com/google/common/base/SuppliersTest.java9
-rw-r--r--guava-tests/test/com/google/common/base/ThrowablesTest.java129
-rw-r--r--guava-tests/test/com/google/common/base/UnannotatedJavaClass.java26
-rw-r--r--guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java37
-rw-r--r--guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java145
-rw-r--r--guava-tests/test/com/google/common/cache/CacheBuilderTest.java147
-rw-r--r--guava-tests/test/com/google/common/cache/CacheLoadingTest.java306
-rw-r--r--guava-tests/test/com/google/common/cache/EmptyCachesTest.java79
-rw-r--r--guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java30
-rw-r--r--guava-tests/test/com/google/common/cache/LocalCacheTest.java79
-rw-r--r--guava-tests/test/com/google/common/cache/NullCacheTest.java17
-rw-r--r--guava-tests/test/com/google/common/cache/PopulatedCachesTest.java7
-rw-r--r--guava-tests/test/com/google/common/collect/AbstractFilteredMapTest.java212
-rw-r--r--guava-tests/test/com/google/common/collect/AbstractHashFloodingTest.java5
-rw-r--r--guava-tests/test/com/google/common/collect/AbstractMapsTransformValuesTest.java275
-rw-r--r--guava-tests/test/com/google/common/collect/Base.java54
-rw-r--r--guava-tests/test/com/google/common/collect/CompactHashMapFloodingTest.java2
-rw-r--r--guava-tests/test/com/google/common/collect/CompactHashSetFloodingTest.java2
-rw-r--r--guava-tests/test/com/google/common/collect/CompactLinkedHashMapFloodingTest.java2
-rw-r--r--guava-tests/test/com/google/common/collect/CompactLinkedHashSetFloodingTest.java2
-rw-r--r--guava-tests/test/com/google/common/collect/ComparatorsTest.java16
-rw-r--r--guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java13
-rw-r--r--guava-tests/test/com/google/common/collect/ContiguousSetTest.java26
-rw-r--r--guava-tests/test/com/google/common/collect/Derived.java29
-rw-r--r--guava-tests/test/com/google/common/collect/DiscreteDomainTest.java49
-rw-r--r--guava-tests/test/com/google/common/collect/FauxveridesTest.java25
-rw-r--r--guava-tests/test/com/google/common/collect/FilteredBiMapTest.java2
-rw-r--r--guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java19
-rw-r--r--guava-tests/test/com/google/common/collect/FilteredMapTest.java186
-rw-r--r--guava-tests/test/com/google/common/collect/FilteredSortedMapTest.java4
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableBiMapFloodingTest.java4
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java13
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java4
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableListTest.java1
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableMapFloodingTest.java4
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableMapTest.java1
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java1
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableMultisetFloodingTest.java4
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java1
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java21
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java52
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableSetFloodingTest.java4
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java4
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableSetTest.java7
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java1
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java84
-rw-r--r--guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java1
-rw-r--r--guava-tests/test/com/google/common/collect/InternersTest.java26
-rw-r--r--guava-tests/test/com/google/common/collect/IterablesTest.java1
-rw-r--r--guava-tests/test/com/google/common/collect/IteratorsTest.java40
-rw-r--r--guava-tests/test/com/google/common/collect/ListsImplTest.java2
-rw-r--r--guava-tests/test/com/google/common/collect/MapsSortedTransformValuesTest.java3
-rw-r--r--guava-tests/test/com/google/common/collect/MapsTest.java36
-rw-r--r--guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java269
-rw-r--r--guava-tests/test/com/google/common/collect/MultimapsTest.java4
-rw-r--r--guava-tests/test/com/google/common/collect/MultisetsTest.java1
-rw-r--r--guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java14
-rw-r--r--guava-tests/test/com/google/common/collect/OrderingTest.java13
-rw-r--r--guava-tests/test/com/google/common/collect/QueuesTest.java15
-rw-r--r--guava-tests/test/com/google/common/collect/RangeTest.java2
-rw-r--r--guava-tests/test/com/google/common/collect/SetsTest.java58
-rw-r--r--guava-tests/test/com/google/common/collect/StreamsTest.java85
-rw-r--r--guava-tests/test/com/google/common/collect/TablesTest.java31
-rw-r--r--guava-tests/test/com/google/common/collect/TreeRangeMapTest.java17
-rw-r--r--guava-tests/test/com/google/common/collect/WriteReplaceOverridesTest.java118
-rw-r--r--guava-tests/test/com/google/common/eventbus/EventBusTest.java22
-rw-r--r--guava-tests/test/com/google/common/eventbus/SubscriberRegistryTest.java21
-rw-r--r--guava-tests/test/com/google/common/eventbus/SubscriberTest.java18
-rw-r--r--guava-tests/test/com/google/common/graph/AbstractGraphTest.java84
-rw-r--r--guava-tests/test/com/google/common/graph/AbstractNetworkTest.java138
-rw-r--r--guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java87
-rw-r--r--guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java253
-rw-r--r--guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java68
-rw-r--r--guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java233
-rw-r--r--guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java48
-rw-r--r--guava-tests/test/com/google/common/graph/EndpointPairTest.java15
-rw-r--r--guava-tests/test/com/google/common/graph/GraphsTest.java78
-rw-r--r--guava-tests/test/com/google/common/graph/PackageSanityTests.java6
-rw-r--r--guava-tests/test/com/google/common/graph/TraverserTest.java120
-rw-r--r--guava-tests/test/com/google/common/graph/ValueGraphTest.java134
-rw-r--r--guava-tests/test/com/google/common/hash/AbstractByteHasherTest.java19
-rw-r--r--guava-tests/test/com/google/common/hash/AbstractStreamingHasherTest.java19
-rw-r--r--guava-tests/test/com/google/common/hash/BloomFilterTest.java119
-rw-r--r--guava-tests/test/com/google/common/hash/HashCodeTest.java43
-rw-r--r--guava-tests/test/com/google/common/hash/HashingTest.java49
-rw-r--r--guava-tests/test/com/google/common/hash/MacHashFunctionTest.java13
-rw-r--r--guava-tests/test/com/google/common/hash/MessageDigestHashFunctionTest.java14
-rw-r--r--guava-tests/test/com/google/common/io/AppendableWriterTest.java14
-rw-r--r--guava-tests/test/com/google/common/io/ByteSinkTest.java23
-rw-r--r--guava-tests/test/com/google/common/io/ByteSourceTest.java35
-rw-r--r--guava-tests/test/com/google/common/io/ByteSourceTester.java21
-rw-r--r--guava-tests/test/com/google/common/io/ByteStreamsTest.java150
-rw-r--r--guava-tests/test/com/google/common/io/CharSequenceReaderTest.java98
-rw-r--r--guava-tests/test/com/google/common/io/CharSinkTest.java19
-rw-r--r--guava-tests/test/com/google/common/io/CharSourceTest.java23
-rw-r--r--guava-tests/test/com/google/common/io/CharStreamsTest.java22
-rw-r--r--guava-tests/test/com/google/common/io/CountingInputStreamTest.java17
-rw-r--r--guava-tests/test/com/google/common/io/CountingOutputStreamTest.java8
-rw-r--r--guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java6
-rw-r--r--guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java43
-rw-r--r--guava-tests/test/com/google/common/io/FilesTest.java94
-rw-r--r--guava-tests/test/com/google/common/io/LittleEndianDataInputStreamTest.java22
-rw-r--r--guava-tests/test/com/google/common/io/MoreFilesTest.java53
-rw-r--r--guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java8
-rw-r--r--guava-tests/test/com/google/common/io/ResourcesTest.java42
-rw-r--r--guava-tests/test/com/google/common/math/BigDecimalMathTest.java11
-rw-r--r--guava-tests/test/com/google/common/math/DoubleUtilsTest.java7
-rw-r--r--guava-tests/test/com/google/common/math/LinearTransformationTest.java115
-rw-r--r--guava-tests/test/com/google/common/math/PairedStatsAccumulatorTest.java169
-rw-r--r--guava-tests/test/com/google/common/math/PairedStatsTest.java116
-rw-r--r--guava-tests/test/com/google/common/math/QuantilesTest.java123
-rw-r--r--guava-tests/test/com/google/common/math/StatsAccumulatorTest.java167
-rw-r--r--guava-tests/test/com/google/common/math/StatsTest.java159
-rw-r--r--guava-tests/test/com/google/common/math/StatsTesting.java18
-rw-r--r--guava-tests/test/com/google/common/net/InetAddressesTest.java219
-rw-r--r--guava-tests/test/com/google/common/net/MediaTypeTest.java21
-rw-r--r--guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java35
-rw-r--r--guava-tests/test/com/google/common/reflect/ImmutableTypeToInstanceMapTest.java16
-rw-r--r--guava-tests/test/com/google/common/reflect/InvokableTest.java23
-rw-r--r--guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java58
-rw-r--r--guava-tests/test/com/google/common/reflect/ReflectionTest.java9
-rw-r--r--guava-tests/test/com/google/common/reflect/TypeParameterTest.java8
-rw-r--r--guava-tests/test/com/google/common/reflect/TypeResolverTest.java112
-rw-r--r--guava-tests/test/com/google/common/reflect/TypeTokenResolutionTest.java7
-rw-r--r--guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java17
-rw-r--r--guava-tests/test/com/google/common/reflect/TypeTokenTest.java78
-rw-r--r--guava-tests/test/com/google/common/reflect/TypesTest.java55
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/AbstractChainedListenableFutureTest.java7
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/AbstractClosingFutureTest.java13
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java63
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java27
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java66
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/AbstractIdleServiceTest.java52
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java67
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java129
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java61
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/AtomicsTest.java26
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToFutureTest.java21
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToValueAndCloserTest.java23
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java187
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/FakeTimeLimiterTest.java54
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java9
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedInputs.java42
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java294
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java49
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java13
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java10
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java7
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java21
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/RateLimiterTest.java61
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java28
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java73
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java56
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/SimpleTimeLimiterTest.java95
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/SupplementalMonitorTest.java25
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java15
-rw-r--r--guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java19
-rw-r--r--guava/module.json118
-rw-r--r--guava/pom.xml12
-rw-r--r--guava/src/com/google/common/base/CharMatcher.java28
-rw-r--r--guava/src/com/google/common/base/Converter.java2
-rw-r--r--guava/src/com/google/common/base/Joiner.java13
-rw-r--r--guava/src/com/google/common/base/MoreObjects.java2
-rw-r--r--guava/src/com/google/common/base/PatternCompiler.java7
-rw-r--r--guava/src/com/google/common/base/Splitter.java7
-rw-r--r--guava/src/com/google/common/base/Throwables.java44
-rw-r--r--guava/src/com/google/common/base/internal/Finalizer.java65
-rw-r--r--guava/src/com/google/common/cache/CacheBuilder.java4
-rw-r--r--guava/src/com/google/common/cache/LocalCache.java54
-rw-r--r--guava/src/com/google/common/collect/AbstractBiMap.java3
-rw-r--r--guava/src/com/google/common/collect/AbstractMapBasedMultimap.java4
-rw-r--r--guava/src/com/google/common/collect/CartesianList.java11
-rw-r--r--guava/src/com/google/common/collect/CollectCollectors.java17
-rw-r--r--guava/src/com/google/common/collect/ConcurrentHashMultiset.java3
-rw-r--r--guava/src/com/google/common/collect/ContiguousSet.java10
-rw-r--r--guava/src/com/google/common/collect/DenseImmutableTable.java51
-rw-r--r--guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java9
-rw-r--r--guava/src/com/google/common/collect/DescendingImmutableSortedSet.java9
-rw-r--r--guava/src/com/google/common/collect/EnumBiMap.java5
-rw-r--r--guava/src/com/google/common/collect/EnumHashBiMap.java3
-rw-r--r--guava/src/com/google/common/collect/EnumMultiset.java3
-rw-r--r--guava/src/com/google/common/collect/HashBiMap.java8
-rw-r--r--guava/src/com/google/common/collect/ImmutableBiMap.java40
-rw-r--r--guava/src/com/google/common/collect/ImmutableBiMapFauxverideShim.java70
-rw-r--r--guava/src/com/google/common/collect/ImmutableCollection.java4
-rw-r--r--guava/src/com/google/common/collect/ImmutableList.java28
-rw-r--r--guava/src/com/google/common/collect/ImmutableListMultimap.java6
-rw-r--r--guava/src/com/google/common/collect/ImmutableMap.java43
-rw-r--r--guava/src/com/google/common/collect/ImmutableMapEntrySet.java9
-rw-r--r--guava/src/com/google/common/collect/ImmutableMapKeySet.java9
-rw-r--r--guava/src/com/google/common/collect/ImmutableMapValues.java18
-rw-r--r--guava/src/com/google/common/collect/ImmutableMultimap.java18
-rw-r--r--guava/src/com/google/common/collect/ImmutableMultiset.java11
-rw-r--r--guava/src/com/google/common/collect/ImmutableRangeMap.java16
-rw-r--r--guava/src/com/google/common/collect/ImmutableRangeSet.java17
-rw-r--r--guava/src/com/google/common/collect/ImmutableSet.java30
-rw-r--r--guava/src/com/google/common/collect/ImmutableSetMultimap.java14
-rw-r--r--guava/src/com/google/common/collect/ImmutableSortedAsList.java10
-rw-r--r--guava/src/com/google/common/collect/ImmutableSortedMap.java307
-rw-r--r--guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java324
-rw-r--r--guava/src/com/google/common/collect/ImmutableSortedMultiset.java160
-rw-r--r--guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java214
-rw-r--r--guava/src/com/google/common/collect/ImmutableSortedSet.java151
-rw-r--r--guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java208
-rw-r--r--guava/src/com/google/common/collect/ImmutableTable.java9
-rw-r--r--guava/src/com/google/common/collect/IndexedImmutableSet.java19
-rw-r--r--guava/src/com/google/common/collect/Iterators.java81
-rw-r--r--guava/src/com/google/common/collect/JdkBackedImmutableBiMap.java20
-rw-r--r--guava/src/com/google/common/collect/JdkBackedImmutableMap.java11
-rw-r--r--guava/src/com/google/common/collect/JdkBackedImmutableMultiset.java11
-rw-r--r--guava/src/com/google/common/collect/JdkBackedImmutableSet.java11
-rw-r--r--guava/src/com/google/common/collect/LinkedHashMultimap.java8
-rw-r--r--guava/src/com/google/common/collect/LinkedListMultimap.java2
-rw-r--r--guava/src/com/google/common/collect/Lists.java9
-rw-r--r--guava/src/com/google/common/collect/Maps.java34
-rw-r--r--guava/src/com/google/common/collect/MinMaxPriorityQueue.java2
-rw-r--r--guava/src/com/google/common/collect/Multimaps.java21
-rw-r--r--guava/src/com/google/common/collect/Multisets.java7
-rw-r--r--guava/src/com/google/common/collect/Platform.java4
-rw-r--r--guava/src/com/google/common/collect/RegularContiguousSet.java9
-rw-r--r--guava/src/com/google/common/collect/RegularImmutableAsList.java10
-rw-r--r--guava/src/com/google/common/collect/RegularImmutableBiMap.java29
-rw-r--r--guava/src/com/google/common/collect/RegularImmutableList.java13
-rw-r--r--guava/src/com/google/common/collect/RegularImmutableMap.java27
-rw-r--r--guava/src/com/google/common/collect/RegularImmutableMultiset.java11
-rw-r--r--guava/src/com/google/common/collect/RegularImmutableSet.java11
-rw-r--r--guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java9
-rw-r--r--guava/src/com/google/common/collect/RegularImmutableSortedSet.java10
-rw-r--r--guava/src/com/google/common/collect/RegularImmutableTable.java26
-rw-r--r--guava/src/com/google/common/collect/Sets.java15
-rw-r--r--guava/src/com/google/common/collect/SingletonImmutableBiMap.java11
-rw-r--r--guava/src/com/google/common/collect/SingletonImmutableList.java11
-rw-r--r--guava/src/com/google/common/collect/SingletonImmutableSet.java11
-rw-r--r--guava/src/com/google/common/collect/SingletonImmutableTable.java6
-rw-r--r--guava/src/com/google/common/collect/SparseImmutableTable.java6
-rw-r--r--guava/src/com/google/common/collect/StandardTable.java4
-rw-r--r--guava/src/com/google/common/collect/Streams.java33
-rw-r--r--guava/src/com/google/common/collect/Synchronized.java64
-rw-r--r--guava/src/com/google/common/collect/TableCollectors.java2
-rw-r--r--guava/src/com/google/common/collect/Tables.java7
-rw-r--r--guava/src/com/google/common/collect/TransformedListIterator.java2
-rw-r--r--guava/src/com/google/common/collect/TreeMultiset.java2
-rw-r--r--guava/src/com/google/common/escape/Platform.java5
-rw-r--r--guava/src/com/google/common/eventbus/Dispatcher.java4
-rw-r--r--guava/src/com/google/common/graph/StandardMutableValueGraph.java9
-rw-r--r--guava/src/com/google/common/hash/BloomFilter.java7
-rw-r--r--guava/src/com/google/common/io/BaseEncoding.java2
-rw-r--r--guava/src/com/google/common/io/TempFileCreator.java77
-rw-r--r--guava/src/com/google/common/net/HostAndPort.java2
-rw-r--r--guava/src/com/google/common/net/HttpHeaders.java19
-rw-r--r--guava/src/com/google/common/net/InetAddresses.java4
-rw-r--r--guava/src/com/google/common/net/MediaType.java14
-rw-r--r--guava/src/com/google/common/primitives/Doubles.java2
-rw-r--r--guava/src/com/google/common/primitives/Floats.java2
-rw-r--r--guava/src/com/google/common/primitives/Ints.java2
-rw-r--r--guava/src/com/google/common/primitives/Longs.java2
-rw-r--r--guava/src/com/google/common/primitives/Shorts.java2
-rw-r--r--guava/src/com/google/common/reflect/Invokable.java25
-rw-r--r--guava/src/com/google/common/reflect/Parameter.java21
-rw-r--r--guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java4
-rw-r--r--guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java14
-rw-r--r--guava/src/com/google/common/util/concurrent/AbstractFuture.java56
-rw-r--r--guava/src/com/google/common/util/concurrent/AbstractScheduledService.java17
-rw-r--r--guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java3
-rw-r--r--guava/src/com/google/common/util/concurrent/AggregateFuture.java7
-rw-r--r--guava/src/com/google/common/util/concurrent/AggregateFutureState.java11
-rw-r--r--guava/src/com/google/common/util/concurrent/AtomicLongMap.java10
-rw-r--r--guava/src/com/google/common/util/concurrent/ClosingFuture.java43
-rw-r--r--guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java11
-rw-r--r--guava/src/com/google/common/util/concurrent/ExecutionList.java18
-rw-r--r--guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java3
-rw-r--r--guava/src/com/google/common/util/concurrent/Futures.java22
-rw-r--r--guava/src/com/google/common/util/concurrent/FuturesGetChecked.java22
-rw-r--r--guava/src/com/google/common/util/concurrent/ImmediateFuture.java18
-rw-r--r--guava/src/com/google/common/util/concurrent/InterruptibleTask.java2
-rw-r--r--guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java8
-rw-r--r--guava/src/com/google/common/util/concurrent/LazyLogger.java56
-rw-r--r--guava/src/com/google/common/util/concurrent/ListenerCallQueue.java29
-rw-r--r--guava/src/com/google/common/util/concurrent/Monitor.java3
-rw-r--r--guava/src/com/google/common/util/concurrent/MoreExecutors.java12
-rw-r--r--guava/src/com/google/common/util/concurrent/SequentialExecutor.java11
-rw-r--r--guava/src/com/google/common/util/concurrent/ServiceManager.java40
-rw-r--r--guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java13
-rw-r--r--guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java16
-rw-r--r--integration-tests/gradle/build.gradle.kts17
-rw-r--r--integration-tests/gradle/gradle/wrapper/gradle-wrapper.jarbin61624 -> 63721 bytes
-rw-r--r--integration-tests/gradle/gradle/wrapper/gradle-wrapper.properties3
-rwxr-xr-xintegration-tests/gradle/gradlew29
-rwxr-xr-xmvnw308
-rw-r--r--mvnw.cmd205
-rw-r--r--pom.xml74
-rw-r--r--proguard/reflect.pro9
-rwxr-xr-xutil/deploy_snapshot.sh2
-rwxr-xr-xutil/gradle_integration_tests.sh4
646 files changed, 13170 insertions, 15846 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml
new file mode 100644
index 000000000..bde97df8e
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.yaml
@@ -0,0 +1,83 @@
+name: Bug Report
+description: Something is not working as expected
+labels: ["type=defect"]
+body:
+ - type: markdown
+ attributes:
+ value: >
+ Thank you for filing a bug report. Please help us identify and resolve the bug by filling
+ out the following fields.
+
+ - type: textarea
+ attributes:
+ label: Description
+ description: Please describe the issue you encountered.
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: Example
+ description: >
+ Please provide a [Short, Self Contained, Correct (Compilable), Example](http://sscce.org/)
+ demonstrating the bug.
+ render: java
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: Expected Behavior
+ description: What did you expect to happen?
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: Actual Behavior
+ description: What actually happened?
+ validations:
+ required: true
+
+ - type: dropdown
+ attributes:
+ label: Packages
+ description: If this issue is package-specific, then please select the relevant packages.
+ multiple: true
+ options:
+ - com.google.common.annotations
+ - com.google.common.base
+ - com.google.common.cache
+ - com.google.common.collect
+ - com.google.common.escape
+ - com.google.common.eventbus
+ - com.google.common.graph
+ - com.google.common.hash
+ - com.google.common.io
+ - com.google.common.math
+ - com.google.common.net
+ - com.google.common.primitives
+ - com.google.common.reflect
+ - com.google.common.testing
+ - com.google.common.util.concurrent
+
+ - type: dropdown
+ attributes:
+ label: Platforms
+ description: If this issue is platform-specific, then please select the relevant platforms.
+ multiple: true
+ options:
+ - Android
+ - GWT
+ - Java 8
+ - Java 11
+ - Java 17
+
+ - type: checkboxes
+ attributes:
+ label: Checklist
+ options:
+ - label: >
+ I agree to follow the
+ [code of conduct](https://github.com/google/.github/blob/master/CODE_OF_CONDUCT.md).
+ required: true
diff --git a/.github/ISSUE_TEMPLATE/feature_addition_request.yaml b/.github/ISSUE_TEMPLATE/feature_addition_request.yaml
new file mode 100644
index 000000000..d86c4ca53
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_addition_request.yaml
@@ -0,0 +1,156 @@
+name: Feature Addition Request
+description: I want to add a new feature
+labels: ["type=addition"]
+body:
+ - type: markdown
+ attributes:
+ value: >
+ Filing feature requests is one of the most popular ways to contribute to Guava.
+
+
+ Be aware, though: most feature requests are not accepted, even if they're suggested by
+ a full-time Guava team member. [Feedback](https://stackoverflow.com/a/4543114) from our
+ users indicates that they really appreciate Guava's high power-to-weight ratio. It's
+ important to us to keep Guava as easy to use and understand as we can. That means boiling
+ features down to compact but powerful abstractions, and controlling feature bloat carefully.
+
+
+ Guava's main yardstick for evaluating proposed features can be summed up as [utility times
+ ubiquity](https://github.com/google/guava/wiki/PhilosophyExplained#utility-times-ubiquity).
+
+
+ #### Utility: compare with alternatives
+
+
+ There is always *some* alternative to adding a new feature to Guava, even if it's just
+ forking Guava yourself.
+
+
+ We want to see that new features have some significant advantage over the alternatives.
+ These advantages can take
+ [many forms](https://github.com/google/guava/wiki/PhilosophyExplained#utility), but taking
+ the time to discuss them in detail will make it much clearer why this feature should be
+ added to Guava.
+
+
+ Please fill out the following fields to give us a better understanding of your proposed
+ feature and its potential value for other Guava users.
+
+ - type: textarea
+ attributes:
+ label: 1. What are you trying to do?
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: 2. What's the best code you can write to accomplish that without the new feature?
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: 3. What would that same code look like if we added your feature?
+ validations:
+ required: true
+
+ - type: markdown
+ attributes:
+ value: >
+ Comparing two approaches to a use case side by side can make it easier to examine the
+ differences between them.
+
+
+ Additionally, it's very useful to us if you can provide a "straw API" &mdash; what the
+ method signatures would look like, for example, even if the method and class names are still
+ in flux. This can make the feature you're suggesting much clearer to us.
+
+ - type: textarea
+ attributes:
+ label: (Optional) What would the method signatures for your feature look like?
+ placeholder: |
+ e.g.,
+ public static <E> ImmutableList<E> of();
+ public static <E> ImmutableList<E> of(E element);
+ public static <E> ImmutableList<E> of(E e1, E e2);
+ ...
+ render: java
+ validations:
+ required: false
+
+ - type: markdown
+ attributes:
+ value: >
+ #### Ubiquity: provide concrete use cases
+
+
+ Did you *actually* encounter the need for this feature in a real-world scenario, or is it
+ just a feature that seems like a sensible addition to Guava?
+
+
+ Before new features get added to Guava, we really want to be sure that it's for a use case
+ that actually comes up in the real world. We want to hear the real-world use case so the
+ community can discuss and debate whether this feature is actually the *best* way to address
+ the real use case, or whether or not a different abstraction might be more appropriate.
+
+
+ It's okay if you can't provide complete context on a use case. We understand if you are not
+ able to discuss the full details of what you're working on.
+
+
+ But Guava aims to provide features that are useful across boundaries of projects, companies,
+ or even industries &mdash; utilities useful for a sizable proportion of all Java programmers
+ everywhere. If you can give enough detail such that any of us can imagine coming across
+ a similar need in our own work, that's extremely helpful in studying how broadly useful the
+ feature will be.
+
+ - type: textarea
+ attributes:
+ label: Concrete Use Cases
+ description: Please provide use cases that actually came up in the real world.
+ validations:
+ required: true
+
+ - type: dropdown
+ attributes:
+ label: Packages
+ description: Please select all of the packages that are relevant to this feature request.
+ multiple: true
+ options:
+ - com.google.common.annotations
+ - com.google.common.base
+ - com.google.common.cache
+ - com.google.common.collect
+ - com.google.common.escape
+ - com.google.common.eventbus
+ - com.google.common.graph
+ - com.google.common.hash
+ - com.google.common.io
+ - com.google.common.math
+ - com.google.common.net
+ - com.google.common.primitives
+ - com.google.common.reflect
+ - com.google.common.testing
+ - com.google.common.util.concurrent
+
+ - type: checkboxes
+ attributes:
+ label: Checklist
+ options:
+ - label: >
+ I agree to follow the
+ [code of conduct](https://github.com/google/.github/blob/master/CODE_OF_CONDUCT.md).
+ required: true
+ - label: >
+ I have read and understood the [contribution
+ guidelines](https://github.com/google/guava/wiki/HowToContribute#feature-requests).
+ required: true
+ - label: >
+ I have read and understood
+ [Guava's philosophy](https://github.com/google/guava/wiki/PhilosophyExplained), and
+ I strongly believe that this proposal aligns with it.
+ required: true
+ - label: >
+ I have visited the [idea graveyard](https://github.com/google/guava/wiki/IdeaGraveyard),
+ and did not see anything similar to this idea.
+ required: true
diff --git a/.github/ISSUE_TEMPLATE/feature_enhancement_request.yaml b/.github/ISSUE_TEMPLATE/feature_enhancement_request.yaml
new file mode 100644
index 000000000..93be44112
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_enhancement_request.yaml
@@ -0,0 +1,108 @@
+name: Feature Enhancement Request
+description: I want to make an existing feature better
+labels: ["type=enhancement"]
+body:
+ - type: markdown
+ attributes:
+ value: >
+ Filing feature requests is one of the most popular ways to contribute to Guava.
+
+
+ Be aware, though: most feature requests are not accepted, even if they're suggested by
+ a full-time Guava team member. [Feedback](https://stackoverflow.com/a/4543114) from our
+ users indicates that they really appreciate Guava's high power-to-weight ratio. It's
+ important to us to keep Guava as easy to use and understand as we can. That means boiling
+ features down to compact but powerful abstractions, and controlling feature bloat carefully.
+
+ - type: textarea
+ attributes:
+ label: API(s)
+ description: Which existing classes or methods do you want to improve?
+ placeholder: e.g., `com.google.common.collect.ImmutableList::of`
+ render: java
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: How do you want it to be improved?
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: Why do we need it to be improved?
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: Example
+ description: >
+ Please provide an example usage of the feature that would be different with the improvement.
+ render: java
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: Current Behavior
+ description: What does the feature currently do?
+ validations:
+ required: true
+
+ - type: textarea
+ attributes:
+ label: Desired Behavior
+ description: What do you want it to do instead?
+ validations:
+ required: true
+
+ - type: markdown
+ attributes:
+ value: >
+ Did you *actually* encounter the need for this enhancement in a real-world scenario, or does
+ it just seem like a sensible behavior for the feature to have?
+
+
+ Before we make significant changes to existing features in Guava, we really want to be sure
+ that it's for a use case that actually comes up in the real world. We want to hear the
+ real-world use case so the community can discuss and debate whether this feature is actually
+ the *best* way to address the real use case, or whether or not a different approach might be
+ more appropriate.
+
+
+ It's okay if you can't provide complete context on a use case. We understand if you are not
+ able to discuss the full details of what you're working on.
+
+
+ But Guava aims to provide functionality that is useful across boundaries of projects,
+ companies, or even industries &mdash; utilities useful for a sizable proportion of all Java
+ programmers everywhere. If you can give enough detail such that any of us can imagine coming
+ across a similar need in our own work, that's extremely helpful in studying how broadly
+ useful the proposed change will be.
+
+ - type: textarea
+ attributes:
+ label: Concrete Use Cases
+ description: Please provide use cases that actually came up in the real world.
+ validations:
+ required: true
+
+ - type: checkboxes
+ attributes:
+ label: Checklist
+ options:
+ - label: >
+ I agree to follow the
+ [code of conduct](https://github.com/google/.github/blob/master/CODE_OF_CONDUCT.md).
+ required: true
+ - label: >
+ I have read and understood the [contribution
+ guidelines](https://github.com/google/guava/wiki/HowToContribute#feature-requests).
+ required: true
+ - label: >
+ I have read and understood
+ [Guava's philosophy](https://github.com/google/guava/wiki/PhilosophyExplained), and
+ I strongly believe that this proposal aligns with it.
+ required: true
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
new file mode 100644
index 000000000..a41327e07
--- /dev/null
+++ b/.github/pull_request_template.md
@@ -0,0 +1,10 @@
+<!--
+Please read the contribution guidelines at
+https://github.com/google/guava/wiki/HowToContribute#code-contributions
+and
+https://github.com/google/guava/blob/master/CONTRIBUTING.md
+before sending a pull request.
+
+We generally welcome PRs for fixing trivial bugs or typos, but please refrain
+from sending a PR with significant changes unless explicitly requested.
+--->
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 23e7c71fc..7e4508d08 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -32,13 +32,13 @@ jobs:
steps:
# Cancel any previous runs for the same branch that are still running.
- name: 'Cancel previous runs'
- uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5
+ uses: styfle/cancel-workflow-action@01ce38bf961b4e243a6342cbade0dbc8ba3f0432
with:
access_token: ${{ github.token }}
- name: 'Check out repository'
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: 'Set up JDK ${{ matrix.java }}'
- uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2
+ uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
with:
java-version: ${{ matrix.java }}
@@ -46,10 +46,10 @@ jobs:
cache: 'maven'
- name: 'Install'
shell: bash
- run: mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn install -U -DskipTests=true -f $ROOT_POM
+ run: ./mvnw -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn install -U -DskipTests=true -f $ROOT_POM
- name: 'Test'
shell: bash
- run: mvn -B -P!standard-with-extra-repos verify -U -Dmaven.javadoc.skip=true -f $ROOT_POM
+ run: ./mvnw -B -P!standard-with-extra-repos verify -U -Dmaven.javadoc.skip=true -f $ROOT_POM
- name: 'Print Surefire reports'
# Note: Normally a step won't run if the job has failed, but this causes it to
if: ${{ failure() }}
@@ -67,9 +67,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Check out repository'
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: 'Set up JDK 11'
- uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2
+ uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
with:
java-version: 11
@@ -93,9 +93,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Check out repository'
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: 'Set up JDK 11'
- uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2
+ uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
with:
java-version: 11
diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml
index 6cd21417d..9e1bf74b3 100644
--- a/.github/workflows/gradle-wrapper-validation.yml
+++ b/.github/workflows/gradle-wrapper-validation.yml
@@ -9,5 +9,5 @@ jobs:
name: "Validation"
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4
diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml
index f41e051c8..44df61b84 100644
--- a/.github/workflows/scorecard.yml
+++ b/.github/workflows/scorecard.yml
@@ -32,12 +32,12 @@ jobs:
steps:
- name: "Checkout code"
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false
- name: "Run analysis"
- uses: ossf/scorecard-action@08b4669551908b1024bb425080c797723083c031 # v2.2.0
+ uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
with:
results_file: results.sarif
results_format: sarif
@@ -59,7 +59,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
+ uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0
with:
name: SARIF file
path: results.sarif
@@ -67,6 +67,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
- uses: github/codeql-action/upload-sarif@1813ca74c3faaa3a2da2070b9b8a0b3e7373a0d8 # v2.21.0
+ uses: github/codeql-action/upload-sarif@b374143c1149a9115d881581d29b8390bbcbb59c # v3.22.11
with:
sarif_file: results.sarif
diff --git a/.gitignore b/.gitignore
index 942c3986a..c6c875cd1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
target/
*.ser
*.ec
+.mvn/wrapper/maven-wrapper.jar
# IntelliJ Idea
.idea/
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
new file mode 100644
index 000000000..e1c4b83d0
--- /dev/null
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
+distributionSha256Sum=7822eb593d29558d8edf87845a2c47e36e2a89d17a84cd2390824633214ed423
+wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
+# TODO: Does not work properly on Windows, see https://issues.apache.org/jira/browse/MWRAPPER-103
+# wrapperSha256Sum=e63a53cfb9c4d291ebe3c2b0edacb7622bbc480326beaa5a0456e412f52f066a
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8e54c6f9a..1c1bd8fba 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -4,10 +4,10 @@ How to contribute
Thank you so much for wanting to contribute to Guava! Here are a few important
things you should know about contributing:
- 1. API changes require discussion, use cases, etc. Code comes later.
- 2. Pull requests are great for small fixes for bugs, documentation, etc.
- 3. Pull requests are not merged directly into the master branch.
- 3. Code contributions require signing a Google CLA.
+1. API changes require discussion, use cases, etc. Code comes later.
+2. Pull requests are great for small fixes for bugs, documentation, etc.
+3. Pull requests are not merged directly into the master branch.
+4. Code contributions require signing a Google CLA.
API changes
-----------
@@ -21,7 +21,7 @@ for it.
If the feature has merit, it will go through a thorough process of API design
and review. Any code should come after this.
-[APIs]: http://en.wikipedia.org/wiki/Application_programming_interface
+[APIs]: https://en.wikipedia.org/wiki/Application_programming_interface
[issue]: https://github.com/google/guava/issues
Pull requests
@@ -53,7 +53,7 @@ Guidelines for any code contributions:
[well-formed commit message][] for the change.
[Java style guide]: https://google.github.io/styleguide/javaguide.html
-[well-formed commit message]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
+[well-formed commit message]: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
#### Merging pull requests ####
diff --git a/METADATA b/METADATA
index d0267190d..aa3faf803 100644
--- a/METADATA
+++ b/METADATA
@@ -1,19 +1,20 @@
+# This project was upgraded with external_updater.
+# Usage: tools/external_updater/updater.sh update guava
+# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md
+
name: "guava"
description: "Google Core Libraries for Java."
third_party {
- url {
- type: HOMEPAGE
- value: "https://github.com/google/guava"
- }
- url {
- type: GIT
- value: "https://github.com/google/guava.git"
- }
- version: "v32.1.2"
license_type: NOTICE
last_upgrade_date {
- year: 2023
- month: 8
- day: 29
+ year: 2024
+ month: 1
+ day: 2
+ }
+ homepage: "https://github.com/google/guava"
+ identifier {
+ type: "Git"
+ value: "https://github.com/google/guava.git"
+ version: "v33.0.0"
}
}
diff --git a/README.md b/README.md
index ea6219ae4..51ec2bea2 100644
--- a/README.md
+++ b/README.md
@@ -17,8 +17,9 @@ other companies as well.
Guava comes in two flavors:
* The JRE flavor requires JDK 1.8 or higher.
-* If you need support for Android, use the Android flavor. You can find the
- Android Guava source in the [`android` directory].
+* If you need support for Android, use
+ [the Android flavor](https://github.com/google/guava/wiki/Android). You can
+ find the Android Guava source in the [`android` directory].
[`android` directory]: https://github.com/google/guava/tree/master/android
@@ -27,8 +28,8 @@ Guava comes in two flavors:
Guava's Maven group ID is `com.google.guava`, and its artifact ID is `guava`.
Guava provides two different "flavors": one for use on a (Java 8+) JRE and one
for use on Android or by any library that wants to be compatible with Android.
-These flavors are specified in the Maven version field as either `32.1.2-jre` or
-`32.1.2-android`. For more about depending on Guava, see
+These flavors are specified in the Maven version field as either `33.0.0-jre` or
+`33.0.0-android`. For more about depending on Guava, see
[using Guava in your build].
To add a dependency on Guava using Maven, use the following:
@@ -37,9 +38,9 @@ To add a dependency on Guava using Maven, use the following:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
- <version>32.1.2-jre</version>
+ <version>33.0.0-jre</version>
<!-- or, for Android: -->
- <version>32.1.2-android</version>
+ <version>33.0.0-android</version>
</dependency>
```
@@ -50,16 +51,16 @@ dependencies {
// Pick one:
// 1. Use Guava in your implementation only:
- implementation("com.google.guava:guava:32.1.2-jre")
+ implementation("com.google.guava:guava:33.0.0-jre")
// 2. Use Guava types in your public API:
- api("com.google.guava:guava:32.1.2-jre")
+ api("com.google.guava:guava:33.0.0-jre")
// 3. Android - Use Guava in your implementation only:
- implementation("com.google.guava:guava:32.1.2-android")
+ implementation("com.google.guava:guava:33.0.0-android")
// 4. Android - Use Guava types in your public API:
- api("com.google.guava:guava:32.1.2-android")
+ api("com.google.guava:guava:33.0.0-android")
}
```
@@ -79,7 +80,7 @@ flavor.
## Learn about Guava
- Our users' guide, [Guava Explained]
-- [A nice collection](http://www.tfnico.com/presentations/google-guava) of
+- [A nice collection](https://www.tfnico.com/presentations/google-guava) of
other helpful links
## Links
@@ -87,8 +88,8 @@ flavor.
- [GitHub project](https://github.com/google/guava)
- [Issue tracker: Report a defect or feature request](https://github.com/google/guava/issues/new)
- [StackOverflow: Ask "how-to" and "why-didn't-it-work" questions](https://stackoverflow.com/questions/ask?tags=guava+java)
-- [guava-announce: Announcements of releases and upcoming significant changes](http://groups.google.com/group/guava-announce)
-- [guava-discuss: For open-ended questions and discussion](http://groups.google.com/group/guava-discuss)
+- [guava-announce: Announcements of releases and upcoming significant changes](https://groups.google.com/group/guava-announce)
+- [guava-discuss: For open-ended questions and discussion](https://groups.google.com/group/guava-discuss)
## IMPORTANT WARNINGS
@@ -107,7 +108,7 @@ flavor.
options open in case of surprises (like, say, a serious security problem).
3. Guava has one dependency that is needed for linkage at runtime:
- `com.google.guava:failureaccess:1.0.1`. It also has
+ `com.google.guava:failureaccess:1.0.2`. It also has
[some annotation-only dependencies][guava-deps], which we discuss in more
detail at that link.
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/AbstractIteratorTester.java b/android/guava-testlib/src/com/google/common/collect/testing/AbstractIteratorTester.java
index b4e5b35e8..f26e6826b 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/AbstractIteratorTester.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/AbstractIteratorTester.java
@@ -58,7 +58,7 @@ abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
static final PermittedMetaException UOE_OR_ISE =
new PermittedMetaException("UnsupportedOperationException or IllegalStateException") {
@Override
- boolean isPermitted(RuntimeException exception) {
+ boolean isPermitted(Exception exception) {
return exception instanceof UnsupportedOperationException
|| exception instanceof IllegalStateException;
}
@@ -66,21 +66,21 @@ abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
static final PermittedMetaException UOE =
new PermittedMetaException("UnsupportedOperationException") {
@Override
- boolean isPermitted(RuntimeException exception) {
+ boolean isPermitted(Exception exception) {
return exception instanceof UnsupportedOperationException;
}
};
static final PermittedMetaException ISE =
new PermittedMetaException("IllegalStateException") {
@Override
- boolean isPermitted(RuntimeException exception) {
+ boolean isPermitted(Exception exception) {
return exception instanceof IllegalStateException;
}
};
static final PermittedMetaException NSEE =
new PermittedMetaException("NoSuchElementException") {
@Override
- boolean isPermitted(RuntimeException exception) {
+ boolean isPermitted(Exception exception) {
return exception instanceof NoSuchElementException;
}
};
@@ -89,9 +89,9 @@ abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
super(message);
}
- abstract boolean isPermitted(RuntimeException exception);
+ abstract boolean isPermitted(Exception exception);
- void assertPermitted(RuntimeException exception) {
+ void assertPermitted(Exception exception) {
if (!isPermitted(exception)) {
String message =
"Exception "
@@ -313,10 +313,11 @@ abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
protected void verify(List<E> elements) {}
/** Executes the test. */
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public final void test() {
try {
recurse(0);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
throw new RuntimeException(Arrays.toString(stimuli), e);
}
}
@@ -372,16 +373,17 @@ abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
*
* @see Stimulus#executeAndCompare(ListIterator, Iterator)
*/
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private <T extends Iterator<E>> void internalExecuteAndCompare(
T reference, T target, IteratorOperation method) {
Object referenceReturnValue = null;
PermittedMetaException referenceException = null;
Object targetReturnValue = null;
- RuntimeException targetException = null;
+ Exception targetException = null;
try {
targetReturnValue = method.execute(target);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
targetException = e;
}
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/AbstractTester.java b/android/guava-testlib/src/com/google/common/collect/testing/AbstractTester.java
index adbc8dcc6..cd9cbfdea 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/AbstractTester.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/AbstractTester.java
@@ -17,6 +17,7 @@
package com.google.common.collect.testing;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import junit.framework.TestCase;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -31,7 +32,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* parameterize the test.
* @author George van den Driessche
*/
-@GwtCompatible
+@GwtCompatible(emulated = true)
public class AbstractTester<G> extends TestCase {
private G subjectGenerator;
private String suiteName;
@@ -73,10 +74,12 @@ public class AbstractTester<G> extends TestCase {
}
/** Returns the name of the test method invoked by this test instance. */
+ @GwtIncompatible // not used under GWT, and super.getName() is not available under J2CL
public final String getTestMethodName() {
return super.getName();
}
+ @GwtIncompatible // not used under GWT, and super.getName() is not available under J2CL
@Override
public String getName() {
return Platform.format("%s[%s]", super.getName(), suiteName);
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/IteratorFeature.java b/android/guava-testlib/src/com/google/common/collect/testing/IteratorFeature.java
index c447e2922..c1e502272 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/IteratorFeature.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/IteratorFeature.java
@@ -16,10 +16,13 @@
package com.google.common.collect.testing;
+import static java.util.Arrays.asList;
+import static java.util.Collections.emptySet;
+import static java.util.Collections.unmodifiableSet;
+
import com.google.common.annotations.GwtCompatible;
-import java.util.Collections;
-import java.util.EnumSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.ListIterator;
import java.util.Set;
@@ -49,12 +52,12 @@ public enum IteratorFeature {
* A set containing none of the optional features of the {@link Iterator} or {@link ListIterator}
* interfaces.
*/
- public static final Set<IteratorFeature> UNMODIFIABLE = Collections.emptySet();
+ public static final Set<IteratorFeature> UNMODIFIABLE = emptySet();
/**
* A set containing all of the optional features of the {@link Iterator} and {@link ListIterator}
* interfaces.
*/
public static final Set<IteratorFeature> MODIFIABLE =
- Collections.unmodifiableSet(EnumSet.allOf(IteratorFeature.class));
+ unmodifiableSet(new LinkedHashSet<>(asList(values())));
}
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/MapInterfaceTest.java b/android/guava-testlib/src/com/google/common/collect/testing/MapInterfaceTest.java
index 484913878..067973c2a 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/MapInterfaceTest.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/MapInterfaceTest.java
@@ -477,8 +477,8 @@ public abstract class MapInterfaceTest<K, V> extends TestCase {
} catch (IllegalStateException expected) {
}
} else {
+ iterator.next();
try {
- iterator.next();
iterator.remove();
fail("Expected UnsupportedOperationException.");
} catch (UnsupportedOperationException expected) {
@@ -729,7 +729,7 @@ public abstract class MapInterfaceTest<K, V> extends TestCase {
try {
entrySet.retainAll(null);
// Returning successfully is not ideal, but tolerated.
- } catch (NullPointerException expected) {
+ } catch (NullPointerException tolerated) {
}
} else {
try {
@@ -1365,7 +1365,7 @@ public abstract class MapInterfaceTest<K, V> extends TestCase {
try {
keySet.retainAll(null);
// Returning successfully is not ideal, but tolerated.
- } catch (NullPointerException expected) {
+ } catch (NullPointerException tolerated) {
}
} else {
try {
@@ -1425,8 +1425,8 @@ public abstract class MapInterfaceTest<K, V> extends TestCase {
} catch (IllegalStateException expected) {
}
} else {
+ iterator.next();
try {
- iterator.next();
iterator.remove();
fail("Expected UnsupportedOperationException.");
} catch (UnsupportedOperationException expected) {
@@ -1527,7 +1527,7 @@ public abstract class MapInterfaceTest<K, V> extends TestCase {
try {
values.removeAll(null);
// Returning successfully is not ideal, but tolerated.
- } catch (NullPointerException expected) {
+ } catch (NullPointerException tolerated) {
}
} else {
try {
@@ -1581,7 +1581,7 @@ public abstract class MapInterfaceTest<K, V> extends TestCase {
try {
values.retainAll(null);
// Returning successfully is not ideal, but tolerated.
- } catch (NullPointerException expected) {
+ } catch (NullPointerException tolerated) {
}
} else {
try {
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/google/AbstractMultisetSetCountTester.java b/android/guava-testlib/src/com/google/common/collect/testing/google/AbstractMultisetSetCountTester.java
index a72fd9fba..cd28cdc28 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/google/AbstractMultisetSetCountTester.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/google/AbstractMultisetSetCountTester.java
@@ -188,9 +188,9 @@ public abstract class AbstractMultisetSetCountTester<E> extends AbstractMultiset
@CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
public void testSetCountZeroToOneConcurrentWithIteration() {
+ Iterator<E> iterator = collection.iterator();
+ assertSetCount(e3(), 1);
try {
- Iterator<E> iterator = collection.iterator();
- assertSetCount(e3(), 1);
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
@@ -200,9 +200,9 @@ public abstract class AbstractMultisetSetCountTester<E> extends AbstractMultiset
@CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
public void testSetCountZeroToOneConcurrentWithEntrySetIteration() {
+ Iterator<Entry<E>> iterator = getMultiset().entrySet().iterator();
+ assertSetCount(e3(), 1);
try {
- Iterator<Entry<E>> iterator = getMultiset().entrySet().iterator();
- assertSetCount(e3(), 1);
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
@@ -248,9 +248,9 @@ public abstract class AbstractMultisetSetCountTester<E> extends AbstractMultiset
@CollectionFeature.Require({SUPPORTS_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
@CollectionSize.Require(absent = ZERO)
public void testSetCountOneToZeroConcurrentWithIteration() {
+ Iterator<E> iterator = collection.iterator();
+ assertSetCount(e0(), 0);
try {
- Iterator<E> iterator = collection.iterator();
- assertSetCount(e0(), 0);
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
@@ -261,9 +261,9 @@ public abstract class AbstractMultisetSetCountTester<E> extends AbstractMultiset
@CollectionFeature.Require({SUPPORTS_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
@CollectionSize.Require(absent = ZERO)
public void testSetCountOneToZeroConcurrentWithEntrySetIteration() {
+ Iterator<Entry<E>> iterator = getMultiset().entrySet().iterator();
+ assertSetCount(e0(), 0);
try {
- Iterator<Entry<E>> iterator = getMultiset().entrySet().iterator();
- assertSetCount(e0(), 0);
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/testers/NavigableMapNavigationTester.java b/android/guava-testlib/src/com/google/common/collect/testing/testers/NavigableMapNavigationTester.java
index ebb86b615..936783e77 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/testers/NavigableMapNavigationTester.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/testers/NavigableMapNavigationTester.java
@@ -20,6 +20,7 @@ import static com.google.common.collect.testing.features.CollectionSize.ONE;
import static com.google.common.collect.testing.features.CollectionSize.SEVERAL;
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.testing.AbstractMapTester;
@@ -162,11 +163,7 @@ public class NavigableMapNavigationTester<K, V> extends AbstractMapTester<K, V>
@MapFeature.Require(absent = SUPPORTS_REMOVE)
public void testPollFirstUnsupported() {
- try {
- navigableMap.pollFirstEntry();
- fail();
- } catch (UnsupportedOperationException e) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> navigableMap.pollFirstEntry());
}
@CollectionSize.Require(SEVERAL)
@@ -229,11 +226,7 @@ public class NavigableMapNavigationTester<K, V> extends AbstractMapTester<K, V>
@MapFeature.Require(absent = SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testPollLastUnsupported() {
- try {
- navigableMap.pollLastEntry();
- fail();
- } catch (UnsupportedOperationException e) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> navigableMap.pollLastEntry());
}
@CollectionSize.Require(SEVERAL)
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/testers/NavigableSetNavigationTester.java b/android/guava-testlib/src/com/google/common/collect/testing/testers/NavigableSetNavigationTester.java
index 8b056b4cb..354dd608d 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/testers/NavigableSetNavigationTester.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/testers/NavigableSetNavigationTester.java
@@ -20,6 +20,7 @@ import static com.google.common.collect.testing.features.CollectionFeature.SUPPO
import static com.google.common.collect.testing.features.CollectionSize.ONE;
import static com.google.common.collect.testing.features.CollectionSize.SEVERAL;
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.testing.Helpers;
@@ -128,11 +129,7 @@ public class NavigableSetNavigationTester<E> extends AbstractSetTester<E> {
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testPollFirstUnsupported() {
- try {
- navigableSet.pollFirst();
- fail();
- } catch (UnsupportedOperationException e) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> navigableSet.pollFirst());
}
@CollectionSize.Require(SEVERAL)
@@ -209,11 +206,7 @@ public class NavigableSetNavigationTester<E> extends AbstractSetTester<E> {
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testPollLastUnsupported() {
- try {
- navigableSet.pollLast();
- fail();
- } catch (UnsupportedOperationException e) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> navigableSet.pollLast());
}
@CollectionSize.Require(SEVERAL)
diff --git a/android/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java b/android/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java
index a52373d64..c47ea9113 100644
--- a/android/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java
+++ b/android/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java
@@ -17,6 +17,7 @@
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
@@ -410,7 +411,8 @@ public final class ArbitraryInstances {
}
private static <T> T createEmptyArray(Class<T> arrayType) {
- return arrayType.cast(Array.newInstance(arrayType.getComponentType(), 0));
+ // getComponentType() is non-null because we call createEmptyArray only with an array type.
+ return arrayType.cast(Array.newInstance(requireNonNull(arrayType.getComponentType()), 0));
}
// Internal implementations of some classes, with public default constructor that get() needs.
diff --git a/android/guava-testlib/src/com/google/common/testing/ClassSanityTester.java b/android/guava-testlib/src/com/google/common/testing/ClassSanityTester.java
index 3a41a7fe1..2c80552ae 100644
--- a/android/guava-testlib/src/com/google/common/testing/ClassSanityTester.java
+++ b/android/guava-testlib/src/com/google/common/testing/ClassSanityTester.java
@@ -496,13 +496,14 @@ public final class ClassSanityTester {
* @return this tester
*/
@CanIgnoreReturnValue
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public FactoryMethodReturnValueTester testSerializable() throws Exception {
for (Invokable<?, ?> factory : getFactoriesToTest()) {
Object instance = instantiate(factory);
if (instance != null) {
try {
SerializableTester.reserialize(instance);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
AssertionError error =
new AssertionFailedError("Serialization failed on return value of " + factory);
error.initCause(e.getCause());
@@ -522,6 +523,7 @@ public final class ClassSanityTester {
* @return this tester
*/
@CanIgnoreReturnValue
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public FactoryMethodReturnValueTester testEqualsAndSerializable() throws Exception {
for (Invokable<?, ?> factory : getFactoriesToTest()) {
try {
@@ -533,7 +535,7 @@ public final class ClassSanityTester {
if (instance != null) {
try {
SerializableTester.reserializeAndAssert(instance);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
AssertionError error =
new AssertionFailedError("Serialization failed on return value of " + factory);
error.initCause(e.getCause());
diff --git a/android/guava-testlib/src/com/google/common/testing/EqualsTester.java b/android/guava-testlib/src/com/google/common/testing/EqualsTester.java
index d4484702a..5f02dba84 100644
--- a/android/guava-testlib/src/com/google/common/testing/EqualsTester.java
+++ b/android/guava-testlib/src/com/google/common/testing/EqualsTester.java
@@ -95,6 +95,16 @@ public final class EqualsTester {
/**
* Adds {@code equalityGroup} with objects that are supposed to be equal to each other and not
* equal to any other equality groups added to this tester.
+ *
+ * <p>The {@code @Nullable} annotations on the {@code equalityGroup} parameter imply that the
+ * objects, and the array itself, can be null. That is for programmer convenience, when the
+ * objects come from factory methods that are themselves {@code @Nullable}. In reality neither the
+ * array nor its contents can be null, but it is not useful to force the use of {@code
+ * requireNonNull} or the like just to assert that.
+ *
+ * <p>{@code EqualsTester} will always check that every object it is given returns false from
+ * {@code equals(null)}, so it is neither useful nor allowed to include a null value in any
+ * equality group.
*/
@CanIgnoreReturnValue
public EqualsTester addEqualityGroup(@Nullable Object @Nullable ... equalityGroup) {
diff --git a/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java b/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java
index 73c5705ba..d0202b471 100644
--- a/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java
+++ b/android/guava-testlib/src/com/google/common/testing/NullPointerTester.java
@@ -35,7 +35,6 @@ import com.google.common.reflect.Reflection;
import com.google.common.reflect.TypeToken;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedType;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
@@ -43,7 +42,6 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ConcurrentMap;
@@ -353,9 +351,9 @@ public final class NullPointerTester {
@Nullable Object instance, Invokable<?, ?> invokable, int paramIndex, Class<?> testedClass) {
/*
* com.google.common is starting to rely on type-use annotations, which aren't visible under
- * Android VMs. So we skip testing there.
+ * Android VMs and in open-source guava-android. So we skip testing there.
*/
- if (isAndroid() && Reflection.getPackageName(testedClass).startsWith("com.google.common")) {
+ if (Reflection.getPackageName(testedClass).startsWith("com.google.common")) {
return;
}
if (isPrimitiveOrNullable(invokable.getParameters().get(paramIndex))) {
@@ -604,47 +602,27 @@ public final class NullPointerTester {
* Looks for declaration nullness annotations and, if supported, type-use nullness annotations.
*
* <p>Under Android VMs, the methods for retrieving type-use annotations don't exist. This means
- * that {@link NullPointerException} may misbehave under Android when used on classes that rely on
+ * that {@link NullPointerTester} may misbehave under Android when used on classes that rely on
* type-use annotations.
*
* <p>Under j2objc, the necessary APIs exist, but some (perhaps all) return stub values, like
- * empty arrays. Presumably {@link NullPointerException} could likewise misbehave under j2objc,
- * but I don't know that anyone uses it there, anyway.
+ * empty arrays. Presumably {@link NullPointerTester} could likewise misbehave under j2objc, but I
+ * don't know that anyone uses it there, anyway.
*/
private enum NullnessAnnotationReader {
- // Usages (which are unsafe only for Android) are guarded by the annotatedTypeExists() check.
- @SuppressWarnings({"Java7ApiChecker", "AndroidApiChecker", "DoNotCall", "deprecation"})
+ @SuppressWarnings("Java7ApiChecker")
FROM_DECLARATION_AND_TYPE_USE_ANNOTATIONS {
@Override
- @IgnoreJRERequirement
boolean isNullable(Invokable<?, ?> invokable) {
return FROM_DECLARATION_ANNOTATIONS_ONLY.isNullable(invokable)
- || containsNullable(invokable.getAnnotatedReturnType().getAnnotations());
+ ;
// TODO(cpovirk): Should we also check isNullableTypeVariable?
}
@Override
- @IgnoreJRERequirement
boolean isNullable(Parameter param) {
return FROM_DECLARATION_ANNOTATIONS_ONLY.isNullable(param)
- || containsNullable(param.getAnnotatedType().getAnnotations())
- || isNullableTypeVariable(param.getAnnotatedType().getType());
- }
-
- @IgnoreJRERequirement
- boolean isNullableTypeVariable(Type type) {
- if (!(type instanceof TypeVariable)) {
- return false;
- }
- TypeVariable<?> typeVar = (TypeVariable<?>) type;
- for (AnnotatedType bound : typeVar.getAnnotatedBounds()) {
- // Until Java 15, the isNullableTypeVariable case here won't help:
- // https://bugs.openjdk.java.net/browse/JDK-8202469
- if (containsNullable(bound.getAnnotations()) || isNullableTypeVariable(bound.getType())) {
- return true;
- }
- }
- return false;
+ ;
}
},
FROM_DECLARATION_ANNOTATIONS_ONLY {
@@ -663,9 +641,4 @@ public final class NullPointerTester {
abstract boolean isNullable(Parameter param);
}
-
- private static boolean isAndroid() {
- // Arguably it would make more sense to test "can we see type-use annotations" directly....
- return checkNotNull(System.getProperty("java.runtime.name", "")).contains("Android");
- }
}
diff --git a/android/guava-testlib/src/com/google/common/testing/Platform.java b/android/guava-testlib/src/com/google/common/testing/Platform.java
index bbad5598d..9726d2de0 100644
--- a/android/guava-testlib/src/com/google/common/testing/Platform.java
+++ b/android/guava-testlib/src/com/google/common/testing/Platform.java
@@ -17,6 +17,7 @@
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import java.io.ByteArrayInputStream;
@@ -42,7 +43,7 @@ final class Platform {
ObjectOutputStream out = new ObjectOutputStream(bytes);
out.writeObject(object);
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()));
- return (T) in.readObject();
+ return (T) requireNonNull(in.readObject());
} catch (IOException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
diff --git a/android/guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java b/android/guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java
index abe419e05..325388342 100644
--- a/android/guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java
+++ b/android/guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java
@@ -18,6 +18,7 @@ package com.google.common.util.concurrent.testing;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.util.concurrent.ListenableFuture;
@@ -70,29 +71,17 @@ public abstract class AbstractListenableFutureTest extends TestCase {
assertFalse(future.isDone());
assertFalse(future.isCancelled());
- CountDownLatch successLatch = new CountDownLatch(1);
- Throwable[] badness = new Throwable[1];
-
- // Wait on the future in a separate thread.
- new Thread(
- () -> {
- try {
- assertSame(Boolean.TRUE, future.get());
- successLatch.countDown();
- } catch (Throwable t) {
- t.printStackTrace();
- badness[0] = t;
- }
- })
- .start();
+ ExecutorService executor = Executors.newSingleThreadExecutor();
- // Release the future value.
- latch.countDown();
+ try {
+ Future<Boolean> getResult = executor.submit(() -> future.get());
- assertTrue(successLatch.await(10, SECONDS));
+ // Release the future value.
+ latch.countDown();
- if (badness[0] != null) {
- throw badness[0];
+ assertTrue(getResult.get(10, SECONDS));
+ } finally {
+ executor.shutdownNow();
}
assertTrue(future.isDone());
@@ -127,13 +116,8 @@ public abstract class AbstractListenableFutureTest extends TestCase {
// Run cancellation in a separate thread as an extra thread-safety test.
new Thread(
() -> {
- try {
- future.get();
- } catch (CancellationException expected) {
- successLatch.countDown();
- } catch (Exception ignored) {
- // All other errors are ignored, we expect a cancellation.
- }
+ assertThrows(CancellationException.class, future::get);
+ successLatch.countDown();
})
.start();
@@ -160,13 +144,8 @@ public abstract class AbstractListenableFutureTest extends TestCase {
new Thread(
() -> {
- try {
- future.get();
- } catch (CancellationException expected) {
- successLatch.countDown();
- } catch (Exception ignored) {
- // No success latch count down.
- }
+ assertThrows(CancellationException.class, future::get);
+ successLatch.countDown();
})
.start();
diff --git a/android/guava-testlib/test/com/google/common/collect/testing/features/FeatureUtilTest.java b/android/guava-testlib/test/com/google/common/collect/testing/features/FeatureUtilTest.java
index 37af90bda..130e86f87 100644
--- a/android/guava-testlib/test/com/google/common/collect/testing/features/FeatureUtilTest.java
+++ b/android/guava-testlib/test/com/google/common/collect/testing/features/FeatureUtilTest.java
@@ -17,6 +17,7 @@
package com.google.common.collect.testing.features;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
@@ -28,7 +29,9 @@ import java.util.Collections;
import java.util.Set;
import junit.framework.TestCase;
-/** @author George van den Driessche */
+/**
+ * @author George van den Driessche
+ */
// Enum values use constructors with generic varargs.
@SuppressWarnings("unchecked")
public class FeatureUtilTest extends TestCase {
@@ -232,27 +235,26 @@ public class FeatureUtilTest extends TestCase {
@AndroidIncompatible // Android runs ExampleDerivedInterfaceTester directly if it exists
public void testBuildTesterRequirements_classClassConflict() throws Exception {
- try {
- FeatureUtil.buildTesterRequirements(
- ConflictingRequirementsExampleDerivedInterfaceTester.class);
- fail("Expected ConflictingRequirementsException");
- } catch (ConflictingRequirementsException e) {
- assertThat(e.getConflicts()).contains(ExampleBaseFeature.BASE_FEATURE_1);
- assertEquals(ConflictingRequirementsExampleDerivedInterfaceTester.class, e.getSource());
- }
+ ConflictingRequirementsException e =
+ assertThrows(
+ ConflictingRequirementsException.class,
+ () ->
+ FeatureUtil.buildTesterRequirements(
+ ConflictingRequirementsExampleDerivedInterfaceTester.class));
+ assertThat(e.getConflicts()).contains(ExampleBaseFeature.BASE_FEATURE_1);
+ assertEquals(ConflictingRequirementsExampleDerivedInterfaceTester.class, e.getSource());
}
@AndroidIncompatible // Android runs ExampleDerivedInterfaceTester directly if it exists
public void testBuildTesterRequirements_methodClassConflict() throws Exception {
final Method method =
ExampleDerivedInterfaceTester.class.getMethod("testRequiringConflictingFeatures");
- try {
- FeatureUtil.buildTesterRequirements(method);
- fail("Expected ConflictingRequirementsException");
- } catch (ConflictingRequirementsException e) {
- assertThat(e.getConflicts()).contains(ExampleBaseFeature.BASE_FEATURE_1);
- assertEquals(method, e.getSource());
- }
+ ConflictingRequirementsException e =
+ assertThrows(
+ ConflictingRequirementsException.class,
+ () -> FeatureUtil.buildTesterRequirements(method));
+ assertThat(e.getConflicts()).contains(ExampleBaseFeature.BASE_FEATURE_1);
+ assertEquals(method, e.getSource());
}
@AndroidIncompatible // Android runs ExampleDerivedInterfaceTester directly if it exists
diff --git a/android/guava-testlib/test/com/google/common/testing/ArbitraryInstancesTest.java b/android/guava-testlib/test/com/google/common/testing/ArbitraryInstancesTest.java
index 4dc80848f..8387d1d57 100644
--- a/android/guava-testlib/test/com/google/common/testing/ArbitraryInstancesTest.java
+++ b/android/guava-testlib/test/com/google/common/testing/ArbitraryInstancesTest.java
@@ -17,6 +17,7 @@
package com.google.common.testing;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.CharMatcher;
import com.google.common.base.Charsets;
@@ -278,11 +279,7 @@ public class ArbitraryInstancesTest extends TestCase {
Comparable<Object> comparable = ArbitraryInstances.get(Comparable.class);
assertEquals(0, comparable.compareTo(comparable));
assertTrue(comparable.compareTo("") > 0);
- try {
- comparable.compareTo(null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> comparable.compareTo(null));
}
public void testGet_array() {
diff --git a/android/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java b/android/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java
deleted file mode 100644
index fee11890b..000000000
--- a/android/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java
+++ /dev/null
@@ -1,1351 +0,0 @@
-/*
- * Copyright (C) 2012 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.testing;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.truth.Truth.assertThat;
-
-import com.google.common.base.Functions;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.testing.ClassSanityTester.FactoryMethodReturnsNullException;
-import com.google.common.testing.ClassSanityTester.ParameterHasNoDistinctValueException;
-import com.google.common.testing.ClassSanityTester.ParameterNotInstantiableException;
-import com.google.common.testing.NullPointerTester.Visibility;
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/**
- * Unit tests for {@link ClassSanityTester}.
- *
- * @author Ben Yu
- */
-@AndroidIncompatible // NullPointerTester refuses to run for c.g.c under Android
-public class ClassSanityTesterTest extends TestCase {
-
- private final ClassSanityTester tester = new ClassSanityTester();
-
- public void testEqualsOnReturnValues_good() throws Exception {
- tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEquals();
- }
-
- public static class GoodEqualsFactory {
- public static Object good(
- String a,
- int b,
- // oneConstantOnly doesn't matter since it's not nullable and can be only 1 value.
- @SuppressWarnings("unused") OneConstantEnum oneConstantOnly,
- // noConstant doesn't matter since it can only be null
- @SuppressWarnings("unused") @Nullable NoConstantEnum noConstant) {
- return new GoodEquals(a, b);
- }
- // instance method ignored
- public Object badIgnored() {
- return new BadEquals();
- }
- // primitive ignored
- public int returnsInt() {
- throw new UnsupportedOperationException();
- }
- // void ignored
- public void voidMethod() {
- throw new UnsupportedOperationException();
- }
- // non-public method ignored
- static Object badButNotPublic() {
- return new BadEquals();
- }
- }
-
- public void testForAllPublicStaticMethods_noPublicStaticMethods() throws Exception {
- try {
- tester.forAllPublicStaticMethods(NoPublicStaticMethods.class).testEquals();
- } catch (AssertionFailedError expected) {
- assertThat(expected)
- .hasMessageThat()
- .isEqualTo(
- "No public static methods that return java.lang.Object or subtype are found in "
- + NoPublicStaticMethods.class
- + ".");
- return;
- }
- fail();
- }
-
- public void testEqualsOnReturnValues_bad() throws Exception {
- try {
- tester.forAllPublicStaticMethods(BadEqualsFactory.class).testEquals();
- } catch (AssertionFailedError expected) {
- return;
- }
- fail();
- }
-
- private static class BadEqualsFactory {
- /** oneConstantOnly matters now since it can be either null or the constant. */
- @SuppressWarnings("unused") // Called by reflection
- public static Object bad(String a, int b, @Nullable OneConstantEnum oneConstantOnly) {
- return new GoodEquals(a, b);
- }
- }
-
- public void testNullsOnReturnValues_good() throws Exception {
- tester.forAllPublicStaticMethods(GoodNullsFactory.class).testNulls();
- }
-
- private static class GoodNullsFactory {
- @SuppressWarnings("unused") // Called by reflection
- public static Object good(String s) {
- return new GoodNulls(s);
- }
- }
-
- public void testNullsOnReturnValues_bad() throws Exception {
- try {
- tester.forAllPublicStaticMethods(BadNullsFactory.class).thatReturn(Object.class).testNulls();
- } catch (AssertionFailedError expected) {
- return;
- }
- fail();
- }
-
- public void testNullsOnReturnValues_returnTypeFiltered() throws Exception {
- try {
- tester
- .forAllPublicStaticMethods(BadNullsFactory.class)
- .thatReturn(Iterable.class)
- .testNulls();
- } catch (AssertionFailedError expected) {
- assertThat(expected)
- .hasMessageThat()
- .isEqualTo(
- "No public static methods that return java.lang.Iterable or subtype are found in "
- + BadNullsFactory.class
- + ".");
- return;
- }
- fail();
- }
-
- public static class BadNullsFactory {
- public static Object bad(@SuppressWarnings("unused") String a) {
- return new BadNulls();
- }
- }
-
- @AndroidIncompatible // TODO(cpovirk): ClassNotFoundException... ClassSanityTesterTest$AnInterface
- public void testSerializableOnReturnValues_good() throws Exception {
- tester.forAllPublicStaticMethods(GoodSerializableFactory.class).testSerializable();
- }
-
- public static class GoodSerializableFactory {
- public static Object good(Runnable r) {
- return r;
- }
-
- public static Object good(AnInterface i) {
- return i;
- }
- }
-
- public void testSerializableOnReturnValues_bad() throws Exception {
- try {
- tester.forAllPublicStaticMethods(BadSerializableFactory.class).testSerializable();
- } catch (AssertionFailedError expected) {
- return;
- }
- fail();
- }
-
- public static class BadSerializableFactory {
- public static Object bad() {
- return new Serializable() {
- @SuppressWarnings("unused")
- private final Object notSerializable = new Object();
- };
- }
- }
-
- public void testEqualsAndSerializableOnReturnValues_equalsIsGoodButNotSerializable()
- throws Exception {
- try {
- tester.forAllPublicStaticMethods(GoodEqualsFactory.class).testEqualsAndSerializable();
- } catch (AssertionFailedError expected) {
- return;
- }
- fail("should have failed");
- }
-
- public void testEqualsAndSerializableOnReturnValues_serializableButNotEquals() throws Exception {
- try {
- tester.forAllPublicStaticMethods(GoodSerializableFactory.class).testEqualsAndSerializable();
- } catch (AssertionFailedError expected) {
- return;
- }
- fail("should have failed");
- }
-
- @AndroidIncompatible // TODO(cpovirk): ClassNotFoundException... ClassSanityTesterTest$AnInterface
- public void testEqualsAndSerializableOnReturnValues_good() throws Exception {
- tester
- .forAllPublicStaticMethods(GoodEqualsAndSerializableFactory.class)
- .testEqualsAndSerializable();
- }
-
- public static class GoodEqualsAndSerializableFactory {
- public static Object good(AnInterface s) {
- return Functions.constant(s);
- }
- }
-
- public void testEqualsForReturnValues_factoryReturnsNullButNotAnnotated() throws Exception {
- try {
- tester.forAllPublicStaticMethods(FactoryThatReturnsNullButNotAnnotated.class).testEquals();
- } catch (AssertionFailedError expected) {
- return;
- }
- fail();
- }
-
- public void testNullsForReturnValues_factoryReturnsNullButNotAnnotated() throws Exception {
- try {
- tester.forAllPublicStaticMethods(FactoryThatReturnsNullButNotAnnotated.class).testNulls();
- } catch (AssertionFailedError expected) {
- return;
- }
- fail();
- }
-
- public void testSerializableForReturnValues_factoryReturnsNullButNotAnnotated() throws Exception {
- try {
- tester
- .forAllPublicStaticMethods(FactoryThatReturnsNullButNotAnnotated.class)
- .testSerializable();
- } catch (AssertionFailedError expected) {
- return;
- }
- fail();
- }
-
- public void testEqualsAndSerializableForReturnValues_factoryReturnsNullButNotAnnotated()
- throws Exception {
- try {
- tester
- .forAllPublicStaticMethods(FactoryThatReturnsNullButNotAnnotated.class)
- .testEqualsAndSerializable();
- } catch (AssertionFailedError expected) {
- return;
- }
- fail();
- }
-
- public static class FactoryThatReturnsNullButNotAnnotated {
- public static Object bad() {
- return null;
- }
- }
-
- public void testEqualsForReturnValues_factoryReturnsNullAndAnnotated() throws Exception {
- tester.forAllPublicStaticMethods(FactoryThatReturnsNullAndAnnotated.class).testEquals();
- }
-
- public void testNullsForReturnValues_factoryReturnsNullAndAnnotated() throws Exception {
- tester.forAllPublicStaticMethods(FactoryThatReturnsNullAndAnnotated.class).testNulls();
- }
-
- public void testSerializableForReturnValues_factoryReturnsNullAndAnnotated() throws Exception {
- tester.forAllPublicStaticMethods(FactoryThatReturnsNullAndAnnotated.class).testSerializable();
- }
-
- public void testEqualsAndSerializableForReturnValues_factoryReturnsNullAndAnnotated()
- throws Exception {
- tester
- .forAllPublicStaticMethods(FactoryThatReturnsNullAndAnnotated.class)
- .testEqualsAndSerializable();
- }
-
- public static class FactoryThatReturnsNullAndAnnotated {
- public static @Nullable Object bad() {
- return null;
- }
- }
-
- public void testGoodEquals() throws Exception {
- tester.testEquals(GoodEquals.class);
- }
-
- public void testEquals_interface() {
- tester.testEquals(AnInterface.class);
- }
-
- public void testEquals_abstractClass() {
- tester.testEquals(AnAbstractClass.class);
- }
-
- public void testEquals_enum() {
- tester.testEquals(OneConstantEnum.class);
- }
-
- public void testBadEquals() throws Exception {
- try {
- tester.testEquals(BadEquals.class);
- } catch (AssertionFailedError expected) {
- assertThat(expected).hasMessageThat().contains("create(null)");
- return;
- }
- fail("should have failed");
- }
-
- public void testBadEquals_withParameterizedType() throws Exception {
- try {
- tester.testEquals(BadEqualsWithParameterizedType.class);
- } catch (AssertionFailedError expected) {
- assertThat(expected).hasMessageThat().contains("create([[1]])");
- return;
- }
- fail("should have failed");
- }
-
- public void testBadEquals_withSingleParameterValue() throws Exception {
- try {
- tester.doTestEquals(ConstructorParameterWithOptionalNotInstantiable.class);
- fail();
- } catch (ParameterHasNoDistinctValueException expected) {
- }
- }
-
- public void testGoodReferentialEqualityComparison() throws Exception {
- tester.testEquals(UsesEnum.class);
- tester.testEquals(UsesReferentialEquality.class);
- tester.testEquals(SameListInstance.class);
- }
-
- @AndroidIncompatible // problem with equality of Type objects?
- public void testEqualsUsingReferentialEquality() throws Exception {
- assertBadUseOfReferentialEquality(SameIntegerInstance.class);
- assertBadUseOfReferentialEquality(SameLongInstance.class);
- assertBadUseOfReferentialEquality(SameFloatInstance.class);
- assertBadUseOfReferentialEquality(SameDoubleInstance.class);
- assertBadUseOfReferentialEquality(SameShortInstance.class);
- assertBadUseOfReferentialEquality(SameByteInstance.class);
- assertBadUseOfReferentialEquality(SameCharacterInstance.class);
- assertBadUseOfReferentialEquality(SameBooleanInstance.class);
- assertBadUseOfReferentialEquality(SameObjectInstance.class);
- assertBadUseOfReferentialEquality(SameStringInstance.class);
- assertBadUseOfReferentialEquality(SameInterfaceInstance.class);
- }
-
- private void assertBadUseOfReferentialEquality(Class<?> cls) throws Exception {
- try {
- tester.testEquals(cls);
- } catch (AssertionFailedError expected) {
- assertThat(expected).hasMessageThat().contains(cls.getSimpleName() + "(");
- return;
- }
- fail("should have failed for " + cls);
- }
-
- public void testParameterNotInstantiableForEqualsTest() throws Exception {
- try {
- tester.doTestEquals(ConstructorParameterNotInstantiable.class);
- fail("should have failed");
- } catch (ParameterNotInstantiableException expected) {
- }
- }
-
- public void testNoDistinctValueForEqualsTest() throws Exception {
- try {
- tester.doTestEquals(ConstructorParameterSingleValue.class);
- fail("should have failed");
- } catch (ParameterHasNoDistinctValueException expected) {
- }
- }
-
- public void testConstructorThrowsForEqualsTest() throws Exception {
- try {
- tester.doTestEquals(ConstructorThrows.class);
- fail("should have failed");
- } catch (InvocationTargetException expected) {
- }
- }
-
- public void testFactoryMethodReturnsNullForEqualsTest() throws Exception {
- try {
- tester.doTestEquals(FactoryMethodReturnsNullAndAnnotated.class);
- fail("should have failed");
- } catch (FactoryMethodReturnsNullException expected) {
- }
- }
-
- public void testFactoryMethodReturnsNullButNotAnnotatedInEqualsTest() throws Exception {
- try {
- tester.testEquals(FactoryMethodReturnsNullButNotAnnotated.class);
- } catch (AssertionFailedError expected) {
- return;
- }
- fail("should have failed");
- }
-
- public void testNoEqualsChecksOnEnum() throws Exception {
- tester.testEquals(OneConstantEnum.class);
- tester.testEquals(NoConstantEnum.class);
- tester.testEquals(TimeUnit.class);
- }
-
- public void testNoEqualsChecksOnInterface() throws Exception {
- tester.testEquals(Runnable.class);
- }
-
- public void testNoEqualsChecksOnAnnotation() throws Exception {
- tester.testEquals(MyAnnotation.class);
- }
-
- public void testGoodNulls() throws Exception {
- tester.testNulls(GoodNulls.class);
- }
-
- public void testNoNullCheckNeededDespiteNotInstantiable() throws Exception {
- tester.doTestNulls(NoNullCheckNeededDespiteNotInstantiable.class, Visibility.PACKAGE);
- }
-
- public void testNulls_interface() {
- tester.testNulls(AnInterface.class);
- }
-
- public void testNulls_abstractClass() {
- tester.testNulls(AnAbstractClass.class);
- }
-
- public void testNulls_enum() throws Exception {
- tester.testNulls(OneConstantEnum.class);
- tester.testNulls(NoConstantEnum.class);
- tester.testNulls(TimeUnit.class);
- }
-
- public void testNulls_parameterOptionalNotInstantiable() throws Exception {
- tester.testNulls(ConstructorParameterWithOptionalNotInstantiable.class);
- }
-
- public void testEnumFailsToCheckNull() throws Exception {
- try {
- tester.testNulls(EnumFailsToCheckNull.class);
- } catch (AssertionFailedError expected) {
- return;
- }
- fail("should have failed");
- }
-
- public void testNoNullChecksOnInterface() throws Exception {
- tester.testNulls(Runnable.class);
- }
-
- public void testNoNullChecksOnAnnotation() throws Exception {
- tester.testNulls(MyAnnotation.class);
- }
-
- public void testBadNulls() throws Exception {
- try {
- tester.testNulls(BadNulls.class);
- } catch (AssertionFailedError expected) {
- return;
- }
- fail("should have failed");
- }
-
- public void testInstantiate_factoryMethodReturnsNullButNotAnnotated() throws Exception {
- try {
- FactoryMethodReturnsNullButNotAnnotated unused =
- tester.instantiate(FactoryMethodReturnsNullButNotAnnotated.class);
- } catch (AssertionFailedError expected) {
- assertThat(expected).hasMessageThat().contains("@Nullable");
- return;
- }
- fail("should have failed");
- }
-
- public void testInstantiate_factoryMethodReturnsNullAndAnnotated() throws Exception {
- try {
- tester.instantiate(FactoryMethodReturnsNullAndAnnotated.class);
- fail("should have failed");
- } catch (FactoryMethodReturnsNullException expected) {
- }
- }
-
- public void testInstantiate_factoryMethodAcceptsNull() throws Exception {
- assertNull(tester.instantiate(FactoryMethodAcceptsNull.class).name);
- }
-
- public void testInstantiate_factoryMethodDoesNotAcceptNull() throws Exception {
- assertNotNull(tester.instantiate(FactoryMethodDoesNotAcceptNull.class).name);
- }
-
- public void testInstantiate_constructorAcceptsNull() throws Exception {
- assertNull(tester.instantiate(ConstructorAcceptsNull.class).name);
- }
-
- public void testInstantiate_constructorDoesNotAcceptNull() throws Exception {
- assertNotNull(tester.instantiate(ConstructorDoesNotAcceptNull.class).name);
- }
-
- public void testInstantiate_notInstantiable() throws Exception {
- assertNull(tester.instantiate(NotInstantiable.class));
- }
-
- public void testInstantiate_noConstantEnum() throws Exception {
- assertNull(tester.instantiate(NoConstantEnum.class));
- }
-
- public void testInstantiate_oneConstantEnum() throws Exception {
- assertEquals(OneConstantEnum.A, tester.instantiate(OneConstantEnum.class));
- }
-
- public void testInstantiate_interface() throws Exception {
- assertNull(tester.instantiate(Runnable.class));
- }
-
- public void testInstantiate_abstractClass() throws Exception {
- assertNull(tester.instantiate(AbstractList.class));
- }
-
- public void testInstantiate_annotation() throws Exception {
- assertNull(tester.instantiate(MyAnnotation.class));
- }
-
- public void testInstantiate_setDefault() throws Exception {
- NotInstantiable x = new NotInstantiable();
- tester.setDefault(NotInstantiable.class, x);
- assertNotNull(tester.instantiate(ConstructorParameterNotInstantiable.class));
- }
-
- public void testSetDistinctValues_equalInstances() {
- try {
- tester.setDistinctValues(String.class, "", "");
- fail();
- } catch (IllegalArgumentException expected) {
- }
- }
-
- public void testInstantiate_setDistinctValues() throws Exception {
- NotInstantiable x = new NotInstantiable();
- NotInstantiable y = new NotInstantiable();
- tester.setDistinctValues(NotInstantiable.class, x, y);
- assertNotNull(tester.instantiate(ConstructorParameterNotInstantiable.class));
- tester.testEquals(ConstructorParameterMapOfNotInstantiable.class);
- }
-
- public void testInstantiate_constructorThrows() throws Exception {
- try {
- tester.instantiate(ConstructorThrows.class);
- fail();
- } catch (InvocationTargetException expected) {
- }
- }
-
- public void testInstantiate_factoryMethodThrows() throws Exception {
- try {
- tester.instantiate(FactoryMethodThrows.class);
- fail();
- } catch (InvocationTargetException expected) {
- }
- }
-
- public void testInstantiate_constructorParameterNotInstantiable() throws Exception {
- try {
- tester.instantiate(ConstructorParameterNotInstantiable.class);
- fail();
- } catch (ParameterNotInstantiableException expected) {
- }
- }
-
- public void testInstantiate_factoryMethodParameterNotInstantiable() throws Exception {
- try {
- tester.instantiate(FactoryMethodParameterNotInstantiable.class);
- fail();
- } catch (ParameterNotInstantiableException expected) {
- }
- }
-
- public void testInstantiate_instantiableFactoryMethodChosen() throws Exception {
- assertEquals("good", tester.instantiate(InstantiableFactoryMethodChosen.class).name);
- }
-
- @AndroidIncompatible // TODO(cpovirk): ClassNotFoundException... ClassSanityTesterTest$AnInterface
- public void testInterfaceProxySerializable() throws Exception {
- SerializableTester.reserializeAndAssert(tester.instantiate(HasAnInterface.class));
- }
-
- public void testReturnValuesFromAnotherPackageIgnoredForNullTests() throws Exception {
- new ClassSanityTester().forAllPublicStaticMethods(JdkObjectFactory.class).testNulls();
- }
-
- /** String doesn't check nulls as we expect. But the framework should ignore. */
- private static class JdkObjectFactory {
- @SuppressWarnings("unused") // Called by reflection
- public static Object create() {
- return new ArrayList<>();
- }
- }
-
- static class HasAnInterface implements Serializable {
- private final AnInterface i;
-
- public HasAnInterface(AnInterface i) {
- this.i = i;
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof HasAnInterface) {
- HasAnInterface that = (HasAnInterface) obj;
- return i.equals(that.i);
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return i.hashCode();
- }
- }
-
- static class InstantiableFactoryMethodChosen {
- final String name;
-
- private InstantiableFactoryMethodChosen(String name) {
- this.name = name;
- }
-
- public InstantiableFactoryMethodChosen(NotInstantiable x) {
- checkNotNull(x);
- this.name = "x1";
- }
-
- public static InstantiableFactoryMethodChosen create(NotInstantiable x) {
- return new InstantiableFactoryMethodChosen(x);
- }
-
- public static InstantiableFactoryMethodChosen create(String s) {
- checkNotNull(s);
- return new InstantiableFactoryMethodChosen("good");
- }
- }
-
- public void testInstantiate_instantiableConstructorChosen() throws Exception {
- assertEquals("good", tester.instantiate(InstantiableConstructorChosen.class).name);
- }
-
- public void testEquals_setOfNonInstantiable() throws Exception {
- try {
- new ClassSanityTester().doTestEquals(SetWrapper.class);
- fail();
- } catch (ParameterNotInstantiableException expected) {
- }
- }
-
- private abstract static class Wrapper {
- private final Object wrapped;
-
- Wrapper(Object wrapped) {
- this.wrapped = checkNotNull(wrapped);
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- // In general getClass().isInstance() is bad for equals.
- // But here we fully control the subclasses to ensure symmetry.
- if (getClass().isInstance(obj)) {
- Wrapper that = (Wrapper) obj;
- return wrapped.equals(that.wrapped);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return wrapped.hashCode();
- }
-
- @Override
- public String toString() {
- return wrapped.toString();
- }
- }
-
- private static class SetWrapper extends Wrapper {
- public SetWrapper(Set<NotInstantiable> wrapped) {
- super(wrapped);
- }
- }
-
- static class InstantiableConstructorChosen {
- final String name;
-
- public InstantiableConstructorChosen(String name) {
- checkNotNull(name);
- this.name = "good";
- }
-
- public InstantiableConstructorChosen(NotInstantiable x) {
- checkNotNull(x);
- this.name = "x1";
- }
-
- public static InstantiableFactoryMethodChosen create(NotInstantiable x) {
- return new InstantiableFactoryMethodChosen(x);
- }
- }
-
- static class GoodEquals {
-
- private final String a;
- private final int b;
-
- private GoodEquals(String a, int b) {
- this.a = checkNotNull(a);
- this.b = b;
- }
-
- // ignored by testEquals()
- GoodEquals(@SuppressWarnings("unused") NotInstantiable x) {
- this.a = "x";
- this.b = -1;
- }
-
- // will keep trying
- public GoodEquals(@SuppressWarnings("unused") NotInstantiable x, int b) {
- this.a = "x";
- this.b = b;
- }
-
- // keep trying
- @SuppressWarnings("unused")
- static GoodEquals create(int a, int b) {
- throw new RuntimeException();
- }
-
- // Good!
- static GoodEquals create(String a, int b) {
- return new GoodEquals(a, b);
- }
-
- // keep trying
- @SuppressWarnings("unused")
- public static @Nullable GoodEquals createMayReturnNull(int a, int b) {
- return null;
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof GoodEquals) {
- GoodEquals that = (GoodEquals) obj;
- return a.equals(that.a) && b == that.b;
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return 0;
- }
- }
-
- static class BadEquals {
-
- public BadEquals() {} // ignored by testEquals() since it has less parameters.
-
- public static BadEquals create(@SuppressWarnings("unused") @Nullable String s) {
- return new BadEquals();
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- return obj instanceof BadEquals;
- }
-
- @Override
- public int hashCode() {
- return 0;
- }
- }
-
- static class SameIntegerInstance {
- private final Integer i;
-
- public SameIntegerInstance(Integer i) {
- this.i = checkNotNull(i);
- }
-
- @Override
- public int hashCode() {
- return i.hashCode();
- }
-
- @Override
- @SuppressWarnings({"BoxedPrimitiveEquality", "NumericEquality"})
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof SameIntegerInstance) {
- SameIntegerInstance that = (SameIntegerInstance) obj;
- return i == that.i;
- }
- return false;
- }
- }
-
- static class SameLongInstance {
- private final Long i;
-
- public SameLongInstance(Long i) {
- this.i = checkNotNull(i);
- }
-
- @Override
- public int hashCode() {
- return i.hashCode();
- }
-
- @Override
- @SuppressWarnings({"BoxedPrimitiveEquality", "NumericEquality"})
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof SameLongInstance) {
- SameLongInstance that = (SameLongInstance) obj;
- return i == that.i;
- }
- return false;
- }
- }
-
- static class SameFloatInstance {
- private final Float i;
-
- public SameFloatInstance(Float i) {
- this.i = checkNotNull(i);
- }
-
- @Override
- public int hashCode() {
- return i.hashCode();
- }
-
- @Override
- @SuppressWarnings({"BoxedPrimitiveEquality", "NumericEquality"})
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof SameFloatInstance) {
- SameFloatInstance that = (SameFloatInstance) obj;
- return i == that.i;
- }
- return false;
- }
- }
-
- static class SameDoubleInstance {
- private final Double i;
-
- public SameDoubleInstance(Double i) {
- this.i = checkNotNull(i);
- }
-
- @Override
- public int hashCode() {
- return i.hashCode();
- }
-
- @Override
- @SuppressWarnings({"BoxedPrimitiveEquality", "NumericEquality"})
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof SameDoubleInstance) {
- SameDoubleInstance that = (SameDoubleInstance) obj;
- return i == that.i;
- }
- return false;
- }
- }
-
- static class SameShortInstance {
- private final Short i;
-
- public SameShortInstance(Short i) {
- this.i = checkNotNull(i);
- }
-
- @Override
- public int hashCode() {
- return i.hashCode();
- }
-
- @Override
- @SuppressWarnings({"BoxedPrimitiveEquality", "NumericEquality"})
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof SameShortInstance) {
- SameShortInstance that = (SameShortInstance) obj;
- return i == that.i;
- }
- return false;
- }
- }
-
- static class SameByteInstance {
- private final Byte i;
-
- public SameByteInstance(Byte i) {
- this.i = checkNotNull(i);
- }
-
- @Override
- public int hashCode() {
- return i.hashCode();
- }
-
- @Override
- @SuppressWarnings({"BoxedPrimitiveEquality", "NumericEquality"})
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof SameByteInstance) {
- SameByteInstance that = (SameByteInstance) obj;
- return i == that.i;
- }
- return false;
- }
- }
-
- static class SameCharacterInstance {
- private final Character i;
-
- public SameCharacterInstance(Character i) {
- this.i = checkNotNull(i);
- }
-
- @Override
- public int hashCode() {
- return i.hashCode();
- }
-
- @Override
- @SuppressWarnings("BoxedPrimitiveEquality")
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof SameCharacterInstance) {
- SameCharacterInstance that = (SameCharacterInstance) obj;
- return i == that.i;
- }
- return false;
- }
- }
-
- static class SameBooleanInstance {
- private final Boolean i;
-
- public SameBooleanInstance(Boolean i) {
- this.i = checkNotNull(i);
- }
-
- @Override
- public int hashCode() {
- return i.hashCode();
- }
-
- @Override
- @SuppressWarnings("BoxedPrimitiveEquality")
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof SameBooleanInstance) {
- SameBooleanInstance that = (SameBooleanInstance) obj;
- return i == that.i;
- }
- return false;
- }
- }
-
- static class SameStringInstance {
- private final String s;
-
- public SameStringInstance(String s) {
- this.s = checkNotNull(s);
- }
-
- @Override
- public int hashCode() {
- return s.hashCode();
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof SameStringInstance) {
- SameStringInstance that = (SameStringInstance) obj;
- return s == that.s;
- }
- return false;
- }
- }
-
- static class SameObjectInstance {
- private final Object s;
-
- public SameObjectInstance(Object s) {
- this.s = checkNotNull(s);
- }
-
- @Override
- public int hashCode() {
- return s.hashCode();
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof SameObjectInstance) {
- SameObjectInstance that = (SameObjectInstance) obj;
- return s == that.s;
- }
- return false;
- }
- }
-
- static class SameInterfaceInstance {
- private final Runnable s;
-
- public SameInterfaceInstance(Runnable s) {
- this.s = checkNotNull(s);
- }
-
- @Override
- public int hashCode() {
- return s.hashCode();
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof SameInterfaceInstance) {
- SameInterfaceInstance that = (SameInterfaceInstance) obj;
- return s == that.s;
- }
- return false;
- }
- }
-
- static class SameListInstance {
- private final List<?> s;
-
- public SameListInstance(List<?> s) {
- this.s = checkNotNull(s);
- }
-
- @Override
- public int hashCode() {
- return System.identityHashCode(s);
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof SameListInstance) {
- SameListInstance that = (SameListInstance) obj;
- return s == that.s;
- }
- return false;
- }
- }
-
- static class UsesReferentialEquality {
- private final ReferentialEquality s;
-
- public UsesReferentialEquality(ReferentialEquality s) {
- this.s = checkNotNull(s);
- }
-
- @Override
- public int hashCode() {
- return s.hashCode();
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof UsesReferentialEquality) {
- UsesReferentialEquality that = (UsesReferentialEquality) obj;
- return s == that.s;
- }
- return false;
- }
- }
-
- static class UsesEnum {
- private final TimeUnit s;
-
- public UsesEnum(TimeUnit s) {
- this.s = checkNotNull(s);
- }
-
- @Override
- public int hashCode() {
- return s.hashCode();
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof UsesEnum) {
- UsesEnum that = (UsesEnum) obj;
- return s == that.s;
- }
- return false;
- }
- }
-
- public static class ReferentialEquality {
- public ReferentialEquality() {}
- }
-
- static class BadEqualsWithParameterizedType {
-
- // ignored by testEquals() since it has less parameters.
- public BadEqualsWithParameterizedType() {}
-
- public static BadEqualsWithParameterizedType create(
- @SuppressWarnings("unused") ImmutableList<Iterable<? extends String>> s) {
- return new BadEqualsWithParameterizedType();
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- return obj instanceof BadEqualsWithParameterizedType;
- }
-
- @Override
- public int hashCode() {
- return 0;
- }
- }
-
- static class GoodNulls {
- public GoodNulls(String s) {
- checkNotNull(s);
- }
-
- public void rejectNull(String s) {
- checkNotNull(s);
- }
- }
-
- public static class BadNulls {
- public void failsToRejectNull(@SuppressWarnings("unused") String s) {}
- }
-
- public static class NoNullCheckNeededDespiteNotInstantiable {
-
- public NoNullCheckNeededDespiteNotInstantiable(NotInstantiable x) {
- checkNotNull(x);
- }
-
- @SuppressWarnings("unused") // reflected
- void primitiveOnly(int i) {}
-
- @SuppressWarnings("unused") // reflected
- void nullableOnly(@Nullable String s) {}
-
- public void noParameter() {}
-
- @SuppressWarnings("unused") // reflected
- void primitiveAndNullable(@Nullable String s, int i) {}
- }
-
- static class FactoryMethodReturnsNullButNotAnnotated {
- private FactoryMethodReturnsNullButNotAnnotated() {}
-
- static FactoryMethodReturnsNullButNotAnnotated returnsNull() {
- return null;
- }
- }
-
- static class FactoryMethodReturnsNullAndAnnotated {
- private FactoryMethodReturnsNullAndAnnotated() {}
-
- public static @Nullable FactoryMethodReturnsNullAndAnnotated returnsNull() {
- return null;
- }
- }
-
- static class FactoryMethodAcceptsNull {
-
- final String name;
-
- private FactoryMethodAcceptsNull(String name) {
- this.name = name;
- }
-
- static FactoryMethodAcceptsNull create(@Nullable String name) {
- return new FactoryMethodAcceptsNull(name);
- }
- }
-
- static class FactoryMethodDoesNotAcceptNull {
-
- final String name;
-
- private FactoryMethodDoesNotAcceptNull(String name) {
- this.name = checkNotNull(name);
- }
-
- public static FactoryMethodDoesNotAcceptNull create(String name) {
- return new FactoryMethodDoesNotAcceptNull(name);
- }
- }
-
- static class ConstructorAcceptsNull {
-
- final String name;
-
- public ConstructorAcceptsNull(@Nullable String name) {
- this.name = name;
- }
- }
-
- static class ConstructorDoesNotAcceptNull {
-
- final String name;
-
- ConstructorDoesNotAcceptNull(String name) {
- this.name = checkNotNull(name);
- }
- }
-
- static class ConstructorParameterNotInstantiable {
- public ConstructorParameterNotInstantiable(@SuppressWarnings("unused") NotInstantiable x) {}
- }
-
- static class ConstructorParameterMapOfNotInstantiable {
- private final Map<NotInstantiable, NotInstantiable> m;
-
- public ConstructorParameterMapOfNotInstantiable(Map<NotInstantiable, NotInstantiable> m) {
- this.m = checkNotNull(m);
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- if (obj instanceof ConstructorParameterMapOfNotInstantiable) {
- return m.equals(((ConstructorParameterMapOfNotInstantiable) obj).m);
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return m.hashCode();
- }
- }
-
- // Test that we should get a distinct parameter error when doing equals test.
- static class ConstructorParameterWithOptionalNotInstantiable {
- public ConstructorParameterWithOptionalNotInstantiable(Optional<NotInstantiable> x) {
- checkNotNull(x);
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int hashCode() {
- throw new UnsupportedOperationException();
- }
- }
-
- static class ConstructorParameterSingleValue {
- public ConstructorParameterSingleValue(@SuppressWarnings("unused") Singleton s) {}
-
- @Override
- public boolean equals(@Nullable Object obj) {
- return obj instanceof ConstructorParameterSingleValue;
- }
-
- @Override
- public int hashCode() {
- return 1;
- }
-
- public static class Singleton {
- public static final Singleton INSTANCE = new Singleton();
-
- private Singleton() {}
- }
- }
-
- static class FactoryMethodParameterNotInstantiable {
-
- private FactoryMethodParameterNotInstantiable() {}
-
- static FactoryMethodParameterNotInstantiable create(
- @SuppressWarnings("unused") NotInstantiable x) {
- return new FactoryMethodParameterNotInstantiable();
- }
- }
-
- static class ConstructorThrows {
- public ConstructorThrows() {
- throw new RuntimeException();
- }
- }
-
- static class FactoryMethodThrows {
- private FactoryMethodThrows() {}
-
- public static FactoryMethodThrows create() {
- throw new RuntimeException();
- }
- }
-
- static class NotInstantiable {
- private NotInstantiable() {}
- }
-
- private enum NoConstantEnum {}
-
- private enum OneConstantEnum {
- A
- }
-
- private enum EnumFailsToCheckNull {
- A;
-
- @SuppressWarnings("unused")
- public void failToCheckNull(String s) {}
- }
-
- private interface AnInterface {}
-
- private abstract static class AnAbstractClass {
- @SuppressWarnings("unused")
- public AnAbstractClass(String s) {}
-
- @SuppressWarnings("unused")
- public void failsToCheckNull(String s) {}
- }
-
- private static class NoPublicStaticMethods {
- @SuppressWarnings("unused") // To test non-public factory isn't used.
- static String notPublic() {
- return "";
- }
- }
-
- @interface MyAnnotation {}
-}
diff --git a/android/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java b/android/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java
index f100ef483..7628637ab 100644
--- a/android/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java
+++ b/android/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java
@@ -17,6 +17,7 @@
package com.google.common.testing;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.testing.GcFinalization.FinalizationPredicate;
import com.google.common.util.concurrent.SettableFuture;
@@ -146,12 +147,9 @@ public class GcFinalizationTest extends TestCase {
Interruptenator interruptenator = new Interruptenator(Thread.currentThread());
try {
final CountDownLatch latch = new CountDownLatch(1);
- try {
- GcFinalization.await(latch);
- fail("should throw");
- } catch (RuntimeException expected) {
- assertWrapsInterruptedException(expected);
- }
+ RuntimeException expected =
+ assertThrows(RuntimeException.class, () -> GcFinalization.await(latch));
+ assertWrapsInterruptedException(expected);
} finally {
interruptenator.shutdown();
Thread.interrupted();
@@ -162,12 +160,9 @@ public class GcFinalizationTest extends TestCase {
Interruptenator interruptenator = new Interruptenator(Thread.currentThread());
try {
final SettableFuture<@Nullable Void> future = SettableFuture.create();
- try {
- GcFinalization.awaitDone(future);
- fail("should throw");
- } catch (RuntimeException expected) {
- assertWrapsInterruptedException(expected);
- }
+ RuntimeException expected =
+ assertThrows(RuntimeException.class, () -> GcFinalization.awaitDone(future));
+ assertWrapsInterruptedException(expected);
} finally {
interruptenator.shutdown();
Thread.interrupted();
@@ -178,12 +173,9 @@ public class GcFinalizationTest extends TestCase {
Interruptenator interruptenator = new Interruptenator(Thread.currentThread());
try {
final WeakReference<Object> ref = new WeakReference<Object>(Boolean.TRUE);
- try {
- GcFinalization.awaitClear(ref);
- fail("should throw");
- } catch (RuntimeException expected) {
- assertWrapsInterruptedException(expected);
- }
+ RuntimeException expected =
+ assertThrows(RuntimeException.class, () -> GcFinalization.awaitClear(ref));
+ assertWrapsInterruptedException(expected);
} finally {
interruptenator.shutdown();
Thread.interrupted();
@@ -193,17 +185,18 @@ public class GcFinalizationTest extends TestCase {
public void testAwaitDone_FinalizationPredicate_Interrupted() {
Interruptenator interruptenator = new Interruptenator(Thread.currentThread());
try {
- try {
- GcFinalization.awaitDone(
- new FinalizationPredicate() {
- public boolean isDone() {
- return false;
- }
- });
- fail("should throw");
- } catch (RuntimeException expected) {
- assertWrapsInterruptedException(expected);
- }
+ RuntimeException expected =
+ assertThrows(
+ RuntimeException.class,
+ () ->
+ GcFinalization.awaitDone(
+ new FinalizationPredicate() {
+ @Override
+ public boolean isDone() {
+ return false;
+ }
+ }));
+ assertWrapsInterruptedException(expected);
} finally {
interruptenator.shutdown();
Thread.interrupted();
diff --git a/android/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java b/android/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
deleted file mode 100644
index d7344abf6..000000000
--- a/android/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
+++ /dev/null
@@ -1,1438 +0,0 @@
-/*
- * Copyright (C) 2005 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.testing;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.truth.Truth.assertThat;
-
-import com.google.common.base.Converter;
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMultimap;
-import com.google.common.collect.ImmutableMultiset;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSortedSet;
-import com.google.common.collect.ImmutableTable;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Multiset;
-import com.google.common.collect.Table;
-import com.google.common.reflect.TypeToken;
-import com.google.common.testing.NullPointerTester.Visibility;
-import com.google.common.testing.anotherpackage.SomeClassThatDoesNotUseNullable;
-import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/**
- * Unit test for {@link NullPointerTester}.
- *
- * @author Kevin Bourrillion
- * @author Mick Killianey
- */
-@SuppressWarnings("CheckReturnValue")
-@AndroidIncompatible // NullPointerTester refuses to run for c.g.c under Android
-public class NullPointerTesterTest extends TestCase {
-
- /** Non-NPE RuntimeException. */
- public static class FooException extends RuntimeException {
- private static final long serialVersionUID = 1L;
- }
-
- /**
- * Class for testing all permutations of static/non-static one-argument methods using
- * methodParameter().
- */
- @SuppressWarnings("unused") // used by reflection
- public static class OneArg {
-
- public static void staticOneArgCorrectlyThrowsNpe(String s) {
- checkNotNull(s); // expect NPE here on null
- }
-
- public static void staticOneArgThrowsOtherThanNpe(String s) {
- throw new FooException(); // should catch as failure
- }
-
- public static void staticOneArgShouldThrowNpeButDoesnt(String s) {
- // should catch as failure
- }
-
- public static void staticOneArgCheckForNullCorrectlyDoesNotThrowNPE(
- @javax.annotation.CheckForNull String s) {
- // null? no problem
- }
-
- public static void staticOneArgJsr305NullableCorrectlyDoesNotThrowNPE(
- @javax.annotation.Nullable String s) {
- // null? no problem
- }
-
- public static void staticOneArgNullableCorrectlyDoesNotThrowNPE(@Nullable String s) {
- // null? no problem
- }
-
- public static void staticOneArgCheckForNullCorrectlyThrowsOtherThanNPE(
- @javax.annotation.CheckForNull String s) {
- throw new FooException(); // ok, as long as it's not NullPointerException
- }
-
- public static void staticOneArgNullableCorrectlyThrowsOtherThanNPE(@Nullable String s) {
- throw new FooException(); // ok, as long as it's not NullPointerException
- }
-
- public static void staticOneArgCheckForNullThrowsNPE(@javax.annotation.CheckForNull String s) {
- checkNotNull(s); // doesn't check if you said you'd accept null, but you don't
- }
-
- public static void staticOneArgNullableThrowsNPE(@Nullable String s) {
- checkNotNull(s); // doesn't check if you said you'd accept null, but you don't
- }
-
- public void oneArgCorrectlyThrowsNpe(String s) {
- checkNotNull(s); // expect NPE here on null
- }
-
- public void oneArgThrowsOtherThanNpe(String s) {
- throw new FooException(); // should catch as failure
- }
-
- public void oneArgShouldThrowNpeButDoesnt(String s) {
- // should catch as failure
- }
-
- public void oneArgCheckForNullCorrectlyDoesNotThrowNPE(
- @javax.annotation.CheckForNull String s) {
- // null? no problem
- }
-
- public void oneArgNullableCorrectlyDoesNotThrowNPE(@Nullable String s) {
- // null? no problem
- }
-
- public void oneArgCheckForNullCorrectlyThrowsOtherThanNPE(
- @javax.annotation.CheckForNull String s) {
- throw new FooException(); // ok, as long as it's not NullPointerException
- }
-
- public void oneArgNullableCorrectlyThrowsOtherThanNPE(@Nullable String s) {
- throw new FooException(); // ok, as long as it's not NullPointerException
- }
-
- public void oneArgCheckForNullThrowsNPE(@javax.annotation.CheckForNull String s) {
- checkNotNull(s); // doesn't check if you said you'd accept null, but you don't
- }
-
- public void oneArgNullableThrowsNPE(@Nullable String s) {
- checkNotNull(s); // doesn't check if you said you'd accept null, but you don't
- }
- }
-
- private static final String[] STATIC_ONE_ARG_METHODS_SHOULD_PASS = {
- "staticOneArgCorrectlyThrowsNpe",
- "staticOneArgCheckForNullCorrectlyDoesNotThrowNPE",
- "staticOneArgCheckForNullCorrectlyThrowsOtherThanNPE",
- "staticOneArgCheckForNullThrowsNPE",
- "staticOneArgNullableCorrectlyDoesNotThrowNPE",
- "staticOneArgNullableCorrectlyThrowsOtherThanNPE",
- "staticOneArgNullableThrowsNPE",
- };
- private static final String[] STATIC_ONE_ARG_METHODS_SHOULD_FAIL = {
- "staticOneArgThrowsOtherThanNpe", "staticOneArgShouldThrowNpeButDoesnt",
- };
- private static final String[] NONSTATIC_ONE_ARG_METHODS_SHOULD_PASS = {
- "oneArgCorrectlyThrowsNpe",
- "oneArgCheckForNullCorrectlyDoesNotThrowNPE",
- "oneArgCheckForNullCorrectlyThrowsOtherThanNPE",
- "oneArgCheckForNullThrowsNPE",
- "oneArgNullableCorrectlyDoesNotThrowNPE",
- "oneArgNullableCorrectlyThrowsOtherThanNPE",
- "oneArgNullableThrowsNPE",
- };
- private static final String[] NONSTATIC_ONE_ARG_METHODS_SHOULD_FAIL = {
- "oneArgThrowsOtherThanNpe", "oneArgShouldThrowNpeButDoesnt",
- };
-
- private static class ThrowsIae {
- public static void christenPoodle(String name) {
- checkArgument(name != null);
- }
- }
-
- private static class ThrowsNpe {
- public static void christenPoodle(String name) {
- checkNotNull(name);
- }
- }
-
- private static class ThrowsUoe {
- public static void christenPoodle(String name) {
- throw new UnsupportedOperationException();
- }
- }
-
- private static class ThrowsSomethingElse {
- public static void christenPoodle(String name) {
- throw new RuntimeException();
- }
- }
-
- public void testDontAcceptIae() {
- NullPointerTester tester = new NullPointerTester();
- tester.testAllPublicStaticMethods(ThrowsNpe.class);
- tester.testAllPublicStaticMethods(ThrowsUoe.class);
- try {
- tester.testAllPublicStaticMethods(ThrowsIae.class);
- } catch (AssertionFailedError expected) {
- return;
- }
- fail();
- }
-
- public void testStaticOneArgMethodsThatShouldPass() throws Exception {
- for (String methodName : STATIC_ONE_ARG_METHODS_SHOULD_PASS) {
- Method method = OneArg.class.getMethod(methodName, String.class);
- try {
- new NullPointerTester().testMethodParameter(new OneArg(), method, 0);
- } catch (AssertionFailedError unexpected) {
- fail("Should not have flagged method " + methodName);
- }
- }
- }
-
- public void testStaticOneArgMethodsThatShouldFail() throws Exception {
- for (String methodName : STATIC_ONE_ARG_METHODS_SHOULD_FAIL) {
- Method method = OneArg.class.getMethod(methodName, String.class);
- boolean foundProblem = false;
- try {
- new NullPointerTester().testMethodParameter(new OneArg(), method, 0);
- } catch (AssertionFailedError expected) {
- foundProblem = true;
- }
- assertTrue("Should report error in method " + methodName, foundProblem);
- }
- }
-
- public void testNonStaticOneArgMethodsThatShouldPass() throws Exception {
- OneArg foo = new OneArg();
- for (String methodName : NONSTATIC_ONE_ARG_METHODS_SHOULD_PASS) {
- Method method = OneArg.class.getMethod(methodName, String.class);
- try {
- new NullPointerTester().testMethodParameter(foo, method, 0);
- } catch (AssertionFailedError unexpected) {
- fail("Should not have flagged method " + methodName);
- }
- }
- }
-
- public void testNonStaticOneArgMethodsThatShouldFail() throws Exception {
- OneArg foo = new OneArg();
- for (String methodName : NONSTATIC_ONE_ARG_METHODS_SHOULD_FAIL) {
- Method method = OneArg.class.getMethod(methodName, String.class);
- boolean foundProblem = false;
- try {
- new NullPointerTester().testMethodParameter(foo, method, 0);
- } catch (AssertionFailedError expected) {
- foundProblem = true;
- }
- assertTrue("Should report error in method " + methodName, foundProblem);
- }
- }
-
- public void testMessageOtherException() throws Exception {
- Method method = OneArg.class.getMethod("staticOneArgThrowsOtherThanNpe", String.class);
- boolean foundProblem = false;
- try {
- new NullPointerTester().testMethodParameter(new OneArg(), method, 0);
- } catch (AssertionFailedError expected) {
- assertThat(expected.getMessage()).contains("index 0");
- assertThat(expected.getMessage()).contains("[null]");
- foundProblem = true;
- }
- assertTrue("Should report error when different exception is thrown", foundProblem);
- }
-
- public void testMessageNoException() throws Exception {
- Method method = OneArg.class.getMethod("staticOneArgShouldThrowNpeButDoesnt", String.class);
- boolean foundProblem = false;
- try {
- new NullPointerTester().testMethodParameter(new OneArg(), method, 0);
- } catch (AssertionFailedError expected) {
- assertThat(expected.getMessage()).contains("index 0");
- assertThat(expected.getMessage()).contains("[null]");
- foundProblem = true;
- }
- assertTrue("Should report error when no exception is thrown", foundProblem);
- }
-
- /**
- * Class for testing all permutations of nullable/non-nullable two-argument methods using
- * testMethod().
- *
- * <ul>
- * <li>normalNormal: two params, neither is Nullable
- * <li>nullableNormal: only first param is Nullable
- * <li>normalNullable: only second param is Nullable
- * <li>nullableNullable: both params are Nullable
- * </ul>
- */
- public static class TwoArg {
- /** Action to take on a null param. */
- public enum Action {
- THROW_A_NPE {
- @Override
- public void act() {
- throw new NullPointerException();
- }
- },
- THROW_OTHER {
- @Override
- public void act() {
- throw new FooException();
- }
- },
- JUST_RETURN {
- @Override
- public void act() {}
- };
-
- public abstract void act();
- }
-
- Action actionWhenFirstParamIsNull;
- Action actionWhenSecondParamIsNull;
-
- public TwoArg(Action actionWhenFirstParamIsNull, Action actionWhenSecondParamIsNull) {
- this.actionWhenFirstParamIsNull = actionWhenFirstParamIsNull;
- this.actionWhenSecondParamIsNull = actionWhenSecondParamIsNull;
- }
-
- /** Method that decides how to react to parameters. */
- public void reactToNullParameters(@Nullable Object first, @Nullable Object second) {
- if (first == null) {
- actionWhenFirstParamIsNull.act();
- }
- if (second == null) {
- actionWhenSecondParamIsNull.act();
- }
- }
-
- /** Two-arg method with no Nullable params. */
- @SuppressWarnings("GoodTime") // false positive; b/122617528
- public void normalNormal(String first, Integer second) {
- reactToNullParameters(first, second);
- }
-
- /** Two-arg method with the second param Nullable. */
- @SuppressWarnings("GoodTime") // false positive; b/122617528
- public void normalNullable(String first, @Nullable Integer second) {
- reactToNullParameters(first, second);
- }
-
- /** Two-arg method with the first param Nullable. */
- @SuppressWarnings("GoodTime") // false positive; b/122617528
- public void nullableNormal(@Nullable String first, Integer second) {
- reactToNullParameters(first, second);
- }
-
- /** Two-arg method with the both params Nullable. */
- @SuppressWarnings("GoodTime") // false positive; b/122617528
- public void nullableNullable(@Nullable String first, @Nullable Integer second) {
- reactToNullParameters(first, second);
- }
-
- /** To provide sanity during debugging. */
- @Override
- public String toString() {
- return rootLocaleFormat(
- "Bar(%s, %s)", actionWhenFirstParamIsNull, actionWhenSecondParamIsNull);
- }
- }
-
- public void verifyBarPass(Method method, TwoArg bar) {
- try {
- new NullPointerTester().testMethod(bar, method);
- } catch (AssertionFailedError incorrectError) {
- String errorMessage =
- rootLocaleFormat("Should not have flagged method %s for %s", method.getName(), bar);
- assertNull(errorMessage, incorrectError);
- }
- }
-
- public void verifyBarFail(Method method, TwoArg bar) {
- try {
- new NullPointerTester().testMethod(bar, method);
- } catch (AssertionFailedError expected) {
- return; // good...we wanted a failure
- }
- String errorMessage =
- rootLocaleFormat("Should have flagged method %s for %s", method.getName(), bar);
- fail(errorMessage);
- }
-
- public void testTwoArgNormalNormal() throws Exception {
- Method method = TwoArg.class.getMethod("normalNormal", String.class, Integer.class);
- for (TwoArg.Action first : TwoArg.Action.values()) {
- for (TwoArg.Action second : TwoArg.Action.values()) {
- TwoArg bar = new TwoArg(first, second);
- if (first.equals(TwoArg.Action.THROW_A_NPE) && second.equals(TwoArg.Action.THROW_A_NPE)) {
- verifyBarPass(method, bar); // require both params to throw NPE
- } else {
- verifyBarFail(method, bar);
- }
- }
- }
- }
-
- public void testTwoArgNormalNullable() throws Exception {
- Method method = TwoArg.class.getMethod("normalNullable", String.class, Integer.class);
- for (TwoArg.Action first : TwoArg.Action.values()) {
- for (TwoArg.Action second : TwoArg.Action.values()) {
- TwoArg bar = new TwoArg(first, second);
- if (first.equals(TwoArg.Action.THROW_A_NPE)) {
- verifyBarPass(method, bar); // only pass if 1st param throws NPE
- } else {
- verifyBarFail(method, bar);
- }
- }
- }
- }
-
- public void testTwoArgNullableNormal() throws Exception {
- Method method = TwoArg.class.getMethod("nullableNormal", String.class, Integer.class);
- for (TwoArg.Action first : TwoArg.Action.values()) {
- for (TwoArg.Action second : TwoArg.Action.values()) {
- TwoArg bar = new TwoArg(first, second);
- if (second.equals(TwoArg.Action.THROW_A_NPE)) {
- verifyBarPass(method, bar); // only pass if 2nd param throws NPE
- } else {
- verifyBarFail(method, bar);
- }
- }
- }
- }
-
- public void testTwoArgNullableNullable() throws Exception {
- Method method = TwoArg.class.getMethod("nullableNullable", String.class, Integer.class);
- for (TwoArg.Action first : TwoArg.Action.values()) {
- for (TwoArg.Action second : TwoArg.Action.values()) {
- TwoArg bar = new TwoArg(first, second);
- verifyBarPass(method, bar); // All args nullable: anything goes!
- }
- }
- }
-
- /*
- * This next part consists of several sample classes that provide
- * demonstrations of conditions that cause NullPointerTester
- * to succeed/fail.
- */
-
- /** Lots of well-behaved methods. */
- @SuppressWarnings("unused") // used by reflection
- private static class PassObject extends SomeClassThatDoesNotUseNullable {
- public static void doThrow(Object arg) {
- if (arg == null) {
- throw new FooException();
- }
- }
-
- public void noArg() {}
-
- public void oneArg(String s) {
- checkNotNull(s);
- }
-
- void packagePrivateOneArg(String s) {
- checkNotNull(s);
- }
-
- protected void protectedOneArg(String s) {
- checkNotNull(s);
- }
-
- public void oneNullableArg(@Nullable String s) {}
-
- public void oneNullableArgThrows(@Nullable String s) {
- doThrow(s);
- }
-
- public void twoArg(String s, Integer i) {
- checkNotNull(s);
- i.intValue();
- }
-
- public void twoMixedArgs(String s, @Nullable Integer i) {
- checkNotNull(s);
- }
-
- public void twoMixedArgs(@Nullable Integer i, String s) {
- checkNotNull(s);
- }
-
- public void twoMixedArgsThrows(String s, @Nullable Integer i) {
- checkNotNull(s);
- doThrow(i);
- }
-
- public void twoMixedArgsThrows(@Nullable Integer i, String s) {
- checkNotNull(s);
- doThrow(i);
- }
-
- public void twoNullableArgs(@Nullable String s, @javax.annotation.Nullable Integer i) {}
-
- public void twoNullableArgsThrowsFirstArg(@Nullable String s, @Nullable Integer i) {
- doThrow(s);
- }
-
- public void twoNullableArgsThrowsSecondArg(@Nullable String s, @Nullable Integer i) {
- doThrow(i);
- }
-
- public static void staticOneArg(String s) {
- checkNotNull(s);
- }
-
- public static void staticOneNullableArg(@Nullable String s) {}
-
- public static void staticOneNullableArgThrows(@Nullable String s) {
- doThrow(s);
- }
- }
-
- public void testGoodClass() {
- shouldPass(new PassObject());
- }
-
- private static class FailOneArgDoesntThrowNPE extends PassObject {
- @Override
- public void oneArg(String s) {
- // Fail: missing NPE for s
- }
- }
-
- public void testFailOneArgDoesntThrowNpe() {
- shouldFail(new FailOneArgDoesntThrowNPE());
- }
-
- private static class FailOneArgThrowsWrongType extends PassObject {
- @Override
- public void oneArg(String s) {
- doThrow(s); // Fail: throwing non-NPE exception for null s
- }
- }
-
- public void testFailOneArgThrowsWrongType() {
- shouldFail(new FailOneArgThrowsWrongType());
- }
-
- private static class PassOneNullableArgThrowsNPE extends PassObject {
- @Override
- public void oneNullableArg(@Nullable String s) {
- checkNotNull(s); // ok to throw NPE
- }
- }
-
- public void testPassOneNullableArgThrowsNPE() {
- shouldPass(new PassOneNullableArgThrowsNPE());
- }
-
- private static class FailTwoArgsFirstArgDoesntThrowNPE extends PassObject {
- @Override
- public void twoArg(String s, Integer i) {
- // Fail: missing NPE for s
- i.intValue();
- }
- }
-
- public void testFailTwoArgsFirstArgDoesntThrowNPE() {
- shouldFail(new FailTwoArgsFirstArgDoesntThrowNPE());
- }
-
- private static class FailTwoArgsFirstArgThrowsWrongType extends PassObject {
- @Override
- public void twoArg(String s, Integer i) {
- doThrow(s); // Fail: throwing non-NPE exception for null s
- i.intValue();
- }
- }
-
- public void testFailTwoArgsFirstArgThrowsWrongType() {
- shouldFail(new FailTwoArgsFirstArgThrowsWrongType());
- }
-
- private static class FailTwoArgsSecondArgDoesntThrowNPE extends PassObject {
- @Override
- public void twoArg(String s, Integer i) {
- checkNotNull(s);
- // Fail: missing NPE for i
- }
- }
-
- public void testFailTwoArgsSecondArgDoesntThrowNPE() {
- shouldFail(new FailTwoArgsSecondArgDoesntThrowNPE());
- }
-
- private static class FailTwoArgsSecondArgThrowsWrongType extends PassObject {
- @Override
- public void twoArg(String s, Integer i) {
- checkNotNull(s);
- doThrow(i); // Fail: throwing non-NPE exception for null i
- }
- }
-
- public void testFailTwoArgsSecondArgThrowsWrongType() {
- shouldFail(new FailTwoArgsSecondArgThrowsWrongType());
- }
-
- private static class FailTwoMixedArgsFirstArgDoesntThrowNPE extends PassObject {
- @Override
- public void twoMixedArgs(String s, @Nullable Integer i) {
- // Fail: missing NPE for s
- }
- }
-
- public void testFailTwoMixedArgsFirstArgDoesntThrowNPE() {
- shouldFail(new FailTwoMixedArgsFirstArgDoesntThrowNPE());
- }
-
- private static class FailTwoMixedArgsFirstArgThrowsWrongType extends PassObject {
- @Override
- public void twoMixedArgs(String s, @Nullable Integer i) {
- doThrow(s); // Fail: throwing non-NPE exception for null s
- }
- }
-
- public void testFailTwoMixedArgsFirstArgThrowsWrongType() {
- shouldFail(new FailTwoMixedArgsFirstArgThrowsWrongType());
- }
-
- private static class PassTwoMixedArgsNullableArgThrowsNPE extends PassObject {
- @Override
- public void twoMixedArgs(String s, @Nullable Integer i) {
- checkNotNull(s);
- i.intValue(); // ok to throw NPE?
- }
- }
-
- public void testPassTwoMixedArgsNullableArgThrowsNPE() {
- shouldPass(new PassTwoMixedArgsNullableArgThrowsNPE());
- }
-
- private static class PassTwoMixedArgSecondNullableArgThrowsOther extends PassObject {
- @Override
- public void twoMixedArgs(String s, @Nullable Integer i) {
- checkNotNull(s);
- doThrow(i); // ok to throw non-NPE exception for null i
- }
- }
-
- public void testPassTwoMixedArgSecondNullableArgThrowsOther() {
- shouldPass(new PassTwoMixedArgSecondNullableArgThrowsOther());
- }
-
- private static class FailTwoMixedArgsSecondArgDoesntThrowNPE extends PassObject {
- @Override
- public void twoMixedArgs(@Nullable Integer i, String s) {
- // Fail: missing NPE for null s
- }
- }
-
- public void testFailTwoMixedArgsSecondArgDoesntThrowNPE() {
- shouldFail(new FailTwoMixedArgsSecondArgDoesntThrowNPE());
- }
-
- private static class FailTwoMixedArgsSecondArgThrowsWrongType extends PassObject {
- @Override
- public void twoMixedArgs(@Nullable Integer i, String s) {
- doThrow(s); // Fail: throwing non-NPE exception for null s
- }
- }
-
- public void testFailTwoMixedArgsSecondArgThrowsWrongType() {
- shouldFail(new FailTwoMixedArgsSecondArgThrowsWrongType());
- }
-
- private static class PassTwoNullableArgsFirstThrowsNPE extends PassObject {
- @Override
- public void twoNullableArgs(@Nullable String s, @Nullable Integer i) {
- checkNotNull(s); // ok to throw NPE?
- }
- }
-
- public void testPassTwoNullableArgsFirstThrowsNPE() {
- shouldPass(new PassTwoNullableArgsFirstThrowsNPE());
- }
-
- private static class PassTwoNullableArgsFirstThrowsOther extends PassObject {
- @Override
- public void twoNullableArgs(@Nullable String s, @Nullable Integer i) {
- doThrow(s); // ok to throw non-NPE exception for null s
- }
- }
-
- public void testPassTwoNullableArgsFirstThrowsOther() {
- shouldPass(new PassTwoNullableArgsFirstThrowsOther());
- }
-
- private static class PassTwoNullableArgsSecondThrowsNPE extends PassObject {
- @Override
- public void twoNullableArgs(@Nullable String s, @Nullable Integer i) {
- i.intValue(); // ok to throw NPE?
- }
- }
-
- public void testPassTwoNullableArgsSecondThrowsNPE() {
- shouldPass(new PassTwoNullableArgsSecondThrowsNPE());
- }
-
- private static class PassTwoNullableArgsSecondThrowsOther extends PassObject {
- @Override
- public void twoNullableArgs(@Nullable String s, @Nullable Integer i) {
- doThrow(i); // ok to throw non-NPE exception for null i
- }
- }
-
- public void testPassTwoNullableArgsSecondThrowsOther() {
- shouldPass(new PassTwoNullableArgsSecondThrowsOther());
- }
-
- private static class PassTwoNullableArgsNeitherThrowsAnything extends PassObject {
- @Override
- public void twoNullableArgs(@Nullable String s, @Nullable Integer i) {
- // ok to do nothing
- }
- }
-
- public void testPassTwoNullableArgsNeitherThrowsAnything() {
- shouldPass(new PassTwoNullableArgsNeitherThrowsAnything());
- }
-
- @SuppressWarnings("unused") // for NullPointerTester
- private abstract static class BaseClassThatFailsToThrow {
- public void oneArg(String s) {}
- }
-
- private static class SubclassWithBadSuperclass extends BaseClassThatFailsToThrow {}
-
- public void testSubclassWithBadSuperclass() {
- shouldFail(new SubclassWithBadSuperclass());
- }
-
- @SuppressWarnings("unused") // for NullPointerTester
- private abstract static class BaseClassThatFailsToThrowForPackagePrivate {
- void packagePrivateOneArg(String s) {}
- }
-
- private static class SubclassWithBadSuperclassForPackagePrivate
- extends BaseClassThatFailsToThrowForPackagePrivate {}
-
- public void testSubclassWithBadSuperclassForPackagePrivateMethod() {
- shouldFail(new SubclassWithBadSuperclassForPackagePrivate(), Visibility.PACKAGE);
- }
-
- @SuppressWarnings("unused") // for NullPointerTester
- private abstract static class BaseClassThatFailsToThrowForProtected {
- protected void protectedOneArg(String s) {}
- }
-
- private static class SubclassWithBadSuperclassForProtected
- extends BaseClassThatFailsToThrowForProtected {}
-
- public void testSubclassWithBadSuperclassForPackageProtectedMethod() {
- shouldFail(new SubclassWithBadSuperclassForProtected(), Visibility.PROTECTED);
- }
-
- private static class SubclassThatOverridesBadSuperclassMethod extends BaseClassThatFailsToThrow {
- @Override
- public void oneArg(@Nullable String s) {}
- }
-
- public void testSubclassThatOverridesBadSuperclassMethod() {
- shouldPass(new SubclassThatOverridesBadSuperclassMethod());
- }
-
- @SuppressWarnings("unused") // for NullPointerTester
- private static class SubclassOverridesTheWrongMethod extends BaseClassThatFailsToThrow {
- public void oneArg(@Nullable CharSequence s) {}
- }
-
- public void testSubclassOverridesTheWrongMethod() {
- shouldFail(new SubclassOverridesTheWrongMethod());
- }
-
- @SuppressWarnings("unused") // for NullPointerTester
- private static class ClassThatFailsToThrowForStatic {
- static void staticOneArg(String s) {}
- }
-
- public void testClassThatFailsToThrowForStatic() {
- shouldFail(ClassThatFailsToThrowForStatic.class);
- }
-
- private static class SubclassThatFailsToThrowForStatic extends ClassThatFailsToThrowForStatic {}
-
- public void testSubclassThatFailsToThrowForStatic() {
- shouldFail(SubclassThatFailsToThrowForStatic.class);
- }
-
- private static class SubclassThatTriesToOverrideBadStaticMethod
- extends ClassThatFailsToThrowForStatic {
- static void staticOneArg(@Nullable String s) {}
- }
-
- public void testSubclassThatTriesToOverrideBadStaticMethod() {
- shouldFail(SubclassThatTriesToOverrideBadStaticMethod.class);
- }
-
- private static final class HardToCreate {
- private HardToCreate(HardToCreate x) {}
- }
-
- @SuppressWarnings("unused") // used by reflection
- private static class CanCreateDefault {
- public void foo(@Nullable HardToCreate ignored, String required) {
- checkNotNull(required);
- }
- }
-
- public void testCanCreateDefault() {
- shouldPass(new CanCreateDefault());
- }
-
- @SuppressWarnings("unused") // used by reflection
- private static class CannotCreateDefault {
- public void foo(HardToCreate ignored, String required) {
- checkNotNull(ignored);
- checkNotNull(required);
- }
- }
-
- public void testCannotCreateDefault() {
- shouldFail(new CannotCreateDefault());
- }
-
- private static void shouldPass(Object instance, Visibility visibility) {
- new NullPointerTester().testInstanceMethods(instance, visibility);
- }
-
- private static void shouldPass(Object instance) {
- shouldPass(instance, Visibility.PACKAGE);
- shouldPass(instance, Visibility.PROTECTED);
- shouldPass(instance, Visibility.PUBLIC);
- }
-
- // TODO(cpovirk): eliminate surprising Object/Class overloading of shouldFail
-
- private static void shouldFail(Object instance, Visibility visibility) {
- try {
- new NullPointerTester().testInstanceMethods(instance, visibility);
- } catch (AssertionFailedError expected) {
- return;
- }
- fail("Should detect problem in " + instance.getClass().getSimpleName());
- }
-
- private static void shouldFail(Object instance) {
- shouldFail(instance, Visibility.PACKAGE);
- shouldFail(instance, Visibility.PROTECTED);
- shouldFail(instance, Visibility.PUBLIC);
- }
-
- private static void shouldFail(Class<?> cls, Visibility visibility) {
- try {
- new NullPointerTester().testStaticMethods(cls, visibility);
- } catch (AssertionFailedError expected) {
- return;
- }
- fail("Should detect problem in " + cls.getSimpleName());
- }
-
- private static void shouldFail(Class<?> cls) {
- shouldFail(cls, Visibility.PACKAGE);
- }
-
- @SuppressWarnings("unused") // used by reflection
- private static class PrivateClassWithPrivateConstructor {
- private PrivateClassWithPrivateConstructor(@Nullable Integer argument) {}
- }
-
- public void testPrivateClass() {
- NullPointerTester tester = new NullPointerTester();
- for (Constructor<?> constructor :
- PrivateClassWithPrivateConstructor.class.getDeclaredConstructors()) {
- tester.testConstructor(constructor);
- }
- }
-
- private interface Foo<T> {
- void doSomething(T bar, Integer baz);
- }
-
- private static class StringFoo implements Foo<String> {
-
- @Override
- public void doSomething(String bar, Integer baz) {
- checkNotNull(bar);
- checkNotNull(baz);
- }
- }
-
- public void testBridgeMethodIgnored() {
- new NullPointerTester().testAllPublicInstanceMethods(new StringFoo());
- }
-
- private abstract static class DefaultValueChecker {
-
- private final Map<Integer, Object> arguments = Maps.newHashMap();
-
- @CanIgnoreReturnValue
- final DefaultValueChecker runTester() {
- new NullPointerTester().testInstanceMethods(this, Visibility.PACKAGE);
- return this;
- }
-
- final void assertNonNullValues(Object... expectedValues) {
- assertEquals(expectedValues.length, arguments.size());
- for (int i = 0; i < expectedValues.length; i++) {
- assertEquals("Default value for parameter #" + i, expectedValues[i], arguments.get(i));
- }
- }
-
- final Object getDefaultParameterValue(int position) {
- return arguments.get(position);
- }
-
- final void calledWith(Object... args) {
- for (int i = 0; i < args.length; i++) {
- if (args[i] != null) {
- arguments.put(i, args[i]);
- }
- }
- for (Object arg : args) {
- checkNotNull(arg); // to fulfill null check
- }
- }
- }
-
- private enum Gender {
- MALE,
- FEMALE
- }
-
- private static class AllDefaultValuesChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkDefaultValuesForTheseTypes(
- Gender gender,
- Integer integer,
- int i,
- String string,
- CharSequence charSequence,
- List<String> list,
- ImmutableList<Integer> immutableList,
- Map<String, Integer> map,
- ImmutableMap<String, String> immutableMap,
- Set<String> set,
- ImmutableSet<Integer> immutableSet,
- SortedSet<Number> sortedSet,
- ImmutableSortedSet<Number> immutableSortedSet,
- Multiset<String> multiset,
- ImmutableMultiset<Integer> immutableMultiset,
- Multimap<String, Integer> multimap,
- ImmutableMultimap<String, Integer> immutableMultimap,
- Table<String, Integer, Exception> table,
- ImmutableTable<Integer, String, Exception> immutableTable) {
- calledWith(
- gender,
- integer,
- i,
- string,
- charSequence,
- list,
- immutableList,
- map,
- immutableMap,
- set,
- immutableSet,
- sortedSet,
- immutableSortedSet,
- multiset,
- immutableMultiset,
- multimap,
- immutableMultimap,
- table,
- immutableTable);
- }
-
- final void check() {
- runTester()
- .assertNonNullValues(
- Gender.MALE,
- Integer.valueOf(0),
- 0,
- "",
- "",
- ImmutableList.of(),
- ImmutableList.of(),
- ImmutableMap.of(),
- ImmutableMap.of(),
- ImmutableSet.of(),
- ImmutableSet.of(),
- ImmutableSortedSet.of(),
- ImmutableSortedSet.of(),
- ImmutableMultiset.of(),
- ImmutableMultiset.of(),
- ImmutableMultimap.of(),
- ImmutableMultimap.of(),
- ImmutableTable.of(),
- ImmutableTable.of());
- }
- }
-
- public void testDefaultValues() {
- new AllDefaultValuesChecker().check();
- }
-
- private static class ObjectArrayDefaultValueChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkArray(Object[] array, String s) {
- calledWith(array, s);
- }
-
- void check() {
- runTester();
- Object[] defaultArray = (Object[]) getDefaultParameterValue(0);
- assertThat(defaultArray).isEmpty();
- }
- }
-
- public void testObjectArrayDefaultValue() {
- new ObjectArrayDefaultValueChecker().check();
- }
-
- private static class StringArrayDefaultValueChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkArray(String[] array, String s) {
- calledWith(array, s);
- }
-
- void check() {
- runTester();
- String[] defaultArray = (String[]) getDefaultParameterValue(0);
- assertThat(defaultArray).isEmpty();
- }
- }
-
- public void testStringArrayDefaultValue() {
- new StringArrayDefaultValueChecker().check();
- }
-
- private static class IntArrayDefaultValueChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkArray(int[] array, String s) {
- calledWith(array, s);
- }
-
- void check() {
- runTester();
- int[] defaultArray = (int[]) getDefaultParameterValue(0);
- assertEquals(0, defaultArray.length);
- }
- }
-
- public void testIntArrayDefaultValue() {
- new IntArrayDefaultValueChecker().check();
- }
-
- private enum EmptyEnum {}
-
- private static class EmptyEnumDefaultValueChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkArray(EmptyEnum object, String s) {
- calledWith(object, s);
- }
-
- void check() {
- try {
- runTester();
- } catch (AssertionFailedError expected) {
- return;
- }
- fail("Should have failed because enum has no constant");
- }
- }
-
- public void testEmptyEnumDefaultValue() {
- new EmptyEnumDefaultValueChecker().check();
- }
-
- private static class GenericClassTypeDefaultValueChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkArray(Class<? extends List<?>> cls, String s) {
- calledWith(cls, s);
- }
-
- void check() {
- runTester();
- Class<?> defaultClass = (Class<?>) getDefaultParameterValue(0);
- assertEquals(List.class, defaultClass);
- }
- }
-
- public void testGenericClassDefaultValue() {
- new GenericClassTypeDefaultValueChecker().check();
- }
-
- private static class NonGenericClassTypeDefaultValueChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkArray(@SuppressWarnings("rawtypes") Class cls, String s) {
- calledWith(cls, s);
- }
-
- void check() {
- runTester();
- Class<?> defaultClass = (Class<?>) getDefaultParameterValue(0);
- assertEquals(Object.class, defaultClass);
- }
- }
-
- public void testNonGenericClassDefaultValue() {
- new NonGenericClassTypeDefaultValueChecker().check();
- }
-
- private static class GenericTypeTokenDefaultValueChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkArray(TypeToken<? extends List<? super Number>> type, String s) {
- calledWith(type, s);
- }
-
- void check() {
- runTester();
- TypeToken<?> defaultType = (TypeToken<?>) getDefaultParameterValue(0);
- assertTrue(new TypeToken<List<? super Number>>() {}.isSupertypeOf(defaultType));
- }
- }
-
- public void testGenericTypeTokenDefaultValue() {
- new GenericTypeTokenDefaultValueChecker().check();
- }
-
- private static class NonGenericTypeTokenDefaultValueChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkArray(@SuppressWarnings("rawtypes") TypeToken type, String s) {
- calledWith(type, s);
- }
-
- void check() {
- runTester();
- TypeToken<?> defaultType = (TypeToken<?>) getDefaultParameterValue(0);
- assertEquals(new TypeToken<Object>() {}, defaultType);
- }
- }
-
- public void testNonGenericTypeTokenDefaultValue() {
- new NonGenericTypeTokenDefaultValueChecker().check();
- }
-
- private interface FromTo<F, T> extends Function<F, T> {}
-
- private static class GenericInterfaceDefaultValueChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkArray(FromTo<String, Integer> f, String s) {
- calledWith(f, s);
- }
-
- void check() {
- runTester();
- FromTo<?, ?> defaultFunction = (FromTo<?, ?>) getDefaultParameterValue(0);
- assertEquals(0, defaultFunction.apply(null));
- }
- }
-
- public void testGenericInterfaceDefaultValue() {
- new GenericInterfaceDefaultValueChecker().check();
- }
-
- private interface NullRejectingFromTo<F, T> extends Function<F, T> {
- @Override
- public abstract T apply(F from);
- }
-
- private static class NullRejectingInterfaceDefaultValueChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkArray(NullRejectingFromTo<String, Integer> f, String s) {
- calledWith(f, s);
- }
-
- void check() {
- runTester();
- NullRejectingFromTo<?, ?> defaultFunction =
- (NullRejectingFromTo<?, ?>) getDefaultParameterValue(0);
- assertNotNull(defaultFunction);
- try {
- defaultFunction.apply(null);
- fail("Proxy Should have rejected null");
- } catch (NullPointerException expected) {
- }
- }
- }
-
- public void testNullRejectingInterfaceDefaultValue() {
- new NullRejectingInterfaceDefaultValueChecker().check();
- }
-
- private static class MultipleInterfacesDefaultValueChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public <T extends FromTo<String, Integer> & Supplier<Long>> void checkArray(T f, String s) {
- calledWith(f, s);
- }
-
- void check() {
- runTester();
- FromTo<?, ?> defaultFunction = (FromTo<?, ?>) getDefaultParameterValue(0);
- assertEquals(0, defaultFunction.apply(null));
- Supplier<?> defaultSupplier = (Supplier<?>) defaultFunction;
- assertEquals(Long.valueOf(0), defaultSupplier.get());
- }
- }
-
- public void testMultipleInterfacesDefaultValue() {
- new MultipleInterfacesDefaultValueChecker().check();
- }
-
- private static class GenericInterface2DefaultValueChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkArray(FromTo<String, FromTo<Integer, String>> f, String s) {
- calledWith(f, s);
- }
-
- void check() {
- runTester();
- FromTo<?, ?> defaultFunction = (FromTo<?, ?>) getDefaultParameterValue(0);
- FromTo<?, ?> returnValue = (FromTo<?, ?>) defaultFunction.apply(null);
- assertEquals("", returnValue.apply(null));
- }
- }
-
- public void testGenericInterfaceReturnedByGenericMethod() {
- new GenericInterface2DefaultValueChecker().check();
- }
-
- private abstract static class AbstractGenericDefaultValueChecker<T> extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkGeneric(T value, String s) {
- calledWith(value, s);
- }
- }
-
- private static class GenericDefaultValueResolvedToStringChecker
- extends AbstractGenericDefaultValueChecker<String> {
- void check() {
- runTester();
- assertEquals("", getDefaultParameterValue(0));
- }
- }
-
- public void testGenericTypeResolvedForDefaultValue() {
- new GenericDefaultValueResolvedToStringChecker().check();
- }
-
- private abstract static class AbstractGenericDefaultValueForPackagePrivateMethodChecker<T>
- extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- void checkGeneric(T value, String s) {
- calledWith(value, s);
- }
- }
-
- private static class DefaultValueForPackagePrivateMethodResolvedToStringChecker
- extends AbstractGenericDefaultValueForPackagePrivateMethodChecker<String> {
- void check() {
- runTester();
- assertEquals("", getDefaultParameterValue(0));
- }
- }
-
- public void testDefaultValueResolvedForPackagePrivateMethod() {
- new DefaultValueForPackagePrivateMethodResolvedToStringChecker().check();
- }
-
- private static class ConverterDefaultValueChecker extends DefaultValueChecker {
-
- @SuppressWarnings("unused") // called by NullPointerTester
- public void checkArray(Converter<String, Integer> c, String s) {
- calledWith(c, s);
- }
-
- void check() {
- runTester();
- @SuppressWarnings("unchecked") // We are checking it anyway
- Converter<String, Integer> defaultConverter =
- (Converter<String, Integer>) getDefaultParameterValue(0);
- assertEquals(Integer.valueOf(0), defaultConverter.convert("anything"));
- assertEquals("", defaultConverter.reverse().convert(123));
- assertNull(defaultConverter.convert(null));
- assertNull(defaultConverter.reverse().convert(null));
- }
- }
-
- public void testConverterDefaultValue() {
- new ConverterDefaultValueChecker().check();
- }
-
- private static class VisibilityMethods {
-
- @SuppressWarnings("unused") // Called by reflection
- private void privateMethod() {}
-
- @SuppressWarnings("unused") // Called by reflection
- void packagePrivateMethod() {}
-
- @SuppressWarnings("unused") // Called by reflection
- protected void protectedMethod() {}
-
- @SuppressWarnings("unused") // Called by reflection
- public void publicMethod() {}
- }
-
- public void testVisibility_public() throws Exception {
- assertFalse(
- Visibility.PUBLIC.isVisible(VisibilityMethods.class.getDeclaredMethod("privateMethod")));
- assertFalse(
- Visibility.PUBLIC.isVisible(
- VisibilityMethods.class.getDeclaredMethod("packagePrivateMethod")));
- assertFalse(
- Visibility.PUBLIC.isVisible(VisibilityMethods.class.getDeclaredMethod("protectedMethod")));
- assertTrue(
- Visibility.PUBLIC.isVisible(VisibilityMethods.class.getDeclaredMethod("publicMethod")));
- }
-
- public void testVisibility_protected() throws Exception {
- assertFalse(
- Visibility.PROTECTED.isVisible(VisibilityMethods.class.getDeclaredMethod("privateMethod")));
- assertFalse(
- Visibility.PROTECTED.isVisible(
- VisibilityMethods.class.getDeclaredMethod("packagePrivateMethod")));
- assertTrue(
- Visibility.PROTECTED.isVisible(
- VisibilityMethods.class.getDeclaredMethod("protectedMethod")));
- assertTrue(
- Visibility.PROTECTED.isVisible(VisibilityMethods.class.getDeclaredMethod("publicMethod")));
- }
-
- public void testVisibility_package() throws Exception {
- assertFalse(
- Visibility.PACKAGE.isVisible(VisibilityMethods.class.getDeclaredMethod("privateMethod")));
- assertTrue(
- Visibility.PACKAGE.isVisible(
- VisibilityMethods.class.getDeclaredMethod("packagePrivateMethod")));
- assertTrue(
- Visibility.PACKAGE.isVisible(VisibilityMethods.class.getDeclaredMethod("protectedMethod")));
- assertTrue(
- Visibility.PACKAGE.isVisible(VisibilityMethods.class.getDeclaredMethod("publicMethod")));
- }
-
- private class Inner {
- public Inner(String s) {
- checkNotNull(s);
- }
- }
-
- public void testNonStaticInnerClass() {
- try {
- new NullPointerTester().testAllPublicConstructors(Inner.class);
- fail();
- } catch (IllegalArgumentException expected) {
- assertThat(expected.getMessage()).contains("inner class");
- }
- }
-
- private static String rootLocaleFormat(String format, Object... args) {
- return String.format(Locale.ROOT, format, args);
- }
-
- static class OverridesEquals {
- @SuppressWarnings("EqualsHashCode")
- @Override
- public boolean equals(@Nullable Object o) {
- return true;
- }
- }
-
- static class DoesNotOverrideEquals {
- public boolean equals(Object a, Object b) {
- return true;
- }
- }
-
- public void testEqualsMethod() {
- shouldPass(new OverridesEquals());
- shouldFail(new DoesNotOverrideEquals());
- }
-
- private static final class FailOnOneOfTwoConstructors {
- @SuppressWarnings("unused") // Called by reflection
- public FailOnOneOfTwoConstructors(String s) {}
-
- @SuppressWarnings("unused") // Called by reflection
- public FailOnOneOfTwoConstructors(Object o) {
- checkNotNull(o);
- }
- }
-
- public void testConstructor_Ignored_ShouldPass() throws Exception {
- new NullPointerTester()
- .ignore(FailOnOneOfTwoConstructors.class.getDeclaredConstructor(String.class))
- .testAllPublicConstructors(FailOnOneOfTwoConstructors.class);
- }
-
- public void testConstructor_ShouldFail() throws Exception {
- try {
- new NullPointerTester().testAllPublicConstructors(FailOnOneOfTwoConstructors.class);
- } catch (AssertionFailedError expected) {
- return;
- }
- fail("Should detect problem in " + FailOnOneOfTwoConstructors.class.getSimpleName());
- }
-}
diff --git a/android/guava-testlib/test/com/google/common/testing/anotherpackage/ForwardingWrapperTesterTest.java b/android/guava-testlib/test/com/google/common/testing/anotherpackage/ForwardingWrapperTesterTest.java
index bd823f8f6..17655f6ef 100644
--- a/android/guava-testlib/test/com/google/common/testing/anotherpackage/ForwardingWrapperTesterTest.java
+++ b/android/guava-testlib/test/com/google/common/testing/anotherpackage/ForwardingWrapperTesterTest.java
@@ -17,6 +17,7 @@
package com.google.common.testing.anotherpackage;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
@@ -265,11 +266,11 @@ public class ForwardingWrapperTesterTest extends TestCase {
}
public void testNotInterfaceType() {
- try {
- new ForwardingWrapperTester().testForwarding(String.class, Functions.<String>identity());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new ForwardingWrapperTester()
+ .testForwarding(String.class, Functions.<String>identity()));
}
public void testNulls() {
@@ -583,6 +584,7 @@ public class ForwardingWrapperTesterTest extends TestCase {
// A method that is defined to 'return this'
@CanIgnoreReturnValue
ChainingCalls chainingCall();
+
// A method that just happens to return a ChainingCalls object
ChainingCalls nonChainingCall();
}
diff --git a/android/guava-testlib/test/com/google/common/util/concurrent/testing/TestingExecutorsTest.java b/android/guava-testlib/test/com/google/common/util/concurrent/testing/TestingExecutorsTest.java
index 66ad78491..a82aa8710 100644
--- a/android/guava-testlib/test/com/google/common/util/concurrent/testing/TestingExecutorsTest.java
+++ b/android/guava-testlib/test/com/google/common/util/concurrent/testing/TestingExecutorsTest.java
@@ -16,6 +16,8 @@
package com.google.common.util.concurrent.testing;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
import java.util.List;
@@ -76,12 +78,7 @@ public class TestingExecutorsTest extends TestCase {
Future<Boolean> future = futureList.get(0);
assertFalse(taskDone);
assertTrue(future.isDone());
- try {
- future.get();
- fail();
- } catch (CancellationException e) {
- // pass
- }
+ assertThrows(CancellationException.class, () -> future.get());
}
public void testSameThreadScheduledExecutor() throws ExecutionException, InterruptedException {
@@ -110,11 +107,6 @@ public class TestingExecutorsTest extends TestCase {
};
Future<?> future = TestingExecutors.sameThreadScheduledExecutor().submit(runnable);
- try {
- future.get();
- fail("Should have thrown exception");
- } catch (ExecutionException e) {
- // pass
- }
+ assertThrows(ExecutionException.class, () -> future.get());
}
}
diff --git a/android/guava-tests/pom.xml b/android/guava-tests/pom.xml
index be387bcbe..0b8f6601a 100644
--- a/android/guava-tests/pom.xml
+++ b/android/guava-tests/pom.xml
@@ -54,7 +54,7 @@
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
- <version>1.2</version>
+ <version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
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 c787ef004..87e93282b 100644
--- a/android/guava-tests/test/com/google/common/base/ConverterTest.java
+++ b/android/guava-tests/test/com/google/common/base/ConverterTest.java
@@ -19,6 +19,7 @@ package com.google.common.base;
import static com.google.common.base.Functions.toStringFunction;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.primitives.Longs;
@@ -29,7 +30,7 @@ import java.util.List;
import junit.framework.TestCase;
/** Unit tests for {@link Converter}. */
-@GwtCompatible
+@GwtCompatible(emulated = true)
public class ConverterTest extends TestCase {
private static final Converter<String, Long> STR_TO_LONG =
@@ -111,6 +112,7 @@ public class ConverterTest extends TestCase {
}
}
+ @GwtIncompatible // J2CL generics problem
public void testAndThen() {
Converter<StringWrapper, String> first =
new Converter<StringWrapper, String>() {
@@ -140,6 +142,7 @@ public class ConverterTest extends TestCase {
assertEquals(first.andThen(STR_TO_LONG), first.andThen(STR_TO_LONG));
}
+ @GwtIncompatible // J2CL generics problem
public void testIdentityConverter() {
Converter<String, String> stringIdentityConverter = Converter.identity();
@@ -213,6 +216,7 @@ public class ConverterTest extends TestCase {
SerializableTester.reserializeAndAssert(reverseConverter);
}
+ @GwtIncompatible // J2CL generics problem
public void testSerialization_andThen() {
Converter<String, Long> converterA = Longs.stringConverter();
Converter<Long, String> reverseConverter = Longs.stringConverter().reverse();
diff --git a/android/guava-tests/test/com/google/common/base/DefaultsTest.java b/android/guava-tests/test/com/google/common/base/DefaultsTest.java
index 7b990ba52..06b3c5da3 100644
--- a/android/guava-tests/test/com/google/common/base/DefaultsTest.java
+++ b/android/guava-tests/test/com/google/common/base/DefaultsTest.java
@@ -16,6 +16,7 @@
package com.google.common.base;
+import com.google.common.annotations.GwtIncompatible;
import junit.framework.TestCase;
/**
@@ -23,6 +24,7 @@ import junit.framework.TestCase;
*
* @author Jige Yu
*/
+@GwtIncompatible
public class DefaultsTest extends TestCase {
public void testGetDefaultValue() {
assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
diff --git a/android/guava-tests/test/com/google/common/base/EnumsTest.java b/android/guava-tests/test/com/google/common/base/EnumsTest.java
index 66dfe591a..df821d361 100644
--- a/android/guava-tests/test/com/google/common/base/EnumsTest.java
+++ b/android/guava-tests/test/com/google/common/base/EnumsTest.java
@@ -19,6 +19,7 @@ package com.google.common.base;
import static com.google.common.base.StandardSystemProperty.JAVA_CLASS_PATH;
import static com.google.common.base.StandardSystemProperty.PATH_SEPARATOR;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
@@ -129,11 +130,7 @@ public class EnumsTest extends TestCase {
@GwtIncompatible // stringConverter
public void testStringConverter_convertError() {
Converter<String, TestEnum> converter = Enums.stringConverter(TestEnum.class);
- try {
- converter.convert("xxx");
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> converter.convert("xxx"));
}
@GwtIncompatible // stringConverter
diff --git a/android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java b/android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java
index 7838f371a..56f2a805b 100644
--- a/android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java
+++ b/android/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java
@@ -16,6 +16,7 @@
package com.google.common.base;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.internal.Finalizer;
import com.google.common.testing.GcFinalization;
import java.lang.ref.ReferenceQueue;
@@ -36,6 +37,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
// - .class files aren't available
// - possibly no real concept of separate ClassLoaders?
@AndroidIncompatible
+@GwtIncompatible
public class FinalizableReferenceQueueTest extends TestCase {
private @Nullable FinalizableReferenceQueue frq;
diff --git a/android/guava-tests/test/com/google/common/base/PackageSanityTests.java b/android/guava-tests/test/com/google/common/base/PackageSanityTests.java
index f524fbb6c..c9eeed0de 100644
--- a/android/guava-tests/test/com/google/common/base/PackageSanityTests.java
+++ b/android/guava-tests/test/com/google/common/base/PackageSanityTests.java
@@ -16,10 +16,12 @@
package com.google.common.base;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.testing.AbstractPackageSanityTests;
/** Basic sanity tests for classes in {@code common.base}. */
+@GwtIncompatible
public class PackageSanityTests extends AbstractPackageSanityTests {
public PackageSanityTests() {
// package private classes like FunctionalEquivalence are tested through the public API.
diff --git a/android/guava-tests/test/com/google/common/base/PreconditionsTest.java b/android/guava-tests/test/com/google/common/base/PreconditionsTest.java
index 6209d3a06..acbd7cfd1 100644
--- a/android/guava-tests/test/com/google/common/base/PreconditionsTest.java
+++ b/android/guava-tests/test/com/google/common/base/PreconditionsTest.java
@@ -17,6 +17,7 @@
package com.google.common.base;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -397,12 +398,11 @@ public class PreconditionsTest extends TestCase {
checkArgumentMethod.invoke(null /* static method */, getParametersForSignature(true, sig));
Object[] failingParams = getParametersForSignature(false, sig);
- try {
- checkArgumentMethod.invoke(null /* static method */, failingParams);
- fail();
- } catch (InvocationTargetException ite) {
- assertFailureCause(ite.getCause(), IllegalArgumentException.class, failingParams);
- }
+ InvocationTargetException ite =
+ assertThrows(
+ InvocationTargetException.class,
+ () -> checkArgumentMethod.invoke(null /* static method */, failingParams));
+ assertFailureCause(ite.getCause(), IllegalArgumentException.class, failingParams);
}
}
@@ -415,12 +415,11 @@ public class PreconditionsTest extends TestCase {
checkArgumentMethod.invoke(null /* static method */, getParametersForSignature(true, sig));
Object[] failingParams = getParametersForSignature(false, sig);
- try {
- checkArgumentMethod.invoke(null /* static method */, failingParams);
- fail();
- } catch (InvocationTargetException ite) {
- assertFailureCause(ite.getCause(), IllegalStateException.class, failingParams);
- }
+ InvocationTargetException ite =
+ assertThrows(
+ InvocationTargetException.class,
+ () -> checkArgumentMethod.invoke(null /* static method */, failingParams));
+ assertFailureCause(ite.getCause(), IllegalStateException.class, failingParams);
}
}
@@ -434,12 +433,11 @@ public class PreconditionsTest extends TestCase {
null /* static method */, getParametersForSignature(new Object(), sig));
Object[] failingParams = getParametersForSignature(null, sig);
- try {
- checkArgumentMethod.invoke(null /* static method */, failingParams);
- fail();
- } catch (InvocationTargetException ite) {
- assertFailureCause(ite.getCause(), NullPointerException.class, failingParams);
- }
+ InvocationTargetException ite =
+ assertThrows(
+ InvocationTargetException.class,
+ () -> checkArgumentMethod.invoke(null /* static method */, failingParams));
+ assertFailureCause(ite.getCause(), NullPointerException.class, failingParams);
}
}
diff --git a/android/guava-tests/test/com/google/common/base/PredicatesTest.java b/android/guava-tests/test/com/google/common/base/PredicatesTest.java
index 24b4e108b..ed017d00f 100644
--- a/android/guava-tests/test/com/google/common/base/PredicatesTest.java
+++ b/android/guava-tests/test/com/google/common/base/PredicatesTest.java
@@ -18,6 +18,7 @@ package com.google.common.base;
import static com.google.common.base.CharMatcher.whitespace;
import static com.google.common.collect.Lists.newArrayList;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -623,11 +624,7 @@ public class PredicatesTest extends TestCase {
assertTrue(isInteger.apply(Integer.class));
assertFalse(isInteger.apply(Float.class));
- try {
- isInteger.apply(null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> isInteger.apply(null));
}
@J2ktIncompatible
diff --git a/android/guava-tests/test/com/google/common/base/SplitterTest.java b/android/guava-tests/test/com/google/common/base/SplitterTest.java
index 728e57aff..42f820f01 100644
--- a/android/guava-tests/test/com/google/common/base/SplitterTest.java
+++ b/android/guava-tests/test/com/google/common/base/SplitterTest.java
@@ -17,6 +17,7 @@
package com.google.common.base;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -464,11 +465,7 @@ public class SplitterTest extends TestCase {
@J2ktIncompatible
@GwtIncompatible // java.util.regex.Pattern
public void testPatternSplitInvalidPattern() {
- try {
- Splitter.on(Pattern.compile("a*"));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Splitter.on(Pattern.compile("a*")));
}
@J2ktIncompatible
diff --git a/android/guava-tests/test/com/google/common/base/StandardSystemPropertyTest.java b/android/guava-tests/test/com/google/common/base/StandardSystemPropertyTest.java
index 3a88366c0..f4907a337 100644
--- a/android/guava-tests/test/com/google/common/base/StandardSystemPropertyTest.java
+++ b/android/guava-tests/test/com/google/common/base/StandardSystemPropertyTest.java
@@ -20,6 +20,7 @@ import static com.google.common.base.StandardSystemProperty.JAVA_COMPILER;
import static com.google.common.base.StandardSystemProperty.JAVA_EXT_DIRS;
import static com.google.common.truth.Truth.assertWithMessage;
+import com.google.common.annotations.GwtIncompatible;
import junit.framework.TestCase;
/**
@@ -27,6 +28,7 @@ import junit.framework.TestCase;
*
* @author Kurt Alfred Kluever
*/
+@GwtIncompatible
public class StandardSystemPropertyTest extends TestCase {
public void testGetKeyMatchesString() {
diff --git a/android/guava-tests/test/com/google/common/base/SuppliersTest.java b/android/guava-tests/test/com/google/common/base/SuppliersTest.java
index 9befacc6f..fef3a2684 100644
--- a/android/guava-tests/test/com/google/common/base/SuppliersTest.java
+++ b/android/guava-tests/test/com/google/common/base/SuppliersTest.java
@@ -18,6 +18,7 @@ package com.google.common.base;
import static com.google.common.testing.SerializableTester.reserialize;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -141,12 +142,8 @@ public class SuppliersTest extends TestCase {
.isEqualTo("Suppliers.memoize(<supplier that returned 10>)");
// Should get an exception when we try to serialize.
- try {
- reserialize(memoizedSupplier);
- fail();
- } catch (RuntimeException ex) {
- assertThat(ex).hasCauseThat().isInstanceOf(java.io.NotSerializableException.class);
- }
+ RuntimeException ex = assertThrows(RuntimeException.class, () -> reserialize(memoizedSupplier));
+ assertThat(ex).hasCauseThat().isInstanceOf(java.io.NotSerializableException.class);
}
@J2ktIncompatible
diff --git a/android/guava-tests/test/com/google/common/base/ThrowablesTest.java b/android/guava-tests/test/com/google/common/base/ThrowablesTest.java
index 975765340..194b435a3 100644
--- a/android/guava-tests/test/com/google/common/base/ThrowablesTest.java
+++ b/android/guava-tests/test/com/google/common/base/ThrowablesTest.java
@@ -25,6 +25,7 @@ import static com.google.common.base.Throwables.throwIfUnchecked;
import static com.google.common.truth.Truth.assertThat;
import static java.util.Arrays.asList;
import static java.util.regex.Pattern.quote;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -100,11 +101,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the unchecked exception to propagate as-is
- try {
- sample.noneDeclared();
- fail();
- } catch (SomeUncheckedException expected) {
- }
+ assertThrows(SomeUncheckedException.class, () -> sample.noneDeclared());
}
@J2ktIncompatible
@@ -124,11 +121,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the undeclared exception to have been chained inside another
- try {
- sample.noneDeclared();
- fail();
- } catch (SomeChainingException expected) {
- }
+ assertThrows(SomeChainingException.class, () -> sample.noneDeclared());
}
@J2ktIncompatible
@@ -170,11 +163,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the unchecked exception to propagate as-is
- try {
- sample.oneDeclared();
- fail();
- } catch (SomeUncheckedException expected) {
- }
+ assertThrows(SomeUncheckedException.class, () -> sample.oneDeclared());
}
@J2ktIncompatible
@@ -194,11 +183,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the checked exception to propagate as-is
- try {
- sample.oneDeclared();
- fail();
- } catch (SomeCheckedException expected) {
- }
+ assertThrows(SomeCheckedException.class, () -> sample.oneDeclared());
}
@J2ktIncompatible
@@ -218,11 +203,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the undeclared exception to have been chained inside another
- try {
- sample.oneDeclared();
- fail();
- } catch (SomeChainingException expected) {
- }
+ assertThrows(SomeChainingException.class, () -> sample.oneDeclared());
}
@J2ktIncompatible
@@ -266,11 +247,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the unchecked exception to propagate as-is
- try {
- sample.twoDeclared();
- fail();
- } catch (SomeUncheckedException expected) {
- }
+ assertThrows(SomeUncheckedException.class, () -> sample.twoDeclared());
}
@J2ktIncompatible
@@ -291,11 +268,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the checked exception to propagate as-is
- try {
- sample.twoDeclared();
- fail();
- } catch (SomeCheckedException expected) {
- }
+ assertThrows(SomeCheckedException.class, () -> sample.twoDeclared());
}
@J2ktIncompatible
@@ -316,11 +289,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the checked exception to propagate as-is
- try {
- sample.twoDeclared();
- fail();
- } catch (SomeOtherCheckedException expected) {
- }
+ assertThrows(SomeOtherCheckedException.class, () -> sample.twoDeclared());
}
public void testThrowIfUnchecked_null() throws SomeCheckedException {
@@ -384,11 +353,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the unchecked exception to propagate as-is
- try {
- sample.noneDeclared();
- fail();
- } catch (SomeUncheckedException expected) {
- }
+ assertThrows(SomeUncheckedException.class, () -> sample.noneDeclared());
}
@J2ktIncompatible
@@ -407,11 +372,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the error to propagate as-is
- try {
- sample.noneDeclared();
- fail();
- } catch (SomeError expected) {
- }
+ assertThrows(SomeError.class, () -> sample.noneDeclared());
}
@J2ktIncompatible
@@ -430,12 +391,8 @@ public class ThrowablesTest extends TestCase {
};
// Expect the undeclared exception to have been chained inside another
- try {
- sample.noneDeclared();
- fail();
- } catch (RuntimeException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(SomeCheckedException.class);
- }
+ RuntimeException expected = assertThrows(RuntimeException.class, () -> sample.noneDeclared());
+ assertThat(expected).hasCauseThat().isInstanceOf(SomeCheckedException.class);
}
@J2ktIncompatible
@@ -453,21 +410,17 @@ public class ThrowablesTest extends TestCase {
@J2ktIncompatible
@GwtIncompatible // throwIfInstanceOf
public void testThrowIfInstanceOf_CheckedSame() {
- try {
- throwIfInstanceOf(new SomeCheckedException(), SomeCheckedException.class);
- fail();
- } catch (SomeCheckedException expected) {
- }
+ assertThrows(
+ SomeCheckedException.class,
+ () -> throwIfInstanceOf(new SomeCheckedException(), SomeCheckedException.class));
}
@J2ktIncompatible
@GwtIncompatible // throwIfInstanceOf
public void testThrowIfInstanceOf_CheckedSubclass() {
- try {
- throwIfInstanceOf(new SomeCheckedException() {}, SomeCheckedException.class);
- fail();
- } catch (SomeCheckedException expected) {
- }
+ assertThrows(
+ SomeCheckedException.class,
+ () -> throwIfInstanceOf(new SomeCheckedException() {}, SomeCheckedException.class));
}
@J2ktIncompatible
@@ -507,11 +460,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect declared exception to be thrown as-is
- try {
- sample.oneDeclared();
- fail();
- } catch (SomeCheckedException expected) {
- }
+ assertThrows(SomeCheckedException.class, () -> sample.oneDeclared());
}
@J2ktIncompatible
@@ -531,11 +480,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect unchecked exception to be thrown as-is
- try {
- sample.oneDeclared();
- fail();
- } catch (SomeUncheckedException expected) {
- }
+ assertThrows(SomeUncheckedException.class, () -> sample.oneDeclared());
}
@J2ktIncompatible
@@ -555,22 +500,15 @@ public class ThrowablesTest extends TestCase {
};
// Expect undeclared exception wrapped by RuntimeException to be thrown
- try {
- sample.oneDeclared();
- fail();
- } catch (RuntimeException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(SomeOtherCheckedException.class);
- }
+ RuntimeException expected = assertThrows(RuntimeException.class, () -> sample.oneDeclared());
+ assertThat(expected).hasCauseThat().isInstanceOf(SomeOtherCheckedException.class);
}
@J2ktIncompatible
@GwtIncompatible // throwIfInstanceOf
public void testThrowIfInstanceOf_null() throws SomeCheckedException {
- try {
- throwIfInstanceOf(null, SomeCheckedException.class);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(
+ NullPointerException.class, () -> throwIfInstanceOf(null, SomeCheckedException.class));
}
@J2ktIncompatible
@@ -720,12 +658,11 @@ public class ThrowablesTest extends TestCase {
assertThat(Throwables.getCauseAs(thrown, SomeCheckedException.class)).isSameInstanceAs(cause);
assertThat(Throwables.getCauseAs(thrown, Exception.class)).isSameInstanceAs(cause);
- try {
- Throwables.getCauseAs(thrown, IllegalStateException.class);
- fail("Should have thrown CCE");
- } catch (ClassCastException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(thrown);
- }
+ ClassCastException expected =
+ assertThrows(
+ ClassCastException.class,
+ () -> Throwables.getCauseAs(thrown, IllegalStateException.class));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(thrown);
}
@AndroidIncompatible // No getJavaLangAccess in Android (at least not in the version we use).
@@ -749,11 +686,7 @@ public class ThrowablesTest extends TestCase {
assertThat(lazyStackTrace(e)).containsExactly((Object[]) originalStackTrace).inOrder();
- try {
- lazyStackTrace(e).set(0, null);
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> lazyStackTrace(e).set(0, null));
// Now we test a property that holds only for the lazy implementation.
diff --git a/android/guava-tests/test/com/google/common/base/UnannotatedJavaClass.java b/android/guava-tests/test/com/google/common/base/UnannotatedJavaClass.java
new file mode 100644
index 000000000..521035c61
--- /dev/null
+++ b/android/guava-tests/test/com/google/common/base/UnannotatedJavaClass.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2023 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.base;
+
+/** Class containing an unannotated Java method for use from {@code OptionalExtensionsTest}. */
+final class UnannotatedJavaClass {
+ static Object getNull() {
+ return null;
+ }
+
+ private UnannotatedJavaClass() {}
+}
diff --git a/android/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java b/android/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java
index 84e004a8b..c029ff3d0 100644
--- a/android/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java
+++ b/android/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java
@@ -17,6 +17,7 @@
package com.google.common.cache;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.ExecutionError;
import com.google.common.util.concurrent.UncheckedExecutionException;
@@ -52,12 +53,9 @@ public class AbstractLoadingCacheTest extends TestCase {
}
};
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(cause);
- }
+ UncheckedExecutionException expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isEqualTo(cause);
Object newValue = new Object();
valueRef.set(newValue);
@@ -84,12 +82,9 @@ public class AbstractLoadingCacheTest extends TestCase {
}
};
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(cause);
- }
+ UncheckedExecutionException expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isEqualTo(cause);
Object newValue = new Object();
valueRef.set(newValue);
@@ -116,12 +111,9 @@ public class AbstractLoadingCacheTest extends TestCase {
}
};
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isEqualTo(cause);
- }
+ ExecutionError expected =
+ assertThrows(ExecutionError.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isEqualTo(cause);
Object newValue = new Object();
valueRef.set(newValue);
@@ -148,12 +140,9 @@ public class AbstractLoadingCacheTest extends TestCase {
}
};
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(cause);
- }
+ UncheckedExecutionException expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isEqualTo(cause);
Object newValue = new Object();
valueRef.set(newValue);
diff --git a/android/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java b/android/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
index 09f2eb6c2..8a60cd30d 100644
--- a/android/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
+++ b/android/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
@@ -18,6 +18,7 @@ package com.google.common.cache;
import static com.google.common.cache.CacheBuilderSpec.parse;
import static com.google.common.cache.TestingWeighers.constantWeigher;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Suppliers;
import com.google.common.cache.LocalCache.Strength;
@@ -60,11 +61,8 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_initialCapacityRepeated() {
- try {
- parse("initialCapacity=10, initialCapacity=20");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> parse("initialCapacity=10, initialCapacity=20"));
}
public void testParse_maximumSize() {
@@ -81,11 +79,7 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_maximumSizeRepeated() {
- try {
- parse("maximumSize=10, maximumSize=20");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("maximumSize=10, maximumSize=20"));
}
public void testParse_maximumWeight() {
@@ -102,19 +96,11 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_maximumWeightRepeated() {
- try {
- parse("maximumWeight=10, maximumWeight=20");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("maximumWeight=10, maximumWeight=20"));
}
public void testParse_maximumSizeAndMaximumWeight() {
- try {
- parse("maximumSize=10, maximumWeight=20");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("maximumSize=10, maximumWeight=20"));
}
public void testParse_concurrencyLevel() {
@@ -132,11 +118,8 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_concurrencyLevelRepeated() {
- try {
- parse("concurrencyLevel=10, concurrencyLevel=20");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> parse("concurrencyLevel=10, concurrencyLevel=20"));
}
public void testParse_weakKeys() {
@@ -153,19 +136,11 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_weakKeysCannotHaveValue() {
- try {
- parse("weakKeys=true");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("weakKeys=true"));
}
public void testParse_repeatedKeyStrength() {
- try {
- parse("weakKeys, weakKeys");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("weakKeys, weakKeys"));
}
public void testParse_softValues() {
@@ -182,11 +157,7 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_softValuesCannotHaveValue() {
- try {
- parse("softValues=true");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("softValues=true"));
}
public void testParse_weakValues() {
@@ -203,37 +174,17 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_weakValuesCannotHaveValue() {
- try {
- parse("weakValues=true");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("weakValues=true"));
}
public void testParse_repeatedValueStrength() {
- try {
- parse("softValues, softValues");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
-
- try {
- parse("softValues, weakValues");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
-
- try {
- parse("weakValues, softValues");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
-
- try {
- parse("weakValues, weakValues");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("softValues, softValues"));
+
+ assertThrows(IllegalArgumentException.class, () -> parse("softValues, weakValues"));
+
+ assertThrows(IllegalArgumentException.class, () -> parse("weakValues, softValues"));
+
+ assertThrows(IllegalArgumentException.class, () -> parse("weakValues, weakValues"));
}
public void testParse_writeExpirationDays() {
@@ -276,11 +227,8 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_writeExpirationRepeated() {
- try {
- parse("expireAfterWrite=10s,expireAfterWrite=10m");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> parse("expireAfterWrite=10s,expireAfterWrite=10m"));
}
public void testParse_accessExpirationDays() {
@@ -325,11 +273,8 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_accessExpirationRepeated() {
- try {
- parse("expireAfterAccess=10s,expireAfterAccess=10m");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> parse("expireAfterAccess=10s,expireAfterAccess=10m"));
}
public void testParse_recordStats() {
@@ -339,19 +284,11 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_recordStatsValueSpecified() {
- try {
- parse("recordStats=True");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("recordStats=True"));
}
public void testParse_recordStatsRepeated() {
- try {
- parse("recordStats,recordStats");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("recordStats,recordStats"));
}
public void testParse_accessExpirationAndWriteExpiration() {
@@ -419,31 +356,15 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_unknownKey() {
- try {
- parse("foo=17");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("foo=17"));
}
public void testParse_extraCommaIsInvalid() {
- try {
- parse("weakKeys,");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("weakKeys,"));
- try {
- parse(",weakKeys");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse(",weakKeys"));
- try {
- parse("weakKeys,,softValues");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("weakKeys,,softValues"));
}
public void testEqualsAndHashCode() {
@@ -477,11 +398,9 @@ public class CacheBuilderSpecTest extends TestCase {
@SuppressWarnings("ReturnValueIgnored")
public void testMaximumWeight_withoutWeigher() {
CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumWeight=9000"));
- try {
- builder.build(CacheLoader.from(Suppliers.ofInstance(null)));
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> builder.build(CacheLoader.from(Suppliers.ofInstance(null))));
}
@SuppressWarnings("ReturnValueIgnored")
diff --git a/android/guava-tests/test/com/google/common/cache/CacheBuilderTest.java b/android/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
index 3a3a571f7..6730c48c3 100644
--- a/android/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
+++ b/android/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
@@ -26,6 +26,7 @@ import static com.google.common.truth.Truth.assertThat;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -164,11 +165,7 @@ public class CacheBuilderTest extends TestCase {
@GwtIncompatible // maximumWeight
public void testMaximumSize_andWeight() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder().maximumSize(16);
- try {
- builder.maximumWeight(16);
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder.maximumWeight(16));
}
@GwtIncompatible // digs into internals of the non-GWT implementation
@@ -182,98 +179,53 @@ public class CacheBuilderTest extends TestCase {
@GwtIncompatible // maximumWeight
public void testMaximumWeight_negative() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
- try {
- builder.maximumWeight(-1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.maximumWeight(-1));
}
@GwtIncompatible // maximumWeight
public void testMaximumWeight_setTwice() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder().maximumWeight(16);
- try {
- // even to the same value is not allowed
- builder.maximumWeight(16);
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- builder.maximumSize(16);
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder.maximumWeight(16));
+ assertThrows(IllegalStateException.class, () -> builder.maximumSize(16));
}
@GwtIncompatible // maximumWeight
public void testMaximumWeight_withoutWeigher() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder().maximumWeight(1);
- try {
- builder.build(identityLoader());
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder.build(identityLoader()));
}
@GwtIncompatible // weigher
public void testWeigher_withoutMaximumWeight() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder().weigher(constantWeigher(42));
- try {
- builder.build(identityLoader());
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder.build(identityLoader()));
}
@GwtIncompatible // weigher
public void testWeigher_withMaximumSize() {
- try {
- CacheBuilder.newBuilder().weigher(constantWeigher(42)).maximumSize(1);
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- CacheBuilder.newBuilder().maximumSize(1).weigher(constantWeigher(42));
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> CacheBuilder.newBuilder().weigher(constantWeigher(42)).maximumSize(1));
+ assertThrows(
+ IllegalStateException.class,
+ () -> CacheBuilder.newBuilder().maximumSize(1).weigher(constantWeigher(42)));
}
@GwtIncompatible // weakKeys
public void testKeyStrengthSetTwice() {
CacheBuilder<Object, Object> builder1 = CacheBuilder.newBuilder().weakKeys();
- try {
- builder1.weakKeys();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder1.weakKeys());
}
@GwtIncompatible // weakValues
public void testValueStrengthSetTwice() {
CacheBuilder<Object, Object> builder1 = CacheBuilder.newBuilder().weakValues();
- try {
- builder1.weakValues();
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- builder1.softValues();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder1.weakValues());
+ assertThrows(IllegalStateException.class, () -> builder1.softValues());
CacheBuilder<Object, Object> builder2 = CacheBuilder.newBuilder().softValues();
- try {
- builder2.softValues();
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- builder2.weakValues();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder2.softValues());
+ assertThrows(IllegalStateException.class, () -> builder2.weakValues());
}
public void testTimeToLive_negative() {
@@ -340,23 +292,14 @@ public class CacheBuilderTest extends TestCase {
@GwtIncompatible // refreshAfterWrite
public void testRefresh_zero() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
- try {
- builder.refreshAfterWrite(0, SECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.refreshAfterWrite(0, SECONDS));
}
@GwtIncompatible // refreshAfterWrite
public void testRefresh_setTwice() {
CacheBuilder<Object, Object> builder =
CacheBuilder.newBuilder().refreshAfterWrite(3600, SECONDS);
- try {
- // even to the same value is not allowed
- builder.refreshAfterWrite(3600, SECONDS);
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder.refreshAfterWrite(3600, SECONDS));
}
public void testTicker_setTwice() {
diff --git a/android/guava-tests/test/com/google/common/cache/CacheLoadingTest.java b/android/guava-tests/test/com/google/common/cache/CacheLoadingTest.java
index 9b193ed7f..df36a81c7 100644
--- a/android/guava-tests/test/com/google/common/cache/CacheLoadingTest.java
+++ b/android/guava-tests/test/com/google/common/cache/CacheLoadingTest.java
@@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
import static java.lang.Thread.currentThread;
import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
import com.google.common.cache.TestingCacheLoaders.CountingLoader;
@@ -521,11 +522,7 @@ public class CacheLoadingTest extends TestCase {
assertSame(extraKey, cache.asMap().get(extraKey));
Object[] lookupKeys = new Object[] {new Object(), new Object(), new Object()};
- try {
- cache.getAll(asList(lookupKeys));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getAll(asList(lookupKeys)));
for (Object key : lookupKeys) {
assertTrue(cache.asMap().containsKey(key));
@@ -561,11 +558,7 @@ public class CacheLoadingTest extends TestCase {
assertSame(extraKey, cache.asMap().get(extraKey));
Object[] lookupKeys = new Object[] {new Object(), new Object(), new Object()};
- try {
- cache.getAll(asList(lookupKeys));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getAll(asList(lookupKeys)));
for (Object key : lookupKeys) {
assertTrue(cache.asMap().containsKey(key));
@@ -595,11 +588,7 @@ public class CacheLoadingTest extends TestCase {
LoadingCache<Object, Object> cache = CacheBuilder.newBuilder().build(loader);
Object[] lookupKeys = new Object[] {new Object(), new Object(), new Object()};
- try {
- cache.getAll(asList(lookupKeys));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getAll(asList(lookupKeys)));
assertSame(extraValue, cache.asMap().get(extraKey));
}
@@ -612,22 +601,14 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.get(new Object());
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.get(new Object()));
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(1, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getUnchecked(new Object()));
stats = cache.stats();
assertEquals(2, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -642,22 +623,15 @@ public class CacheLoadingTest extends TestCase {
assertEquals(3, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.get(new Object(), Callables.returning(null));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(
+ InvalidCacheLoadException.class, () -> cache.get(new Object(), Callables.returning(null)));
stats = cache.stats();
assertEquals(3, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(4, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getAll(asList(new Object())));
stats = cache.stats();
assertEquals(4, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -828,11 +802,7 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getAll(asList(new Object())));
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -863,11 +833,7 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getAll(asList(new Object())));
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -885,24 +851,16 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.get(new Object());
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ ExecutionError expected = assertThrows(ExecutionError.class, () -> cache.get(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(1, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected = assertThrows(ExecutionError.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(2, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -918,31 +876,27 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.hitCount());
final Error callableError = new Error();
- try {
- cache.get(
- new Object(),
- new Callable<Object>() {
- @Override
- public Object call() {
- throw callableError;
- }
- });
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(callableError);
- }
+ expected =
+ assertThrows(
+ ExecutionError.class,
+ () ->
+ cache.get(
+ new Object(),
+ new Callable<Object>() {
+ @Override
+ public Object call() {
+ throw callableError;
+ }
+ }));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(callableError);
stats = cache.stats();
assertEquals(3, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(4, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected = assertThrows(ExecutionError.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(4, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1118,12 +1072,9 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ ExecutionError expected =
+ assertThrows(ExecutionError.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1141,24 +1092,17 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.get(new Object());
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ Exception expected = assertThrows(ExecutionException.class, () -> cache.get(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(1, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(2, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1174,24 +1118,18 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.hitCount());
Exception callableException = new Exception();
- try {
- cache.get(new Object(), throwing(callableException));
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(callableException);
- }
+ expected =
+ assertThrows(
+ ExecutionException.class, () -> cache.get(new Object(), throwing(callableException)));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(callableException);
stats = cache.stats();
assertEquals(3, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(4, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected = assertThrows(ExecutionException.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(4, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1212,12 +1150,8 @@ public class CacheLoadingTest extends TestCase {
// Sanity check:
assertFalse(currentThread().interrupted());
- try {
- cache.get(new Object());
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ Exception expected = assertThrows(ExecutionException.class, () -> cache.get(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
assertTrue(currentThread().interrupted());
stats = cache.stats();
assertEquals(1, stats.missCount());
@@ -1225,12 +1159,9 @@ public class CacheLoadingTest extends TestCase {
assertEquals(1, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
assertTrue(currentThread().interrupted());
stats = cache.stats();
assertEquals(2, stats.missCount());
@@ -1248,12 +1179,10 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.hitCount());
Exception callableException = new InterruptedException();
- try {
- cache.get(new Object(), throwing(callableException));
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(callableException);
- }
+ expected =
+ assertThrows(
+ ExecutionException.class, () -> cache.get(new Object(), throwing(callableException)));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(callableException);
assertTrue(currentThread().interrupted());
stats = cache.stats();
assertEquals(3, stats.missCount());
@@ -1261,12 +1190,8 @@ public class CacheLoadingTest extends TestCase {
assertEquals(4, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected = assertThrows(ExecutionException.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
assertTrue(currentThread().interrupted());
stats = cache.stats();
assertEquals(4, stats.missCount());
@@ -1443,12 +1368,9 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ ExecutionException expected =
+ assertThrows(ExecutionException.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1467,12 +1389,9 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ ExecutionException expected =
+ assertThrows(ExecutionException.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
assertTrue(currentThread().interrupted());
stats = cache.stats();
assertEquals(1, stats.missCount());
@@ -1491,24 +1410,18 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.get(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ UncheckedExecutionException expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.get(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(1, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(2, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1524,24 +1437,20 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.hitCount());
Exception callableException = new RuntimeException();
- try {
- cache.get(new Object(), throwing(callableException));
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(callableException);
- }
+ expected =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () -> cache.get(new Object(), throwing(callableException)));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(callableException);
stats = cache.stats();
assertEquals(3, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(4, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(4, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1717,12 +1626,9 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ UncheckedExecutionException expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1748,12 +1654,9 @@ public class CacheLoadingTest extends TestCase {
LoadingCache<Integer, String> cache =
CacheBuilder.newBuilder().removalListener(removalListener).build(failOnceFunction);
- try {
- cache.getUnchecked(1);
- fail();
- } catch (UncheckedExecutionException ue) {
- assertThat(ue).hasCauseThat().isSameInstanceAs(e);
- }
+ UncheckedExecutionException ue =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(1));
+ assertThat(ue).hasCauseThat().isSameInstanceAs(e);
assertEquals("1", cache.getUnchecked(1));
assertEquals(0, removalListener.getCount());
@@ -1871,12 +1774,10 @@ public class CacheLoadingTest extends TestCase {
assertThat(caughtEe).hasCauseThat().isSameInstanceAs(uee);
}
- try {
- cacheUnchecked.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException caughtUee) {
- assertThat(caughtUee).hasCauseThat().isSameInstanceAs(uee);
- }
+ UncheckedExecutionException caughtUee =
+ assertThrows(
+ UncheckedExecutionException.class, () -> cacheUnchecked.getUnchecked(new Object()));
+ assertThat(caughtUee).hasCauseThat().isSameInstanceAs(uee);
cacheUnchecked.refresh(new Object());
checkLoggedCause(uee);
@@ -1890,29 +1791,21 @@ public class CacheLoadingTest extends TestCase {
assertThat(caughtEe).hasCauseThat().isSameInstanceAs(uee);
}
- try {
- cacheChecked.get(new Object());
- fail();
- } catch (ExecutionException caughtEe) {
- assertThat(caughtEe).hasCauseThat().isSameInstanceAs(ee);
- }
+ ExecutionException caughtEe =
+ assertThrows(ExecutionException.class, () -> cacheChecked.get(new Object()));
+ assertThat(caughtEe).hasCauseThat().isSameInstanceAs(ee);
- try {
- cacheChecked.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException caughtUee) {
- assertThat(caughtUee).hasCauseThat().isSameInstanceAs(ee);
- }
+ caughtUee =
+ assertThrows(
+ UncheckedExecutionException.class, () -> cacheChecked.getUnchecked(new Object()));
+ assertThat(caughtUee).hasCauseThat().isSameInstanceAs(ee);
cacheChecked.refresh(new Object());
checkLoggedCause(ee);
- try {
- cacheChecked.getAll(asList(new Object()));
- fail();
- } catch (ExecutionException caughtEe) {
- assertThat(caughtEe).hasCauseThat().isSameInstanceAs(ee);
- }
+ caughtEe =
+ assertThrows(ExecutionException.class, () -> cacheChecked.getAll(asList(new Object())));
+ assertThat(caughtEe).hasCauseThat().isSameInstanceAs(ee);
}
public void testBulkLoadingExceptionWithCause() {
@@ -1934,12 +1827,9 @@ public class CacheLoadingTest extends TestCase {
assertThat(caughtEe).hasCauseThat().isSameInstanceAs(uee);
}
- try {
- cacheChecked.getAll(asList(new Object()));
- fail();
- } catch (ExecutionException caughtEe) {
- assertThat(caughtEe).hasCauseThat().isSameInstanceAs(ee);
- }
+ ExecutionException caughtEe =
+ assertThrows(ExecutionException.class, () -> cacheChecked.getAll(asList(new Object())));
+ assertThat(caughtEe).hasCauseThat().isSameInstanceAs(ee);
}
@AndroidIncompatible // Bug? expected:<1> but was:<2>
diff --git a/android/guava-tests/test/com/google/common/cache/EmptyCachesTest.java b/android/guava-tests/test/com/google/common/cache/EmptyCachesTest.java
index a5e3a59a0..ccdcb955d 100644
--- a/android/guava-tests/test/com/google/common/cache/EmptyCachesTest.java
+++ b/android/guava-tests/test/com/google/common/cache/EmptyCachesTest.java
@@ -19,6 +19,7 @@ import static com.google.common.cache.TestingCacheLoaders.identityLoader;
import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Function;
import com.google.common.cache.CacheBuilderFactory.DurationSpec;
@@ -89,22 +90,14 @@ public class EmptyCachesTest extends TestCase {
public void testGet_null() throws ExecutionException {
for (LoadingCache<Object, Object> cache : caches()) {
- try {
- cache.get(null);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> cache.get(null));
checkEmpty(cache);
}
}
public void testGetUnchecked_null() {
for (LoadingCache<Object, Object> cache : caches()) {
- try {
- cache.getUnchecked(null);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> cache.getUnchecked(null));
checkEmpty(cache);
}
}
@@ -114,28 +107,17 @@ public class EmptyCachesTest extends TestCase {
public void testKeySet_nullToArray() {
for (LoadingCache<Object, Object> cache : caches()) {
Set<Object> keys = cache.asMap().keySet();
- try {
- keys.toArray((Object[]) null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> keys.toArray((Object[]) null));
checkEmpty(cache);
}
}
public void testKeySet_addNotSupported() {
for (LoadingCache<Object, Object> cache : caches()) {
- try {
- cache.asMap().keySet().add(1);
- fail();
- } catch (UnsupportedOperationException expected) {
- }
-
- try {
- cache.asMap().keySet().addAll(asList(1, 2));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> cache.asMap().keySet().add(1));
+
+ assertThrows(
+ UnsupportedOperationException.class, () -> cache.asMap().keySet().addAll(asList(1, 2)));
}
}
@@ -189,28 +171,17 @@ public class EmptyCachesTest extends TestCase {
public void testValues_nullToArray() {
for (LoadingCache<Object, Object> cache : caches()) {
Collection<Object> values = cache.asMap().values();
- try {
- values.toArray((Object[]) null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> values.toArray((Object[]) null));
checkEmpty(cache);
}
}
public void testValues_addNotSupported() {
for (LoadingCache<Object, Object> cache : caches()) {
- try {
- cache.asMap().values().add(1);
- fail();
- } catch (UnsupportedOperationException expected) {
- }
-
- try {
- cache.asMap().values().addAll(asList(1, 2));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> cache.asMap().values().add(1));
+
+ assertThrows(
+ UnsupportedOperationException.class, () -> cache.asMap().values().addAll(asList(1, 2)));
}
}
@@ -264,28 +235,20 @@ public class EmptyCachesTest extends TestCase {
public void testEntrySet_nullToArray() {
for (LoadingCache<Object, Object> cache : caches()) {
Set<Entry<Object, Object>> entries = cache.asMap().entrySet();
- try {
- entries.toArray((Entry<Object, Object>[]) null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(
+ NullPointerException.class, () -> entries.toArray((Entry<Object, Object>[]) null));
checkEmpty(cache);
}
}
public void testEntrySet_addNotSupported() {
for (LoadingCache<Object, Object> cache : caches()) {
- try {
- cache.asMap().entrySet().add(entryOf(1, 1));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
-
- try {
- cache.asMap().values().addAll(asList(entryOf(1, 1), entryOf(2, 2)));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(
+ UnsupportedOperationException.class, () -> cache.asMap().entrySet().add(entryOf(1, 1)));
+
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> cache.asMap().values().addAll(asList(entryOf(1, 1), entryOf(2, 2))));
}
}
diff --git a/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java b/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java
index 431c962f4..cd1d340d5 100644
--- a/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java
+++ b/android/guava-tests/test/com/google/common/cache/LocalCacheTest.java
@@ -58,6 +58,7 @@ import com.google.common.testing.FakeTicker;
import com.google.common.testing.NullPointerTester;
import com.google.common.testing.SerializableTester;
import com.google.common.testing.TestLogHandler;
+import com.google.common.util.concurrent.UncheckedExecutionException;
import java.io.Serializable;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
@@ -2639,8 +2640,86 @@ public class LocalCacheTest extends TestCase {
assertEquals(localCacheTwo.ticker, localCacheThree.ticker);
}
+ public void testLoadDifferentKeyInLoader() throws ExecutionException, InterruptedException {
+ LocalCache<String, String> cache = makeLocalCache(createCacheBuilder());
+ String key1 = "key1";
+ String key2 = "key2";
+
+ assertEquals(
+ key2,
+ cache.get(
+ key1,
+ new CacheLoader<String, String>() {
+ @Override
+ public String load(String key) throws Exception {
+ return cache.get(key2, identityLoader()); // loads a different key, should work
+ }
+ }));
+ }
+
+ public void testRecursiveLoad() throws InterruptedException {
+ LocalCache<String, String> cache = makeLocalCache(createCacheBuilder());
+ String key = "key";
+ CacheLoader<String, String> loader =
+ new CacheLoader<String, String>() {
+ @Override
+ public String load(String key) throws Exception {
+ return cache.get(key, identityLoader()); // recursive load, this should fail
+ }
+ };
+ testLoadThrows(key, cache, loader);
+ }
+
+ public void testRecursiveLoadWithProxy() throws InterruptedException {
+ String key = "key";
+ String otherKey = "otherKey";
+ LocalCache<String, String> cache = makeLocalCache(createCacheBuilder());
+ CacheLoader<String, String> loader =
+ new CacheLoader<String, String>() {
+ @Override
+ public String load(String key) throws Exception {
+ return cache.get(
+ key,
+ identityLoader()); // recursive load (same as the initial one), this should fail
+ }
+ };
+ CacheLoader<String, String> proxyLoader =
+ new CacheLoader<String, String>() {
+ @Override
+ public String load(String key) throws Exception {
+ return cache.get(otherKey, loader); // loads another key, is ok
+ }
+ };
+ testLoadThrows(key, cache, proxyLoader);
+ }
+
// utility methods
+ private void testLoadThrows(
+ String key, LocalCache<String, String> cache, CacheLoader<String, String> loader)
+ throws InterruptedException {
+ CountDownLatch doneSignal = new CountDownLatch(1);
+ Thread thread =
+ new Thread(
+ () -> {
+ try {
+ cache.get(key, loader);
+ } catch (UncheckedExecutionException | ExecutionException e) {
+ doneSignal.countDown();
+ }
+ });
+ thread.start();
+
+ boolean done = doneSignal.await(1, TimeUnit.SECONDS);
+ if (!done) {
+ StringBuilder builder = new StringBuilder();
+ for (StackTraceElement trace : thread.getStackTrace()) {
+ builder.append("\tat ").append(trace).append('\n');
+ }
+ fail(builder.toString());
+ }
+ }
+
/**
* Returns an iterable containing all combinations of maximumSize, expireAfterAccess/Write,
* weakKeys and weak/softValues.
diff --git a/android/guava-tests/test/com/google/common/cache/NullCacheTest.java b/android/guava-tests/test/com/google/common/cache/NullCacheTest.java
index 89dc3fb14..6fa8f7b13 100644
--- a/android/guava-tests/test/com/google/common/cache/NullCacheTest.java
+++ b/android/guava-tests/test/com/google/common/cache/NullCacheTest.java
@@ -20,6 +20,7 @@ import static com.google.common.cache.TestingCacheLoaders.exceptionLoader;
import static com.google.common.cache.TestingRemovalListeners.queuingRemovalListener;
import static com.google.common.truth.Truth.assertThat;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
import com.google.common.cache.TestingRemovalListeners.QueuingRemovalListener;
@@ -100,12 +101,7 @@ public class NullCacheTest extends TestCase {
.removalListener(listener)
.build(constantLoader(null));
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (InvalidCacheLoadException e) {
- /* expected */
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getUnchecked(new Object()));
assertTrue(listener.isEmpty());
checkEmpty(cache);
@@ -119,12 +115,9 @@ public class NullCacheTest extends TestCase {
.removalListener(listener)
.build(exceptionLoader(e));
- try {
- map.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException uee) {
- assertThat(uee).hasCauseThat().isSameInstanceAs(e);
- }
+ UncheckedExecutionException uee =
+ assertThrows(UncheckedExecutionException.class, () -> map.getUnchecked(new Object()));
+ assertThat(uee).hasCauseThat().isSameInstanceAs(e);
assertTrue(listener.isEmpty());
checkEmpty(map);
}
diff --git a/android/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java b/android/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java
index b02b8ac61..5518190a5 100644
--- a/android/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java
+++ b/android/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java
@@ -20,6 +20,7 @@ import static com.google.common.cache.TestingCacheLoaders.identityLoader;
import static com.google.common.truth.Truth.assertThat;
import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Function;
import com.google.common.cache.CacheBuilderFactory.DurationSpec;
@@ -279,11 +280,7 @@ public class PopulatedCachesTest extends TestCase {
assertEquals(3, cache.getIfPresent(1));
checkValidState(cache);
- try {
- entry.setValue(null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> entry.setValue(null));
checkValidState(cache);
}
}
diff --git a/android/guava-tests/test/com/google/common/collect/AbstractFilteredMapTest.java b/android/guava-tests/test/com/google/common/collect/AbstractFilteredMapTest.java
new file mode 100644
index 000000000..b415b2b1b
--- /dev/null
+++ b/android/guava-tests/test/com/google/common/collect/AbstractFilteredMapTest.java
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 2007 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.collect;
+
+import com.google.common.annotations.GwtCompatible;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import java.util.Map;
+import java.util.Map.Entry;
+import junit.framework.TestCase;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+@GwtCompatible
+abstract class AbstractFilteredMapTest extends TestCase {
+ private static final Predicate<@Nullable String> NOT_LENGTH_3 =
+ input -> input == null || input.length() != 3;
+ private static final Predicate<@Nullable Integer> EVEN = input -> input == null || input % 2 == 0;
+ static final Predicate<Entry<String, Integer>> CORRECT_LENGTH =
+ input -> input.getKey().length() == input.getValue();
+
+ abstract Map<String, Integer> createUnfiltered();
+
+ public void testFilteredKeysIllegalPut() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3);
+ filtered.put("a", 1);
+ filtered.put("b", 2);
+ assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered);
+
+ try {
+ filtered.put("yyy", 3);
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ public void testFilteredKeysIllegalPutAll() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3);
+ filtered.put("a", 1);
+ filtered.put("b", 2);
+ assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered);
+
+ try {
+ filtered.putAll(ImmutableMap.of("c", 3, "zzz", 4, "b", 5));
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+
+ assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered);
+ }
+
+ public void testFilteredKeysFilteredReflectsBackingChanges() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3);
+ unfiltered.put("two", 2);
+ unfiltered.put("three", 3);
+ unfiltered.put("four", 4);
+ assertEquals(ImmutableMap.of("two", 2, "three", 3, "four", 4), unfiltered);
+ assertEquals(ImmutableMap.of("three", 3, "four", 4), filtered);
+
+ unfiltered.remove("three");
+ assertEquals(ImmutableMap.of("two", 2, "four", 4), unfiltered);
+ assertEquals(ImmutableMap.of("four", 4), filtered);
+
+ unfiltered.clear();
+ assertEquals(ImmutableMap.of(), unfiltered);
+ assertEquals(ImmutableMap.of(), filtered);
+ }
+
+ public void testFilteredValuesIllegalPut() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
+ filtered.put("a", 2);
+ unfiltered.put("b", 4);
+ unfiltered.put("c", 5);
+ assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
+
+ try {
+ filtered.put("yyy", 3);
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
+ }
+
+ public void testFilteredValuesIllegalPutAll() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
+ filtered.put("a", 2);
+ unfiltered.put("b", 4);
+ unfiltered.put("c", 5);
+ assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
+
+ try {
+ filtered.putAll(ImmutableMap.of("c", 4, "zzz", 5, "b", 6));
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
+ }
+
+ public void testFilteredValuesIllegalSetValue() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
+ filtered.put("a", 2);
+ filtered.put("b", 4);
+ assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
+
+ Entry<String, Integer> entry = filtered.entrySet().iterator().next();
+ try {
+ entry.setValue(5);
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+
+ assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
+ }
+
+ public void testFilteredValuesClear() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ unfiltered.put("one", 1);
+ unfiltered.put("two", 2);
+ unfiltered.put("three", 3);
+ unfiltered.put("four", 4);
+ Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
+ assertEquals(ImmutableMap.of("one", 1, "two", 2, "three", 3, "four", 4), unfiltered);
+ assertEquals(ImmutableMap.of("two", 2, "four", 4), filtered);
+
+ filtered.clear();
+ assertEquals(ImmutableMap.of("one", 1, "three", 3), unfiltered);
+ assertTrue(filtered.isEmpty());
+ }
+
+ public void testFilteredEntriesIllegalPut() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ unfiltered.put("cat", 3);
+ unfiltered.put("dog", 2);
+ unfiltered.put("horse", 5);
+ Map<String, Integer> filtered = Maps.filterEntries(unfiltered, CORRECT_LENGTH);
+ assertEquals(ImmutableMap.of("cat", 3, "horse", 5), filtered);
+
+ filtered.put("chicken", 7);
+ assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
+
+ try {
+ filtered.put("cow", 7);
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
+ }
+
+ public void testFilteredEntriesIllegalPutAll() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ unfiltered.put("cat", 3);
+ unfiltered.put("dog", 2);
+ unfiltered.put("horse", 5);
+ Map<String, Integer> filtered = Maps.filterEntries(unfiltered, CORRECT_LENGTH);
+ assertEquals(ImmutableMap.of("cat", 3, "horse", 5), filtered);
+
+ filtered.put("chicken", 7);
+ assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
+
+ try {
+ filtered.putAll(ImmutableMap.of("sheep", 5, "cow", 7));
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
+ }
+
+ public void testFilteredEntriesObjectPredicate() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ unfiltered.put("cat", 3);
+ unfiltered.put("dog", 2);
+ unfiltered.put("horse", 5);
+ Predicate<Object> predicate = Predicates.alwaysFalse();
+ Map<String, Integer> filtered = Maps.filterEntries(unfiltered, predicate);
+ assertTrue(filtered.isEmpty());
+ }
+
+ public void testFilteredEntriesWildCardEntryPredicate() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ unfiltered.put("cat", 3);
+ unfiltered.put("dog", 2);
+ unfiltered.put("horse", 5);
+ Predicate<Entry<?, ?>> predicate =
+ new Predicate<Entry<?, ?>>() {
+ @Override
+ public boolean apply(Entry<?, ?> input) {
+ return "cat".equals(input.getKey()) || Integer.valueOf(2) == input.getValue();
+ }
+ };
+ Map<String, Integer> filtered = Maps.filterEntries(unfiltered, predicate);
+ assertEquals(ImmutableMap.of("cat", 3, "dog", 2), filtered);
+ }
+}
diff --git a/android/guava-tests/test/com/google/common/collect/AbstractMapsTransformValuesTest.java b/android/guava-tests/test/com/google/common/collect/AbstractMapsTransformValuesTest.java
new file mode 100644
index 000000000..3b56fef5e
--- /dev/null
+++ b/android/guava-tests/test/com/google/common/collect/AbstractMapsTransformValuesTest.java
@@ -0,0 +1,275 @@
+/*
+ * Copyright (C) 2008 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.collect;
+
+import com.google.common.annotations.GwtCompatible;
+import com.google.common.base.Function;
+import com.google.common.base.Functions;
+import com.google.common.collect.testing.MapInterfaceTest;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/**
+ * Superclass for tests for {@link Maps#transformValues} overloads.
+ *
+ * @author Isaac Shum
+ */
+@GwtCompatible
+abstract class AbstractMapsTransformValuesTest extends MapInterfaceTest<String, String> {
+ public AbstractMapsTransformValuesTest() {
+ super(false, true, false, true, true);
+ }
+
+ @Override
+ protected String getKeyNotInPopulatedMap() throws UnsupportedOperationException {
+ return "z";
+ }
+
+ @Override
+ protected String getValueNotInPopulatedMap() throws UnsupportedOperationException {
+ return "26";
+ }
+
+ /** Helper assertion comparing two maps */
+ private void assertMapsEqual(Map<?, ?> expected, Map<?, ?> map) {
+ assertEquals(expected, map);
+ assertEquals(expected.hashCode(), map.hashCode());
+ assertEquals(expected.entrySet(), map.entrySet());
+
+ // Assert that expectedValues > mapValues and that
+ // mapValues > expectedValues; i.e. that expectedValues == mapValues.
+ Collection<?> expectedValues = expected.values();
+ Collection<?> mapValues = map.values();
+ assertEquals(expectedValues.size(), mapValues.size());
+ assertTrue(expectedValues.containsAll(mapValues));
+ assertTrue(mapValues.containsAll(expectedValues));
+ }
+
+ public void testTransformEmptyMapEquality() {
+ Map<String, String> map =
+ Maps.transformValues(ImmutableMap.<String, Integer>of(), Functions.toStringFunction());
+ assertMapsEqual(Maps.newHashMap(), map);
+ }
+
+ public void testTransformSingletonMapEquality() {
+ Map<String, String> map =
+ Maps.transformValues(ImmutableMap.of("a", 1), Functions.toStringFunction());
+ Map<String, String> expected = ImmutableMap.of("a", "1");
+ assertMapsEqual(expected, map);
+ assertEquals(expected.get("a"), map.get("a"));
+ }
+
+ public void testTransformIdentityFunctionEquality() {
+ Map<String, Integer> underlying = ImmutableMap.of("a", 1);
+ Map<String, Integer> map = Maps.transformValues(underlying, Functions.<Integer>identity());
+ assertMapsEqual(underlying, map);
+ }
+
+ public void testTransformPutEntryIsUnsupported() {
+ Map<String, String> map =
+ Maps.transformValues(ImmutableMap.of("a", 1), Functions.toStringFunction());
+ try {
+ map.put("b", "2");
+ fail();
+ } catch (UnsupportedOperationException expected) {
+ }
+
+ try {
+ map.putAll(ImmutableMap.of("b", "2"));
+ fail();
+ } catch (UnsupportedOperationException expected) {
+ }
+
+ try {
+ map.entrySet().iterator().next().setValue("one");
+ fail();
+ } catch (UnsupportedOperationException expected) {
+ }
+ }
+
+ public void testTransformRemoveEntry() {
+ Map<String, Integer> underlying = Maps.newHashMap();
+ underlying.put("a", 1);
+ Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction());
+ assertEquals("1", map.remove("a"));
+ assertNull(map.remove("b"));
+ }
+
+ public void testTransformEqualityOfMapsWithNullValues() {
+ Map<String, String> underlying = Maps.newHashMap();
+ underlying.put("a", null);
+ underlying.put("b", "");
+
+ Map<String, Boolean> map =
+ Maps.transformValues(
+ underlying,
+ new Function<String, Boolean>() {
+ @Override
+ public Boolean apply(@Nullable String from) {
+ return from == null;
+ }
+ });
+ Map<String, Boolean> expected = ImmutableMap.of("a", true, "b", false);
+ assertMapsEqual(expected, map);
+ assertEquals(expected.get("a"), map.get("a"));
+ assertEquals(expected.containsKey("a"), map.containsKey("a"));
+ assertEquals(expected.get("b"), map.get("b"));
+ assertEquals(expected.containsKey("b"), map.containsKey("b"));
+ assertEquals(expected.get("c"), map.get("c"));
+ assertEquals(expected.containsKey("c"), map.containsKey("c"));
+ }
+
+ public void testTransformReflectsUnderlyingMap() {
+ Map<String, Integer> underlying = Maps.newHashMap();
+ underlying.put("a", 1);
+ underlying.put("b", 2);
+ underlying.put("c", 3);
+ Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction());
+ assertEquals(underlying.size(), map.size());
+
+ underlying.put("d", 4);
+ assertEquals(underlying.size(), map.size());
+ assertEquals("4", map.get("d"));
+
+ underlying.remove("c");
+ assertEquals(underlying.size(), map.size());
+ assertFalse(map.containsKey("c"));
+
+ underlying.clear();
+ assertEquals(underlying.size(), map.size());
+ }
+
+ public void testTransformChangesAreReflectedInUnderlyingMap() {
+ Map<String, Integer> underlying = Maps.newLinkedHashMap();
+ underlying.put("a", 1);
+ underlying.put("b", 2);
+ underlying.put("c", 3);
+ underlying.put("d", 4);
+ underlying.put("e", 5);
+ underlying.put("f", 6);
+ underlying.put("g", 7);
+ Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction());
+
+ map.remove("a");
+ assertFalse(underlying.containsKey("a"));
+
+ Set<String> keys = map.keySet();
+ keys.remove("b");
+ assertFalse(underlying.containsKey("b"));
+
+ Iterator<String> keyIterator = keys.iterator();
+ keyIterator.next();
+ keyIterator.remove();
+ assertFalse(underlying.containsKey("c"));
+
+ Collection<String> values = map.values();
+ values.remove("4");
+ assertFalse(underlying.containsKey("d"));
+
+ Iterator<String> valueIterator = values.iterator();
+ valueIterator.next();
+ valueIterator.remove();
+ assertFalse(underlying.containsKey("e"));
+
+ Set<Entry<String, String>> entries = map.entrySet();
+ Entry<String, String> firstEntry = entries.iterator().next();
+ entries.remove(firstEntry);
+ assertFalse(underlying.containsKey("f"));
+
+ Iterator<Entry<String, String>> entryIterator = entries.iterator();
+ entryIterator.next();
+ entryIterator.remove();
+ assertFalse(underlying.containsKey("g"));
+
+ assertTrue(underlying.isEmpty());
+ assertTrue(map.isEmpty());
+ assertTrue(keys.isEmpty());
+ assertTrue(values.isEmpty());
+ assertTrue(entries.isEmpty());
+ }
+
+ public void testTransformEquals() {
+ Map<String, Integer> underlying = ImmutableMap.of("a", 0, "b", 1, "c", 2);
+ Map<String, Integer> expected = Maps.transformValues(underlying, Functions.<Integer>identity());
+
+ assertMapsEqual(expected, expected);
+
+ Map<String, Integer> equalToUnderlying = Maps.newTreeMap();
+ equalToUnderlying.putAll(underlying);
+ Map<String, Integer> map =
+ Maps.transformValues(equalToUnderlying, Functions.<Integer>identity());
+ assertMapsEqual(expected, map);
+
+ map =
+ Maps.transformValues(
+ ImmutableMap.of("a", 1, "b", 2, "c", 3),
+ new Function<Integer, Integer>() {
+ @Override
+ public Integer apply(Integer from) {
+ return from - 1;
+ }
+ });
+ assertMapsEqual(expected, map);
+ }
+
+ public void testTransformEntrySetContains() {
+ Map<@Nullable String, @Nullable Boolean> underlying = Maps.newHashMap();
+ underlying.put("a", null);
+ underlying.put("b", true);
+ underlying.put(null, true);
+
+ Map<@Nullable String, @Nullable Boolean> map =
+ Maps.transformValues(
+ underlying,
+ new Function<@Nullable Boolean, @Nullable Boolean>() {
+ @Override
+ public @Nullable Boolean apply(@Nullable Boolean from) {
+ return (from == null) ? true : null;
+ }
+ });
+
+ Set<Entry<@Nullable String, @Nullable Boolean>> entries = map.entrySet();
+ assertTrue(entries.contains(Maps.immutableEntry("a", true)));
+ assertTrue(entries.contains(Maps.immutableEntry("b", (Boolean) null)));
+ assertTrue(entries.contains(Maps.immutableEntry((String) null, (Boolean) null)));
+
+ assertFalse(entries.contains(Maps.immutableEntry("c", (Boolean) null)));
+ assertFalse(entries.contains(Maps.immutableEntry((String) null, true)));
+ }
+
+ @Override
+ public void testKeySetRemoveAllNullFromEmpty() {
+ try {
+ super.testKeySetRemoveAllNullFromEmpty();
+ } catch (RuntimeException tolerated) {
+ // GWT's HashMap.keySet().removeAll(null) doesn't throws NPE.
+ }
+ }
+
+ @Override
+ public void testEntrySetRemoveAllNullFromEmpty() {
+ try {
+ super.testEntrySetRemoveAllNullFromEmpty();
+ } catch (RuntimeException tolerated) {
+ // GWT's HashMap.entrySet().removeAll(null) doesn't throws NPE.
+ }
+ }
+}
diff --git a/android/guava-tests/test/com/google/common/collect/Base.java b/android/guava-tests/test/com/google/common/collect/Base.java
new file mode 100644
index 000000000..b68bd7f65
--- /dev/null
+++ b/android/guava-tests/test/com/google/common/collect/Base.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2007 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.collect;
+
+import com.google.common.annotations.GwtCompatible;
+import java.io.Serializable;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/** Simple base class to verify that we handle generics correctly. */
+@GwtCompatible
+class Base implements Comparable<Base>, Serializable {
+ private final String s;
+
+ public Base(String s) {
+ this.s = s;
+ }
+
+ @Override
+ public int hashCode() { // delegate to 's'
+ return s.hashCode();
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (other == null) {
+ return false;
+ } else if (other instanceof Base) {
+ return s.equals(((Base) other).s);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int compareTo(Base o) {
+ return s.compareTo(o.s);
+ }
+
+ private static final long serialVersionUID = 0;
+}
diff --git a/android/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java b/android/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java
index 1d38c8600..f7ffbc92f 100644
--- a/android/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java
@@ -20,6 +20,7 @@ import static com.google.common.collect.MapMakerInternalMap.Strength.STRONG;
import static com.google.common.collect.MapMakerInternalMap.Strength.WEAK;
import static com.google.common.testing.SerializableTester.reserializeAndAssert;
import static java.util.Arrays.asList;
+import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
@@ -159,11 +160,7 @@ public class ConcurrentHashMultisetTest extends TestCase {
when(backingMap.get(KEY)).thenReturn(new AtomicInteger(INITIAL_COUNT));
- try {
- multiset.add(KEY, COUNT_TO_ADD);
- fail("Must reject arguments that would cause counter overflow.");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> multiset.add(KEY, COUNT_TO_ADD));
}
/**
@@ -246,11 +243,7 @@ public class ConcurrentHashMultisetTest extends TestCase {
cms.add("a", 2);
cms.add("b", 3);
- try {
- cms.removeExactly("a", -2);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> cms.removeExactly("a", -2));
assertTrue(cms.removeExactly("a", 0));
assertEquals(2, cms.count("a"));
diff --git a/android/guava-tests/test/com/google/common/collect/ContiguousSetTest.java b/android/guava-tests/test/com/google/common/collect/ContiguousSetTest.java
index 6b19b1edc..f3c5fe864 100644
--- a/android/guava-tests/test/com/google/common/collect/ContiguousSetTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ContiguousSetTest.java
@@ -44,7 +44,9 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-/** @author Gregory Kick */
+/**
+ * @author Gregory Kick
+ */
@GwtCompatible(emulated = true)
public class ContiguousSetTest extends TestCase {
private static final DiscreteDomain<Integer> NOT_EQUAL_TO_INTEGERS =
@@ -155,10 +157,28 @@ public class ContiguousSetTest extends TestCase {
assertEquals(enormous, enormousReserialized);
}
+ private static final DiscreteDomain<Integer> UNBOUNDED_THROWING_DOMAIN =
+ new DiscreteDomain<Integer>() {
+ @Override
+ public Integer next(Integer value) {
+ throw new AssertionError();
+ }
+
+ @Override
+ public Integer previous(Integer value) {
+ throw new AssertionError();
+ }
+
+ @Override
+ public long distance(Integer start, Integer end) {
+ throw new AssertionError();
+ }
+ };
+
public void testCreate_noMin() {
Range<Integer> range = Range.lessThan(0);
try {
- ContiguousSet.create(range, RangeTest.UNBOUNDED_DOMAIN);
+ ContiguousSet.create(range, UNBOUNDED_THROWING_DOMAIN);
fail();
} catch (IllegalArgumentException expected) {
}
@@ -167,7 +187,7 @@ public class ContiguousSetTest extends TestCase {
public void testCreate_noMax() {
Range<Integer> range = Range.greaterThan(0);
try {
- ContiguousSet.create(range, RangeTest.UNBOUNDED_DOMAIN);
+ ContiguousSet.create(range, UNBOUNDED_THROWING_DOMAIN);
fail();
} catch (IllegalArgumentException expected) {
}
diff --git a/android/guava-tests/test/com/google/common/collect/Derived.java b/android/guava-tests/test/com/google/common/collect/Derived.java
new file mode 100644
index 000000000..995c42be8
--- /dev/null
+++ b/android/guava-tests/test/com/google/common/collect/Derived.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.collect;
+
+import com.google.common.annotations.GwtCompatible;
+
+/** Simple derived class to verify that we handle generics correctly. */
+@GwtCompatible
+class Derived extends Base {
+ public Derived(String s) {
+ super(s);
+ }
+
+ private static final long serialVersionUID = 0;
+}
diff --git a/android/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java b/android/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java
index b9e15fd9c..bd7fa8b64 100644
--- a/android/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java
+++ b/android/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import static com.google.common.testing.SerializableTester.reserializeAndAssert;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import java.math.BigInteger;
@@ -43,16 +44,10 @@ public class DiscreteDomainTest extends TestCase {
}
public void testIntegersOffsetExceptions() {
- try {
- DiscreteDomain.integers().offset(0, -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- DiscreteDomain.integers().offset(Integer.MAX_VALUE, 1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> DiscreteDomain.integers().offset(0, -1));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> DiscreteDomain.integers().offset(Integer.MAX_VALUE, 1));
}
public void testLongsOffset() {
@@ -61,16 +56,9 @@ public class DiscreteDomainTest extends TestCase {
}
public void testLongsOffsetExceptions() {
- try {
- DiscreteDomain.longs().offset(0L, -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- DiscreteDomain.longs().offset(Long.MAX_VALUE, 1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> DiscreteDomain.longs().offset(0L, -1));
+ assertThrows(
+ IllegalArgumentException.class, () -> DiscreteDomain.longs().offset(Long.MAX_VALUE, 1));
}
public void testBigIntegersOffset() {
@@ -81,24 +69,15 @@ public class DiscreteDomainTest extends TestCase {
}
public void testBigIntegersOffsetExceptions() {
- try {
- DiscreteDomain.bigIntegers().offset(BigInteger.ZERO, -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> DiscreteDomain.bigIntegers().offset(BigInteger.ZERO, -1));
}
public void testCustomOffsetExceptions() {
- try {
- new MyIntegerDomain().offset(0, -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- new MyIntegerDomain().offset(Integer.MAX_VALUE, 1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> new MyIntegerDomain().offset(0, -1));
+ assertThrows(
+ IllegalArgumentException.class, () -> new MyIntegerDomain().offset(Integer.MAX_VALUE, 1));
}
private static final class MyIntegerDomain extends DiscreteDomain<Integer> {
diff --git a/android/guava-tests/test/com/google/common/collect/FauxveridesTest.java b/android/guava-tests/test/com/google/common/collect/FauxveridesTest.java
index f7eda67d5..9dfac093f 100644
--- a/android/guava-tests/test/com/google/common/collect/FauxveridesTest.java
+++ b/android/guava-tests/test/com/google/common/collect/FauxveridesTest.java
@@ -21,6 +21,7 @@ import static com.google.common.collect.Sets.difference;
import static com.google.common.collect.Sets.newHashSet;
import static java.lang.reflect.Modifier.isPublic;
import static java.lang.reflect.Modifier.isStatic;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
@@ -44,26 +45,32 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @author Chris Povirk
*/
public class FauxveridesTest extends TestCase {
+ @AndroidIncompatible // similar to ImmutableTableTest.testNullPointerInstance
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);
}
+ @AndroidIncompatible // similar to ImmutableTableTest.testNullPointerInstance
public void testImmutableSortedMap() {
doHasAllFauxveridesTest(ImmutableSortedMap.class, ImmutableMap.class);
}
+ @AndroidIncompatible // similar to ImmutableTableTest.testNullPointerInstance
public void testImmutableSortedSet() {
doHasAllFauxveridesTest(ImmutableSortedSet.class, ImmutableSet.class);
}
+ @AndroidIncompatible // similar to ImmutableTableTest.testNullPointerInstance
public void testImmutableSortedMultiset() {
doHasAllFauxveridesTest(ImmutableSortedMultiset.class, ImmutableMultiset.class);
}
@@ -78,31 +85,19 @@ public class FauxveridesTest extends TestCase {
Map<Object, Object> original =
ImmutableMap.of(new Object(), new Object(), new Object(), new Object());
- try {
- ImmutableSortedMap.copyOf(original);
- fail();
- } catch (ClassCastException expected) {
- }
+ assertThrows(ClassCastException.class, () -> ImmutableSortedMap.copyOf(original));
}
public void testImmutableSortedSetCopyOfIterable() {
Set<Object> original = ImmutableSet.of(new Object(), new Object());
- try {
- ImmutableSortedSet.copyOf(original);
- fail();
- } catch (ClassCastException expected) {
- }
+ assertThrows(ClassCastException.class, () -> ImmutableSortedSet.copyOf(original));
}
public void testImmutableSortedSetCopyOfIterator() {
Set<Object> original = ImmutableSet.of(new Object(), new Object());
- try {
- ImmutableSortedSet.copyOf(original.iterator());
- fail();
- } catch (ClassCastException expected) {
- }
+ assertThrows(ClassCastException.class, () -> ImmutableSortedSet.copyOf(original.iterator()));
}
private void doHasAllFauxveridesTest(Class<?> descendant, Class<?> ancestor) {
diff --git a/android/guava-tests/test/com/google/common/collect/FilteredBiMapTest.java b/android/guava-tests/test/com/google/common/collect/FilteredBiMapTest.java
index f575a73c4..8f5f4c6c3 100644
--- a/android/guava-tests/test/com/google/common/collect/FilteredBiMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/FilteredBiMapTest.java
@@ -19,7 +19,7 @@ package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
@GwtCompatible
-public class FilteredBiMapTest extends FilteredMapTest {
+public class FilteredBiMapTest extends AbstractFilteredMapTest {
@Override
BiMap<String, Integer> createUnfiltered() {
return HashBiMap.create();
diff --git a/android/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java b/android/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java
index 77e01dc58..d2fc05fd8 100644
--- a/android/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java
+++ b/android/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
@@ -156,11 +157,7 @@ public final class FilteredCollectionsTestUtil {
C filtered = filter(createUnfiltered(contents), EVEN);
C filteredToModify = filter(createUnfiltered(contents), EVEN);
- try {
- filteredToModify.addAll(toAdd);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> filteredToModify.addAll(toAdd));
assertThat(filteredToModify).containsExactlyElementsIn(filtered);
}
@@ -172,17 +169,9 @@ public final class FilteredCollectionsTestUtil {
C filtered1 = filter(unfiltered, EVEN);
C filtered2 = filter(filtered1, PRIME_DIGIT);
- try {
- filtered2.add(4);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> filtered2.add(4));
- try {
- filtered2.add(3);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> filtered2.add(3));
filtered2.add(2);
}
diff --git a/android/guava-tests/test/com/google/common/collect/FilteredMapTest.java b/android/guava-tests/test/com/google/common/collect/FilteredMapTest.java
index 159fec9a9..da080fbe3 100644
--- a/android/guava-tests/test/com/google/common/collect/FilteredMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/FilteredMapTest.java
@@ -16,196 +16,14 @@
package com.google.common.collect;
-import static com.google.common.collect.MapsTest.CORRECT_LENGTH;
-import static com.google.common.collect.MapsTest.EVEN;
-import static com.google.common.collect.MapsTest.NOT_LENGTH_3;
import com.google.common.annotations.GwtCompatible;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
import java.util.Map;
-import java.util.Map.Entry;
-import junit.framework.TestCase;
@GwtCompatible
-public class FilteredMapTest extends TestCase {
+public class FilteredMapTest extends AbstractFilteredMapTest {
+ @Override
Map<String, Integer> createUnfiltered() {
return Maps.newHashMap();
}
-
- public void testFilteredKeysIllegalPut() {
- Map<String, Integer> unfiltered = createUnfiltered();
- Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3);
- filtered.put("a", 1);
- filtered.put("b", 2);
- assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered);
-
- try {
- filtered.put("yyy", 3);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- }
-
- public void testFilteredKeysIllegalPutAll() {
- Map<String, Integer> unfiltered = createUnfiltered();
- Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3);
- filtered.put("a", 1);
- filtered.put("b", 2);
- assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered);
-
- try {
- filtered.putAll(ImmutableMap.of("c", 3, "zzz", 4, "b", 5));
- fail();
- } catch (IllegalArgumentException expected) {
- }
-
- assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered);
- }
-
- public void testFilteredKeysFilteredReflectsBackingChanges() {
- Map<String, Integer> unfiltered = createUnfiltered();
- Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3);
- unfiltered.put("two", 2);
- unfiltered.put("three", 3);
- unfiltered.put("four", 4);
- assertEquals(ImmutableMap.of("two", 2, "three", 3, "four", 4), unfiltered);
- assertEquals(ImmutableMap.of("three", 3, "four", 4), filtered);
-
- unfiltered.remove("three");
- assertEquals(ImmutableMap.of("two", 2, "four", 4), unfiltered);
- assertEquals(ImmutableMap.of("four", 4), filtered);
-
- unfiltered.clear();
- assertEquals(ImmutableMap.of(), unfiltered);
- assertEquals(ImmutableMap.of(), filtered);
- }
-
- public void testFilteredValuesIllegalPut() {
- Map<String, Integer> unfiltered = createUnfiltered();
- Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
- filtered.put("a", 2);
- unfiltered.put("b", 4);
- unfiltered.put("c", 5);
- assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
-
- try {
- filtered.put("yyy", 3);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
- }
-
- public void testFilteredValuesIllegalPutAll() {
- Map<String, Integer> unfiltered = createUnfiltered();
- Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
- filtered.put("a", 2);
- unfiltered.put("b", 4);
- unfiltered.put("c", 5);
- assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
-
- try {
- filtered.putAll(ImmutableMap.of("c", 4, "zzz", 5, "b", 6));
- fail();
- } catch (IllegalArgumentException expected) {
- }
- assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
- }
-
- public void testFilteredValuesIllegalSetValue() {
- Map<String, Integer> unfiltered = createUnfiltered();
- Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
- filtered.put("a", 2);
- filtered.put("b", 4);
- assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
-
- Entry<String, Integer> entry = filtered.entrySet().iterator().next();
- try {
- entry.setValue(5);
- fail();
- } catch (IllegalArgumentException expected) {
- }
-
- assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
- }
-
- public void testFilteredValuesClear() {
- Map<String, Integer> unfiltered = createUnfiltered();
- unfiltered.put("one", 1);
- unfiltered.put("two", 2);
- unfiltered.put("three", 3);
- unfiltered.put("four", 4);
- Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
- assertEquals(ImmutableMap.of("one", 1, "two", 2, "three", 3, "four", 4), unfiltered);
- assertEquals(ImmutableMap.of("two", 2, "four", 4), filtered);
-
- filtered.clear();
- assertEquals(ImmutableMap.of("one", 1, "three", 3), unfiltered);
- assertTrue(filtered.isEmpty());
- }
-
- public void testFilteredEntriesIllegalPut() {
- Map<String, Integer> unfiltered = createUnfiltered();
- unfiltered.put("cat", 3);
- unfiltered.put("dog", 2);
- unfiltered.put("horse", 5);
- Map<String, Integer> filtered = Maps.filterEntries(unfiltered, CORRECT_LENGTH);
- assertEquals(ImmutableMap.of("cat", 3, "horse", 5), filtered);
-
- filtered.put("chicken", 7);
- assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
-
- try {
- filtered.put("cow", 7);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
- }
-
- public void testFilteredEntriesIllegalPutAll() {
- Map<String, Integer> unfiltered = createUnfiltered();
- unfiltered.put("cat", 3);
- unfiltered.put("dog", 2);
- unfiltered.put("horse", 5);
- Map<String, Integer> filtered = Maps.filterEntries(unfiltered, CORRECT_LENGTH);
- assertEquals(ImmutableMap.of("cat", 3, "horse", 5), filtered);
-
- filtered.put("chicken", 7);
- assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
-
- try {
- filtered.putAll(ImmutableMap.of("sheep", 5, "cow", 7));
- fail();
- } catch (IllegalArgumentException expected) {
- }
- assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
- }
-
- public void testFilteredEntriesObjectPredicate() {
- Map<String, Integer> unfiltered = createUnfiltered();
- unfiltered.put("cat", 3);
- unfiltered.put("dog", 2);
- unfiltered.put("horse", 5);
- Predicate<Object> predicate = Predicates.alwaysFalse();
- Map<String, Integer> filtered = Maps.filterEntries(unfiltered, predicate);
- assertTrue(filtered.isEmpty());
- }
-
- public void testFilteredEntriesWildCardEntryPredicate() {
- Map<String, Integer> unfiltered = createUnfiltered();
- unfiltered.put("cat", 3);
- unfiltered.put("dog", 2);
- unfiltered.put("horse", 5);
- Predicate<Entry<?, ?>> predicate =
- new Predicate<Entry<?, ?>>() {
- @Override
- public boolean apply(Entry<?, ?> input) {
- return "cat".equals(input.getKey()) || Integer.valueOf(2) == input.getValue();
- }
- };
- Map<String, Integer> filtered = Maps.filterEntries(unfiltered, predicate);
- assertEquals(ImmutableMap.of("cat", 3, "dog", 2), filtered);
- }
}
diff --git a/android/guava-tests/test/com/google/common/collect/FilteredSortedMapTest.java b/android/guava-tests/test/com/google/common/collect/FilteredSortedMapTest.java
index 23b3f2a99..0a08da3d8 100644
--- a/android/guava-tests/test/com/google/common/collect/FilteredSortedMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/FilteredSortedMapTest.java
@@ -16,13 +16,11 @@
package com.google.common.collect;
-import static com.google.common.collect.MapsTest.CORRECT_LENGTH;
-
import com.google.common.annotations.GwtCompatible;
import java.util.SortedMap;
@GwtCompatible
-public class FilteredSortedMapTest extends FilteredMapTest {
+public class FilteredSortedMapTest extends AbstractFilteredMapTest {
@Override
SortedMap<String, Integer> createUnfiltered() {
return Maps.newTreeMap();
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java
index b9696301f..3ea288d6e 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import static com.google.common.collect.Maps.immutableEntry;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.testing.MapTestSuiteBuilder;
import com.google.common.collect.testing.SampleElements;
@@ -116,19 +117,11 @@ public class ImmutableClassToInstanceMapTest extends TestCase {
public void testCopyOf_map_nulls() {
Map<Class<? extends Number>, Number> nullKey = Collections.singletonMap(null, (Number) 1.0);
- try {
- ImmutableClassToInstanceMap.copyOf(nullKey);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ImmutableClassToInstanceMap.copyOf(nullKey));
Map<? extends Class<? extends Number>, Number> nullValue =
Collections.singletonMap(Number.class, null);
- try {
- ImmutableClassToInstanceMap.copyOf(nullValue);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ImmutableClassToInstanceMap.copyOf(nullValue));
}
public void testCopyOf_imap_empty() {
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java
index 126074004..cb68484ea 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java
@@ -574,6 +574,7 @@ public class ImmutableListMultimapTest extends TestCase {
}
@GwtIncompatible // reflection
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableListMultimap.class);
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 95ae532f9..bbe638803 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableListTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableListTest.java
@@ -462,6 +462,7 @@ public class ImmutableListTest extends TestCase {
// Basic tests
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableList.class);
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableMapTest.java
index 67c039af1..6b5e0731b 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableMapTest.java
@@ -893,6 +893,7 @@ public class ImmutableMapTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableMap.class);
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
index ac09593ba..bf32922e1 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
@@ -128,6 +128,7 @@ public class ImmutableMultimapTest extends TestCase {
}
@GwtIncompatible // reflection
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableMultimap.class);
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java
index 2b320ce1e..2c772b4bc 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java
@@ -471,6 +471,7 @@ public class ImmutableMultisetTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableMultiset.class);
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
index 59f3a1b59..2719aeecd 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
@@ -16,6 +16,7 @@ package com.google.common.collect;
import static com.google.common.collect.BoundType.OPEN;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.testing.SerializableTester;
@@ -65,18 +66,10 @@ public class ImmutableRangeMapTest extends TestCase {
public void testBuilderRejectsEmptyRanges() {
for (int i = MIN_BOUND; i <= MAX_BOUND; i++) {
+ final int ii = i;
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
- try {
- builder.put(Range.closedOpen(i, i), 1);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- // success
- }
- try {
- builder.put(Range.openClosed(i, i), 1);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.put(Range.closedOpen(ii, ii), 1));
+ assertThrows(IllegalArgumentException.class, () -> builder.put(Range.openClosed(ii, ii), 1));
}
}
@@ -120,11 +113,7 @@ public class ImmutableRangeMapTest extends TestCase {
}
public void testSpanEmpty() {
- try {
- ImmutableRangeMap.of().span();
- fail("Expected NoSuchElementException");
- } catch (NoSuchElementException expected) {
- }
+ assertThrows(NoSuchElementException.class, () -> ImmutableRangeMap.of().span());
}
public void testSpanSingleRange() {
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
index 4c2bf3f92..95ab09bbc 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
@@ -15,6 +15,7 @@
package com.google.common.collect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.testing.NavigableSetTestSuiteBuilder;
@@ -320,12 +321,7 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
.add(Range.closedOpen(1, 3))
.build();
- try {
- rangeSet.add(Range.open(3, 4));
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(UnsupportedOperationException.class, () -> rangeSet.add(Range.open(3, 4)));
}
@SuppressWarnings("DoNotCall")
@@ -336,12 +332,9 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
.add(Range.closedOpen(1, 3))
.build();
- try {
- rangeSet.addAll(ImmutableRangeSet.<Integer>of());
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> rangeSet.addAll(ImmutableRangeSet.<Integer>of()));
}
@SuppressWarnings("DoNotCall")
@@ -352,12 +345,7 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
.add(Range.closedOpen(1, 3))
.build();
- try {
- rangeSet.remove(Range.closed(6, 7));
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(UnsupportedOperationException.class, () -> rangeSet.remove(Range.closed(6, 7)));
}
@SuppressWarnings("DoNotCall")
@@ -368,19 +356,13 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
.add(Range.closedOpen(1, 3))
.build();
- try {
- rangeSet.removeAll(ImmutableRangeSet.<Integer>of());
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> rangeSet.removeAll(ImmutableRangeSet.<Integer>of()));
- try {
- rangeSet.removeAll(ImmutableRangeSet.of(Range.closed(6, 8)));
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> rangeSet.removeAll(ImmutableRangeSet.of(Range.closed(6, 8))));
}
@AndroidIncompatible // slow
@@ -428,11 +410,11 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
}
if (anyOverlaps) {
- try {
- RangeSet<Integer> copy = ImmutableRangeSet.copyOf(subset);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ RangeSet<Integer> copy = ImmutableRangeSet.copyOf(subset);
+ });
} else {
RangeSet<Integer> copy = ImmutableRangeSet.copyOf(subset);
assertEquals(mutable, copy);
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java
index 33d4ec1aa..0db23b6aa 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java
@@ -595,6 +595,7 @@ public class ImmutableSetMultimapTest extends TestCase {
}
@GwtIncompatible // reflection
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableSetMultimap.class);
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java
index 2ddd1ee6c..3c3139925 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableSetTest.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -279,11 +280,7 @@ public class ImmutableSetTest extends AbstractImmutableSetTest {
assertEquals(1 << 30, ImmutableSet.chooseTableSize((1 << 30) - 1));
// Now we've gone too far
- try {
- ImmutableSet.chooseTableSize(1 << 30);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> ImmutableSet.chooseTableSize(1 << 30));
}
@GwtIncompatible // RegularImmutableSet.table not in emulation
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java
index f3e7c1bd6..39b907a77 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java
@@ -659,6 +659,7 @@ public class ImmutableSortedMapTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableSortedMap.class);
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java
index cda23ddf2..9366f3c87 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java
@@ -17,6 +17,7 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.truth.Truth.assertThat;
import static java.util.Arrays.asList;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableSortedMultiset.Builder;
@@ -193,11 +194,7 @@ public class ImmutableSortedMultisetTest extends TestCase {
public void testCreation_arrayContainingOnlyNull() {
String[] array = new String[] {null};
- try {
- ImmutableSortedMultiset.copyOf(array);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ImmutableSortedMultiset.copyOf(array));
}
public void testCopyOf_collection_empty() {
@@ -221,11 +218,7 @@ public class ImmutableSortedMultisetTest extends TestCase {
public void testCopyOf_collectionContainingNull() {
Collection<String> c = MinimalCollection.of("a", null, "b");
- try {
- ImmutableSortedMultiset.copyOf(c);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ImmutableSortedMultiset.copyOf(c));
}
public void testCopyOf_multiset_empty() {
@@ -248,11 +241,7 @@ public class ImmutableSortedMultisetTest extends TestCase {
public void testCopyOf_multisetContainingNull() {
Multiset<String> c = HashMultiset.create(asList("a", null, "b"));
- try {
- ImmutableSortedMultiset.copyOf(c);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ImmutableSortedMultiset.copyOf(c));
}
public void testCopyOf_iterator_empty() {
@@ -275,11 +264,7 @@ public class ImmutableSortedMultisetTest extends TestCase {
public void testCopyOf_iteratorContainingNull() {
Iterator<String> iterator = asList("a", null, "b").iterator();
- try {
- ImmutableSortedMultiset.copyOf(iterator);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ImmutableSortedMultiset.copyOf(iterator));
}
private static class CountingIterable implements Iterable<String> {
@@ -403,75 +388,50 @@ public class ImmutableSortedMultisetTest extends TestCase {
public void testBuilderAddHandlesNullsCorrectly() {
ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
- try {
- builder.add((String) null);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> builder.add((String) null));
}
public void testBuilderAddAllHandlesNullsCorrectly() {
- ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
- try {
- builder.addAll((Collection<String>) null);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
+ {
+ ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
+ assertThrows(NullPointerException.class, () -> builder.addAll((Collection<String>) null));
}
- builder = ImmutableSortedMultiset.naturalOrder();
- List<String> listWithNulls = asList("a", null, "b");
- try {
- builder.addAll(listWithNulls);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
+ {
+ ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
+ List<String> listWithNulls = asList("a", null, "b");
+ assertThrows(NullPointerException.class, () -> builder.addAll(listWithNulls));
}
- builder = ImmutableSortedMultiset.naturalOrder();
- Multiset<String> multisetWithNull = LinkedHashMultiset.create(asList("a", null, "b"));
- try {
- builder.addAll(multisetWithNull);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
+ {
+ ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
+ Multiset<String> multisetWithNull = LinkedHashMultiset.create(asList("a", null, "b"));
+ assertThrows(NullPointerException.class, () -> builder.addAll(multisetWithNull));
}
}
public void testBuilderAddCopiesHandlesNullsCorrectly() {
ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
- try {
- builder.addCopies(null, 2);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> builder.addCopies(null, 2));
}
public void testBuilderAddCopiesIllegal() {
ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
- try {
- builder.addCopies("a", -2);
- fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.addCopies("a", -2));
}
public void testBuilderSetCountHandlesNullsCorrectly() {
ImmutableSortedMultiset.Builder<String> builder =
new ImmutableSortedMultiset.Builder<>(Ordering.natural().nullsFirst());
- try {
- builder.setCount(null, 2);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> builder.setCount(null, 2));
}
public void testBuilderSetCountIllegal() {
ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
- try {
- builder.setCount("a", -2);
- fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.setCount("a", -2));
}
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
new NullPointerTester().testAllPublicStaticMethods(ImmutableSortedMultiset.class);
}
diff --git a/android/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java b/android/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java
index 4043497b6..0bea3b69d 100644
--- a/android/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java
@@ -230,6 +230,7 @@ public class ImmutableSortedSetTest extends AbstractImmutableSetTest {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
new NullPointerTester().testAllPublicStaticMethods(ImmutableSortedSet.class);
}
diff --git a/android/guava-tests/test/com/google/common/collect/InternersTest.java b/android/guava-tests/test/com/google/common/collect/InternersTest.java
index cfa14b892..51cf835ea 100644
--- a/android/guava-tests/test/com/google/common/collect/InternersTest.java
+++ b/android/guava-tests/test/com/google/common/collect/InternersTest.java
@@ -16,6 +16,8 @@
package com.google.common.collect;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.base.Function;
import com.google.common.collect.Interners.InternerImpl;
import com.google.common.collect.MapMakerInternalMap.Strength;
@@ -42,11 +44,7 @@ public class InternersTest extends TestCase {
public void testStrong_null() {
Interner<String> pool = Interners.newStrongInterner();
- try {
- pool.intern(null);
- fail();
- } catch (NullPointerException ok) {
- }
+ assertThrows(NullPointerException.class, () -> pool.intern(null));
}
public void testStrong_builder() {
@@ -68,11 +66,7 @@ public class InternersTest extends TestCase {
public void testWeak_null() {
Interner<String> pool = Interners.newWeakInterner();
- try {
- pool.intern(null);
- fail();
- } catch (NullPointerException ok) {
- }
+ assertThrows(NullPointerException.class, () -> pool.intern(null));
}
public void testWeak_builder() {
@@ -116,19 +110,11 @@ public class InternersTest extends TestCase {
public void testConcurrencyLevel_Zero() {
Interners.InternerBuilder builder = Interners.newBuilder();
- try {
- builder.concurrencyLevel(0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.concurrencyLevel(0));
}
public void testConcurrencyLevel_Negative() {
Interners.InternerBuilder builder = Interners.newBuilder();
- try {
- builder.concurrencyLevel(-42);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.concurrencyLevel(-42));
}
}
diff --git a/android/guava-tests/test/com/google/common/collect/IterablesTest.java b/android/guava-tests/test/com/google/common/collect/IterablesTest.java
index 41772100b..168e85a23 100644
--- a/android/guava-tests/test/com/google/common/collect/IterablesTest.java
+++ b/android/guava-tests/test/com/google/common/collect/IterablesTest.java
@@ -1396,6 +1396,7 @@ public class IterablesTest extends TestCase {
}
@GwtIncompatible // reflection
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testIterables_nullCheck() throws Exception {
new ClassSanityTester()
.forAllPublicStaticMethods(Iterables.class)
diff --git a/android/guava-tests/test/com/google/common/collect/IteratorsTest.java b/android/guava-tests/test/com/google/common/collect/IteratorsTest.java
index e71c8bd51..96ae2417e 100644
--- a/android/guava-tests/test/com/google/common/collect/IteratorsTest.java
+++ b/android/guava-tests/test/com/google/common/collect/IteratorsTest.java
@@ -1119,6 +1119,11 @@ public class IteratorsTest extends TestCase {
fail();
} catch (NoSuchElementException expected) {
}
+ try {
+ Iterators.forArrayWithPosition(array, 1);
+ fail();
+ } catch (IndexOutOfBoundsException expected) {
+ }
}
@SuppressWarnings("DoNotCall")
@@ -1142,33 +1147,26 @@ public class IteratorsTest extends TestCase {
}
}
- public void testForArrayOffset() {
- String[] array = {"foo", "bar", "cat", "dog"};
- Iterator<String> iterator = Iterators.forArray(array, 1, 2, 0);
+ public void testForArrayWithPosition() {
+ String[] array = {"foo", "bar", "cat"};
+ Iterator<String> iterator = Iterators.forArrayWithPosition(array, 1);
assertTrue(iterator.hasNext());
assertEquals("bar", iterator.next());
assertTrue(iterator.hasNext());
assertEquals("cat", iterator.next());
assertFalse(iterator.hasNext());
- try {
- Iterators.forArray(array, 2, 3, 0);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
}
- public void testForArrayLength0() {
+ public void testForArrayLengthWithPositionBoundaryCases() {
String[] array = {"foo", "bar"};
- assertFalse(Iterators.forArray(array, 0, 0, 0).hasNext());
- assertFalse(Iterators.forArray(array, 1, 0, 0).hasNext());
- assertFalse(Iterators.forArray(array, 2, 0, 0).hasNext());
+ assertFalse(Iterators.forArrayWithPosition(array, 2).hasNext());
try {
- Iterators.forArray(array, -1, 0, 0);
+ Iterators.forArrayWithPosition(array, -1);
fail();
} catch (IndexOutOfBoundsException expected) {
}
try {
- Iterators.forArray(array, 3, 0, 0);
+ Iterators.forArrayWithPosition(array, 3);
fail();
} catch (IndexOutOfBoundsException expected) {
}
@@ -1185,16 +1183,10 @@ public class IteratorsTest extends TestCase {
}.test();
}
- @GwtIncompatible // unreasonably slow
- public void testForArrayWithOffsetUsingTester() {
- new IteratorTester<Integer>(
- 6, UNMODIFIABLE, asList(1, 2, 3), IteratorTester.KnownOrder.KNOWN_ORDER) {
- @Override
- protected Iterator<Integer> newTargetIterator() {
- return Iterators.forArray(new Integer[] {0, 1, 2, 3, 4}, 1, 3, 0);
- }
- }.test();
- }
+ /*
+ * TODO(cpovirk): Test forArray with ListIteratorTester (not just IteratorTester), including with
+ * a start position other than 0.
+ */
public void testForEnumerationEmpty() {
Enumeration<Integer> enumer = enumerate();
diff --git a/android/guava-tests/test/com/google/common/collect/ListsImplTest.java b/android/guava-tests/test/com/google/common/collect/ListsImplTest.java
index 8ef599c99..6ed0b66b3 100644
--- a/android/guava-tests/test/com/google/common/collect/ListsImplTest.java
+++ b/android/guava-tests/test/com/google/common/collect/ListsImplTest.java
@@ -99,11 +99,13 @@ public class ListsImplTest extends TestCase {
return example == null ? new ImmutableListExample("test") : example;
}
+ @GwtIncompatible // not used under GWT, and super.getName() is not available under J2CL
@Override
public String getName() {
return example == null ? super.getName() : buildTestName();
}
+ @GwtIncompatible // not used under GWT, and super.getName() is not available under J2CL
private String buildTestName() {
return super.getName() + ":" + example.getName();
}
diff --git a/android/guava-tests/test/com/google/common/collect/MapsSortedTransformValuesTest.java b/android/guava-tests/test/com/google/common/collect/MapsSortedTransformValuesTest.java
index 98bbde501..6bf066f51 100644
--- a/android/guava-tests/test/com/google/common/collect/MapsSortedTransformValuesTest.java
+++ b/android/guava-tests/test/com/google/common/collect/MapsSortedTransformValuesTest.java
@@ -27,8 +27,7 @@ import java.util.SortedMap;
* @author Louis Wasserman
*/
@GwtCompatible
-public class MapsSortedTransformValuesTest extends MapsTransformValuesTest {
-
+public class MapsSortedTransformValuesTest extends AbstractMapsTransformValuesTest {
@Override
protected SortedMap<String, String> makeEmptyMap() {
return Maps.transformValues(Maps.<String, String>newTreeMap(), Functions.<String>identity());
diff --git a/android/guava-tests/test/com/google/common/collect/MapsTest.java b/android/guava-tests/test/com/google/common/collect/MapsTest.java
index 1672efa19..1294a285d 100644
--- a/android/guava-tests/test/com/google/common/collect/MapsTest.java
+++ b/android/guava-tests/test/com/google/common/collect/MapsTest.java
@@ -30,10 +30,8 @@ import com.google.common.base.Converter;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
import com.google.common.base.Functions;
-import com.google.common.base.Predicate;
import com.google.common.collect.Maps.EntryTransformer;
import com.google.common.collect.Maps.ValueDifferenceImpl;
-import com.google.common.collect.SetsTest.Derived;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
import com.google.common.testing.SerializableTester;
@@ -62,7 +60,6 @@ import java.util.SortedSet;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentMap;
import junit.framework.TestCase;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Unit test for {@code Maps}.
@@ -385,6 +382,7 @@ public class MapsTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointerExceptions() {
new NullPointerTester().testAllPublicStaticMethods(Maps.class);
}
@@ -1326,37 +1324,7 @@ public class MapsTest extends TestCase {
assertEquals(ImmutableSet.of(1, 2, 3), sync.inverse().keySet());
}
- static final Predicate<@Nullable String> NOT_LENGTH_3 =
- new Predicate<@Nullable String>() {
- @Override
- public boolean apply(@Nullable String input) {
- return input == null || input.length() != 3;
- }
- };
-
- static final Predicate<@Nullable Integer> EVEN =
- new Predicate<@Nullable Integer>() {
- @Override
- public boolean apply(@Nullable Integer input) {
- return input == null || input % 2 == 0;
- }
- };
-
- static final Predicate<Entry<String, Integer>> CORRECT_LENGTH =
- new Predicate<Entry<String, Integer>>() {
- @Override
- public boolean apply(Entry<String, Integer> input) {
- return input.getKey().length() == input.getValue();
- }
- };
-
- static final Function<Integer, Double> SQRT_FUNCTION =
- new Function<Integer, Double>() {
- @Override
- public Double apply(Integer in) {
- return Math.sqrt(in);
- }
- };
+ private static final Function<Integer, Double> SQRT_FUNCTION = in -> Math.sqrt(in);
public void testTransformValues() {
Map<String, Integer> map = ImmutableMap.of("a", 4, "b", 9);
diff --git a/android/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java b/android/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java
index a88ff9cd1..6c6bca3dd 100644
--- a/android/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java
+++ b/android/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java
@@ -19,45 +19,16 @@ package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
import com.google.common.base.Functions;
-import com.google.common.collect.testing.MapInterfaceTest;
-import java.util.Collection;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
- * Tests for {@link Maps#transformValues}.
+ * Tests for {@link Maps#transformValues(Map, Function)}.
*
* @author Isaac Shum
*/
@GwtCompatible
-public class MapsTransformValuesTest extends MapInterfaceTest<String, String> {
-
- /**
- * Constructor that assigns {@code supportsIteratorRemove} the same value as {@code
- * supportsRemove}.
- */
- protected MapsTransformValuesTest(
- boolean allowsNullKeys,
- boolean allowsNullValues,
- boolean supportsPut,
- boolean supportsRemove,
- boolean supportsClear) {
- super(
- allowsNullKeys,
- allowsNullValues,
- supportsPut,
- supportsRemove,
- supportsClear,
- supportsRemove);
- }
-
- public MapsTransformValuesTest() {
- super(false, true, false, true, true);
- }
-
+public class MapsTransformValuesTest extends AbstractMapsTransformValuesTest {
+ @Override
protected Map<String, String> makeEmptyMap() {
return Maps.transformValues(Maps.<String, String>newHashMap(), Functions.<String>identity());
}
@@ -70,239 +41,4 @@ public class MapsTransformValuesTest extends MapInterfaceTest<String, String> {
underlying.put("c", 3);
return Maps.transformValues(underlying, Functions.toStringFunction());
}
-
- @Override
- protected String getKeyNotInPopulatedMap() throws UnsupportedOperationException {
- return "z";
- }
-
- @Override
- protected String getValueNotInPopulatedMap() throws UnsupportedOperationException {
- return "26";
- }
-
- /** Helper assertion comparing two maps */
- private void assertMapsEqual(Map<?, ?> expected, Map<?, ?> map) {
- assertEquals(expected, map);
- assertEquals(expected.hashCode(), map.hashCode());
- assertEquals(expected.entrySet(), map.entrySet());
-
- // Assert that expectedValues > mapValues and that
- // mapValues > expectedValues; i.e. that expectedValues == mapValues.
- Collection<?> expectedValues = expected.values();
- Collection<?> mapValues = map.values();
- assertEquals(expectedValues.size(), mapValues.size());
- assertTrue(expectedValues.containsAll(mapValues));
- assertTrue(mapValues.containsAll(expectedValues));
- }
-
- public void testTransformEmptyMapEquality() {
- Map<String, String> map =
- Maps.transformValues(ImmutableMap.<String, Integer>of(), Functions.toStringFunction());
- assertMapsEqual(Maps.newHashMap(), map);
- }
-
- public void testTransformSingletonMapEquality() {
- Map<String, String> map =
- Maps.transformValues(ImmutableMap.of("a", 1), Functions.toStringFunction());
- Map<String, String> expected = ImmutableMap.of("a", "1");
- assertMapsEqual(expected, map);
- assertEquals(expected.get("a"), map.get("a"));
- }
-
- public void testTransformIdentityFunctionEquality() {
- Map<String, Integer> underlying = ImmutableMap.of("a", 1);
- Map<String, Integer> map = Maps.transformValues(underlying, Functions.<Integer>identity());
- assertMapsEqual(underlying, map);
- }
-
- public void testTransformPutEntryIsUnsupported() {
- Map<String, String> map =
- Maps.transformValues(ImmutableMap.of("a", 1), Functions.toStringFunction());
- try {
- map.put("b", "2");
- fail();
- } catch (UnsupportedOperationException expected) {
- }
-
- try {
- map.putAll(ImmutableMap.of("b", "2"));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
-
- try {
- map.entrySet().iterator().next().setValue("one");
- fail();
- } catch (UnsupportedOperationException expected) {
- }
- }
-
- public void testTransformRemoveEntry() {
- Map<String, Integer> underlying = Maps.newHashMap();
- underlying.put("a", 1);
- Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction());
- assertEquals("1", map.remove("a"));
- assertNull(map.remove("b"));
- }
-
- public void testTransformEqualityOfMapsWithNullValues() {
- Map<String, String> underlying = Maps.newHashMap();
- underlying.put("a", null);
- underlying.put("b", "");
-
- Map<String, Boolean> map =
- Maps.transformValues(
- underlying,
- new Function<String, Boolean>() {
- @Override
- public Boolean apply(@Nullable String from) {
- return from == null;
- }
- });
- Map<String, Boolean> expected = ImmutableMap.of("a", true, "b", false);
- assertMapsEqual(expected, map);
- assertEquals(expected.get("a"), map.get("a"));
- assertEquals(expected.containsKey("a"), map.containsKey("a"));
- assertEquals(expected.get("b"), map.get("b"));
- assertEquals(expected.containsKey("b"), map.containsKey("b"));
- assertEquals(expected.get("c"), map.get("c"));
- assertEquals(expected.containsKey("c"), map.containsKey("c"));
- }
-
- public void testTransformReflectsUnderlyingMap() {
- Map<String, Integer> underlying = Maps.newHashMap();
- underlying.put("a", 1);
- underlying.put("b", 2);
- underlying.put("c", 3);
- Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction());
- assertEquals(underlying.size(), map.size());
-
- underlying.put("d", 4);
- assertEquals(underlying.size(), map.size());
- assertEquals("4", map.get("d"));
-
- underlying.remove("c");
- assertEquals(underlying.size(), map.size());
- assertFalse(map.containsKey("c"));
-
- underlying.clear();
- assertEquals(underlying.size(), map.size());
- }
-
- public void testTransformChangesAreReflectedInUnderlyingMap() {
- Map<String, Integer> underlying = Maps.newLinkedHashMap();
- underlying.put("a", 1);
- underlying.put("b", 2);
- underlying.put("c", 3);
- underlying.put("d", 4);
- underlying.put("e", 5);
- underlying.put("f", 6);
- underlying.put("g", 7);
- Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction());
-
- map.remove("a");
- assertFalse(underlying.containsKey("a"));
-
- Set<String> keys = map.keySet();
- keys.remove("b");
- assertFalse(underlying.containsKey("b"));
-
- Iterator<String> keyIterator = keys.iterator();
- keyIterator.next();
- keyIterator.remove();
- assertFalse(underlying.containsKey("c"));
-
- Collection<String> values = map.values();
- values.remove("4");
- assertFalse(underlying.containsKey("d"));
-
- Iterator<String> valueIterator = values.iterator();
- valueIterator.next();
- valueIterator.remove();
- assertFalse(underlying.containsKey("e"));
-
- Set<Entry<String, String>> entries = map.entrySet();
- Entry<String, String> firstEntry = entries.iterator().next();
- entries.remove(firstEntry);
- assertFalse(underlying.containsKey("f"));
-
- Iterator<Entry<String, String>> entryIterator = entries.iterator();
- entryIterator.next();
- entryIterator.remove();
- assertFalse(underlying.containsKey("g"));
-
- assertTrue(underlying.isEmpty());
- assertTrue(map.isEmpty());
- assertTrue(keys.isEmpty());
- assertTrue(values.isEmpty());
- assertTrue(entries.isEmpty());
- }
-
- public void testTransformEquals() {
- Map<String, Integer> underlying = ImmutableMap.of("a", 0, "b", 1, "c", 2);
- Map<String, Integer> expected = Maps.transformValues(underlying, Functions.<Integer>identity());
-
- assertMapsEqual(expected, expected);
-
- Map<String, Integer> equalToUnderlying = Maps.newTreeMap();
- equalToUnderlying.putAll(underlying);
- Map<String, Integer> map =
- Maps.transformValues(equalToUnderlying, Functions.<Integer>identity());
- assertMapsEqual(expected, map);
-
- map =
- Maps.transformValues(
- ImmutableMap.of("a", 1, "b", 2, "c", 3),
- new Function<Integer, Integer>() {
- @Override
- public Integer apply(Integer from) {
- return from - 1;
- }
- });
- assertMapsEqual(expected, map);
- }
-
- public void testTransformEntrySetContains() {
- Map<@Nullable String, @Nullable Boolean> underlying = Maps.newHashMap();
- underlying.put("a", null);
- underlying.put("b", true);
- underlying.put(null, true);
-
- Map<@Nullable String, @Nullable Boolean> map =
- Maps.transformValues(
- underlying,
- new Function<@Nullable Boolean, @Nullable Boolean>() {
- @Override
- public @Nullable Boolean apply(@Nullable Boolean from) {
- return (from == null) ? true : null;
- }
- });
-
- Set<Entry<@Nullable String, @Nullable Boolean>> entries = map.entrySet();
- assertTrue(entries.contains(Maps.immutableEntry("a", true)));
- assertTrue(entries.contains(Maps.immutableEntry("b", (Boolean) null)));
- assertTrue(entries.contains(Maps.immutableEntry((String) null, (Boolean) null)));
-
- assertFalse(entries.contains(Maps.immutableEntry("c", (Boolean) null)));
- assertFalse(entries.contains(Maps.immutableEntry((String) null, true)));
- }
-
- @Override
- public void testKeySetRemoveAllNullFromEmpty() {
- try {
- super.testKeySetRemoveAllNullFromEmpty();
- } catch (RuntimeException tolerated) {
- // GWT's HashMap.keySet().removeAll(null) doesn't throws NPE.
- }
- }
-
- @Override
- public void testEntrySetRemoveAllNullFromEmpty() {
- try {
- super.testEntrySetRemoveAllNullFromEmpty();
- } catch (RuntimeException tolerated) {
- // GWT's HashMap.entrySet().removeAll(null) doesn't throws NPE.
- }
- }
}
diff --git a/android/guava-tests/test/com/google/common/collect/MultimapsTest.java b/android/guava-tests/test/com/google/common/collect/MultimapsTest.java
index 1894c2613..33c29db18 100644
--- a/android/guava-tests/test/com/google/common/collect/MultimapsTest.java
+++ b/android/guava-tests/test/com/google/common/collect/MultimapsTest.java
@@ -1000,6 +1000,7 @@ public class MultimapsTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
new NullPointerTester().testAllPublicStaticMethods(Multimaps.class);
}
diff --git a/android/guava-tests/test/com/google/common/collect/MultisetsTest.java b/android/guava-tests/test/com/google/common/collect/MultisetsTest.java
index 32e4408f9..3348300bf 100644
--- a/android/guava-tests/test/com/google/common/collect/MultisetsTest.java
+++ b/android/guava-tests/test/com/google/common/collect/MultisetsTest.java
@@ -273,6 +273,7 @@ public class MultisetsTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
new NullPointerTester().testAllPublicStaticMethods(Multisets.class);
}
diff --git a/android/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java b/android/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java
index 156b62d98..8384f03f9 100644
--- a/android/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java
@@ -16,6 +16,8 @@
package com.google.common.collect;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.collect.ImmutableClassToInstanceMapTest.Impl;
import com.google.common.collect.ImmutableClassToInstanceMapTest.TestClassToInstanceMapGenerator;
import com.google.common.collect.testing.MapTestSuiteBuilder;
@@ -83,11 +85,7 @@ public class MutableClassToInstanceMapTest extends TestCase {
* well-tested. A purist would object to this, but what can I say, we're dirty cheaters.
*/
map.put(Integer.class, new Integer(5));
- try {
- map.put(Double.class, new Long(42));
- fail();
- } catch (ClassCastException expected) {
- }
+ assertThrows(ClassCastException.class, () -> map.put(Double.class, new Long(42)));
// Won't compile: map.put(String.class, "x");
}
@@ -104,11 +102,7 @@ public class MutableClassToInstanceMapTest extends TestCase {
}
public void testNull() {
- try {
- map.put(null, new Integer(1));
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> map.put(null, new Integer(1)));
map.putInstance(Integer.class, null);
assertNull(map.get(Integer.class));
assertNull(map.getInstance(Integer.class));
diff --git a/android/guava-tests/test/com/google/common/collect/OrderingTest.java b/android/guava-tests/test/com/google/common/collect/OrderingTest.java
index a98379986..8a8854097 100644
--- a/android/guava-tests/test/com/google/common/collect/OrderingTest.java
+++ b/android/guava-tests/test/com/google/common/collect/OrderingTest.java
@@ -161,6 +161,19 @@ public class OrderingTest extends TestCase {
assertEquals("Ordering.explicit([0])", c.toString());
}
+ public void testExplicitMax_b297601553() {
+ Ordering<Integer> c = Ordering.explicit(1, 2, 3);
+
+ // TODO(b/297601553): this should probably throw an CCE since 0 isn't explicitly listed
+ assertEquals(0, (int) c.max(asList(0)));
+ try {
+ c.max(asList(0, 1));
+ fail();
+ } catch (IncomparableValueException expected) {
+ assertEquals(0, expected.value);
+ }
+ }
+
public void testExplicit_two() {
Comparator<Integer> c = Ordering.explicit(42, 5);
assertEquals(0, c.compare(5, 5));
diff --git a/android/guava-tests/test/com/google/common/collect/QueuesTest.java b/android/guava-tests/test/com/google/common/collect/QueuesTest.java
index e2c3485f9..e0878d7ed 100644
--- a/android/guava-tests/test/com/google/common/collect/QueuesTest.java
+++ b/android/guava-tests/test/com/google/common/collect/QueuesTest.java
@@ -24,6 +24,7 @@ import static java.util.concurrent.Executors.newCachedThreadPool;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Stopwatch;
import java.util.Collection;
@@ -239,23 +240,13 @@ public class QueuesTest extends TestCase {
}
public void testNewLinkedBlockingDequeCapacity() {
- try {
- Queues.newLinkedBlockingDeque(0);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- // any capacity less than 1 should throw IllegalArgumentException
- }
+ assertThrows(IllegalArgumentException.class, () -> Queues.newLinkedBlockingDeque(0));
assertEquals(1, Queues.newLinkedBlockingDeque(1).remainingCapacity());
assertEquals(11, Queues.newLinkedBlockingDeque(11).remainingCapacity());
}
public void testNewLinkedBlockingQueueCapacity() {
- try {
- Queues.newLinkedBlockingQueue(0);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- // any capacity less than 1 should throw IllegalArgumentException
- }
+ assertThrows(IllegalArgumentException.class, () -> Queues.newLinkedBlockingQueue(0));
assertEquals(1, Queues.newLinkedBlockingQueue(1).remainingCapacity());
assertEquals(11, Queues.newLinkedBlockingQueue(11).remainingCapacity());
}
diff --git a/android/guava-tests/test/com/google/common/collect/RangeTest.java b/android/guava-tests/test/com/google/common/collect/RangeTest.java
index e8578bfd1..16764a699 100644
--- a/android/guava-tests/test/com/google/common/collect/RangeTest.java
+++ b/android/guava-tests/test/com/google/common/collect/RangeTest.java
@@ -614,7 +614,7 @@ public class RangeTest extends TestCase {
Range<LegacyComparable> range = Range.closed(LegacyComparable.X, LegacyComparable.Y);
}
- static final DiscreteDomain<Integer> UNBOUNDED_DOMAIN =
+ private static final DiscreteDomain<Integer> UNBOUNDED_DOMAIN =
new DiscreteDomain<Integer>() {
@Override
public Integer next(Integer value) {
diff --git a/android/guava-tests/test/com/google/common/collect/SetsTest.java b/android/guava-tests/test/com/google/common/collect/SetsTest.java
index 82c40b09f..c271abe79 100644
--- a/android/guava-tests/test/com/google/common/collect/SetsTest.java
+++ b/android/guava-tests/test/com/google/common/collect/SetsTest.java
@@ -52,7 +52,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.Serializable;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
@@ -638,6 +637,7 @@ public class SetsTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointerExceptions() {
new NullPointerTester()
.setDefault(Enum.class, SomeEnum.A)
@@ -752,6 +752,21 @@ public class SetsTest extends TestCase {
assertFalse(actual.contains(list(3, 1)));
}
+ public void testCartesianProduct_equals() {
+ Set<List<Integer>> cartesian = Sets.cartesianProduct(set(1, 2), set(3, 4));
+ ImmutableSet<List<Integer>> equivalent =
+ ImmutableSet.of(ImmutableList.of(1, 3), ImmutableList.of(1, 4), list(2, 3), list(2, 4));
+ ImmutableSet<List<Integer>> different1 =
+ ImmutableSet.of(ImmutableList.of(0, 3), ImmutableList.of(1, 4), list(2, 3), list(2, 4));
+ ImmutableSet<List<Integer>> different2 =
+ ImmutableSet.of(ImmutableList.of(1, 3), ImmutableList.of(1, 4), list(2, 3));
+ new EqualsTester()
+ .addEqualityGroup(cartesian, equivalent)
+ .addEqualityGroup(different1)
+ .addEqualityGroup(different2)
+ .testEquals();
+ }
+
@SuppressWarnings("unchecked") // varargs!
public void testCartesianProduct_unrelatedTypes() {
Set<Integer> x = set(1, 2);
@@ -1107,47 +1122,6 @@ public class SetsTest extends TestCase {
assertEquals(expected, set);
}
- /** Simple base class to verify that we handle generics correctly. */
- static class Base implements Comparable<Base>, Serializable {
- private final String s;
-
- public Base(String s) {
- this.s = s;
- }
-
- @Override
- public int hashCode() { // delegate to 's'
- return s.hashCode();
- }
-
- @Override
- public boolean equals(@Nullable Object other) {
- if (other == null) {
- return false;
- } else if (other instanceof Base) {
- return s.equals(((Base) other).s);
- } else {
- return false;
- }
- }
-
- @Override
- public int compareTo(Base o) {
- return s.compareTo(o.s);
- }
-
- private static final long serialVersionUID = 0;
- }
-
- /** Simple derived class to verify that we handle generics correctly. */
- static class Derived extends Base {
- public Derived(String s) {
- super(s);
- }
-
- private static final long serialVersionUID = 0;
- }
-
@GwtIncompatible // NavigableSet
public void testUnmodifiableNavigableSet() {
TreeSet<Integer> mod = Sets.newTreeSet();
diff --git a/android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java b/android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
index db68b89ec..0c452b13a 100644
--- a/android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
+++ b/android/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
@@ -16,6 +16,7 @@ package com.google.common.collect;
import static com.google.common.collect.BoundType.OPEN;
import static com.google.common.collect.testing.Helpers.mapEntry;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.testing.MapTestSuiteBuilder;
@@ -617,14 +618,10 @@ public class TreeRangeMapTest extends TestCase {
3),
rangeMap.asMapOfRanges());
- try {
- sub.put(Range.open(9, 12), 5);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> sub.put(Range.open(9, 12), 5));
- sub = sub.subRangeMap(Range.closedOpen(5, 5));
- sub.put(Range.closedOpen(5, 5), 6); // should be a no-op
+ RangeMap<Integer, Integer> subSub = sub.subRangeMap(Range.closedOpen(5, 5));
+ subSub.put(Range.closedOpen(5, 5), 6); // should be a no-op
assertEquals(
ImmutableMap.of(
Range.open(3, 7),
@@ -668,11 +665,7 @@ public class TreeRangeMapTest extends TestCase {
3),
rangeMap.asMapOfRanges());
- try {
- sub.putCoalescing(Range.open(9, 12), 5);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> sub.putCoalescing(Range.open(9, 12), 5));
}
public void testSubRangeMapRemove() {
diff --git a/android/guava-tests/test/com/google/common/collect/WriteReplaceOverridesTest.java b/android/guava-tests/test/com/google/common/collect/WriteReplaceOverridesTest.java
new file mode 100644
index 000000000..bf10f5f75
--- /dev/null
+++ b/android/guava-tests/test/com/google/common/collect/WriteReplaceOverridesTest.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2023 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.collect;
+
+import static com.google.common.truth.Truth.assertWithMessage;
+import static java.lang.reflect.Modifier.PRIVATE;
+import static java.lang.reflect.Modifier.PROTECTED;
+import static java.lang.reflect.Modifier.PUBLIC;
+import static java.util.Arrays.asList;
+
+import com.google.common.base.Optional;
+import com.google.common.reflect.ClassPath;
+import com.google.common.reflect.ClassPath.ClassInfo;
+import com.google.common.reflect.TypeToken;
+import java.lang.reflect.Method;
+import junit.framework.TestCase;
+
+/**
+ * Tests that all package-private {@code writeReplace} methods are overridden in any existing
+ * subclasses. Without such overrides, optimizers might put a {@code writeReplace}-containing class
+ * and its subclass in different packages, causing the serialization system to fail to invoke {@code
+ * writeReplace} when serializing an instance of the subclass. For an example of this problem, see
+ * b/310253115.
+ */
+public class WriteReplaceOverridesTest extends TestCase {
+ private static final ImmutableSet<String> GUAVA_PACKAGES =
+ FluentIterable.of(
+ "base",
+ "cache",
+ "collect",
+ "escape",
+ "eventbus",
+ "graph",
+ "hash",
+ "html",
+ "io",
+ "math",
+ "net",
+ "primitives",
+ "reflect",
+ "util.concurrent",
+ "xml")
+ .transform("com.google.common."::concat)
+ .toSet();
+
+ public void testClassesHaveOverrides() throws Exception {
+ for (ClassInfo info : ClassPath.from(getClass().getClassLoader()).getAllClasses()) {
+ if (!GUAVA_PACKAGES.contains(info.getPackageName())) {
+ continue;
+ }
+ if (info.getName().endsWith("GwtSerializationDependencies")) {
+ continue; // These classes exist only for the GWT compiler, not to be used.
+ }
+ if (
+ /*
+ * At least one of the classes nested inside TypeResolverTest triggers a bug under older JDKs:
+ * https://bugs.openjdk.org/browse/JDK-8215328 -> https://bugs.openjdk.org/browse/JDK-8215470
+ * https://github.com/google/guava/blob/4f12c5891a7adedbaa1d99fc9f77d8cc4e9da206/guava-tests/test/com/google/common/reflect/TypeResolverTest.java#L201
+ */
+ info.getName().contains("TypeResolverTest")
+ /*
+ * And at least one of the classes inside TypeTokenTest ends up with a null value in
+ * TypeMappingIntrospector.mappings. That happens only under older JDKs, too, so it may
+ * well be a JDK bug.
+ */
+ || info.getName().contains("TypeTokenTest")
+ /*
+ * Luckily, we don't care about analyzing tests at all. We'd skip them all if we could do so
+ * trivially, but it's enough to skip these ones.
+ */
+ ) {
+ continue;
+ }
+ Class<?> clazz = info.load();
+ try {
+ Method unused = clazz.getDeclaredMethod("writeReplace");
+ continue; // It overrides writeReplace, so it's safe.
+ } catch (NoSuchMethodException e) {
+ // This is a class whose supertypes we want to examine. We'll do that below.
+ }
+ Optional<Class<?>> supersWithPackagePrivateWriteReplace =
+ FluentIterable.from(TypeToken.of(clazz).getTypes())
+ .transform(TypeToken::getRawType)
+ .transformAndConcat(c -> asList(c.getDeclaredMethods()))
+ .firstMatch(
+ m ->
+ m.getName().equals("writeReplace")
+ && m.getParameterTypes().length == 0
+ // Only package-private methods are a problem.
+ && (m.getModifiers() & (PUBLIC | PROTECTED | PRIVATE)) == 0)
+ .transform(Method::getDeclaringClass);
+ if (!supersWithPackagePrivateWriteReplace.isPresent()) {
+ continue;
+ }
+ assertWithMessage(
+ "To help optimizers, any class that inherits a package-private writeReplace() method"
+ + " should override that method.\n"
+ + "(An override that delegates to the supermethod is fine.)\n"
+ + "%s has no such override despite inheriting writeReplace() from %s",
+ clazz.getName(), supersWithPackagePrivateWriteReplace.get().getName())
+ .fail();
+ }
+ }
+}
diff --git a/android/guava-tests/test/com/google/common/eventbus/EventBusTest.java b/android/guava-tests/test/com/google/common/eventbus/EventBusTest.java
index d314f7ee7..8161c271b 100644
--- a/android/guava-tests/test/com/google/common/eventbus/EventBusTest.java
+++ b/android/guava-tests/test/com/google/common/eventbus/EventBusTest.java
@@ -16,6 +16,8 @@
package com.google.common.eventbus;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.util.List;
@@ -194,12 +196,7 @@ public class EventBusTest extends TestCase {
public void testUnregister() {
StringCatcher catcher1 = new StringCatcher();
StringCatcher catcher2 = new StringCatcher();
- try {
- bus.unregister(catcher1);
- fail("Attempting to unregister an unregistered object succeeded");
- } catch (IllegalArgumentException expected) {
- // OK.
- }
+ assertThrows(IllegalArgumentException.class, () -> bus.unregister(catcher1));
bus.register(catcher1);
bus.post(EVENT);
@@ -222,12 +219,7 @@ public class EventBusTest extends TestCase {
"Shouldn't catch any more events when unregistered.", expectedEvents, catcher1.getEvents());
assertEquals("Two correct events should be delivered.", expectedEvents, catcher2.getEvents());
- try {
- bus.unregister(catcher1);
- fail("Attempting to unregister an unregistered object succeeded");
- } catch (IllegalArgumentException expected) {
- // OK.
- }
+ assertThrows(IllegalArgumentException.class, () -> bus.unregister(catcher1));
bus.unregister(catcher2);
bus.post(EVENT);
@@ -293,11 +285,7 @@ public class EventBusTest extends TestCase {
@Subscribe
public void toInt(int i) {}
}
- try {
- bus.register(new SubscribesToPrimitive());
- fail("should have thrown");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> bus.register(new SubscribesToPrimitive()));
}
/** Records thrown exception information. */
diff --git a/android/guava-tests/test/com/google/common/eventbus/SubscriberRegistryTest.java b/android/guava-tests/test/com/google/common/eventbus/SubscriberRegistryTest.java
index c9e5c9a5b..901bb2b51 100644
--- a/android/guava-tests/test/com/google/common/eventbus/SubscriberRegistryTest.java
+++ b/android/guava-tests/test/com/google/common/eventbus/SubscriberRegistryTest.java
@@ -16,6 +16,8 @@
package com.google.common.eventbus;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterators;
import java.util.Iterator;
@@ -59,28 +61,15 @@ public class SubscriberRegistryTest extends TestCase {
}
public void testUnregister_notRegistered() {
- try {
- registry.unregister(new StringSubscriber());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> registry.unregister(new StringSubscriber()));
StringSubscriber s1 = new StringSubscriber();
registry.register(s1);
- try {
- registry.unregister(new StringSubscriber());
- fail();
- } catch (IllegalArgumentException expected) {
- // a StringSubscriber was registered, but not the same one we tried to unregister
- }
+ assertThrows(IllegalArgumentException.class, () -> registry.unregister(new StringSubscriber()));
registry.unregister(s1);
- try {
- registry.unregister(s1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> registry.unregister(s1));
}
public void testGetSubscribers() {
diff --git a/android/guava-tests/test/com/google/common/eventbus/SubscriberTest.java b/android/guava-tests/test/com/google/common/eventbus/SubscriberTest.java
index 14210ac14..6e02627fe 100644
--- a/android/guava-tests/test/com/google/common/eventbus/SubscriberTest.java
+++ b/android/guava-tests/test/com/google/common/eventbus/SubscriberTest.java
@@ -17,6 +17,7 @@
package com.google.common.eventbus;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.testing.EqualsTester;
import java.lang.reflect.InvocationTargetException;
@@ -70,23 +71,18 @@ public class SubscriberTest extends TestCase {
Method method = getTestSubscriberMethod("exceptionThrowingMethod");
Subscriber subscriber = Subscriber.create(bus, this, method);
- try {
- subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT);
- fail("Subscribers whose methods throw must throw InvocationTargetException");
- } catch (InvocationTargetException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(IntentionalException.class);
- }
+ InvocationTargetException expected =
+ assertThrows(
+ InvocationTargetException.class,
+ () -> subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT));
+ assertThat(expected).hasCauseThat().isInstanceOf(IntentionalException.class);
}
public void testInvokeSubscriberMethod_errorPassthrough() throws Throwable {
Method method = getTestSubscriberMethod("errorThrowingMethod");
Subscriber subscriber = Subscriber.create(bus, this, method);
- try {
- subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT);
- fail("Subscribers whose methods throw Errors must rethrow them");
- } catch (JudgmentError expected) {
- }
+ assertThrows(JudgmentError.class, () -> subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT));
}
public void testEquals() throws Exception {
diff --git a/android/guava-tests/test/com/google/common/graph/AbstractGraphTest.java b/android/guava-tests/test/com/google/common/graph/AbstractGraphTest.java
index 3a489a11c..a8209244c 100644
--- a/android/guava-tests/test/com/google/common/graph/AbstractGraphTest.java
+++ b/android/guava-tests/test/com/google/common/graph/AbstractGraphTest.java
@@ -16,13 +16,12 @@
package com.google.common.graph;
-import static com.google.common.graph.TestUtil.ERROR_NODE_NOT_IN_GRAPH;
import static com.google.common.graph.TestUtil.assertNodeNotInGraphErrorMessage;
import static com.google.common.graph.TestUtil.assertStronglyEquivalent;
import static com.google.common.graph.TestUtil.sanityCheckSet;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableSet;
import java.util.HashSet;
@@ -235,12 +234,9 @@ public abstract class AbstractGraphTest {
@Test
public void adjacentNodes_nodeNotInGraph() {
- try {
- graph.adjacentNodes(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.adjacentNodes(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -251,12 +247,9 @@ public abstract class AbstractGraphTest {
@Test
public void predecessors_nodeNotInGraph() {
- try {
- graph.predecessors(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.predecessors(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -267,12 +260,9 @@ public abstract class AbstractGraphTest {
@Test
public void successors_nodeNotInGraph() {
- try {
- graph.successors(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.successors(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -283,12 +273,9 @@ public abstract class AbstractGraphTest {
@Test
public void incidentEdges_nodeNotInGraph() {
- try {
- graph.incidentEdges(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.incidentEdges(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -306,12 +293,9 @@ public abstract class AbstractGraphTest {
@Test
public void degree_nodeNotInGraph() {
- try {
- graph.degree(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.degree(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -322,12 +306,9 @@ public abstract class AbstractGraphTest {
@Test
public void inDegree_nodeNotInGraph() {
- try {
- graph.inDegree(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.inDegree(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -338,12 +319,9 @@ public abstract class AbstractGraphTest {
@Test
public void outDegree_nodeNotInGraph() {
- try {
- graph.outDegree(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.outDegree(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -407,16 +385,16 @@ public abstract class AbstractGraphTest {
public void removeNode_queryAfterRemoval() {
assume().that(graphIsMutable()).isTrue();
- addNode(N1);
- @SuppressWarnings("unused")
- Set<Integer> unused = graph.adjacentNodes(N1); // ensure cache (if any) is populated
+ putEdge(N1, N2);
+ putEdge(N2, N1);
+ Set<Integer> n1AdjacentNodes = graph.adjacentNodes(N1);
+ Set<Integer> n2AdjacentNodes = graph.adjacentNodes(N2);
assertThat(graphAsMutableGraph.removeNode(N1)).isTrue();
- try {
- graph.adjacentNodes(N1);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ assertThat(n1AdjacentNodes).isEmpty();
+ assertThat(n2AdjacentNodes).isEmpty();
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.adjacentNodes(N1));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
diff --git a/android/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java b/android/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java
index a02783f61..b9558f706 100644
--- a/android/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java
+++ b/android/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java
@@ -16,7 +16,6 @@
package com.google.common.graph;
-import static com.google.common.graph.TestUtil.ERROR_NODE_NOT_IN_GRAPH;
import static com.google.common.graph.TestUtil.assertEdgeNotInGraphErrorMessage;
import static com.google.common.graph.TestUtil.assertNodeNotInGraphErrorMessage;
import static com.google.common.graph.TestUtil.assertStronglyEquivalent;
@@ -25,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -416,12 +416,10 @@ public abstract class AbstractNetworkTest {
@Test
public void incidentEdges_nodeNotInGraph() {
- try {
- network.incidentEdges(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> network.incidentEdges(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -432,12 +430,10 @@ public abstract class AbstractNetworkTest {
@Test
public void incidentNodes_edgeNotInGraph() {
- try {
- network.incidentNodes(EDGE_NOT_IN_GRAPH);
- fail(ERROR_EDGE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertEdgeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> network.incidentNodes(EDGE_NOT_IN_GRAPH));
+ assertEdgeNotInGraphErrorMessage(e);
}
@Test
@@ -455,12 +451,10 @@ public abstract class AbstractNetworkTest {
@Test
public void adjacentNodes_nodeNotInGraph() {
- try {
- network.adjacentNodes(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> network.adjacentNodes(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -481,12 +475,10 @@ public abstract class AbstractNetworkTest {
@Test
public void adjacentEdges_edgeNotInGraph() {
- try {
- network.adjacentEdges(EDGE_NOT_IN_GRAPH);
- fail(ERROR_EDGE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertEdgeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> network.adjacentEdges(EDGE_NOT_IN_GRAPH));
+ assertEdgeNotInGraphErrorMessage(e);
}
@Test
@@ -512,24 +504,19 @@ public abstract class AbstractNetworkTest {
public void edgesConnecting_nodesNotInGraph() {
addNode(N1);
addNode(N2);
- try {
- network.edgesConnecting(N1, NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
- try {
- network.edgesConnecting(NODE_NOT_IN_GRAPH, N2);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
- try {
- network.edgesConnecting(NODE_NOT_IN_GRAPH, NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> network.edgesConnecting(N1, NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> network.edgesConnecting(NODE_NOT_IN_GRAPH, N2));
+ assertNodeNotInGraphErrorMessage(e);
+ e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> network.edgesConnecting(NODE_NOT_IN_GRAPH, NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -594,12 +581,9 @@ public abstract class AbstractNetworkTest {
@Test
public void inEdges_nodeNotInGraph() {
- try {
- network.inEdges(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> network.inEdges(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -610,12 +594,9 @@ public abstract class AbstractNetworkTest {
@Test
public void outEdges_nodeNotInGraph() {
- try {
- network.outEdges(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> network.outEdges(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -626,12 +607,9 @@ public abstract class AbstractNetworkTest {
@Test
public void predecessors_nodeNotInGraph() {
- try {
- network.predecessors(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> network.predecessors(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -642,12 +620,9 @@ public abstract class AbstractNetworkTest {
@Test
public void successors_nodeNotInGraph() {
- try {
- network.successors(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> network.successors(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -695,17 +670,16 @@ public abstract class AbstractNetworkTest {
public void removeNode_queryAfterRemoval() {
assume().that(graphIsMutable()).isTrue();
- addNode(N1);
- @SuppressWarnings("unused")
- Set<Integer> unused =
- networkAsMutableNetwork.adjacentNodes(N1); // ensure cache (if any) is populated
+ addEdge(N1, N2, E12);
+ Set<Integer> n1AdjacentNodes = networkAsMutableNetwork.adjacentNodes(N1);
+ Set<Integer> n2AdjacentNodes = networkAsMutableNetwork.adjacentNodes(N2);
assertTrue(networkAsMutableNetwork.removeNode(N1));
- try {
- networkAsMutableNetwork.adjacentNodes(N1);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ assertThat(n1AdjacentNodes).isEmpty();
+ assertThat(n2AdjacentNodes).isEmpty();
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.adjacentNodes(N1));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -750,12 +724,10 @@ public abstract class AbstractNetworkTest {
EndpointPair<Integer> unused =
networkAsMutableNetwork.incidentNodes(E12); // ensure cache (if any) is populated
assertTrue(networkAsMutableNetwork.removeEdge(E12));
- try {
- networkAsMutableNetwork.incidentNodes(E12);
- fail(ERROR_EDGE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertEdgeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.incidentNodes(E12));
+ assertEdgeNotInGraphErrorMessage(e);
}
@Test
diff --git a/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java b/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java
index c50a7da67..b1a69de2f 100644
--- a/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java
+++ b/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java
@@ -19,8 +19,8 @@ package com.google.common.graph;
import static com.google.common.graph.GraphConstants.ENDPOINTS_MISMATCH;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.util.Set;
import org.junit.Test;
@@ -36,13 +36,10 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
assume().that(graphIsMutable()).isTrue();
Set<Integer> nodes = graph.nodes();
- try {
- nodes.add(N2);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- addNode(N1);
- assertThat(graph.nodes()).containsExactlyElementsIn(nodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2));
+ addNode(N1);
+ assertThat(graph.nodes()).containsExactlyElementsIn(nodes);
}
@Override
@@ -52,13 +49,10 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
addNode(N1);
Set<Integer> adjacentNodes = graph.adjacentNodes(N1);
- try {
- adjacentNodes.add(N2);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2));
+ putEdge(N1, N2);
+ assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
}
@Override
@@ -68,13 +62,10 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
addNode(N2);
Set<Integer> predecessors = graph.predecessors(N2);
- try {
- predecessors.add(N1);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(graph.predecessors(N2)).containsExactlyElementsIn(predecessors);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1));
+ putEdge(N1, N2);
+ assertThat(graph.predecessors(N2)).containsExactlyElementsIn(predecessors);
}
@Override
@@ -84,13 +75,10 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
addNode(N1);
Set<Integer> successors = graph.successors(N1);
- try {
- successors.add(N2);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(successors).containsExactlyElementsIn(graph.successors(N1));
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> successors.add(N2));
+ putEdge(N1, N2);
+ assertThat(successors).containsExactlyElementsIn(graph.successors(N1));
}
@Override
@@ -100,13 +88,12 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
addNode(N1);
Set<EndpointPair<Integer>> incidentEdges = graph.incidentEdges(N1);
- try {
- incidentEdges.add(EndpointPair.ordered(N1, N2));
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(incidentEdges).containsExactlyElementsIn(graph.incidentEdges(N1));
- }
+ UnsupportedOperationException e =
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> incidentEdges.add(EndpointPair.ordered(N1, N2)));
+ putEdge(N1, N2);
+ assertThat(incidentEdges).containsExactlyElementsIn(graph.incidentEdges(N1));
}
@Test
@@ -364,12 +351,9 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
assume().that(graphIsMutable()).isTrue();
EndpointPair<Integer> endpoints = EndpointPair.unordered(N1, N2);
- try {
- graphAsMutableGraph.putEdge(endpoints);
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graphAsMutableGraph.putEdge(endpoints));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
/**
@@ -398,12 +382,9 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
assume().that(graphIsMutable()).isTrue();
assume().that(graph.allowsSelfLoops()).isFalse();
- try {
- graphAsMutableGraph.putEdge(N1, N1);
- fail(ERROR_ADDED_SELF_LOOP);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graphAsMutableGraph.putEdge(N1, N1));
+ assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
}
@Test
@@ -449,12 +430,10 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
putEdge(N1, N2);
EndpointPair<Integer> endpoints = EndpointPair.unordered(N1, N2);
- try {
- graphAsMutableGraph.removeEdge(endpoints);
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graphAsMutableGraph.removeEdge(endpoints));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
diff --git a/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java b/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java
index 98bc2fd65..1e6d22863 100644
--- a/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java
+++ b/android/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java
@@ -20,6 +20,7 @@ import static com.google.common.graph.GraphConstants.ENDPOINTS_MISMATCH;
import static com.google.common.graph.TestUtil.assertEdgeNotInGraphErrorMessage;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -64,13 +65,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(graphIsMutable()).isTrue();
Set<Integer> nodes = network.nodes();
- try {
- nodes.add(N2);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addNode(N1);
- assertThat(network.nodes()).containsExactlyElementsIn(nodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2));
+ addNode(N1);
+ assertThat(network.nodes()).containsExactlyElementsIn(nodes);
}
@Override
@@ -79,13 +77,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(graphIsMutable()).isTrue();
Set<String> edges = network.edges();
- try {
- edges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.edges()).containsExactlyElementsIn(edges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> edges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.edges()).containsExactlyElementsIn(edges);
}
@Override
@@ -95,13 +90,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N1);
Set<String> incidentEdges = network.incidentEdges(N1);
- try {
- incidentEdges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> incidentEdges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges);
}
@Override
@@ -111,13 +103,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N1);
Set<Integer> adjacentNodes = network.adjacentNodes(N1);
- try {
- adjacentNodes.add(N2);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2));
+ addEdge(N1, N2, E12);
+ assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
}
@Override
@@ -143,13 +132,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N1);
addNode(N2);
Set<String> edgesConnecting = network.edgesConnecting(N1, N2);
- try {
- edgesConnecting.add(E23);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23));
+ addEdge(N1, N2, E12);
+ assertThat(network.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
}
@Override
@@ -159,13 +145,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N2);
Set<String> inEdges = network.inEdges(N2);
- try {
- inEdges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.inEdges(N2)).containsExactlyElementsIn(inEdges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> inEdges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.inEdges(N2)).containsExactlyElementsIn(inEdges);
}
@Override
@@ -175,13 +158,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N1);
Set<String> outEdges = network.outEdges(N1);
- try {
- outEdges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.outEdges(N1)).containsExactlyElementsIn(outEdges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> outEdges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.outEdges(N1)).containsExactlyElementsIn(outEdges);
}
@Override
@@ -191,13 +171,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N2);
Set<Integer> predecessors = network.predecessors(N2);
- try {
- predecessors.add(N1);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.predecessors(N2)).containsExactlyElementsIn(predecessors);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1));
+ addEdge(N1, N2, E12);
+ assertThat(network.predecessors(N2)).containsExactlyElementsIn(predecessors);
}
@Override
@@ -207,13 +184,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N1);
Set<Integer> successors = network.successors(N1);
- try {
- successors.add(N2);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(successors).containsExactlyElementsIn(network.successors(N1));
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> successors.add(N2));
+ addEdge(N1, N2, E12);
+ assertThat(successors).containsExactlyElementsIn(network.successors(N1));
}
@Test
@@ -228,23 +202,25 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
@Test
public void edgesConnecting_orderMismatch() {
addEdge(N1, N2, E12);
- try {
- Set<String> unused = network.edgesConnecting(EndpointPair.unordered(N1, N2));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ Set<String> unused = network.edgesConnecting(EndpointPair.unordered(N1, N2));
+ });
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
public void edgeConnectingOrNull_orderMismatch() {
addEdge(N1, N2, E12);
- try {
- String unused = network.edgeConnectingOrNull(EndpointPair.unordered(N1, N2));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ String unused = network.edgeConnectingOrNull(EndpointPair.unordered(N1, N2));
+ });
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Override
@@ -304,12 +280,11 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
@Test
public void source_edgeNotInGraph() {
- try {
- network.incidentNodes(EDGE_NOT_IN_GRAPH).source();
- fail(ERROR_EDGE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertEdgeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> network.incidentNodes(EDGE_NOT_IN_GRAPH).source());
+ assertEdgeNotInGraphErrorMessage(e);
}
@Test
@@ -320,12 +295,11 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
@Test
public void target_edgeNotInGraph() {
- try {
- network.incidentNodes(EDGE_NOT_IN_GRAPH).target();
- fail(ERROR_EDGE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertEdgeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> network.incidentNodes(EDGE_NOT_IN_GRAPH).target());
+ assertEdgeNotInGraphErrorMessage(e);
}
@Test
@@ -516,20 +490,12 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(graphIsMutable()).isTrue();
addEdge(N1, N2, E12);
- try {
- // Edge between totally different nodes
- networkAsMutableNetwork.addEdge(N4, N5, E12);
- fail(ERROR_ADDED_EXISTING_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
- }
- try {
- // Edge between same nodes but in reverse direction
- addEdge(N2, N1, E12);
- fail(ERROR_ADDED_EXISTING_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N4, N5, E12));
+ assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
+ e = assertThrows(IllegalArgumentException.class, () -> addEdge(N2, N1, E12));
+ assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
}
@Test
@@ -538,12 +504,11 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(network.allowsParallelEdges()).isFalse();
addEdge(N1, N2, E12);
- try {
- networkAsMutableNetwork.addEdge(N1, N2, EDGE_NOT_IN_GRAPH);
- fail(ERROR_ADDED_PARALLEL_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkAsMutableNetwork.addEdge(N1, N2, EDGE_NOT_IN_GRAPH));
+ assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
}
@Test
@@ -561,12 +526,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(graphIsMutable()).isTrue();
EndpointPair<Integer> endpoints = EndpointPair.unordered(N1, N2);
- try {
- networkAsMutableNetwork.addEdge(endpoints, E12);
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(endpoints, E12));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -574,12 +537,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(graphIsMutable()).isTrue();
assume().that(network.allowsSelfLoops()).isFalse();
- try {
- networkAsMutableNetwork.addEdge(N1, N1, E11);
- fail(ERROR_ADDED_SELF_LOOP);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N1, E11));
+ assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
}
/**
@@ -632,25 +593,19 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(network.allowsSelfLoops()).isTrue();
addEdge(N1, N1, E11);
- try {
- networkAsMutableNetwork.addEdge(N1, N2, E11);
- fail("Reusing an existing self-loop edge to connect different nodes succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_REUSE_EDGE);
- }
- try {
- networkAsMutableNetwork.addEdge(N2, N2, E11);
- fail("Reusing an existing self-loop edge to make a different self-loop edge succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_REUSE_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N2, E11));
+ assertThat(e.getMessage()).contains(ERROR_REUSE_EDGE);
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N2, N2, E11));
+ assertThat(e.getMessage()).contains(ERROR_REUSE_EDGE);
addEdge(N1, N2, E12);
- try {
- networkAsMutableNetwork.addEdge(N1, N1, E12);
- fail("Reusing an existing edge to add a self-loop edge between different nodes succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_REUSE_EDGE);
- }
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N1, E12));
+ assertThat(e.getMessage()).contains(ERROR_REUSE_EDGE);
}
@Test
@@ -660,12 +615,11 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(network.allowsParallelEdges()).isFalse();
addEdge(N1, N1, E11);
- try {
- networkAsMutableNetwork.addEdge(N1, N1, EDGE_NOT_IN_GRAPH);
- fail("Adding a parallel self-loop edge succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkAsMutableNetwork.addEdge(N1, N1, EDGE_NOT_IN_GRAPH));
+ assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
}
@Test
diff --git a/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java b/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java
index da9226c31..0acc786a4 100644
--- a/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java
+++ b/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java
@@ -18,8 +18,8 @@ package com.google.common.graph;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import com.google.common.testing.EqualsTester;
import java.util.Set;
@@ -47,13 +47,10 @@ public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphT
assume().that(graphIsMutable()).isTrue();
Set<Integer> nodes = graph.nodes();
- try {
- nodes.add(N2);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- addNode(N1);
- assertThat(graph.nodes()).containsExactlyElementsIn(nodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2));
+ addNode(N1);
+ assertThat(graph.nodes()).containsExactlyElementsIn(nodes);
}
@Override
@@ -63,13 +60,10 @@ public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphT
addNode(N1);
Set<Integer> adjacentNodes = graph.adjacentNodes(N1);
- try {
- adjacentNodes.add(N2);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2));
+ putEdge(N1, N2);
+ assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
}
@Override
@@ -79,13 +73,10 @@ public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphT
addNode(N2);
Set<Integer> predecessors = graph.predecessors(N2);
- try {
- predecessors.add(N1);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(graph.predecessors(N2)).containsExactlyElementsIn(predecessors);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1));
+ putEdge(N1, N2);
+ assertThat(graph.predecessors(N2)).containsExactlyElementsIn(predecessors);
}
@Override
@@ -95,13 +86,10 @@ public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphT
addNode(N1);
Set<Integer> successors = graph.successors(N1);
- try {
- successors.add(N2);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(graph.successors(N1)).containsExactlyElementsIn(successors);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> successors.add(N2));
+ putEdge(N1, N2);
+ assertThat(graph.successors(N1)).containsExactlyElementsIn(successors);
}
@Override
@@ -111,13 +99,12 @@ public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphT
addNode(N1);
Set<EndpointPair<Integer>> incidentEdges = graph.incidentEdges(N1);
- try {
- incidentEdges.add(EndpointPair.unordered(N1, N2));
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(incidentEdges).containsExactlyElementsIn(graph.incidentEdges(N1));
- }
+ UnsupportedOperationException e =
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> incidentEdges.add(EndpointPair.unordered(N1, N2)));
+ putEdge(N1, N2);
+ assertThat(incidentEdges).containsExactlyElementsIn(graph.incidentEdges(N1));
}
@Test
@@ -380,12 +367,9 @@ public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphT
assume().that(graphIsMutable()).isTrue();
assume().that(graph.allowsSelfLoops()).isFalse();
- try {
- putEdge(N1, N1);
- fail(ERROR_ADDED_SELF_LOOP);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> putEdge(N1, N1));
+ assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
}
@Test
diff --git a/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java b/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java
index beadaf92d..52f65577a 100644
--- a/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java
+++ b/android/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java
@@ -19,6 +19,7 @@ package com.google.common.graph;
import static com.google.common.graph.GraphConstants.ENDPOINTS_MISMATCH;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -59,26 +60,20 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
@Test
public void nodes_checkReturnedSetMutability() {
Set<Integer> nodes = network.nodes();
- try {
- nodes.add(N2);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addNode(N1);
- assertThat(network.nodes()).containsExactlyElementsIn(nodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2));
+ addNode(N1);
+ assertThat(network.nodes()).containsExactlyElementsIn(nodes);
}
@Override
@Test
public void edges_checkReturnedSetMutability() {
Set<String> edges = network.edges();
- try {
- edges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.edges()).containsExactlyElementsIn(edges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> edges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.edges()).containsExactlyElementsIn(edges);
}
@Override
@@ -86,13 +81,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
public void incidentEdges_checkReturnedSetMutability() {
addNode(N1);
Set<String> incidentEdges = network.incidentEdges(N1);
- try {
- incidentEdges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> incidentEdges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges);
}
@Override
@@ -100,13 +92,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
public void adjacentNodes_checkReturnedSetMutability() {
addNode(N1);
Set<Integer> adjacentNodes = network.adjacentNodes(N1);
- try {
- adjacentNodes.add(N2);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2));
+ addEdge(N1, N2, E12);
+ assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
}
@Override
@@ -128,13 +117,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
addNode(N1);
addNode(N2);
Set<String> edgesConnecting = network.edgesConnecting(N1, N2);
- try {
- edgesConnecting.add(E23);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23));
+ addEdge(N1, N2, E12);
+ assertThat(network.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
}
@Override
@@ -142,13 +128,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
public void inEdges_checkReturnedSetMutability() {
addNode(N2);
Set<String> inEdges = network.inEdges(N2);
- try {
- inEdges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.inEdges(N2)).containsExactlyElementsIn(inEdges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> inEdges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.inEdges(N2)).containsExactlyElementsIn(inEdges);
}
@Override
@@ -156,13 +139,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
public void outEdges_checkReturnedSetMutability() {
addNode(N1);
Set<String> outEdges = network.outEdges(N1);
- try {
- outEdges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.outEdges(N1)).containsExactlyElementsIn(outEdges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> outEdges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.outEdges(N1)).containsExactlyElementsIn(outEdges);
}
@Override
@@ -170,13 +150,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
public void predecessors_checkReturnedSetMutability() {
addNode(N2);
Set<Integer> predecessors = network.predecessors(N2);
- try {
- predecessors.add(N1);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.predecessors(N2)).containsExactlyElementsIn(predecessors);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1));
+ addEdge(N1, N2, E12);
+ assertThat(network.predecessors(N2)).containsExactlyElementsIn(predecessors);
}
@Override
@@ -184,13 +161,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
public void successors_checkReturnedSetMutability() {
addNode(N1);
Set<Integer> successors = network.successors(N1);
- try {
- successors.add(N2);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.successors(N1)).containsExactlyElementsIn(successors);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> successors.add(N2));
+ addEdge(N1, N2, E12);
+ assertThat(network.successors(N1)).containsExactlyElementsIn(successors);
}
@Test
@@ -203,23 +177,25 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
@Test
public void edgesConnecting_orderMismatch() {
addEdge(N1, N2, E12);
- try {
- Set<String> unused = network.edgesConnecting(ENDPOINTS_N1N2);
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ Set<String> unused = network.edgesConnecting(ENDPOINTS_N1N2);
+ });
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
public void edgeConnectingOrNull_orderMismatch() {
addEdge(N1, N2, E12);
- try {
- String unused = network.edgeConnectingOrNull(ENDPOINTS_N1N2);
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ String unused = network.edgeConnectingOrNull(ENDPOINTS_N1N2);
+ });
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -429,13 +405,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
assume().that(graphIsMutable()).isTrue();
addEdge(N1, N2, E12);
- try {
- // Edge between totally different nodes
- networkAsMutableNetwork.addEdge(N4, N5, E12);
- fail(ERROR_ADDED_EXISTING_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N4, N5, E12));
+ assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
}
@Test
@@ -444,18 +417,16 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
assume().that(network.allowsParallelEdges()).isFalse();
addEdge(N1, N2, E12);
- try {
- networkAsMutableNetwork.addEdge(N1, N2, EDGE_NOT_IN_GRAPH);
- fail(ERROR_ADDED_PARALLEL_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
- }
- try {
- networkAsMutableNetwork.addEdge(N2, N1, EDGE_NOT_IN_GRAPH);
- fail(ERROR_ADDED_PARALLEL_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkAsMutableNetwork.addEdge(N1, N2, EDGE_NOT_IN_GRAPH));
+ assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
+ e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkAsMutableNetwork.addEdge(N2, N1, EDGE_NOT_IN_GRAPH));
+ assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
}
@Test
@@ -474,12 +445,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
assume().that(graphIsMutable()).isTrue();
EndpointPair<Integer> endpoints = EndpointPair.ordered(N1, N2);
- try {
- networkAsMutableNetwork.addEdge(endpoints, E12);
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(endpoints, E12));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -487,12 +456,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
assume().that(graphIsMutable()).isTrue();
assume().that(network.allowsSelfLoops()).isFalse();
- try {
- networkAsMutableNetwork.addEdge(N1, N1, E11);
- fail(ERROR_ADDED_SELF_LOOP);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N1, E11));
+ assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
}
/**
@@ -544,25 +511,19 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
assume().that(network.allowsSelfLoops()).isTrue();
addEdge(N1, N1, E11);
- try {
- networkAsMutableNetwork.addEdge(N1, N2, E11);
- fail("Reusing an existing self-loop edge to connect different nodes succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
- }
- try {
- networkAsMutableNetwork.addEdge(N2, N2, E11);
- fail("Reusing an existing self-loop edge to make a different self-loop edge succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N2, E11));
+ assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N2, N2, E11));
+ assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
addEdge(N1, N2, E12);
- try {
- networkAsMutableNetwork.addEdge(N1, N1, E12);
- fail("Reusing an existing edge to add a self-loop edge between different nodes succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
- }
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N1, E12));
+ assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
}
@Test
@@ -572,12 +533,11 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
assume().that(network.allowsParallelEdges()).isFalse();
addEdge(N1, N1, E11);
- try {
- networkAsMutableNetwork.addEdge(N1, N1, EDGE_NOT_IN_GRAPH);
- fail("Adding a parallel self-loop edge succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkAsMutableNetwork.addEdge(N1, N1, EDGE_NOT_IN_GRAPH));
+ assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
}
@Test
diff --git a/android/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java b/android/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java
index eaddb949c..b773a36e6 100644
--- a/android/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java
+++ b/android/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java
@@ -16,13 +16,11 @@
package com.google.common.graph;
-import static com.google.common.graph.AbstractNetworkTest.ERROR_MODIFIABLE_COLLECTION;
-import static com.google.common.graph.TestUtil.ERROR_NODE_NOT_IN_GRAPH;
import static com.google.common.graph.TestUtil.EdgeType.DIRECTED;
import static com.google.common.graph.TestUtil.EdgeType.UNDIRECTED;
import static com.google.common.graph.TestUtil.assertNodeNotInGraphErrorMessage;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import com.google.common.graph.TestUtil.EdgeType;
import java.util.Arrays;
@@ -89,24 +87,21 @@ public final class DefaultNetworkImplementationsTest {
public void edgesConnecting_nodesNotInGraph() {
network.addNode(N1);
network.addNode(N2);
- try {
- networkForTest.edgesConnecting(N1, NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
- try {
- networkForTest.edgesConnecting(NODE_NOT_IN_GRAPH, N2);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
- try {
- networkForTest.edgesConnecting(NODE_NOT_IN_GRAPH, NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkForTest.edgesConnecting(N1, NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
+ e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkForTest.edgesConnecting(NODE_NOT_IN_GRAPH, N2));
+ assertNodeNotInGraphErrorMessage(e);
+ e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkForTest.edgesConnecting(NODE_NOT_IN_GRAPH, NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -114,13 +109,10 @@ public final class DefaultNetworkImplementationsTest {
network.addNode(N1);
network.addNode(N2);
Set<String> edgesConnecting = network.edgesConnecting(N1, N2);
- try {
- edgesConnecting.add(E23);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- network.addEdge(N1, N2, E12);
- assertThat(networkForTest.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23));
+ network.addEdge(N1, N2, E12);
+ assertThat(networkForTest.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
}
@Test
diff --git a/android/guava-tests/test/com/google/common/graph/EndpointPairTest.java b/android/guava-tests/test/com/google/common/graph/EndpointPairTest.java
index c67693a71..391f4c838 100644
--- a/android/guava-tests/test/com/google/common/graph/EndpointPairTest.java
+++ b/android/guava-tests/test/com/google/common/graph/EndpointPairTest.java
@@ -17,7 +17,7 @@
package com.google.common.graph;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -91,11 +91,7 @@ public final class EndpointPairTest {
for (MutableNetwork<Integer, String> network : testNetworks) {
network.addEdge(1, 2, "1-2");
EndpointPair<Integer> endpointPair = network.incidentNodes("1-2");
- try {
- endpointPair.adjacentNode(3);
- fail("Should have rejected adjacentNode() called with a node not incident to edge.");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> endpointPair.adjacentNode(3));
}
}
@@ -195,11 +191,8 @@ public final class EndpointPairTest {
directedGraph.removeEdge(N2, N1);
containsExactlySanityCheck(edges);
- try {
- edges.add(EndpointPair.ordered(N1, N2));
- fail("Set returned by edges() should be unmodifiable");
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(
+ UnsupportedOperationException.class, () -> edges.add(EndpointPair.ordered(N1, N2)));
}
@Test
diff --git a/android/guava-tests/test/com/google/common/graph/GraphsTest.java b/android/guava-tests/test/com/google/common/graph/GraphsTest.java
index a07def019..b31121da4 100644
--- a/android/guava-tests/test/com/google/common/graph/GraphsTest.java
+++ b/android/guava-tests/test/com/google/common/graph/GraphsTest.java
@@ -22,7 +22,7 @@ import static com.google.common.graph.Graphs.reachableNodes;
import static com.google.common.graph.Graphs.transitiveClosure;
import static com.google.common.graph.Graphs.transpose;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableSet;
import java.util.Set;
@@ -399,20 +399,14 @@ public class GraphsTest {
public void inducedSubgraph_nodeNotInGraph() {
MutableNetwork<Integer, String> undirectedGraph = NetworkBuilder.undirected().build();
- try {
- inducedSubgraph(undirectedGraph, ImmutableSet.of(N1));
- fail("Should have rejected getting induced subgraph with node not in original graph.");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> inducedSubgraph(undirectedGraph, ImmutableSet.of(N1)));
}
@Test
public void copyOf_nullArgument() {
- try {
- copyOf((Graph<?>) null);
- fail("Should have rejected a null graph.");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> copyOf((Graph<?>) null));
}
@Test
@@ -475,20 +469,13 @@ public class GraphsTest {
assertThat(directedGraph.edgesConnecting(N2, N1)).isEmpty();
// By default, parallel edges are not allowed.
- try {
- directedGraph.addEdge(N1, N2, E12_A);
- fail(ERROR_ADDED_PARALLEL_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> directedGraph.addEdge(N1, N2, E12_A));
+ assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
// By default, self-loop edges are not allowed.
- try {
- directedGraph.addEdge(N1, N1, E11);
- fail(ERROR_ADDED_SELF_LOOP);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
- }
+ e = assertThrows(IllegalArgumentException.class, () -> directedGraph.addEdge(N1, N1, E11));
+ assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
}
@Test
@@ -501,26 +488,15 @@ public class GraphsTest {
assertThat(undirectedGraph.edgesConnecting(N2, N1)).isEqualTo(ImmutableSet.of(E12));
// By default, parallel edges are not allowed.
- try {
- undirectedGraph.addEdge(N1, N2, E12_A);
- fail(ERROR_ADDED_PARALLEL_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
- }
- try {
- undirectedGraph.addEdge(N2, N1, E21);
- fail(ERROR_ADDED_PARALLEL_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> undirectedGraph.addEdge(N1, N2, E12_A));
+ assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
+ e = assertThrows(IllegalArgumentException.class, () -> undirectedGraph.addEdge(N2, N1, E21));
+ assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
// By default, self-loop edges are not allowed.
- try {
- undirectedGraph.addEdge(N1, N1, E11);
- fail(ERROR_ADDED_SELF_LOOP);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
- }
+ e = assertThrows(IllegalArgumentException.class, () -> undirectedGraph.addEdge(N1, N1, E11));
+ assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
}
@Test
@@ -564,12 +540,10 @@ public class GraphsTest {
@Test
public void builder_expectedNodeCount_negative() {
- try {
- NetworkBuilder.directed().expectedNodeCount(-1);
- fail("Should have rejected negative expected node count.");
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_NEGATIVE_COUNT);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> NetworkBuilder.directed().expectedNodeCount(-1));
+ assertThat(e.getMessage()).contains(ERROR_NEGATIVE_COUNT);
}
@Test
@@ -592,12 +566,10 @@ public class GraphsTest {
@Test
public void builder_expectedEdgeCount_negative() {
- try {
- NetworkBuilder.directed().expectedEdgeCount(-1);
- fail("Should have rejected negative expected edge count.");
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_NEGATIVE_COUNT);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> NetworkBuilder.directed().expectedEdgeCount(-1));
+ assertThat(e.getMessage()).contains(ERROR_NEGATIVE_COUNT);
}
private static <N> void checkTransitiveClosure(Graph<N> originalGraph, Graph<N> expectedClosure) {
diff --git a/android/guava-tests/test/com/google/common/graph/PackageSanityTests.java b/android/guava-tests/test/com/google/common/graph/PackageSanityTests.java
index f1526c235..4c863020e 100644
--- a/android/guava-tests/test/com/google/common/graph/PackageSanityTests.java
+++ b/android/guava-tests/test/com/google/common/graph/PackageSanityTests.java
@@ -51,8 +51,14 @@ public class PackageSanityTests extends AbstractPackageSanityTests {
NetworkBuilder.directed().<String, String>immutable().addNode("B").build();
public PackageSanityTests() {
+ MutableNetwork<String, String> mutableNetworkA = NetworkBuilder.directed().build();
+ mutableNetworkA.addNode("a");
+ MutableNetwork<String, String> mutableNetworkB = NetworkBuilder.directed().build();
+ mutableNetworkB.addNode("b");
+
setDistinctValues(AbstractGraphBuilder.class, GRAPH_BUILDER_A, GRAPH_BUILDER_B);
setDistinctValues(Graph.class, IMMUTABLE_GRAPH_A, IMMUTABLE_GRAPH_B);
+ setDistinctValues(MutableNetwork.class, mutableNetworkA, mutableNetworkB);
setDistinctValues(NetworkBuilder.class, NETWORK_BUILDER_A, NETWORK_BUILDER_B);
setDistinctValues(Network.class, IMMUTABLE_NETWORK_A, IMMUTABLE_NETWORK_B);
setDefault(EndpointPair.class, EndpointPair.ordered("A", "B"));
diff --git a/android/guava-tests/test/com/google/common/graph/TraverserTest.java b/android/guava-tests/test/com/google/common/graph/TraverserTest.java
index d4c8cf752..a941b9529 100644
--- a/android/guava-tests/test/com/google/common/graph/TraverserTest.java
+++ b/android/guava-tests/test/com/google/common/graph/TraverserTest.java
@@ -21,7 +21,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Lists.charactersOf;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.ImmutableList;
@@ -311,11 +311,9 @@ public class TraverserTest {
@Test
public void forGraph_breadthFirst_emptyGraph() {
- try {
- Traverser.forGraph(createDirectedGraph()).breadthFirst('a');
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forGraph(createDirectedGraph()).breadthFirst('a'));
}
/**
@@ -326,11 +324,9 @@ public class TraverserTest {
public void forGraph_breadthFirstIterable_emptyGraph() {
assertEqualCharNodes(
Traverser.forGraph(createDirectedGraph()).breadthFirst(charactersOf("")), "");
- try {
- Traverser.forGraph(createDirectedGraph()).breadthFirst(charactersOf("a"));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forGraph(createDirectedGraph()).breadthFirst(charactersOf("a")));
}
/**
@@ -509,22 +505,18 @@ public class TraverserTest {
@Test
public void forGraph_depthFirstPreOrder_emptyGraph() {
- try {
- Traverser.forGraph(createDirectedGraph()).depthFirstPreOrder('a');
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forGraph(createDirectedGraph()).depthFirstPreOrder('a'));
}
@Test
public void forGraph_depthFirstPreOrderIterable_emptyGraph() {
assertEqualCharNodes(
Traverser.forGraph(createDirectedGraph()).depthFirstPreOrder(charactersOf("")), "");
- try {
- Traverser.forGraph(createDirectedGraph()).depthFirstPreOrder(charactersOf("a"));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forGraph(createDirectedGraph()).depthFirstPreOrder(charactersOf("a")));
}
@Test
@@ -691,22 +683,18 @@ public class TraverserTest {
@Test
public void forGraph_depthFirstPostOrder_emptyGraph() {
- try {
- Traverser.forGraph(createDirectedGraph()).depthFirstPostOrder('a');
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forGraph(createDirectedGraph()).depthFirstPostOrder('a'));
}
@Test
public void forGraph_depthFirstPostOrderIterable_emptyGraph() {
assertEqualCharNodes(
Traverser.forGraph(createDirectedGraph()).depthFirstPostOrder(charactersOf("")), "");
- try {
- Traverser.forGraph(createDirectedGraph()).depthFirstPostOrder(charactersOf("a"));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forGraph(createDirectedGraph()).depthFirstPostOrder(charactersOf("a")));
}
@Test
@@ -749,11 +737,7 @@ public class TraverserTest {
MutableGraph<String> graph = GraphBuilder.undirected().build();
graph.putEdge("a", "b");
- try {
- Traverser.forTree(graph);
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Traverser.forTree(graph));
}
@Test
@@ -770,11 +754,7 @@ public class TraverserTest {
MutableValueGraph<String, Integer> valueGraph = ValueGraphBuilder.undirected().build();
valueGraph.putEdgeValue("a", "b", 11);
- try {
- Traverser.forTree(valueGraph);
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Traverser.forTree(valueGraph));
}
@Test
@@ -791,11 +771,7 @@ public class TraverserTest {
MutableNetwork<String, Integer> network = NetworkBuilder.undirected().build();
network.addEdge("a", "b", 11);
- try {
- Traverser.forTree(network);
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Traverser.forTree(network));
}
@Test
@@ -889,22 +865,18 @@ public class TraverserTest {
@Test
public void forTree_breadthFirst_emptyGraph() {
- try {
- Traverser.forTree(createDirectedGraph()).breadthFirst('a');
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forTree(createDirectedGraph()).breadthFirst('a'));
}
@Test
public void forTree_breadthFirstIterable_emptyGraph() {
assertEqualCharNodes(
Traverser.forTree(createDirectedGraph()).breadthFirst(charactersOf("")), "");
- try {
- Traverser.forTree(createDirectedGraph()).breadthFirst(charactersOf("a"));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forTree(createDirectedGraph()).breadthFirst(charactersOf("a")));
}
@Test
@@ -1026,22 +998,18 @@ public class TraverserTest {
@Test
public void forTree_depthFirstPreOrder_emptyGraph() {
- try {
- Traverser.forTree(createDirectedGraph()).depthFirstPreOrder('a');
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forTree(createDirectedGraph()).depthFirstPreOrder('a'));
}
@Test
public void forTree_depthFirstPreOrderIterable_emptyGraph() {
assertEqualCharNodes(
Traverser.forTree(createDirectedGraph()).depthFirstPreOrder(charactersOf("")), "");
- try {
- Traverser.forTree(createDirectedGraph()).depthFirstPreOrder(charactersOf("a"));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forTree(createDirectedGraph()).depthFirstPreOrder(charactersOf("a")));
}
@Test
@@ -1156,22 +1124,18 @@ public class TraverserTest {
@Test
public void forTree_depthFirstPostOrder_emptyGraph() {
- try {
- Traverser.forTree(createDirectedGraph()).depthFirstPostOrder('a');
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forTree(createDirectedGraph()).depthFirstPostOrder('a'));
}
@Test
public void forTree_depthFirstPostOrderIterable_emptyGraph() {
assertEqualCharNodes(
Traverser.forTree(createDirectedGraph()).depthFirstPostOrder(charactersOf("")), "");
- try {
- Traverser.forTree(createDirectedGraph()).depthFirstPostOrder(charactersOf("a"));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forTree(createDirectedGraph()).depthFirstPostOrder(charactersOf("a")));
}
@Test
@@ -1201,11 +1165,11 @@ public class TraverserTest {
}
private static SuccessorsFunction<Character> createDirectedGraph(String... edges) {
- return createGraph(/* directed = */ true, edges);
+ return createGraph(/* directed= */ true, edges);
}
private static SuccessorsFunction<Character> createUndirectedGraph(String... edges) {
- return createGraph(/* directed = */ false, edges);
+ return createGraph(/* directed= */ false, edges);
}
/**
diff --git a/android/guava-tests/test/com/google/common/graph/ValueGraphTest.java b/android/guava-tests/test/com/google/common/graph/ValueGraphTest.java
index 24323ca00..caf7ed984 100644
--- a/android/guava-tests/test/com/google/common/graph/ValueGraphTest.java
+++ b/android/guava-tests/test/com/google/common/graph/ValueGraphTest.java
@@ -20,7 +20,7 @@ import static com.google.common.graph.GraphConstants.ENDPOINTS_MISMATCH;
import static com.google.common.graph.TestUtil.assertStronglyEquivalent;
import static com.google.common.truth.Truth.assertThat;
import static java.util.concurrent.Executors.newFixedThreadPool;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import java.util.Set;
@@ -197,13 +197,16 @@ public final class ValueGraphTest {
public void edgeValueOrDefault_directed_mismatch() {
graph = ValueGraphBuilder.directed().build();
graph.putEdgeValue(1, 2, "A");
- try {
- String unused = graph.edgeValueOrDefault(EndpointPair.unordered(1, 2), "default");
- unused = graph.edgeValueOrDefault(EndpointPair.unordered(2, 1), "default");
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> graph.edgeValueOrDefault(EndpointPair.unordered(1, 2), "default"));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
+ e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> graph.edgeValueOrDefault(EndpointPair.unordered(2, 1), "default"));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -225,18 +228,16 @@ public final class ValueGraphTest {
graph = ValueGraphBuilder.undirected().build();
graph.putEdgeValue(1, 2, "A");
// Check that edgeValueOrDefault() throws on each possible ordering of an ordered EndpointPair
- try {
- String unused = graph.edgeValueOrDefault(EndpointPair.ordered(1, 2), "default");
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
- try {
- String unused = graph.edgeValueOrDefault(EndpointPair.ordered(2, 1), "default");
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> graph.edgeValueOrDefault(EndpointPair.ordered(1, 2), "default"));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
+ e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> graph.edgeValueOrDefault(EndpointPair.ordered(2, 1), "default"));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -252,23 +253,21 @@ public final class ValueGraphTest {
@Test
public void putEdgeValue_directed_orderMismatch() {
graph = ValueGraphBuilder.directed().build();
- try {
- graph.putEdgeValue(EndpointPair.unordered(1, 2), "irrelevant");
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> graph.putEdgeValue(EndpointPair.unordered(1, 2), "irrelevant"));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
public void putEdgeValue_undirected_orderMismatch() {
graph = ValueGraphBuilder.undirected().build();
- try {
- graph.putEdgeValue(EndpointPair.ordered(1, 2), "irrelevant");
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> graph.putEdgeValue(EndpointPair.ordered(1, 2), "irrelevant"));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -315,13 +314,14 @@ public final class ValueGraphTest {
graph = ValueGraphBuilder.directed().build();
graph.putEdgeValue(1, 2, "1->2");
graph.putEdgeValue(2, 1, "2->1");
- try {
- graph.removeEdge(EndpointPair.unordered(1, 2));
- graph.removeEdge(EndpointPair.unordered(2, 1));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graph.removeEdge(EndpointPair.unordered(1, 2)));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graph.removeEdge(EndpointPair.unordered(2, 1)));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -329,18 +329,14 @@ public final class ValueGraphTest {
graph = ValueGraphBuilder.undirected().build();
graph.putEdgeValue(1, 2, "1-2");
// Check that removeEdge() throws on each possible ordering of an ordered EndpointPair
- try {
- graph.removeEdge(EndpointPair.ordered(1, 2));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
- try {
- graph.removeEdge(EndpointPair.ordered(2, 1));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graph.removeEdge(EndpointPair.ordered(1, 2)));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graph.removeEdge(EndpointPair.ordered(2, 1)));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
diff --git a/android/guava-tests/test/com/google/common/hash/AbstractByteHasherTest.java b/android/guava-tests/test/com/google/common/hash/AbstractByteHasherTest.java
index 7ceb25e0c..8b54d4959 100644
--- a/android/guava-tests/test/com/google/common/hash/AbstractByteHasherTest.java
+++ b/android/guava-tests/test/com/google/common/hash/AbstractByteHasherTest.java
@@ -16,6 +16,7 @@ package com.google.common.hash;
import static com.google.common.base.Charsets.UTF_16LE;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertThrows;
import java.io.ByteArrayOutputStream;
import java.util.Random;
@@ -92,21 +93,9 @@ public class AbstractByteHasherTest extends TestCase {
public void testCorrectExceptions() {
TestHasher hasher = new TestHasher();
- try {
- hasher.putBytes(new byte[8], -1, 4);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
- try {
- hasher.putBytes(new byte[8], 0, 16);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
- try {
- hasher.putBytes(new byte[8], 0, -1);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> hasher.putBytes(new byte[8], -1, 4));
+ assertThrows(IndexOutOfBoundsException.class, () -> hasher.putBytes(new byte[8], 0, 16));
+ assertThrows(IndexOutOfBoundsException.class, () -> hasher.putBytes(new byte[8], 0, -1));
}
private class TestHasher extends AbstractByteHasher {
diff --git a/android/guava-tests/test/com/google/common/hash/AbstractStreamingHasherTest.java b/android/guava-tests/test/com/google/common/hash/AbstractStreamingHasherTest.java
index 99b2c71a0..77b4e67cc 100644
--- a/android/guava-tests/test/com/google/common/hash/AbstractStreamingHasherTest.java
+++ b/android/guava-tests/test/com/google/common/hash/AbstractStreamingHasherTest.java
@@ -17,6 +17,7 @@
package com.google.common.hash;
import static com.google.common.base.Charsets.UTF_16LE;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -113,21 +114,9 @@ public class AbstractStreamingHasherTest extends TestCase {
public void testCorrectExceptions() {
Sink sink = new Sink(4);
- try {
- sink.putBytes(new byte[8], -1, 4);
- fail();
- } catch (IndexOutOfBoundsException ok) {
- }
- try {
- sink.putBytes(new byte[8], 0, 16);
- fail();
- } catch (IndexOutOfBoundsException ok) {
- }
- try {
- sink.putBytes(new byte[8], 0, -1);
- fail();
- } catch (IndexOutOfBoundsException ok) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> sink.putBytes(new byte[8], -1, 4));
+ assertThrows(IndexOutOfBoundsException.class, () -> sink.putBytes(new byte[8], 0, 16));
+ assertThrows(IndexOutOfBoundsException.class, () -> sink.putBytes(new byte[8], 0, -1));
}
/**
diff --git a/android/guava-tests/test/com/google/common/hash/BloomFilterTest.java b/android/guava-tests/test/com/google/common/hash/BloomFilterTest.java
index 8ee920ca9..dd9a776d2 100644
--- a/android/guava-tests/test/com/google/common/hash/BloomFilterTest.java
+++ b/android/guava-tests/test/com/google/common/hash/BloomFilterTest.java
@@ -18,6 +18,7 @@ package com.google.common.hash;
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableSet;
@@ -221,38 +222,31 @@ public class BloomFilterTest extends TestCase {
}
public void testPreconditions() {
- try {
- BloomFilter.create(Funnels.unencodedCharsFunnel(), -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- BloomFilter.create(Funnels.unencodedCharsFunnel(), -1, 0.03);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- BloomFilter.create(Funnels.unencodedCharsFunnel(), 1, 0.0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- BloomFilter.create(Funnels.unencodedCharsFunnel(), 1, 1.0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> BloomFilter.create(Funnels.unencodedCharsFunnel(), -1));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> BloomFilter.create(Funnels.unencodedCharsFunnel(), -1, 0.03));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> BloomFilter.create(Funnels.unencodedCharsFunnel(), 1, 0.0));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> BloomFilter.create(Funnels.unencodedCharsFunnel(), 1, 1.0));
}
public void testFailureWhenMoreThan255HashFunctionsAreNeeded() {
- try {
- int n = 1000;
- double p = 0.00000000000000000000000000000000000000000000000000000000000000000000000000000001;
- BloomFilter.create(Funnels.unencodedCharsFunnel(), n, p);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ int n = 1000;
+ double p = 0.00000000000000000000000000000000000000000000000000000000000000000000000000000001;
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ BloomFilter.create(Funnels.unencodedCharsFunnel(), n, p);
+ });
}
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicInstanceMethods(BloomFilter.create(Funnels.unencodedCharsFunnel(), 100));
@@ -289,15 +283,16 @@ public class BloomFilterTest extends TestCase {
// and some crazy values (this used to be capped to Integer.MAX_VALUE, now it can go bigger
assertEquals(3327428144502L, BloomFilter.optimalNumOfBits(Integer.MAX_VALUE, Double.MIN_VALUE));
- try {
- BloomFilter<String> unused =
- BloomFilter.create(HashTestUtils.BAD_FUNNEL, Integer.MAX_VALUE, Double.MIN_VALUE);
- fail("we can't represent such a large BF!");
- } catch (IllegalArgumentException expected) {
- assertThat(expected)
- .hasMessageThat()
- .isEqualTo("Could not create BloomFilter of 3327428144502 bits");
- }
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ BloomFilter<String> unused =
+ BloomFilter.create(HashTestUtils.BAD_FUNNEL, Integer.MAX_VALUE, Double.MIN_VALUE);
+ });
+ assertThat(expected)
+ .hasMessageThat()
+ .isEqualTo("Could not create BloomFilter of 3327428144502 bits");
}
@AndroidIncompatible // OutOfMemoryError
@@ -456,29 +451,29 @@ public class BloomFilterTest extends TestCase {
BloomFilter<Integer> bf1 = BloomFilter.create(Funnels.integerFunnel(), 1);
BloomFilter<Integer> bf2 = BloomFilter.create(Funnels.integerFunnel(), 10);
- try {
- assertFalse(bf1.isCompatible(bf2));
- bf1.putAll(bf2);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertFalse(bf1.isCompatible(bf2));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ bf1.putAll(bf2);
+ });
- try {
- assertFalse(bf2.isCompatible(bf1));
- bf2.putAll(bf1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertFalse(bf2.isCompatible(bf1));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ bf2.putAll(bf1);
+ });
}
public void testPutAllWithSelf() {
BloomFilter<Integer> bf1 = BloomFilter.create(Funnels.integerFunnel(), 1);
- try {
- assertFalse(bf1.isCompatible(bf1));
- bf1.putAll(bf1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertFalse(bf1.isCompatible(bf1));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ bf1.putAll(bf1);
+ });
}
public void testJavaSerialization() {
diff --git a/android/guava-tests/test/com/google/common/hash/HashCodeTest.java b/android/guava-tests/test/com/google/common/hash/HashCodeTest.java
index 231fd402b..fc0a7be1e 100644
--- a/android/guava-tests/test/com/google/common/hash/HashCodeTest.java
+++ b/android/guava-tests/test/com/google/common/hash/HashCodeTest.java
@@ -17,6 +17,7 @@
package com.google.common.hash;
import static com.google.common.io.BaseEncoding.base16;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
@@ -230,42 +231,22 @@ public class HashCodeTest extends TestCase {
}
public void testFromStringFailsWithInvalidHexChar() {
- try {
- HashCode.fromString("7f8005ff0z");
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> HashCode.fromString("7f8005ff0z"));
}
public void testFromStringFailsWithUpperCaseString() {
String string = Hashing.sha1().hashString("foo", Charsets.US_ASCII).toString().toUpperCase();
- try {
- HashCode.fromString(string);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> HashCode.fromString(string));
}
public void testFromStringFailsWithShortInputs() {
- try {
- HashCode.fromString("");
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- HashCode.fromString("7");
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> HashCode.fromString(""));
+ assertThrows(IllegalArgumentException.class, () -> HashCode.fromString("7"));
HashCode unused = HashCode.fromString("7f");
}
public void testFromStringFailsWithOddLengthInput() {
- try {
- HashCode.fromString("7f8");
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> HashCode.fromString("7f8"));
}
public void testIntWriteBytesTo() {
@@ -316,20 +297,12 @@ public class HashCodeTest extends TestCase {
public void testWriteBytesToUndersizedArray() {
byte[] dest = new byte[3];
- try {
- HASH_ABCD.writeBytesTo(dest, 0, 4);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> HASH_ABCD.writeBytesTo(dest, 0, 4));
}
public void testWriteBytesToUndersizedArrayLongMaxLength() {
byte[] dest = new byte[3];
- try {
- HASH_ABCD.writeBytesTo(dest, 0, 5);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> HASH_ABCD.writeBytesTo(dest, 0, 5));
}
public void testWriteBytesToUndersizedArrayShortMaxLength() {
diff --git a/android/guava-tests/test/com/google/common/hash/HashingTest.java b/android/guava-tests/test/com/google/common/hash/HashingTest.java
index aff5c254f..e70219265 100644
--- a/android/guava-tests/test/com/google/common/hash/HashingTest.java
+++ b/android/guava-tests/test/com/google/common/hash/HashingTest.java
@@ -18,6 +18,7 @@ package com.google.common.hash;
import static com.google.common.base.Charsets.UTF_8;
import static java.util.Arrays.asList;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableTable;
@@ -219,11 +220,7 @@ public class HashingTest extends TestCase {
private static final int MAX_SHARDS = 500;
public void testConsistentHash_outOfRange() {
- try {
- Hashing.consistentHash(5L, 0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Hashing.consistentHash(5L, 0));
}
public void testConsistentHash_ofHashCode() {
@@ -260,20 +257,19 @@ public class HashingTest extends TestCase {
private static final long RANDOM_SEED = 177L;
public void testCombineOrdered_empty() {
- try {
- Hashing.combineOrdered(Collections.<HashCode>emptySet());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Hashing.combineOrdered(Collections.<HashCode>emptySet()));
}
public void testCombineOrdered_differentBitLengths() {
- try {
- HashCode unused =
- Hashing.combineOrdered(ImmutableList.of(HashCode.fromInt(32), HashCode.fromLong(32L)));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ HashCode unused =
+ Hashing.combineOrdered(
+ ImmutableList.of(HashCode.fromInt(32), HashCode.fromLong(32L)));
+ });
}
public void testCombineOrdered() {
@@ -305,20 +301,19 @@ public class HashingTest extends TestCase {
}
public void testCombineUnordered_empty() {
- try {
- Hashing.combineUnordered(Collections.<HashCode>emptySet());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Hashing.combineUnordered(Collections.<HashCode>emptySet()));
}
public void testCombineUnordered_differentBitLengths() {
- try {
- HashCode unused =
- Hashing.combineUnordered(ImmutableList.of(HashCode.fromInt(32), HashCode.fromLong(32L)));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ HashCode unused =
+ Hashing.combineUnordered(
+ ImmutableList.of(HashCode.fromInt(32), HashCode.fromLong(32L)));
+ });
}
public void testCombineUnordered() {
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 7783b5fc3..40c1f349e 100644
--- a/android/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java
+++ b/android/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java
@@ -18,6 +18,7 @@ package com.google.common.hash;
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.io.BaseEncoding.base16;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableTable;
@@ -225,11 +226,7 @@ public class MacHashFunctionTest extends TestCase {
assertEquals(
"9753980fe94daa8ecaa82216519393a9",
hasher.putString("The quick brown fox jumps over the lazy dog", UTF_8).hash().toString());
- try {
- hasher.putInt(42);
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> hasher.putInt(42));
}
public void testHashTwice() {
@@ -238,11 +235,7 @@ public class MacHashFunctionTest extends TestCase {
assertEquals(
"9753980fe94daa8ecaa82216519393a9",
hasher.putString("The quick brown fox jumps over the lazy dog", UTF_8).hash().toString());
- try {
- hasher.hash();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> hasher.hash());
}
public void testToString() {
diff --git a/android/guava-tests/test/com/google/common/hash/MessageDigestHashFunctionTest.java b/android/guava-tests/test/com/google/common/hash/MessageDigestHashFunctionTest.java
index 535d45521..922df28da 100644
--- a/android/guava-tests/test/com/google/common/hash/MessageDigestHashFunctionTest.java
+++ b/android/guava-tests/test/com/google/common/hash/MessageDigestHashFunctionTest.java
@@ -16,6 +16,8 @@
package com.google.common.hash;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -65,11 +67,7 @@ public class MessageDigestHashFunctionTest extends TestCase {
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
.toString());
- try {
- sha1.putInt(42);
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> sha1.putInt(42));
}
public void testHashTwice() {
@@ -80,11 +78,7 @@ public class MessageDigestHashFunctionTest extends TestCase {
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
.toString());
- try {
- sha1.hash();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> sha1.hash());
}
public void testToString() {
diff --git a/android/guava-tests/test/com/google/common/io/AppendableWriterTest.java b/android/guava-tests/test/com/google/common/io/AppendableWriterTest.java
index dd0408362..bfc6a082f 100644
--- a/android/guava-tests/test/com/google/common/io/AppendableWriterTest.java
+++ b/android/guava-tests/test/com/google/common/io/AppendableWriterTest.java
@@ -16,6 +16,8 @@
package com.google.common.io;
+import static org.junit.Assert.assertThrows;
+
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
@@ -113,17 +115,9 @@ public class AppendableWriterTest extends IoTestCase {
writer.write("Hi");
writer.close();
- try {
- writer.write(" Greg");
- fail("Should have thrown IOException due to writer already closed");
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> writer.write(" Greg"));
- try {
- writer.flush();
- fail("Should have thrown IOException due to writer already closed");
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> writer.flush());
// close()ing already closed writer is allowed
writer.close();
diff --git a/android/guava-tests/test/com/google/common/io/ByteSinkTest.java b/android/guava-tests/test/com/google/common/io/ByteSinkTest.java
index 208a8fc5e..4ce3981c0 100644
--- a/android/guava-tests/test/com/google/common/io/ByteSinkTest.java
+++ b/android/guava-tests/test/com/google/common/io/ByteSinkTest.java
@@ -21,6 +21,7 @@ import static com.google.common.io.TestOption.OPEN_THROWS;
import static com.google.common.io.TestOption.READ_THROWS;
import static com.google.common.io.TestOption.WRITE_THROWS;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertThrows;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -82,11 +83,7 @@ public class ByteSinkTest extends IoTestCase {
for (TestOption option : EnumSet.of(OPEN_THROWS, READ_THROWS, CLOSE_THROWS)) {
TestByteSource failSource = new TestByteSource(new byte[10], option);
TestByteSink okSink = new TestByteSink();
- try {
- failSource.copyTo(okSink);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> failSource.copyTo(okSink));
// ensure stream was closed IF it was opened (depends on implementation whether or not it's
// opened at all if source.newInputStream() throws).
assertTrue(
@@ -97,22 +94,14 @@ public class ByteSinkTest extends IoTestCase {
public void testClosesOnErrors_whenWriteThrows() {
TestByteSink failSink = new TestByteSink(WRITE_THROWS);
- try {
- new TestByteSource(new byte[10]).copyTo(failSink);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> new TestByteSource(new byte[10]).copyTo(failSink));
assertTrue(failSink.wasStreamClosed());
}
- public void testClosesOnErrors_writingFromInputStreamThatThrows() {
+ public void testClosesOnErrors_writingFromInputStreamThatThrows() throws IOException {
TestByteSink okSink = new TestByteSink();
- try {
- TestInputStream in = new TestInputStream(new ByteArrayInputStream(new byte[10]), READ_THROWS);
- okSink.writeFrom(in);
- fail();
- } catch (IOException expected) {
- }
+ TestInputStream in = new TestInputStream(new ByteArrayInputStream(new byte[10]), READ_THROWS);
+ assertThrows(IOException.class, () -> okSink.writeFrom(in));
assertTrue(okSink.wasStreamClosed());
}
}
diff --git a/android/guava-tests/test/com/google/common/io/ByteSourceTest.java b/android/guava-tests/test/com/google/common/io/ByteSourceTest.java
index 58ad653c2..078b0f98b 100644
--- a/android/guava-tests/test/com/google/common/io/ByteSourceTest.java
+++ b/android/guava-tests/test/com/google/common/io/ByteSourceTest.java
@@ -24,6 +24,7 @@ import static com.google.common.io.TestOption.READ_THROWS;
import static com.google.common.io.TestOption.SKIP_THROWS;
import static com.google.common.io.TestOption.WRITE_THROWS;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
@@ -199,17 +200,9 @@ public class ByteSourceTest extends IoTestCase {
public void testSlice() throws IOException {
// Test preconditions
- try {
- source.slice(-1, 10);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> source.slice(-1, 10));
- try {
- source.slice(0, -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> source.slice(0, -1));
assertCorrectSlice(0, 0, 0, 0);
assertCorrectSlice(0, 0, 1, 0);
@@ -320,11 +313,7 @@ public class ByteSourceTest extends IoTestCase {
public void testClosesOnErrors_copyingToByteSinkThatThrows() {
for (TestOption option : EnumSet.of(OPEN_THROWS, WRITE_THROWS, CLOSE_THROWS)) {
TestByteSource okSource = new TestByteSource(bytes);
- try {
- okSource.copyTo(new TestByteSink(option));
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> okSource.copyTo(new TestByteSink(option)));
// ensure stream was closed IF it was opened (depends on implementation whether or not it's
// opened at all if sink.newOutputStream() throws).
assertTrue(
@@ -335,22 +324,14 @@ public class ByteSourceTest extends IoTestCase {
public void testClosesOnErrors_whenReadThrows() {
TestByteSource failSource = new TestByteSource(bytes, READ_THROWS);
- try {
- failSource.copyTo(new TestByteSink());
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> failSource.copyTo(new TestByteSink()));
assertTrue(failSource.wasStreamClosed());
}
- public void testClosesOnErrors_copyingToOutputStreamThatThrows() {
+ public void testClosesOnErrors_copyingToOutputStreamThatThrows() throws IOException {
TestByteSource okSource = new TestByteSource(bytes);
- try {
- OutputStream out = new TestOutputStream(ByteStreams.nullOutputStream(), WRITE_THROWS);
- okSource.copyTo(out);
- fail();
- } catch (IOException expected) {
- }
+ OutputStream out = new TestOutputStream(ByteStreams.nullOutputStream(), WRITE_THROWS);
+ assertThrows(IOException.class, () -> okSource.copyTo(out));
assertTrue(okSource.wasStreamClosed());
}
diff --git a/android/guava-tests/test/com/google/common/io/ByteSourceTester.java b/android/guava-tests/test/com/google/common/io/ByteSourceTester.java
index fe10810f6..187c2d00a 100644
--- a/android/guava-tests/test/com/google/common/io/ByteSourceTester.java
+++ b/android/guava-tests/test/com/google/common/io/ByteSourceTester.java
@@ -19,6 +19,7 @@ package com.google.common.io;
import static com.google.common.io.SourceSinkFactory.ByteSourceFactory;
import static com.google.common.io.SourceSinkFactory.CharSourceFactory;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Charsets;
import com.google.common.base.Optional;
@@ -219,17 +220,15 @@ public class ByteSourceTester extends SourceSinkTester<ByteSource, byte[], ByteS
}
public void testSlice_illegalArguments() {
- try {
- source.slice(-1, 0);
- fail("expected IllegalArgumentException for call to slice with offset -1: " + source);
- } catch (IllegalArgumentException expected) {
- }
-
- try {
- source.slice(0, -1);
- fail("expected IllegalArgumentException for call to slice with length -1: " + source);
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ "expected IllegalArgumentException for call to slice with offset -1: " + source,
+ IllegalArgumentException.class,
+ () -> source.slice(-1, 0));
+
+ assertThrows(
+ "expected IllegalArgumentException for call to slice with length -1: " + source,
+ IllegalArgumentException.class,
+ () -> source.slice(0, -1));
}
// Test that you can not expand the readable data in a previously sliced ByteSource.
diff --git a/android/guava-tests/test/com/google/common/io/ByteStreamsTest.java b/android/guava-tests/test/com/google/common/io/ByteStreamsTest.java
index 2598b9fed..cd8332c21 100644
--- a/android/guava-tests/test/com/google/common/io/ByteStreamsTest.java
+++ b/android/guava-tests/test/com/google/common/io/ByteStreamsTest.java
@@ -17,6 +17,7 @@
package com.google.common.io;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Charsets;
import java.io.ByteArrayInputStream;
@@ -76,47 +77,24 @@ public class ByteStreamsTest extends IoTestCase {
public void testReadFully() throws IOException {
byte[] b = new byte[10];
- try {
- ByteStreams.readFully(newTestStream(10), null, 0, 10);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(
+ NullPointerException.class, () -> ByteStreams.readFully(newTestStream(10), null, 0, 10));
- try {
- ByteStreams.readFully(null, b, 0, 10);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ByteStreams.readFully(null, b, 0, 10));
- try {
- ByteStreams.readFully(newTestStream(10), b, -1, 10);
- fail("expected exception");
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(
+ IndexOutOfBoundsException.class, () -> ByteStreams.readFully(newTestStream(10), b, -1, 10));
- try {
- ByteStreams.readFully(newTestStream(10), b, 0, -1);
- fail("expected exception");
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(
+ IndexOutOfBoundsException.class, () -> ByteStreams.readFully(newTestStream(10), b, 0, -1));
- try {
- ByteStreams.readFully(newTestStream(10), b, 0, -1);
- fail("expected exception");
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(
+ IndexOutOfBoundsException.class, () -> ByteStreams.readFully(newTestStream(10), b, 0, -1));
- try {
- ByteStreams.readFully(newTestStream(10), b, 2, 10);
- fail("expected exception");
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(
+ IndexOutOfBoundsException.class, () -> ByteStreams.readFully(newTestStream(10), b, 2, 10));
- try {
- ByteStreams.readFully(newTestStream(5), b, 0, 10);
- fail("expected exception");
- } catch (EOFException expected) {
- }
+ assertThrows(EOFException.class, () -> ByteStreams.readFully(newTestStream(5), b, 0, 10));
Arrays.fill(b, (byte) 0);
ByteStreams.readFully(newTestStream(10), b, 0, 0);
@@ -138,11 +116,7 @@ public class ByteStreamsTest extends IoTestCase {
skipHelper(50, 50, new SlowSkipper(new ByteArrayInputStream(bytes), 1));
skipHelper(50, 50, new SlowSkipper(new ByteArrayInputStream(bytes), 0));
skipHelper(100, -1, new ByteArrayInputStream(bytes));
- try {
- skipHelper(101, 0, new ByteArrayInputStream(bytes));
- fail("expected exception");
- } catch (EOFException expected) {
- }
+ assertThrows(EOFException.class, () -> skipHelper(101, 0, new ByteArrayInputStream(bytes)));
}
private static void skipHelper(long n, int expect, InputStream in) throws IOException {
@@ -156,22 +130,14 @@ public class ByteStreamsTest extends IoTestCase {
public void testNewDataInput_empty() {
byte[] b = new byte[0];
ByteArrayDataInput in = ByteStreams.newDataInput(b);
- try {
- in.readInt();
- fail("expected exception");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> in.readInt());
}
public void testNewDataInput_normal() {
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
assertEquals(0x12345678, in.readInt());
assertEquals(0x76543210, in.readInt());
- try {
- in.readInt();
- fail("expected exception");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> in.readInt());
}
public void testNewDataInput_readFully() {
@@ -184,12 +150,9 @@ public class ByteStreamsTest extends IoTestCase {
public void testNewDataInput_readFullyAndThenSome() {
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
byte[] actual = new byte[bytes.length * 2];
- try {
- in.readFully(actual);
- fail("expected exception");
- } catch (IllegalStateException ex) {
- assertThat(ex).hasCauseThat().isInstanceOf(EOFException.class);
- }
+ IllegalStateException ex =
+ assertThrows(IllegalStateException.class, () -> in.readFully(actual));
+ assertThat(ex).hasCauseThat().isInstanceOf(EOFException.class);
}
public void testNewDataInput_readFullyWithOffset() {
@@ -266,12 +229,8 @@ public class ByteStreamsTest extends IoTestCase {
for (byte aByte : bytes) {
assertEquals(aByte, in.readByte());
}
- try {
- in.readByte();
- fail("expected exception");
- } catch (IllegalStateException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(EOFException.class);
- }
+ IllegalStateException expected = assertThrows(IllegalStateException.class, () -> in.readByte());
+ assertThat(expected).hasCauseThat().isInstanceOf(EOFException.class);
}
public void testNewDataInput_readUnsignedByte() {
@@ -279,22 +238,15 @@ public class ByteStreamsTest extends IoTestCase {
for (byte aByte : bytes) {
assertEquals(aByte, in.readUnsignedByte());
}
- try {
- in.readUnsignedByte();
- fail("expected exception");
- } catch (IllegalStateException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(EOFException.class);
- }
+ IllegalStateException expected =
+ assertThrows(IllegalStateException.class, () -> in.readUnsignedByte());
+ assertThat(expected).hasCauseThat().isInstanceOf(EOFException.class);
}
public void testNewDataInput_offset() {
ByteArrayDataInput in = ByteStreams.newDataInput(bytes, 2);
assertEquals(0x56787654, in.readInt());
- try {
- in.readInt();
- fail("expected exception");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> in.readInt());
}
public void testNewDataInput_skip() {
@@ -572,37 +524,13 @@ public class ByteStreamsTest extends IoTestCase {
public void testNullOutputStream_exceptions() throws Exception {
OutputStream nos = ByteStreams.nullOutputStream();
- try {
- nos.write(null);
- fail();
- } catch (NullPointerException expected) {
- }
- try {
- nos.write(null, 0, 1);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> nos.write(null));
+ assertThrows(NullPointerException.class, () -> nos.write(null, 0, 1));
byte[] tenBytes = new byte[10];
- try {
- nos.write(tenBytes, -1, 1);
- fail("Expected exception from negative offset");
- } catch (IndexOutOfBoundsException expected) {
- }
- try {
- nos.write(tenBytes, 1, -1);
- fail("Expected exception from negative length");
- } catch (IndexOutOfBoundsException expected) {
- }
- try {
- nos.write(tenBytes, 9, 2);
- fail("Expected exception from offset+length > array size");
- } catch (IndexOutOfBoundsException expected) {
- }
- try {
- nos.write(tenBytes, 9, 100);
- fail("Expected exception from offset+length > array size");
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> nos.write(tenBytes, -1, 1));
+ assertThrows(IndexOutOfBoundsException.class, () -> nos.write(tenBytes, 1, -1));
+ assertThrows(IndexOutOfBoundsException.class, () -> nos.write(tenBytes, 9, 2));
+ assertThrows(IndexOutOfBoundsException.class, () -> nos.write(tenBytes, 9, 100));
}
public void testLimit() throws Exception {
@@ -679,23 +607,15 @@ public class ByteStreamsTest extends IoTestCase {
InputStream bin = new ByteArrayInputStream(big);
InputStream lin = ByteStreams.limit(bin, 2);
- try {
- lin.reset();
- fail();
- } catch (IOException expected) {
- assertThat(expected).hasMessageThat().isEqualTo("Mark not set");
- }
+ IOException expected = assertThrows(IOException.class, () -> lin.reset());
+ assertThat(expected).hasMessageThat().isEqualTo("Mark not set");
}
public void testLimit_markNotSupported() {
InputStream lin = ByteStreams.limit(new UnmarkableInputStream(), 2);
- try {
- lin.reset();
- fail();
- } catch (IOException expected) {
- assertThat(expected).hasMessageThat().isEqualTo("Mark not supported");
- }
+ IOException expected = assertThrows(IOException.class, () -> lin.reset());
+ assertThat(expected).hasMessageThat().isEqualTo("Mark not supported");
}
private static class UnmarkableInputStream extends InputStream {
diff --git a/android/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java b/android/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java
index dbe94fcf7..6a4b3c472 100644
--- a/android/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java
+++ b/android/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java
@@ -16,6 +16,8 @@
package com.google.common.io;
+import static org.junit.Assert.assertThrows;
+
import java.io.IOException;
import java.nio.CharBuffer;
import junit.framework.TestCase;
@@ -73,106 +75,42 @@ public class CharSequenceReaderTest extends TestCase {
CharSequenceReader reader = new CharSequenceReader("12345");
char[] buf = new char[10];
- try {
- reader.read(buf, 0, 11);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> reader.read(buf, 0, 11));
- try {
- reader.read(buf, 10, 1);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> reader.read(buf, 10, 1));
- try {
- reader.read(buf, 11, 0);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> reader.read(buf, 11, 0));
- try {
- reader.read(buf, -1, 5);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> reader.read(buf, -1, 5));
- try {
- reader.read(buf, 5, -1);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> reader.read(buf, 5, -1));
- try {
- reader.read(buf, 0, 11);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> reader.read(buf, 0, 11));
- try {
- reader.skip(-1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> reader.skip(-1));
- try {
- reader.mark(-1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> reader.mark(-1));
}
public void testMethodsThrowWhenClosed() throws IOException {
CharSequenceReader reader = new CharSequenceReader("");
reader.close();
- try {
- reader.read();
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.read());
- try {
- reader.read(new char[10]);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.read(new char[10]));
- try {
- reader.read(new char[10], 0, 10);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.read(new char[10], 0, 10));
- try {
- reader.read(CharBuffer.allocate(10));
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.read(CharBuffer.allocate(10)));
- try {
- reader.skip(10);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.skip(10));
- try {
- reader.ready();
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.ready());
- try {
- reader.mark(10);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.mark(10));
- try {
- reader.reset();
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.reset());
}
/**
diff --git a/android/guava-tests/test/com/google/common/io/CharSinkTest.java b/android/guava-tests/test/com/google/common/io/CharSinkTest.java
index ac96d9064..42c84eea0 100644
--- a/android/guava-tests/test/com/google/common/io/CharSinkTest.java
+++ b/android/guava-tests/test/com/google/common/io/CharSinkTest.java
@@ -20,6 +20,7 @@ import static com.google.common.io.TestOption.CLOSE_THROWS;
import static com.google.common.io.TestOption.OPEN_THROWS;
import static com.google.common.io.TestOption.READ_THROWS;
import static com.google.common.io.TestOption.WRITE_THROWS;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
@@ -93,11 +94,7 @@ public class CharSinkTest extends IoTestCase {
for (TestOption option : EnumSet.of(OPEN_THROWS, READ_THROWS, CLOSE_THROWS)) {
TestCharSource failSource = new TestCharSource(STRING, option);
TestCharSink okSink = new TestCharSink();
- try {
- failSource.copyTo(okSink);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> failSource.copyTo(okSink));
// ensure writer was closed IF it was opened (depends on implementation whether or not it's
// opened at all if source.newReader() throws).
assertTrue(
@@ -108,21 +105,13 @@ public class CharSinkTest extends IoTestCase {
public void testClosesOnErrors_whenWriteThrows() {
TestCharSink failSink = new TestCharSink(WRITE_THROWS);
- try {
- new TestCharSource(STRING).copyTo(failSink);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> new TestCharSource(STRING).copyTo(failSink));
assertTrue(failSink.wasStreamClosed());
}
public void testClosesOnErrors_whenWritingFromReaderThatThrows() {
TestCharSink okSink = new TestCharSink();
- try {
- okSink.writeFrom(new TestReader(READ_THROWS));
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> okSink.writeFrom(new TestReader(READ_THROWS)));
assertTrue(okSink.wasStreamClosed());
}
}
diff --git a/android/guava-tests/test/com/google/common/io/CharSourceTest.java b/android/guava-tests/test/com/google/common/io/CharSourceTest.java
index 6cc210b56..a55ff4751 100644
--- a/android/guava-tests/test/com/google/common/io/CharSourceTest.java
+++ b/android/guava-tests/test/com/google/common/io/CharSourceTest.java
@@ -20,6 +20,7 @@ import static com.google.common.io.TestOption.CLOSE_THROWS;
import static com.google.common.io.TestOption.OPEN_THROWS;
import static com.google.common.io.TestOption.READ_THROWS;
import static com.google.common.io.TestOption.WRITE_THROWS;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -180,11 +181,7 @@ public class CharSourceTest extends IoTestCase {
public void testClosesOnErrors_copyingToCharSinkThatThrows() {
for (TestOption option : EnumSet.of(OPEN_THROWS, WRITE_THROWS, CLOSE_THROWS)) {
TestCharSource okSource = new TestCharSource(STRING);
- try {
- okSource.copyTo(new TestCharSink(option));
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> okSource.copyTo(new TestCharSink(option)));
// ensure reader was closed IF it was opened (depends on implementation whether or not it's
// opened at all if sink.newWriter() throws).
assertTrue(
@@ -195,21 +192,13 @@ public class CharSourceTest extends IoTestCase {
public void testClosesOnErrors_whenReadThrows() {
TestCharSource failSource = new TestCharSource(STRING, READ_THROWS);
- try {
- failSource.copyTo(new TestCharSink());
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> failSource.copyTo(new TestCharSink()));
assertTrue(failSource.wasStreamClosed());
}
public void testClosesOnErrors_copyingToWriterThatThrows() {
TestCharSource okSource = new TestCharSource(STRING);
- try {
- okSource.copyTo(new TestWriter(WRITE_THROWS));
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> okSource.copyTo(new TestWriter(WRITE_THROWS)));
assertTrue(okSource.wasStreamClosed());
}
@@ -332,7 +321,9 @@ public class CharSourceTest extends IoTestCase {
}
}
- /** @return the number of exceptions that were suppressed on the expected thrown exception */
+ /**
+ * @return the number of exceptions that were suppressed on the expected thrown exception
+ */
private static int runSuppressionFailureTest(CharSource in, CharSink out) {
try {
in.copyTo(out);
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 9b2c24e28..ea5e51c29 100644
--- a/android/guava-tests/test/com/google/common/io/CharStreamsTest.java
+++ b/android/guava-tests/test/com/google/common/io/CharStreamsTest.java
@@ -16,6 +16,8 @@
package com.google.common.io;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import java.io.EOFException;
@@ -118,11 +120,7 @@ public class CharStreamsTest extends IoTestCase {
public void testSkipFully_EOF() throws IOException {
Reader reader = new StringReader("abcde");
- try {
- CharStreams.skipFully(reader, 6);
- fail("expected EOFException");
- } catch (EOFException expected) {
- }
+ assertThrows(EOFException.class, () -> CharStreams.skipFully(reader, 6));
}
public void testSkipFully() throws IOException {
@@ -270,17 +268,9 @@ public class CharStreamsTest extends IoTestCase {
nullWriter.append(null);
nullWriter.append(null, 0, 4);
- try {
- nullWriter.append(null, -1, 4);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
-
- try {
- nullWriter.append(null, 0, 5);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> nullWriter.append(null, -1, 4));
+
+ assertThrows(IndexOutOfBoundsException.class, () -> nullWriter.append(null, 0, 5));
// nothing really to assert?
assertSame(CharStreams.nullWriter(), CharStreams.nullWriter());
diff --git a/android/guava-tests/test/com/google/common/io/CountingInputStreamTest.java b/android/guava-tests/test/com/google/common/io/CountingInputStreamTest.java
index 163027b49..945f5d023 100644
--- a/android/guava-tests/test/com/google/common/io/CountingInputStreamTest.java
+++ b/android/guava-tests/test/com/google/common/io/CountingInputStreamTest.java
@@ -17,6 +17,7 @@
package com.google.common.io;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -90,23 +91,15 @@ public class CountingInputStreamTest extends IoTestCase {
}
public void testMarkNotSet() {
- try {
- counter.reset();
- fail();
- } catch (IOException expected) {
- assertThat(expected).hasMessageThat().isEqualTo("Mark not set");
- }
+ IOException expected = assertThrows(IOException.class, () -> counter.reset());
+ assertThat(expected).hasMessageThat().isEqualTo("Mark not set");
}
public void testMarkNotSupported() {
counter = new CountingInputStream(new UnmarkableInputStream());
- try {
- counter.reset();
- fail();
- } catch (IOException expected) {
- assertThat(expected).hasMessageThat().isEqualTo("Mark not supported");
- }
+ IOException expected = assertThrows(IOException.class, () -> counter.reset());
+ assertThat(expected).hasMessageThat().isEqualTo("Mark not supported");
}
private static class UnmarkableInputStream extends InputStream {
diff --git a/android/guava-tests/test/com/google/common/io/CountingOutputStreamTest.java b/android/guava-tests/test/com/google/common/io/CountingOutputStreamTest.java
index 870692b32..d5023492b 100644
--- a/android/guava-tests/test/com/google/common/io/CountingOutputStreamTest.java
+++ b/android/guava-tests/test/com/google/common/io/CountingOutputStreamTest.java
@@ -16,6 +16,8 @@
package com.google.common.io;
+import static org.junit.Assert.assertThrows;
+
import java.io.ByteArrayOutputStream;
/**
@@ -54,11 +56,7 @@ public class CountingOutputStreamTest extends IoTestCase {
assertEquals(written, counter.getCount());
// Test that illegal arguments do not affect count
- try {
- counter.write(data, 0, data.length + 1);
- fail("expected exception");
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> counter.write(data, 0, data.length + 1));
assertEquals(written, out.size());
assertEquals(written, counter.getCount());
}
diff --git a/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java b/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java
index 3d756a88b..daf47a6f4 100644
--- a/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java
+++ b/android/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java
@@ -137,11 +137,7 @@ public class FileBackedOutputStreamTest extends IoTestCase {
assertTrue(Arrays.equals(data, source.read()));
out.close();
- try {
- out.write(42);
- fail("expected exception");
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> out.write(42));
// Verify that write had no effect
assertTrue(Arrays.equals(data, source.read()));
diff --git a/android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java b/android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java
index a31c43770..381eef258 100644
--- a/android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java
+++ b/android/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java
@@ -17,6 +17,7 @@
package com.google.common.io;
import static com.google.common.base.StandardSystemProperty.JAVA_IO_TMPDIR;
+import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.truth.Truth.assertThat;
import static java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE;
@@ -64,6 +65,44 @@ public class FilesCreateTempDirTest extends TestCase {
}
}
+ public void testBogusSystemPropertiesUsername() {
+ if (isAndroid()) {
+ /*
+ * The test calls directly into the "ACL-based filesystem" code, which isn't available under
+ * old versions of Android. Since Android doesn't use that code path, anyway, there's no need
+ * to test it.
+ */
+ return;
+ }
+
+ /*
+ * Only under Windows (or hypothetically when running with some other non-POSIX, ACL-based
+ * filesystem) does our prod code look up the username. Thus, this test doesn't necessarily test
+ * anything interesting under most environments. Still, we can run it (except for Android, at
+ * least old versions), so we mostly do. This is useful because we don't actually run our CI on
+ * Windows under Java 8, at least as of this writing.
+ *
+ * Under Windows in particular, we want to test that:
+ *
+ * - Under Java 9+, createTempDir() succeeds because it can look up the *real* username, rather
+ * than relying on the one from the system property.
+ *
+ * - Under Java 8, createTempDir() fails because it falls back to the bogus username from the
+ * system property.
+ */
+
+ String save = System.getProperty("user.name");
+ System.setProperty("user.name", "-this-is-definitely-not-the-username-we-are-running-as//?");
+ try {
+ TempFileCreator.testMakingUserPermissionsFromScratch();
+ assertThat(isJava8()).isFalse();
+ } catch (IOException expectedIfJava8) {
+ assertThat(isJava8()).isTrue();
+ } finally {
+ System.setProperty("user.name", save);
+ }
+ }
+
private static boolean isAndroid() {
return System.getProperty("java.runtime.name", "").contains("Android");
}
@@ -71,4 +110,8 @@ public class FilesCreateTempDirTest extends TestCase {
private static boolean isWindows() {
return OS_NAME.value().startsWith("Windows");
}
+
+ private static boolean isJava8() {
+ return JAVA_SPECIFICATION_VERSION.value().equals("1.8");
+ }
}
diff --git a/android/guava-tests/test/com/google/common/io/FilesTest.java b/android/guava-tests/test/com/google/common/io/FilesTest.java
index 6ffcf5c81..abe2c4e25 100644
--- a/android/guava-tests/test/com/google/common/io/FilesTest.java
+++ b/android/guava-tests/test/com/google/common/io/FilesTest.java
@@ -17,6 +17,7 @@
package com.google.common.io;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
@@ -133,11 +134,7 @@ public class FilesTest extends IoTestCase {
Files.write(data, temp);
assertTrue(Arrays.equals(data, Files.toByteArray(temp)));
- try {
- Files.write(null, temp);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Files.write(null, temp));
}
public void testAppendString() throws IOException {
@@ -176,22 +173,14 @@ public class FilesTest extends IoTestCase {
File temp2 = file(temp1.getPath());
assertEquals(temp1, temp2);
Files.write(ASCII, temp1, Charsets.UTF_8);
- try {
- Files.copy(temp1, temp2);
- fail("Expected an IAE to be thrown but wasn't");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Files.copy(temp1, temp2));
assertEquals(ASCII, Files.toString(temp1, Charsets.UTF_8));
}
public void testCopySameFile() throws IOException {
File temp = createTempFile();
Files.write(ASCII, temp, Charsets.UTF_8);
- try {
- Files.copy(temp, temp);
- fail("Expected an IAE to be thrown but wasn't");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Files.copy(temp, temp));
assertEquals(ASCII, Files.toString(temp, Charsets.UTF_8));
}
@@ -232,17 +221,9 @@ public class FilesTest extends IoTestCase {
public void testNewReader() throws IOException {
File asciiFile = getTestFile("ascii.txt");
- try {
- Files.newReader(asciiFile, null);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Files.newReader(asciiFile, null));
- try {
- Files.newReader(null, Charsets.UTF_8);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Files.newReader(null, Charsets.UTF_8));
BufferedReader r = Files.newReader(asciiFile, Charsets.US_ASCII);
try {
@@ -254,17 +235,9 @@ public class FilesTest extends IoTestCase {
public void testNewWriter() throws IOException {
File temp = createTempFile();
- try {
- Files.newWriter(temp, null);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Files.newWriter(temp, null));
- try {
- Files.newWriter(null, Charsets.UTF_8);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Files.newWriter(null, Charsets.UTF_8));
BufferedWriter w = Files.newWriter(temp, Charsets.UTF_8);
try {
@@ -287,19 +260,18 @@ public class FilesTest extends IoTestCase {
Files.touch(temp);
assertTrue(temp.exists());
- try {
- Files.touch(
- new File(temp.getPath()) {
- @Override
- public boolean setLastModified(long t) {
- return false;
- }
+ assertThrows(
+ IOException.class,
+ () ->
+ Files.touch(
+ new File(temp.getPath()) {
+ @Override
+ public boolean setLastModified(long t) {
+ return false;
+ }
- private static final long serialVersionUID = 0;
- });
- fail("expected exception");
- } catch (IOException expected) {
- }
+ private static final long serialVersionUID = 0;
+ }));
}
public void testTouchTime() throws IOException {
@@ -356,11 +328,7 @@ public class FilesTest extends IoTestCase {
File parent = getTestFile("ascii.txt");
assertTrue(parent.isFile());
File file = file(parent, "foo");
- try {
- Files.createParentDirs(file);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> Files.createParentDirs(file));
}
public void testMove() throws IOException {
@@ -391,12 +359,8 @@ public class FilesTest extends IoTestCase {
moveHelper(
false, new UnmovableFile(temp1, false, false), new UnmovableFile(temp2, true, false));
- try {
- File asciiFile = getTestFile("ascii.txt");
- moveHelper(false, asciiFile, asciiFile);
- fail("expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ File asciiFile = getTestFile("ascii.txt");
+ assertThrows(IllegalArgumentException.class, () -> moveHelper(false, asciiFile, asciiFile));
}
private void moveHelper(boolean success, File from, File to) throws IOException {
@@ -547,11 +511,7 @@ public class FilesTest extends IoTestCase {
assertTrue(deleted);
// Test
- try {
- Files.map(file);
- fail("Should have thrown FileNotFoundException.");
- } catch (FileNotFoundException expected) {
- }
+ assertThrows(FileNotFoundException.class, () -> Files.map(file));
}
public void testMap_readWrite() throws IOException {
@@ -603,11 +563,9 @@ public class FilesTest extends IoTestCase {
// Setup
File file = createTempFile();
// Test
- try {
- Files.map(file, MapMode.READ_WRITE, (long) Integer.MAX_VALUE + 1);
- fail("Should throw when size exceeds Integer.MAX_VALUE");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Files.map(file, MapMode.READ_WRITE, (long) Integer.MAX_VALUE + 1));
}
public void testGetFileExtension() {
diff --git a/android/guava-tests/test/com/google/common/io/LittleEndianDataInputStreamTest.java b/android/guava-tests/test/com/google/common/io/LittleEndianDataInputStreamTest.java
index 160df410b..faa0b9549 100644
--- a/android/guava-tests/test/com/google/common/io/LittleEndianDataInputStreamTest.java
+++ b/android/guava-tests/test/com/google/common/io/LittleEndianDataInputStreamTest.java
@@ -17,6 +17,7 @@
package com.google.common.io;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.primitives.Bytes;
import java.io.ByteArrayInputStream;
@@ -75,32 +76,21 @@ public class LittleEndianDataInputStreamTest extends TestCase {
public void testReadUnsignedByte_eof() throws IOException {
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(new byte[0]));
- try {
- in.readUnsignedByte();
- fail();
- } catch (EOFException expected) {
- }
+ assertThrows(EOFException.class, () -> in.readUnsignedByte());
}
public void testReadUnsignedShort_eof() throws IOException {
byte[] buf = {23};
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(buf));
- try {
- in.readUnsignedShort();
- fail();
- } catch (EOFException expected) {
- }
+ assertThrows(EOFException.class, () -> in.readUnsignedShort());
}
@SuppressWarnings("DoNotCall")
public void testReadLine() throws IOException {
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(data));
- try {
- in.readLine();
- fail();
- } catch (UnsupportedOperationException expected) {
- assertThat(expected).hasMessageThat().isEqualTo("readLine is not supported");
- }
+ UnsupportedOperationException expected =
+ assertThrows(UnsupportedOperationException.class, () -> in.readLine());
+ assertThat(expected).hasMessageThat().isEqualTo("readLine is not supported");
}
public void testReadLittleEndian() throws IOException {
diff --git a/android/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java b/android/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
index 94ab1f016..699b2a458 100644
--- a/android/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
+++ b/android/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
@@ -16,6 +16,8 @@
package com.google.common.io;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.testing.NullPointerTester;
import com.google.common.testing.NullPointerTester.Visibility;
import java.io.File;
@@ -31,11 +33,7 @@ import junit.framework.TestCase;
public class PatternFilenameFilterTest extends TestCase {
public void testSyntaxException() {
- try {
- new PatternFilenameFilter("(");
- fail("expected exception");
- } catch (PatternSyntaxException expected) {
- }
+ assertThrows(PatternSyntaxException.class, () -> new PatternFilenameFilter("("));
}
public void testAccept() {
diff --git a/android/guava-tests/test/com/google/common/io/ResourcesTest.java b/android/guava-tests/test/com/google/common/io/ResourcesTest.java
index b1a46c698..4344ed1ca 100644
--- a/android/guava-tests/test/com/google/common/io/ResourcesTest.java
+++ b/android/guava-tests/test/com/google/common/io/ResourcesTest.java
@@ -18,6 +18,7 @@ package com.google.common.io;
import static com.google.common.base.CharMatcher.whitespace;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
@@ -104,12 +105,10 @@ public class ResourcesTest extends IoTestCase {
}
public void testGetResource_notFound() {
- try {
- Resources.getResource("no such resource");
- fail();
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().isEqualTo("resource no such resource not found.");
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> Resources.getResource("no such resource"));
+ assertThat(e).hasMessageThat().isEqualTo("resource no such resource not found.");
}
public void testGetResource() {
@@ -117,16 +116,15 @@ public class ResourcesTest extends IoTestCase {
}
public void testGetResource_relativePath_notFound() {
- try {
- Resources.getResource(getClass(), "com/google/common/io/testdata/i18n.txt");
- fail();
- } catch (IllegalArgumentException e) {
- assertThat(e)
- .hasMessageThat()
- .isEqualTo(
- "resource com/google/common/io/testdata/i18n.txt"
- + " relative to com.google.common.io.ResourcesTest not found.");
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Resources.getResource(getClass(), "com/google/common/io/testdata/i18n.txt"));
+ assertThat(e)
+ .hasMessageThat()
+ .isEqualTo(
+ "resource com/google/common/io/testdata/i18n.txt"
+ + " relative to com.google.common.io.ResourcesTest not found.");
}
public void testGetResource_relativePath() {
@@ -145,11 +143,7 @@ public class ResourcesTest extends IoTestCase {
// First check that we can't find it without setting the context loader.
// This is a sanity check that the test doesn't spuriously pass because
// the resource is visible to the system class loader.
- try {
- Resources.getResource(tempFile.getName());
- fail("Should get IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Resources.getResource(tempFile.getName()));
// Now set the context loader to one that should find the resource.
URL baseUrl = tempFile.getParentFile().toURI().toURL();
@@ -170,11 +164,7 @@ public class ResourcesTest extends IoTestCase {
try {
Thread.currentThread().setContextClassLoader(null);
assertNotNull(Resources.getResource("com/google/common/io/testdata/i18n.txt"));
- try {
- Resources.getResource("no such resource");
- fail("Should get IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Resources.getResource("no such resource"));
} finally {
Thread.currentThread().setContextClassLoader(oldContextLoader);
}
diff --git a/android/guava-tests/test/com/google/common/math/BigDecimalMathTest.java b/android/guava-tests/test/com/google/common/math/BigDecimalMathTest.java
index ff86fd52f..b200a3840 100644
--- a/android/guava-tests/test/com/google/common/math/BigDecimalMathTest.java
+++ b/android/guava-tests/test/com/google/common/math/BigDecimalMathTest.java
@@ -25,6 +25,7 @@ import static java.math.RoundingMode.HALF_UP;
import static java.math.RoundingMode.UNNECESSARY;
import static java.math.RoundingMode.UP;
import static java.math.RoundingMode.values;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import java.math.BigDecimal;
@@ -76,12 +77,10 @@ public class BigDecimalMathTest extends TestCase {
assertWithMessage("Expected roundUnnecessaryShouldThrow call")
.that(unnecessaryShouldThrow)
.isTrue();
- try {
- BigDecimalMath.roundToDouble(input, UNNECESSARY);
- fail("Expected ArithmeticException for roundToDouble(" + input + ", UNNECESSARY)");
- } catch (ArithmeticException expected) {
- // expected
- }
+ assertThrows(
+ "Expected ArithmeticException for roundToDouble(" + input + ", UNNECESSARY)",
+ ArithmeticException.class,
+ () -> BigDecimalMath.roundToDouble(input, UNNECESSARY));
}
}
}
diff --git a/android/guava-tests/test/com/google/common/math/DoubleUtilsTest.java b/android/guava-tests/test/com/google/common/math/DoubleUtilsTest.java
index 2f6263ea9..72224bc38 100644
--- a/android/guava-tests/test/com/google/common/math/DoubleUtilsTest.java
+++ b/android/guava-tests/test/com/google/common/math/DoubleUtilsTest.java
@@ -19,6 +19,7 @@ package com.google.common.math;
import static com.google.common.math.MathTesting.ALL_BIGINTEGER_CANDIDATES;
import static com.google.common.math.MathTesting.FINITE_DOUBLE_CANDIDATES;
import static com.google.common.math.MathTesting.POSITIVE_FINITE_DOUBLE_CANDIDATES;
+import static org.junit.Assert.assertThrows;
import java.lang.reflect.Method;
import java.math.BigInteger;
@@ -65,11 +66,7 @@ public class DoubleUtilsTest extends TestCase {
}
assertEquals(Double.POSITIVE_INFINITY, DoubleUtils.ensureNonNegative(Double.POSITIVE_INFINITY));
assertEquals(0.0, DoubleUtils.ensureNonNegative(Double.NEGATIVE_INFINITY));
- try {
- DoubleUtils.ensureNonNegative(Double.NaN);
- fail("Expected IllegalArgumentException from ensureNonNegative(Double.NaN)");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> DoubleUtils.ensureNonNegative(Double.NaN));
}
public void testOneBits() {
diff --git a/android/guava-tests/test/com/google/common/math/LinearTransformationTest.java b/android/guava-tests/test/com/google/common/math/LinearTransformationTest.java
index 36d5e8432..a9d028980 100644
--- a/android/guava-tests/test/com/google/common/math/LinearTransformationTest.java
+++ b/android/guava-tests/test/com/google/common/math/LinearTransformationTest.java
@@ -21,6 +21,7 @@ import static com.google.common.math.StatsTesting.assertHorizontalLinearTransfor
import static com.google.common.math.StatsTesting.assertLinearTransformationNaN;
import static com.google.common.math.StatsTesting.assertVerticalLinearTransformation;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import junit.framework.TestCase;
@@ -60,79 +61,59 @@ public class LinearTransformationTest extends TestCase {
}
public void testMapping_infiniteX1() {
- try {
- LinearTransformation.mapping(Double.POSITIVE_INFINITY, 3.4);
- fail("Expected IllegalArgumentException from mapping(x, y) with infinite x");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(Double.POSITIVE_INFINITY, 3.4));
}
public void testMapping_infiniteY1() {
- try {
- LinearTransformation.mapping(1.2, Double.NEGATIVE_INFINITY);
- fail("Expected IllegalArgumentException from mapping(x, y) with infinite y");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(1.2, Double.NEGATIVE_INFINITY));
}
public void testMappingAnd_infiniteX2() {
- try {
- LinearTransformation.mapping(1.2, 3.4).and(Double.NEGATIVE_INFINITY, 7.8);
- fail("Expected IllegalArgumentException from and(x, y) with infinite x");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(1.2, 3.4).and(Double.NEGATIVE_INFINITY, 7.8));
}
public void testMappingAnd_infiniteY2() {
- try {
- LinearTransformation.mapping(1.2, 3.4).and(5.6, Double.POSITIVE_INFINITY);
- fail("Expected IllegalArgumentException from and(x, y) with infinite y");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(1.2, 3.4).and(5.6, Double.POSITIVE_INFINITY));
}
public void testMapping_nanX1() {
- try {
- LinearTransformation.mapping(Double.NaN, 3.4);
- fail("Expected IllegalArgumentException from mapping(x, y) with NaN x");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> LinearTransformation.mapping(Double.NaN, 3.4));
}
public void testMapping_nanY1() {
- try {
- LinearTransformation.mapping(1.2, Double.NaN);
- fail("Expected IllegalArgumentException from mapping(x, y) with NaN y");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> LinearTransformation.mapping(1.2, Double.NaN));
}
public void testMappingAnd_nanX2() {
- try {
- LinearTransformation.mapping(1.2, 3.4).and(Double.NaN, 7.8);
- fail("Expected IllegalArgumentException from and(x, y) with NaN x");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(1.2, 3.4).and(Double.NaN, 7.8));
}
public void testMappingAnd_nanY2() {
- try {
- LinearTransformation.mapping(1.2, 3.4).and(5.6, Double.NaN);
- fail("Expected IllegalArgumentException from and(x, y) with NaN y");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(1.2, 3.4).and(5.6, Double.NaN));
}
public void testMappingAnd_samePointTwice() {
- try {
- double x = 1.2;
- double y = 3.4;
- LinearTransformation.mapping(x, y).and(x, y);
- fail(
- "Expected IllegalArgumentException from mapping(x1, y1).and(x2, y2) with"
- + " (x1 == x2) && (y1 == y2)");
- } catch (IllegalArgumentException expected) {
- }
+ double x = 1.2;
+ double y = 3.4;
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ LinearTransformation.mapping(x, y).and(x, y);
+ });
}
public void testMappingWithSlope_regular() {
@@ -184,11 +165,9 @@ public class LinearTransformationTest extends TestCase {
}
public void testMappingWithSlope_nanSlope() {
- try {
- LinearTransformation.mapping(1.2, 3.4).withSlope(Double.NaN);
- fail("Expected IllegalArgumentException from withSlope(slope) with NaN slope");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(1.2, 3.4).withSlope(Double.NaN));
}
public void testVertical_regular() {
@@ -198,19 +177,13 @@ public class LinearTransformationTest extends TestCase {
}
public void testVertical_infiniteX() {
- try {
- LinearTransformation.vertical(Double.NEGATIVE_INFINITY);
- fail("Expected IllegalArgumentException from vertical(x) with infinite x");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.vertical(Double.NEGATIVE_INFINITY));
}
public void testVertical_nanX() {
- try {
- LinearTransformation.vertical(Double.NaN);
- fail("Expected IllegalArgumentException from vertical(x) with NaN x");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> LinearTransformation.vertical(Double.NaN));
}
public void testHorizontal_regular() {
@@ -220,19 +193,13 @@ public class LinearTransformationTest extends TestCase {
}
public void testHorizontal_infiniteY() {
- try {
- LinearTransformation.horizontal(Double.POSITIVE_INFINITY);
- fail("Expected IllegalArgumentException from horizontal(y) with infinite y");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.horizontal(Double.POSITIVE_INFINITY));
}
public void testHorizontal_nanY() {
- try {
- LinearTransformation.horizontal(Double.NaN);
- fail("Expected IllegalArgumentException from horizontal(y) with NaN y");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> LinearTransformation.horizontal(Double.NaN));
}
public void testForNaN() {
diff --git a/android/guava-tests/test/com/google/common/math/PairedStatsAccumulatorTest.java b/android/guava-tests/test/com/google/common/math/PairedStatsAccumulatorTest.java
index 34f82e907..1f3d68ff6 100644
--- a/android/guava-tests/test/com/google/common/math/PairedStatsAccumulatorTest.java
+++ b/android/guava-tests/test/com/google/common/math/PairedStatsAccumulatorTest.java
@@ -44,6 +44,7 @@ import static com.google.common.math.StatsTesting.createFilledPairedStatsAccumul
import static com.google.common.math.StatsTesting.createPartitionedFilledPairedStatsAccumulator;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assert.assertThrows;
import com.google.common.math.StatsTesting.ManyValues;
import java.util.Collections;
@@ -174,16 +175,10 @@ public class PairedStatsAccumulatorTest extends TestCase {
}
public void testPopulationCovariance() {
- try {
- emptyAccumulator.populationCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyPairedStats.populationCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.populationCovariance());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyPairedStats.populationCovariance());
assertThat(oneValueAccumulator.populationCovariance()).isWithin(0.0).of(0.0);
assertThat(oneValueAccumulatorByAddAllEmptyPairedStats.populationCovariance())
.isWithin(0.0)
@@ -241,26 +236,14 @@ public class PairedStatsAccumulatorTest extends TestCase {
}
public void testSampleCovariance() {
- try {
- emptyAccumulator.sampleCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyPairedStats.sampleCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulator.sampleCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulatorByAddAllEmptyPairedStats.sampleCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.sampleCovariance());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyPairedStats.sampleCovariance());
+ assertThrows(IllegalStateException.class, () -> oneValueAccumulator.sampleCovariance());
+ assertThrows(
+ IllegalStateException.class,
+ () -> oneValueAccumulatorByAddAllEmptyPairedStats.sampleCovariance());
assertThat(twoValuesAccumulator.sampleCovariance())
.isWithin(ALLOWED_ERROR)
.of(TWO_VALUES_SUM_OF_PRODUCTS_OF_DELTAS);
@@ -288,26 +271,16 @@ public class PairedStatsAccumulatorTest extends TestCase {
}
public void testPearsonsCorrelationCoefficient() {
- try {
- emptyAccumulator.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyPairedStats.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulator.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulatorByAddAllEmptyPairedStats.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class, () -> emptyAccumulator.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyPairedStats.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class, () -> oneValueAccumulator.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> oneValueAccumulatorByAddAllEmptyPairedStats.pearsonsCorrelationCoefficient());
assertThat(twoValuesAccumulator.pearsonsCorrelationCoefficient())
.isWithin(ALLOWED_ERROR)
.of(
@@ -368,59 +341,41 @@ public class PairedStatsAccumulatorTest extends TestCase {
.populationStandardDeviation()));
}
}
- try {
- horizontalValuesAccumulator.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- horizontalValuesAccumulatorByAddAllPartitionedPairedStats.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- verticalValuesAccumulator.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- verticalValuesAccumulatorByAddAllPartitionedPairedStats.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- constantValuesAccumulator.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- constantValuesAccumulatorByAddAllPartitionedPairedStats.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> horizontalValuesAccumulator.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () ->
+ horizontalValuesAccumulatorByAddAllPartitionedPairedStats
+ .pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> verticalValuesAccumulator.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () ->
+ verticalValuesAccumulatorByAddAllPartitionedPairedStats
+ .pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> constantValuesAccumulator.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () ->
+ constantValuesAccumulatorByAddAllPartitionedPairedStats
+ .pearsonsCorrelationCoefficient());
}
public void testLeastSquaresFit() {
- try {
- emptyAccumulator.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyPairedStats.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulator.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulatorByAddAllEmptyPairedStats.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.leastSquaresFit());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyPairedStats.leastSquaresFit());
+ assertThrows(IllegalStateException.class, () -> oneValueAccumulator.leastSquaresFit());
+ assertThrows(
+ IllegalStateException.class,
+ () -> oneValueAccumulatorByAddAllEmptyPairedStats.leastSquaresFit());
assertDiagonalLinearTransformation(
twoValuesAccumulator.leastSquaresFit(),
twoValuesAccumulator.xStats().mean(),
@@ -483,15 +438,9 @@ public class PairedStatsAccumulatorTest extends TestCase {
assertVerticalLinearTransformation(
verticalValuesAccumulatorByAddAllPartitionedPairedStats.leastSquaresFit(),
verticalValuesAccumulatorByAddAllPartitionedPairedStats.xStats().mean());
- try {
- constantValuesAccumulator.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- constantValuesAccumulatorByAddAllPartitionedPairedStats.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> constantValuesAccumulator.leastSquaresFit());
+ assertThrows(
+ IllegalStateException.class,
+ () -> constantValuesAccumulatorByAddAllPartitionedPairedStats.leastSquaresFit());
}
}
diff --git a/android/guava-tests/test/com/google/common/math/PairedStatsTest.java b/android/guava-tests/test/com/google/common/math/PairedStatsTest.java
index 7dd9e94d6..3219bb5f9 100644
--- a/android/guava-tests/test/com/google/common/math/PairedStatsTest.java
+++ b/android/guava-tests/test/com/google/common/math/PairedStatsTest.java
@@ -48,6 +48,7 @@ import static com.google.common.math.StatsTesting.assertVerticalLinearTransforma
import static com.google.common.math.StatsTesting.createPairedStatsOf;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.math.StatsTesting.ManyValues;
@@ -87,11 +88,7 @@ public class PairedStatsTest extends TestCase {
}
public void testPopulationCovariance() {
- try {
- EMPTY_PAIRED_STATS.populationCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_PAIRED_STATS.populationCovariance());
assertThat(ONE_VALUE_PAIRED_STATS.populationCovariance()).isWithin(0.0).of(0.0);
assertThat(createSingleStats(Double.POSITIVE_INFINITY, 1.23).populationCovariance()).isNaN();
assertThat(createSingleStats(Double.NEGATIVE_INFINITY, 1.23).populationCovariance()).isNaN();
@@ -121,16 +118,8 @@ public class PairedStatsTest extends TestCase {
}
public void testSampleCovariance() {
- try {
- EMPTY_PAIRED_STATS.sampleCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- ONE_VALUE_PAIRED_STATS.sampleCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_PAIRED_STATS.sampleCovariance());
+ assertThrows(IllegalStateException.class, () -> ONE_VALUE_PAIRED_STATS.sampleCovariance());
assertThat(TWO_VALUES_PAIRED_STATS.sampleCovariance())
.isWithin(ALLOWED_ERROR)
.of(TWO_VALUES_SUM_OF_PRODUCTS_OF_DELTAS);
@@ -143,21 +132,13 @@ public class PairedStatsTest extends TestCase {
}
public void testPearsonsCorrelationCoefficient() {
- try {
- EMPTY_PAIRED_STATS.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- ONE_VALUE_PAIRED_STATS.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- createSingleStats(Double.POSITIVE_INFINITY, 1.23).pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class, () -> EMPTY_PAIRED_STATS.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class, () -> ONE_VALUE_PAIRED_STATS.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> createSingleStats(Double.POSITIVE_INFINITY, 1.23).pearsonsCorrelationCoefficient());
assertThat(TWO_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient())
.isWithin(ALLOWED_ERROR)
.of(
@@ -183,39 +164,23 @@ public class PairedStatsTest extends TestCase {
* stats.yStats().populationStandardDeviation()));
}
}
- try {
- HORIZONTAL_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- VERTICAL_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- CONSTANT_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> HORIZONTAL_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> VERTICAL_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> CONSTANT_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient());
}
public void testLeastSquaresFit() {
- try {
- EMPTY_PAIRED_STATS.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- ONE_VALUE_PAIRED_STATS.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- createSingleStats(Double.POSITIVE_INFINITY, 1.23).leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_PAIRED_STATS.leastSquaresFit());
+ assertThrows(IllegalStateException.class, () -> ONE_VALUE_PAIRED_STATS.leastSquaresFit());
+ assertThrows(
+ IllegalStateException.class,
+ () -> createSingleStats(Double.POSITIVE_INFINITY, 1.23).leastSquaresFit());
assertDiagonalLinearTransformation(
TWO_VALUES_PAIRED_STATS.leastSquaresFit(),
TWO_VALUES_PAIRED_STATS.xStats().mean(),
@@ -244,11 +209,7 @@ public class PairedStatsTest extends TestCase {
assertVerticalLinearTransformation(
VERTICAL_VALUES_PAIRED_STATS.leastSquaresFit(),
VERTICAL_VALUES_PAIRED_STATS.xStats().mean());
- try {
- CONSTANT_VALUES_PAIRED_STATS.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> CONSTANT_VALUES_PAIRED_STATS.leastSquaresFit());
}
public void testEqualsAndHashCode() {
@@ -303,19 +264,11 @@ public class PairedStatsTest extends TestCase {
}
public void testFromByteArray_withNullInputThrowsNullPointerException() {
- try {
- PairedStats.fromByteArray(null);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> PairedStats.fromByteArray(null));
}
public void testFromByteArray_withEmptyArrayInputThrowsIllegalArgumentException() {
- try {
- PairedStats.fromByteArray(new byte[0]);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> PairedStats.fromByteArray(new byte[0]));
}
public void testFromByteArray_withTooLongArrayInputThrowsIllegalArgumentException() {
@@ -326,11 +279,7 @@ public class PairedStatsTest extends TestCase {
.put(buffer)
.putChar('.')
.array();
- try {
- PairedStats.fromByteArray(tooLongByteArray);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> PairedStats.fromByteArray(tooLongByteArray));
}
public void testFromByteArrayWithTooShortArrayInputThrowsIllegalArgumentException() {
@@ -340,10 +289,7 @@ public class PairedStatsTest extends TestCase {
.order(ByteOrder.LITTLE_ENDIAN)
.put(buffer, 0, buffer.length - 1)
.array();
- try {
- PairedStats.fromByteArray(tooShortByteArray);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> PairedStats.fromByteArray(tooShortByteArray));
}
}
diff --git a/android/guava-tests/test/com/google/common/math/QuantilesTest.java b/android/guava-tests/test/com/google/common/math/QuantilesTest.java
index 9c8d8e65a..788abb7f7 100644
--- a/android/guava-tests/test/com/google/common/math/QuantilesTest.java
+++ b/android/guava-tests/test/com/google/common/math/QuantilesTest.java
@@ -27,6 +27,7 @@ import static java.lang.Double.POSITIVE_INFINITY;
import static java.math.RoundingMode.CEILING;
import static java.math.RoundingMode.FLOOR;
import static java.math.RoundingMode.UNNECESSARY;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -598,171 +599,103 @@ public class QuantilesTest extends TestCase {
private static final ImmutableList<Double> EMPTY_DATASET = ImmutableList.of();
public void testScale_zero() {
- try {
- Quantiles.scale(0);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Quantiles.scale(0));
}
public void testScale_negative() {
- try {
- Quantiles.scale(-4);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Quantiles.scale(-4));
}
public void testScale_index_negative() {
Quantiles.Scale intermediate = Quantiles.scale(10);
- try {
- intermediate.index(-1);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.index(-1));
}
public void testScale_index_tooHigh() {
Quantiles.Scale intermediate = Quantiles.scale(10);
- try {
- intermediate.index(11);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.index(11));
}
public void testScale_indexes_varargs_negative() {
Quantiles.Scale intermediate = Quantiles.scale(10);
- try {
- intermediate.indexes(1, -1, 3);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.indexes(1, -1, 3));
}
public void testScale_indexes_varargs_tooHigh() {
Quantiles.Scale intermediate = Quantiles.scale(10);
- try {
- intermediate.indexes(1, 11, 3);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.indexes(1, 11, 3));
}
public void testScale_indexes_collection_negative() {
Quantiles.Scale intermediate = Quantiles.scale(10);
- try {
- intermediate.indexes(ImmutableList.of(1, -1, 3));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> intermediate.indexes(ImmutableList.of(1, -1, 3)));
}
public void testScale_indexes_collection_tooHigh() {
Quantiles.Scale intermediate = Quantiles.scale(10);
- try {
- intermediate.indexes(ImmutableList.of(1, 11, 3));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> intermediate.indexes(ImmutableList.of(1, 11, 3)));
}
public void testScale_index_compute_doubleCollection_empty() {
Quantiles.ScaleAndIndex intermediate = Quantiles.scale(10).index(3);
- try {
- intermediate.compute(EMPTY_DATASET);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(EMPTY_DATASET));
}
public void testScale_index_compute_doubleVarargs_empty() {
Quantiles.ScaleAndIndex intermediate = Quantiles.scale(10).index(3);
- try {
- intermediate.compute(new double[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(new double[] {}));
}
public void testScale_index_compute_longVarargs_empty() {
Quantiles.ScaleAndIndex intermediate = Quantiles.scale(10).index(3);
- try {
- intermediate.compute(new long[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(new long[] {}));
}
public void testScale_index_compute_intVarargs_empty() {
Quantiles.ScaleAndIndex intermediate = Quantiles.scale(10).index(3);
- try {
- intermediate.compute(new int[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(new int[] {}));
}
public void testScale_index_computeInPlace_empty() {
Quantiles.ScaleAndIndex intermediate = Quantiles.scale(10).index(3);
- try {
- intermediate.computeInPlace(new double[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> intermediate.computeInPlace(new double[] {}));
}
public void testScale_indexes_varargs_compute_doubleCollection_empty() {
Quantiles.ScaleAndIndexes intermediate = Quantiles.scale(10).indexes(1, 3, 5);
- try {
- intermediate.compute(EMPTY_DATASET);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(EMPTY_DATASET));
}
public void testScale_indexes_varargs_compute_doubleVarargs_empty() {
Quantiles.ScaleAndIndexes intermediate = Quantiles.scale(10).indexes(1, 3, 5);
- try {
- intermediate.compute(new double[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(new double[] {}));
}
public void testScale_indexes_varargs_compute_longVarargs_empty() {
Quantiles.ScaleAndIndexes intermediate = Quantiles.scale(10).indexes(1, 3, 5);
- try {
- intermediate.compute(new long[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(new long[] {}));
}
public void testScale_indexes_varargs_compute_intVarargs_empty() {
Quantiles.ScaleAndIndexes intermediate = Quantiles.scale(10).indexes(1, 3, 5);
- try {
- intermediate.compute(new int[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(new int[] {}));
}
public void testScale_indexes_varargs_computeInPlace_empty() {
Quantiles.ScaleAndIndexes intermediate = Quantiles.scale(10).indexes(1, 3, 5);
- try {
- intermediate.computeInPlace(new double[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> intermediate.computeInPlace(new double[] {}));
}
public void testScale_indexes_indexes_computeInPlace_empty() {
int[] emptyIndexes = {};
- try {
- Quantiles.ScaleAndIndexes unused = Quantiles.scale(10).indexes(emptyIndexes);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ Quantiles.ScaleAndIndexes unused = Quantiles.scale(10).indexes(emptyIndexes);
+ });
}
}
diff --git a/android/guava-tests/test/com/google/common/math/StatsAccumulatorTest.java b/android/guava-tests/test/com/google/common/math/StatsAccumulatorTest.java
index 6926a69c6..bf4396f9a 100644
--- a/android/guava-tests/test/com/google/common/math/StatsAccumulatorTest.java
+++ b/android/guava-tests/test/com/google/common/math/StatsAccumulatorTest.java
@@ -46,6 +46,7 @@ import static com.google.common.math.StatsTesting.TWO_VALUES_SUM_OF_SQUARES_OF_D
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static java.lang.Math.sqrt;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.math.StatsTesting.ManyValues;
@@ -188,21 +189,9 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testMean() {
- try {
- emptyAccumulator.mean();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.mean();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.mean();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.mean());
+ assertThrows(IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyIterable.mean());
+ assertThrows(IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyStats.mean());
assertThat(oneValueAccumulator.mean()).isWithin(ALLOWED_ERROR).of(ONE_VALUE);
assertThat(oneValueAccumulatorByAddAllEmptyStats.mean()).isWithin(ALLOWED_ERROR).of(ONE_VALUE);
assertThat(twoValuesAccumulator.mean()).isWithin(ALLOWED_ERROR).of(TWO_VALUES_MEAN);
@@ -322,21 +311,12 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testPopulationVariance() {
- try {
- emptyAccumulator.populationVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.populationVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.populationVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.populationVariance());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyIterable.populationVariance());
+ assertThrows(
+ IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyStats.populationVariance());
assertThat(oneValueAccumulator.populationVariance()).isWithin(0.0).of(0.0);
assertThat(oneValueAccumulatorByAddAllEmptyStats.populationVariance()).isWithin(0.0).of(0.0);
assertThat(twoValuesAccumulator.populationVariance())
@@ -405,21 +385,13 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testPopulationStandardDeviation() {
- try {
- emptyAccumulator.populationStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.populationStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.populationStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.populationStandardDeviation());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyIterable.populationStandardDeviation());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyStats.populationStandardDeviation());
assertThat(oneValueAccumulator.populationStandardDeviation()).isWithin(0.0).of(0.0);
assertThat(oneValueAccumulatorByAddAllEmptyStats.populationStandardDeviation())
.isWithin(0.0)
@@ -463,31 +435,14 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testSampleVariance() {
- try {
- emptyAccumulator.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulator.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulatorByAddAllEmptyStats.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.sampleVariance());
+ assertThrows(
+ IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyIterable.sampleVariance());
+ assertThrows(
+ IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyStats.sampleVariance());
+ assertThrows(IllegalStateException.class, () -> oneValueAccumulator.sampleVariance());
+ assertThrows(
+ IllegalStateException.class, () -> oneValueAccumulatorByAddAllEmptyStats.sampleVariance());
assertThat(twoValuesAccumulator.sampleVariance())
.isWithin(ALLOWED_ERROR)
.of(TWO_VALUES_SUM_OF_SQUARES_OF_DELTAS);
@@ -527,31 +482,17 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testSampleStandardDeviation() {
- try {
- emptyAccumulator.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulator.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulatorByAddAllEmptyStats.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.sampleStandardDeviation());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyIterable.sampleStandardDeviation());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyStats.sampleStandardDeviation());
+ assertThrows(IllegalStateException.class, () -> oneValueAccumulator.sampleStandardDeviation());
+ assertThrows(
+ IllegalStateException.class,
+ () -> oneValueAccumulatorByAddAllEmptyStats.sampleStandardDeviation());
assertThat(twoValuesAccumulator.sampleStandardDeviation())
.isWithin(ALLOWED_ERROR)
.of(sqrt(TWO_VALUES_SUM_OF_SQUARES_OF_DELTAS));
@@ -591,21 +532,9 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testMax() {
- try {
- emptyAccumulator.max();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.max();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.max();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.max());
+ assertThrows(IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyIterable.max());
+ assertThrows(IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyStats.max());
assertThat(oneValueAccumulator.max()).isEqualTo(ONE_VALUE);
assertThat(oneValueAccumulatorByAddAllEmptyStats.max()).isEqualTo(ONE_VALUE);
assertThat(twoValuesAccumulator.max()).isEqualTo(TWO_VALUES_MAX);
@@ -650,21 +579,9 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testMin() {
- try {
- emptyAccumulator.min();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.min();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.min();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.min());
+ assertThrows(IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyIterable.min());
+ assertThrows(IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyStats.min());
assertThat(oneValueAccumulator.min()).isEqualTo(ONE_VALUE);
assertThat(oneValueAccumulatorByAddAllEmptyStats.min()).isEqualTo(ONE_VALUE);
assertThat(twoValuesAccumulator.min()).isEqualTo(TWO_VALUES_MIN);
diff --git a/android/guava-tests/test/com/google/common/math/StatsTest.java b/android/guava-tests/test/com/google/common/math/StatsTest.java
index 76de5b55c..9fe9a96b1 100644
--- a/android/guava-tests/test/com/google/common/math/StatsTest.java
+++ b/android/guava-tests/test/com/google/common/math/StatsTest.java
@@ -69,6 +69,7 @@ import static java.lang.Double.NEGATIVE_INFINITY;
import static java.lang.Double.NaN;
import static java.lang.Double.POSITIVE_INFINITY;
import static java.lang.Math.sqrt;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.math.StatsTesting.ManyValues;
@@ -104,16 +105,8 @@ public class StatsTest extends TestCase {
}
public void testMean() {
- try {
- EMPTY_STATS_VARARGS.mean();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.mean();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_VARARGS.mean());
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.mean());
assertThat(ONE_VALUE_STATS.mean()).isWithin(ALLOWED_ERROR).of(ONE_VALUE);
assertThat(Stats.of(POSITIVE_INFINITY).mean()).isPositiveInfinity();
assertThat(Stats.of(NEGATIVE_INFINITY).mean()).isNegativeInfinity();
@@ -196,16 +189,8 @@ public class StatsTest extends TestCase {
}
public void testPopulationVariance() {
- try {
- EMPTY_STATS_VARARGS.populationVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.populationVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_VARARGS.populationVariance());
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.populationVariance());
assertThat(ONE_VALUE_STATS.populationVariance()).isWithin(0.0).of(0.0);
assertThat(Stats.of(POSITIVE_INFINITY).populationVariance()).isNaN();
assertThat(Stats.of(NEGATIVE_INFINITY).populationVariance()).isNaN();
@@ -256,16 +241,10 @@ public class StatsTest extends TestCase {
}
public void testPopulationStandardDeviation() {
- try {
- EMPTY_STATS_VARARGS.populationStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.populationStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class, () -> EMPTY_STATS_VARARGS.populationStandardDeviation());
+ assertThrows(
+ IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.populationStandardDeviation());
assertThat(ONE_VALUE_STATS.populationStandardDeviation()).isWithin(0.0).of(0.0);
assertThat(TWO_VALUES_STATS.populationStandardDeviation())
.isWithin(ALLOWED_ERROR)
@@ -297,21 +276,9 @@ public class StatsTest extends TestCase {
}
public void testSampleVariance() {
- try {
- EMPTY_STATS_VARARGS.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- ONE_VALUE_STATS.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_VARARGS.sampleVariance());
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.sampleVariance());
+ assertThrows(IllegalStateException.class, () -> ONE_VALUE_STATS.sampleVariance());
assertThat(TWO_VALUES_STATS.sampleVariance())
.isWithin(ALLOWED_ERROR)
.of(TWO_VALUES_SUM_OF_SQUARES_OF_DELTAS);
@@ -342,21 +309,9 @@ public class StatsTest extends TestCase {
}
public void testSampleStandardDeviation() {
- try {
- EMPTY_STATS_VARARGS.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- ONE_VALUE_STATS.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_VARARGS.sampleStandardDeviation());
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.sampleStandardDeviation());
+ assertThrows(IllegalStateException.class, () -> ONE_VALUE_STATS.sampleStandardDeviation());
assertThat(TWO_VALUES_STATS.sampleStandardDeviation())
.isWithin(ALLOWED_ERROR)
.of(sqrt(TWO_VALUES_SUM_OF_SQUARES_OF_DELTAS));
@@ -387,16 +342,8 @@ public class StatsTest extends TestCase {
}
public void testMax() {
- try {
- EMPTY_STATS_VARARGS.max();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.max();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_VARARGS.max());
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.max());
assertThat(ONE_VALUE_STATS.max()).isEqualTo(ONE_VALUE);
assertThat(Stats.of(POSITIVE_INFINITY).max()).isPositiveInfinity();
assertThat(Stats.of(NEGATIVE_INFINITY).max()).isNegativeInfinity();
@@ -424,16 +371,8 @@ public class StatsTest extends TestCase {
}
public void testMin() {
- try {
- EMPTY_STATS_VARARGS.min();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.min();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_VARARGS.min());
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.min());
assertThat(ONE_VALUE_STATS.min()).isEqualTo(ONE_VALUE);
assertThat(Stats.of(POSITIVE_INFINITY).min()).isPositiveInfinity();
assertThat(Stats.of(NEGATIVE_INFINITY).min()).isNegativeInfinity();
@@ -505,16 +444,8 @@ public class StatsTest extends TestCase {
}
public void testMeanOf() {
- try {
- Stats.meanOf();
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
- try {
- Stats.meanOf(ImmutableList.<Number>of());
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Stats.meanOf());
+ assertThrows(IllegalArgumentException.class, () -> Stats.meanOf(ImmutableList.<Number>of()));
assertThat(Stats.meanOf(ONE_VALUE)).isWithin(ALLOWED_ERROR).of(ONE_VALUE);
assertThat(Stats.meanOf(POSITIVE_INFINITY)).isPositiveInfinity();
assertThat(Stats.meanOf(NEGATIVE_INFINITY)).isNegativeInfinity();
@@ -565,19 +496,11 @@ public class StatsTest extends TestCase {
}
public void testFromByteArray_withNullInputThrowsNullPointerException() {
- try {
- Stats.fromByteArray(null);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Stats.fromByteArray(null));
}
public void testFromByteArray_withEmptyArrayInputThrowsIllegalArgumentException() {
- try {
- Stats.fromByteArray(new byte[0]);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Stats.fromByteArray(new byte[0]));
}
public void testFromByteArray_withTooLongArrayInputThrowsIllegalArgumentException() {
@@ -588,11 +511,7 @@ public class StatsTest extends TestCase {
.put(buffer)
.putChar('.')
.array();
- try {
- Stats.fromByteArray(tooLongByteArray);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Stats.fromByteArray(tooLongByteArray));
}
public void testFromByteArrayWithTooShortArrayInputThrowsIllegalArgumentException() {
@@ -602,10 +521,6 @@ public class StatsTest extends TestCase {
.order(ByteOrder.LITTLE_ENDIAN)
.put(buffer, 0, Stats.BYTES - 1)
.array();
- try {
- Stats.fromByteArray(tooShortByteArray);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Stats.fromByteArray(tooShortByteArray));
}
}
diff --git a/android/guava-tests/test/com/google/common/math/StatsTesting.java b/android/guava-tests/test/com/google/common/math/StatsTesting.java
index dddf20f94..1dc0235f9 100644
--- a/android/guava-tests/test/com/google/common/math/StatsTesting.java
+++ b/android/guava-tests/test/com/google/common/math/StatsTesting.java
@@ -17,6 +17,7 @@
package com.google.common.math;
import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
import static java.lang.Double.NEGATIVE_INFINITY;
import static java.lang.Double.NaN;
@@ -39,8 +40,8 @@ import java.util.List;
* @author Pete Gillin
*/
class StatsTesting {
-
- static final double ALLOWED_ERROR = 1e-10;
+ // TODO(cpovirk): Convince myself that this larger error makes sense.
+ static final double ALLOWED_ERROR = isAndroid() ? .25 : 1e-10;
// Inputs and their statistics:
@@ -501,5 +502,9 @@ class StatsTesting {
return accumulator;
}
+ private static boolean isAndroid() {
+ return checkNotNull(System.getProperty("java.runtime.name", "")).contains("Android");
+ }
+
private StatsTesting() {}
}
diff --git a/android/guava-tests/test/com/google/common/net/InetAddressesTest.java b/android/guava-tests/test/com/google/common/net/InetAddressesTest.java
index 7d070e404..241c6bbf5 100644
--- a/android/guava-tests/test/com/google/common/net/InetAddressesTest.java
+++ b/android/guava-tests/test/com/google/common/net/InetAddressesTest.java
@@ -17,6 +17,7 @@
package com.google.common.net;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableSet;
import com.google.common.testing.NullPointerTester;
@@ -109,21 +110,16 @@ public class InetAddressesTest extends TestCase {
":1:2:3:4:5:6:");
for (String bogusInput : bogusInputs) {
- try {
- InetAddresses.forString(bogusInput);
- fail("IllegalArgumentException expected for '" + bogusInput + "'");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ "IllegalArgumentException expected for '" + bogusInput + "'",
+ IllegalArgumentException.class,
+ () -> InetAddresses.forString(bogusInput));
assertFalse(InetAddresses.isInetAddress(bogusInput));
}
}
public void test3ff31() {
- try {
- InetAddresses.forString("3ffe:::1");
- fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.forString("3ffe:::1"));
assertFalse(InetAddresses.isInetAddress("016.016.016.016"));
}
@@ -327,71 +323,33 @@ public class InetAddressesTest extends TestCase {
}
public void testForUriStringBad() {
- try {
- InetAddresses.forUriString("");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.forUriString(""));
- try {
- InetAddresses.forUriString("192.168.999.888");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> InetAddresses.forUriString("192.168.999.888"));
- try {
- InetAddresses.forUriString("www.google.com");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> InetAddresses.forUriString("www.google.com"));
- try {
- InetAddresses.forUriString("[1:2e]");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.forUriString("[1:2e]"));
- try {
- InetAddresses.forUriString("[192.168.1.1]");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.forUriString("[192.168.1.1]"));
- try {
- InetAddresses.forUriString("192.168.1.1]");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.forUriString("192.168.1.1]"));
- try {
- InetAddresses.forUriString("[192.168.1.1");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.forUriString("[192.168.1.1"));
- try {
- InetAddresses.forUriString("[3ffe:0:0:0:0:0:0:1");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> InetAddresses.forUriString("[3ffe:0:0:0:0:0:0:1"));
- try {
- InetAddresses.forUriString("3ffe:0:0:0:0:0:0:1]");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> InetAddresses.forUriString("3ffe:0:0:0:0:0:0:1]"));
- try {
- InetAddresses.forUriString("3ffe:0:0:0:0:0:0:1");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> InetAddresses.forUriString("3ffe:0:0:0:0:0:0:1"));
- try {
- InetAddresses.forUriString("::ffff:192.0.2.1");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> InetAddresses.forUriString("::ffff:192.0.2.1"));
}
public void testCompatIPv4Addresses() {
@@ -400,11 +358,10 @@ public class InetAddressesTest extends TestCase {
for (String nonCompatAddress : nonCompatAddresses) {
InetAddress ip = InetAddresses.forString(nonCompatAddress);
assertFalse(InetAddresses.isCompatIPv4Address((Inet6Address) ip));
- try {
- InetAddresses.getCompatIPv4Address((Inet6Address) ip);
- fail("IllegalArgumentException expected for '" + nonCompatAddress + "'");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ "IllegalArgumentException expected for '" + nonCompatAddress + "'",
+ IllegalArgumentException.class,
+ () -> InetAddresses.getCompatIPv4Address((Inet6Address) ip));
}
ImmutableSet<String> validCompatAddresses = ImmutableSet.of("::1.2.3.4", "::102:304");
@@ -470,11 +427,10 @@ public class InetAddressesTest extends TestCase {
for (String non6to4Address : non6to4Addresses) {
InetAddress ip = InetAddresses.forString(non6to4Address);
assertFalse(InetAddresses.is6to4Address((Inet6Address) ip));
- try {
- InetAddresses.get6to4IPv4Address((Inet6Address) ip);
- fail("IllegalArgumentException expected for '" + non6to4Address + "'");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ "IllegalArgumentException expected for '" + non6to4Address + "'",
+ IllegalArgumentException.class,
+ () -> InetAddresses.get6to4IPv4Address((Inet6Address) ip));
}
String valid6to4Address = "2002:0102:0304::1";
@@ -492,11 +448,10 @@ public class InetAddressesTest extends TestCase {
for (String nonTeredoAddress : nonTeredoAddresses) {
InetAddress ip = InetAddresses.forString(nonTeredoAddress);
assertFalse(InetAddresses.isTeredoAddress((Inet6Address) ip));
- try {
- InetAddresses.getTeredoInfo((Inet6Address) ip);
- fail("IllegalArgumentException expected for '" + nonTeredoAddress + "'");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ "IllegalArgumentException expected for '" + nonTeredoAddress + "'",
+ IllegalArgumentException.class,
+ () -> InetAddresses.getTeredoInfo((Inet6Address) ip));
}
String validTeredoAddress = "2001:0000:4136:e378:8000:63bf:3fff:fdd2";
@@ -559,11 +514,10 @@ public class InetAddressesTest extends TestCase {
for (String nonIsatapAddress : nonIsatapAddresses) {
InetAddress ip = InetAddresses.forString(nonIsatapAddress);
assertFalse(InetAddresses.isIsatapAddress((Inet6Address) ip));
- try {
- InetAddresses.getIsatapIPv4Address((Inet6Address) ip);
- fail("IllegalArgumentException expected for '" + nonIsatapAddress + "'");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ "IllegalArgumentException expected for '" + nonIsatapAddress + "'",
+ IllegalArgumentException.class,
+ () -> InetAddresses.getIsatapIPv4Address((Inet6Address) ip));
}
}
@@ -683,12 +637,8 @@ public class InetAddressesTest extends TestCase {
InetAddress.getByAddress(
new byte[] {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}));
- try {
- InetAddresses.fromLittleEndianByteArray(new byte[3]);
- fail("expected exception");
- } catch (UnknownHostException expected) {
- // success
- }
+ assertThrows(
+ UnknownHostException.class, () -> InetAddresses.fromLittleEndianByteArray(new byte[3]));
}
public void testIsMaximum() throws UnknownHostException {
@@ -720,12 +670,7 @@ public class InetAddressesTest extends TestCase {
assertEquals(address_67_0, address);
InetAddress address_ffffff = InetAddress.getByName("255.255.255.255");
- address = address_ffffff;
- try {
- address = InetAddresses.increment(address);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.increment(address_ffffff));
}
public void testIncrementIPv6() throws UnknownHostException {
@@ -743,12 +688,7 @@ public class InetAddressesTest extends TestCase {
assertEquals(addressV6_67_0, address);
InetAddress addressV6_ffffff = InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
- address = addressV6_ffffff;
- try {
- address = InetAddresses.increment(address);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.increment(addressV6_ffffff));
}
public void testDecrementIPv4() throws UnknownHostException {
@@ -767,12 +707,7 @@ public class InetAddressesTest extends TestCase {
assertEquals(address660, address);
InetAddress address0000 = InetAddress.getByName("0.0.0.0");
- address = address0000;
- try {
- address = InetAddresses.decrement(address);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.decrement(address0000));
}
public void testDecrementIPv6() throws UnknownHostException {
@@ -791,30 +726,23 @@ public class InetAddressesTest extends TestCase {
assertEquals(addressV6660, address);
InetAddress addressV6000000 = InetAddress.getByName("0:0:0:0:0:0:0:0");
- address = addressV6000000;
- try {
- address = InetAddresses.decrement(address);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.decrement(addressV6000000));
}
public void testFromIpv4BigIntegerThrowsLessThanZero() {
- try {
- InetAddresses.fromIPv4BigInteger(BigInteger.valueOf(-1L));
- fail();
- } catch (IllegalArgumentException expected) {
- assertEquals("BigInteger must be greater than or equal to 0", expected.getMessage());
- }
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> InetAddresses.fromIPv4BigInteger(BigInteger.valueOf(-1L)));
+ assertEquals("BigInteger must be greater than or equal to 0", expected.getMessage());
}
public void testFromIpv6BigIntegerThrowsLessThanZero() {
- try {
- InetAddresses.fromIPv6BigInteger(BigInteger.valueOf(-1L));
- fail();
- } catch (IllegalArgumentException expected) {
- assertEquals("BigInteger must be greater than or equal to 0", expected.getMessage());
- }
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> InetAddresses.fromIPv6BigInteger(BigInteger.valueOf(-1L)));
+ assertEquals("BigInteger must be greater than or equal to 0", expected.getMessage());
}
public void testFromIpv4BigIntegerValid() {
@@ -840,27 +768,28 @@ public class InetAddressesTest extends TestCase {
}
public void testFromIpv4BigIntegerInputTooLarge() {
- try {
- InetAddresses.fromIPv4BigInteger(BigInteger.ONE.shiftLeft(32).add(BigInteger.ONE));
- fail();
- } catch (IllegalArgumentException expected) {
- assertEquals(
- "BigInteger cannot be converted to InetAddress because it has more than 4 bytes:"
- + " 4294967297",
- expected.getMessage());
- }
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ InetAddresses.fromIPv4BigInteger(BigInteger.ONE.shiftLeft(32).add(BigInteger.ONE)));
+ assertEquals(
+ "BigInteger cannot be converted to InetAddress because it has more than 4 bytes:"
+ + " 4294967297",
+ expected.getMessage());
}
public void testFromIpv6BigIntegerInputTooLarge() {
- try {
- InetAddresses.fromIPv6BigInteger(BigInteger.ONE.shiftLeft(128).add(BigInteger.ONE));
- fail();
- } catch (IllegalArgumentException expected) {
- assertEquals(
- "BigInteger cannot be converted to InetAddress because it has more than 16 bytes:"
- + " 340282366920938463463374607431768211457",
- expected.getMessage());
- }
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ InetAddresses.fromIPv6BigInteger(
+ BigInteger.ONE.shiftLeft(128).add(BigInteger.ONE)));
+ assertEquals(
+ "BigInteger cannot be converted to InetAddress because it has more than 16 bytes:"
+ + " 340282366920938463463374607431768211457",
+ expected.getMessage());
}
/** Checks that the IP converts to the big integer and the big integer converts to the IP. */
diff --git a/android/guava-tests/test/com/google/common/net/MediaTypeTest.java b/android/guava-tests/test/com/google/common/net/MediaTypeTest.java
index 574db68e8..a3428b32f 100644
--- a/android/guava-tests/test/com/google/common/net/MediaTypeTest.java
+++ b/android/guava-tests/test/com/google/common/net/MediaTypeTest.java
@@ -16,8 +16,6 @@
package com.google.common.net;
-import static com.google.common.base.Charsets.UTF_16;
-import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.net.MediaType.ANY_APPLICATION_TYPE;
import static com.google.common.net.MediaType.ANY_AUDIO_TYPE;
import static com.google.common.net.MediaType.ANY_IMAGE_TYPE;
@@ -31,6 +29,8 @@ import static com.google.common.truth.Truth.assertThat;
import static java.lang.reflect.Modifier.isFinal;
import static java.lang.reflect.Modifier.isPublic;
import static java.lang.reflect.Modifier.isStatic;
+import static java.nio.charset.StandardCharsets.UTF_16;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Arrays.asList;
import com.google.common.annotations.GwtCompatible;
@@ -512,6 +512,14 @@ public class MediaTypeTest extends TestCase {
}
}
+ // https://github.com/google/guava/issues/6663
+ public void testParse_spaceInParameterSeparator() {
+ assertThat(MediaType.parse("text/plain; charset =utf-8").charset()).hasValue(UTF_8);
+ assertThat(MediaType.parse("text/plain; charset= utf-8").charset()).hasValue(UTF_8);
+ assertThat(MediaType.parse("text/plain; charset = utf-8").charset()).hasValue(UTF_8);
+ assertThat(MediaType.parse("text/plain;charset =utf-8").charset()).hasValue(UTF_8);
+ }
+
public void testGetCharset() {
assertThat(MediaType.parse("text/plain").charset()).isAbsent();
assertThat(MediaType.parse("text/plain; charset=utf-8").charset()).hasValue(UTF_8);
@@ -556,6 +564,9 @@ public class MediaTypeTest extends TestCase {
MediaType.create("TEXT", "PLAIN"),
MediaType.parse("text/plain"),
MediaType.parse("TEXT/PLAIN"),
+ MediaType.parse("text /plain"),
+ MediaType.parse("TEXT/ plain"),
+ MediaType.parse("text / plain"),
MediaType.create("text", "plain").withParameter("a", "1").withoutParameters())
.addEqualityGroup(
MediaType.create("text", "plain").withCharset(UTF_8),
@@ -571,7 +582,11 @@ public class MediaTypeTest extends TestCase {
MediaType.parse("text/plain; charset=\"utf-8\""),
MediaType.parse("text/plain; charset=\"\\u\\tf-\\8\""),
MediaType.parse("text/plain; charset=UTF-8"),
- MediaType.parse("text/plain ; charset=utf-8"))
+ MediaType.parse("text/plain ; charset=utf-8"),
+ MediaType.parse("text/plain; charset =UTF-8"),
+ MediaType.parse("text/plain; charset= UTF-8"),
+ MediaType.parse("text/plain; charset = UTF-8"),
+ MediaType.parse("text/plain; charset=\tUTF-8"))
.addEqualityGroup(MediaType.parse("text/plain; charset=utf-8; charset=utf-8"))
.addEqualityGroup(
MediaType.create("text", "plain").withParameter("a", "value"),
diff --git a/android/guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java b/android/guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java
index 840ae97c3..10f9a662b 100644
--- a/android/guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java
+++ b/android/guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java
@@ -18,6 +18,7 @@ package com.google.common.primitives;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.testing.Helpers;
import com.google.common.testing.NullPointerTester;
@@ -97,11 +98,7 @@ public class UnsignedBytesTest extends TestCase {
}
public void testMax_noArgs() {
- try {
- UnsignedBytes.max();
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> UnsignedBytes.max());
}
public void testMax() {
@@ -112,11 +109,7 @@ public class UnsignedBytesTest extends TestCase {
}
public void testMin_noArgs() {
- try {
- UnsignedBytes.min();
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> UnsignedBytes.min());
}
public void testMin() {
@@ -177,24 +170,16 @@ public class UnsignedBytesTest extends TestCase {
public void testParseUnsignedByteThrowsExceptionForInvalidRadix() {
// Valid radix values are Character.MIN_RADIX to Character.MAX_RADIX,
// inclusive.
- try {
- UnsignedBytes.parseUnsignedByte("0", Character.MIN_RADIX - 1);
- fail();
- } catch (NumberFormatException expected) {
- }
+ assertThrows(
+ NumberFormatException.class,
+ () -> UnsignedBytes.parseUnsignedByte("0", Character.MIN_RADIX - 1));
- try {
- UnsignedBytes.parseUnsignedByte("0", Character.MAX_RADIX + 1);
- fail();
- } catch (NumberFormatException expected) {
- }
+ assertThrows(
+ NumberFormatException.class,
+ () -> UnsignedBytes.parseUnsignedByte("0", Character.MAX_RADIX + 1));
// The radix is used as an array index, so try a negative value.
- try {
- UnsignedBytes.parseUnsignedByte("0", -1);
- fail();
- } catch (NumberFormatException expected) {
- }
+ assertThrows(NumberFormatException.class, () -> UnsignedBytes.parseUnsignedByte("0", -1));
}
public void testToString() {
diff --git a/android/guava-tests/test/com/google/common/reflect/ImmutableTypeToInstanceMapTest.java b/android/guava-tests/test/com/google/common/reflect/ImmutableTypeToInstanceMapTest.java
index 064c4b5c1..83b56c445 100644
--- a/android/guava-tests/test/com/google/common/reflect/ImmutableTypeToInstanceMapTest.java
+++ b/android/guava-tests/test/com/google/common/reflect/ImmutableTypeToInstanceMapTest.java
@@ -18,6 +18,7 @@ package com.google.common.reflect;
import static com.google.common.collect.Maps.immutableEntry;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.testing.MapTestSuiteBuilder;
@@ -121,21 +122,16 @@ public class ImmutableTypeToInstanceMapTest extends TestCase {
public void testGetInstance_containsTypeVariable() {
ImmutableTypeToInstanceMap<Iterable<Number>> map = ImmutableTypeToInstanceMap.of();
- try {
- map.getInstance(this.<Number>anyIterableType());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> map.getInstance(this.<Number>anyIterableType()));
}
public void testPut_containsTypeVariable() {
ImmutableTypeToInstanceMap.Builder<Iterable<Integer>> builder =
ImmutableTypeToInstanceMap.builder();
- try {
- builder.put(this.<Integer>anyIterableType(), ImmutableList.of(1));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> builder.put(this.<Integer>anyIterableType(), ImmutableList.of(1)));
}
private <T> TypeToken<Iterable<T>> anyIterableType() {
diff --git a/android/guava-tests/test/com/google/common/reflect/InvokableTest.java b/android/guava-tests/test/com/google/common/reflect/InvokableTest.java
index ab5ff738f..54f20a537 100644
--- a/android/guava-tests/test/com/google/common/reflect/InvokableTest.java
+++ b/android/guava-tests/test/com/google/common/reflect/InvokableTest.java
@@ -17,6 +17,7 @@
package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -285,11 +286,7 @@ public class InvokableTest extends TestCase {
public void testConstructor_invalidReturning() throws Exception {
Invokable<?, Prepender> delegate = Prepender.constructor(String.class, int.class);
- try {
- delegate.returning(SubPrepender.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> delegate.returning(SubPrepender.class));
}
public void testStaticMethod_returnType() throws Exception {
@@ -352,11 +349,9 @@ public class InvokableTest extends TestCase {
public void testStaticMethod_invalidReturning() throws Exception {
Invokable<?, Object> delegate = Prepender.method("prepend", String.class, Iterable.class);
- try {
- delegate.returning(new TypeToken<Iterable<Integer>>() {});
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> delegate.returning(new TypeToken<Iterable<Integer>>() {}));
}
public void testInstanceMethod_returnType() throws Exception {
@@ -414,11 +409,9 @@ public class InvokableTest extends TestCase {
public void testInstanceMethod_invalidReturning() throws Exception {
Invokable<?, Object> delegate = Prepender.method("prepend", Iterable.class);
- try {
- delegate.returning(new TypeToken<Iterable<Integer>>() {});
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> delegate.returning(new TypeToken<Iterable<Integer>>() {}));
}
public void testPrivateInstanceMethod_isOverridable() throws Exception {
diff --git a/android/guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java b/android/guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java
index cea81e3a2..0ea574e46 100644
--- a/android/guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java
+++ b/android/guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java
@@ -18,6 +18,7 @@ package com.google.common.reflect;
import static com.google.common.collect.Maps.immutableEntry;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -81,30 +82,23 @@ public class MutableTypeToInstanceMapTest extends TestCase {
}
public void testPutThrows() {
- try {
- map.put(TypeToken.of(Integer.class), new Integer(5));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> map.put(TypeToken.of(Integer.class), new Integer(5)));
}
public void testPutAllThrows() {
- try {
- map.putAll(ImmutableMap.of(TypeToken.of(Integer.class), new Integer(5)));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> map.putAll(ImmutableMap.of(TypeToken.of(Integer.class), new Integer(5))));
}
public void testEntrySetMutationThrows() {
map.putInstance(String.class, "test");
assertEquals(TypeToken.of(String.class), map.entrySet().iterator().next().getKey());
assertEquals("test", map.entrySet().iterator().next().getValue());
- try {
- map.entrySet().iterator().next().setValue(1);
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(
+ UnsupportedOperationException.class, () -> map.entrySet().iterator().next().setValue(1));
}
public void testEntrySetToArrayMutationThrows() {
@@ -113,11 +107,7 @@ public class MutableTypeToInstanceMapTest extends TestCase {
Entry<Object, Object> entry = (Entry<Object, Object>) map.entrySet().toArray()[0];
assertEquals(TypeToken.of(String.class), entry.getKey());
assertEquals("test", entry.getValue());
- try {
- entry.setValue(1);
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> entry.setValue(1));
}
public void testEntrySetToTypedArrayMutationThrows() {
@@ -126,11 +116,7 @@ public class MutableTypeToInstanceMapTest extends TestCase {
Entry<Object, Object> entry = map.entrySet().toArray(new Entry[0])[0];
assertEquals(TypeToken.of(String.class), entry.getKey());
assertEquals("test", entry.getValue());
- try {
- entry.setValue(1);
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> entry.setValue(1));
}
public void testPutAndGetInstance() {
@@ -147,11 +133,8 @@ public class MutableTypeToInstanceMapTest extends TestCase {
}
public void testNull() {
- try {
- map.putInstance((TypeToken) null, new Integer(1));
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(
+ NullPointerException.class, () -> map.putInstance((TypeToken) null, new Integer(1)));
map.putInstance(Integer.class, null);
assertTrue(map.containsKey(TypeToken.of(Integer.class)));
assertTrue(map.entrySet().contains(immutableEntry(TypeToken.of(Integer.class), null)));
@@ -208,19 +191,14 @@ public class MutableTypeToInstanceMapTest extends TestCase {
}
public void testGetInstance_withTypeVariable() {
- try {
- map.getInstance(this.<Number>anyIterableType());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> map.getInstance(this.<Number>anyIterableType()));
}
public void testPutInstance_withTypeVariable() {
- try {
- map.putInstance(this.<Integer>anyIterableType(), ImmutableList.of(1));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> map.putInstance(this.<Integer>anyIterableType(), ImmutableList.of(1)));
}
private <T> TypeToken<Iterable<T>> anyIterableType() {
diff --git a/android/guava-tests/test/com/google/common/reflect/ReflectionTest.java b/android/guava-tests/test/com/google/common/reflect/ReflectionTest.java
index 2885f8956..83d0168a6 100644
--- a/android/guava-tests/test/com/google/common/reflect/ReflectionTest.java
+++ b/android/guava-tests/test/com/google/common/reflect/ReflectionTest.java
@@ -16,6 +16,8 @@
package com.google.common.reflect;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.testing.NullPointerTester;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
@@ -39,11 +41,8 @@ public class ReflectionTest extends TestCase {
}
public void testNewProxyCantWorkOnAClass() throws Exception {
- try {
- Reflection.newProxy(Object.class, X_RETURNER);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> Reflection.newProxy(Object.class, X_RETURNER));
}
private static final InvocationHandler X_RETURNER =
diff --git a/android/guava-tests/test/com/google/common/reflect/TypeParameterTest.java b/android/guava-tests/test/com/google/common/reflect/TypeParameterTest.java
index b83e48596..ca49283a6 100644
--- a/android/guava-tests/test/com/google/common/reflect/TypeParameterTest.java
+++ b/android/guava-tests/test/com/google/common/reflect/TypeParameterTest.java
@@ -16,6 +16,8 @@
package com.google.common.reflect;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
import java.lang.reflect.Method;
@@ -38,11 +40,7 @@ public class TypeParameterTest extends TestCase {
}
public void testConcreteTypeRejected() {
- try {
- new TypeParameter<String>() {};
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> new TypeParameter<String>() {});
}
public <A, B> void testEquals() throws Exception {
diff --git a/android/guava-tests/test/com/google/common/reflect/TypeResolverTest.java b/android/guava-tests/test/com/google/common/reflect/TypeResolverTest.java
index e970a8d99..5eba7052d 100644
--- a/android/guava-tests/test/com/google/common/reflect/TypeResolverTest.java
+++ b/android/guava-tests/test/com/google/common/reflect/TypeResolverTest.java
@@ -16,6 +16,8 @@
package com.google.common.reflect;
+import static org.junit.Assert.assertThrows;
+
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
@@ -80,11 +82,7 @@ public class TypeResolverTest extends TestCase {
public <T> void testWhere_duplicateMapping() {
Type t = aTypeVariable();
TypeResolver resolver = new TypeResolver().where(t, String.class);
- try {
- resolver.where(t, String.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> resolver.where(t, String.class));
}
public <T1, T2 extends List<T1>> void testWhere_recursiveMapping() {
@@ -153,87 +151,77 @@ public class TypeResolverTest extends TestCase {
}
public <T> void testWhere_incompatibleGenericArrayMapping() {
- try {
- new TypeResolver().where(new TypeCapture<T[]>() {}.capture(), String.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new TypeResolver().where(new TypeCapture<T[]>() {}.capture(), String.class));
}
public <T> void testWhere_incompatibleParameterizedTypeMapping() {
- try {
- new TypeResolver().where(new TypeCapture<Iterable<T>>() {}.capture(), List.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new TypeResolver().where(new TypeCapture<Iterable<T>>() {}.capture(), List.class));
}
public <T> void testWhere_impossibleParameterizedTypeMapping() {
- try {
- new TypeResolver()
- .where(
- new TypeCapture<List<T>>() {}.capture(),
- new TypeCapture<Map<String, Integer>>() {}.capture());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new TypeResolver()
+ .where(
+ new TypeCapture<List<T>>() {}.capture(),
+ new TypeCapture<Map<String, Integer>>() {}.capture()));
}
public <T> void testWhere_incompatibleWildcardUpperBound() {
- try {
- new TypeResolver()
- .where(
- new TypeCapture<List<? extends String>>() {}.capture(),
- new TypeCapture<List<? extends Integer>>() {}.capture());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new TypeResolver()
+ .where(
+ new TypeCapture<List<? extends String>>() {}.capture(),
+ new TypeCapture<List<? extends Integer>>() {}.capture()));
}
public <T> void testWhere_incompatibleWildcardLowerBound() {
- try {
- new TypeResolver()
- .where(
- new TypeCapture<List<? super String>>() {}.capture(),
- new TypeCapture<List<? super Integer>>() {}.capture());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new TypeResolver()
+ .where(
+ new TypeCapture<List<? super String>>() {}.capture(),
+ new TypeCapture<List<? super Integer>>() {}.capture()));
}
public <T> void testWhere_incompatibleWildcardBounds() {
- try {
- new TypeResolver()
- .where(
- new TypeCapture<List<? extends T>>() {}.capture(),
- new TypeCapture<List<? super String>>() {}.capture());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new TypeResolver()
+ .where(
+ new TypeCapture<List<? extends T>>() {}.capture(),
+ new TypeCapture<List<? super String>>() {}.capture()));
}
public <T> void testWhere_wrongOrder() {
- try {
- new TypeResolver().where(String.class, aTypeVariable());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new TypeResolver().where(String.class, aTypeVariable()));
}
public <T> void testWhere_mapFromConcreteParameterizedType() {
- try {
- new TypeResolver().where(new TypeCapture<List<String>>() {}.capture(), aTypeVariable());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new TypeResolver()
+ .where(new TypeCapture<List<String>>() {}.capture(), aTypeVariable()));
}
public <T> void testWhere_mapFromConcreteGenericArrayType() {
- try {
- new TypeResolver().where(new TypeCapture<List<String>>() {}.capture(), aTypeVariable());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new TypeResolver()
+ .where(new TypeCapture<List<String>>() {}.capture(), aTypeVariable()));
}
public <K, V> void testWhere_actualArgHasWildcard() {
diff --git a/android/guava-tests/test/com/google/common/reflect/TypeTokenResolutionTest.java b/android/guava-tests/test/com/google/common/reflect/TypeTokenResolutionTest.java
index b8f5edbe0..0a7a9da32 100644
--- a/android/guava-tests/test/com/google/common/reflect/TypeTokenResolutionTest.java
+++ b/android/guava-tests/test/com/google/common/reflect/TypeTokenResolutionTest.java
@@ -17,6 +17,7 @@
package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
@@ -248,11 +249,7 @@ public class TypeTokenResolutionTest extends TestCase {
TypeToken.of(StringIterable.class)
.resolveType(Iterable.class.getTypeParameters()[0])
.getType());
- try {
- TypeToken.of(this.getClass()).resolveType(null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> TypeToken.of(this.getClass()).resolveType(null));
}
public void testContextIsParameterizedType() throws Exception {
diff --git a/android/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java b/android/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java
index b25aab57c..067f03c37 100644
--- a/android/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java
+++ b/android/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java
@@ -17,6 +17,7 @@
package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import java.io.Serializable;
import java.util.Comparator;
@@ -39,12 +40,10 @@ public class TypeTokenSubtypeTest extends TestCase {
* recursively bounded.
*/
public void testRecursiveWildcardSubtypeBug() throws Exception {
- try {
- new RecursiveTypeBoundBugExample<>().testAllDeclarations();
- fail();
- } catch (Exception e) {
- assertThat(e).hasCauseThat().isInstanceOf(AssertionError.class);
- }
+ Exception e =
+ assertThrows(
+ Exception.class, () -> new RecursiveTypeBoundBugExample<>().testAllDeclarations());
+ assertThat(e).hasCauseThat().isInstanceOf(AssertionError.class);
}
@SuppressWarnings("RestrictedApiChecker") // crashes under JDK8, which EP no longer supports
@@ -96,11 +95,7 @@ public class TypeTokenSubtypeTest extends TestCase {
public void testGetSubtypeOf_impossibleWildcard() {
TypeToken<List<? extends Number>> numberList = new TypeToken<List<? extends Number>>() {};
abstract class StringList implements List<String> {}
- try {
- numberList.getSubtype(StringList.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> numberList.getSubtype(StringList.class));
}
private static class OwnerTypeSubtypingTests extends SubtypeTester {
diff --git a/android/guava-tests/test/com/google/common/reflect/TypeTokenTest.java b/android/guava-tests/test/com/google/common/reflect/TypeTokenTest.java
index 5d66b840b..409d02b70 100644
--- a/android/guava-tests/test/com/google/common/reflect/TypeTokenTest.java
+++ b/android/guava-tests/test/com/google/common/reflect/TypeTokenTest.java
@@ -17,6 +17,7 @@
package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
@@ -65,6 +66,11 @@ public class TypeTokenTest extends TestCase {
}
public <T> void testVariableTypeTokenNotAllowed() {
+ /*
+ * We'd use assertThrows here, but that causes no exception to be thrown under Java 8,
+ * presumably because the ThrowingRunnable lambda triggers some kind of bug in Java 8's
+ * reflection implementation.
+ */
try {
new TypeToken<T>() {};
fail();
@@ -1147,11 +1153,9 @@ public class TypeTokenTest extends TestCase {
@SuppressWarnings({"rawtypes", "unchecked"}) // purpose is to test raw type
public void testGetSupertype_notSupertype() {
- try {
- new TypeToken<List<String>>() {}.getSupertype((Class) String.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new TypeToken<List<String>>() {}.getSupertype((Class) String.class));
}
public void testGetSupertype_fromArray() {
@@ -1235,11 +1239,7 @@ public class TypeTokenTest extends TestCase {
TypeToken<? super Iterable<String>> type =
(TypeToken<? super Iterable<String>>)
TypeToken.of(Types.supertypeOf(new TypeToken<ImmutableList<String>>() {}.getType()));
- try {
- type.getSubtype(List.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> type.getSubtype(List.class));
}
public void testGetSubtype_fromWildcard_upperBounded() {
@@ -1247,14 +1247,15 @@ public class TypeTokenTest extends TestCase {
TypeToken<? extends Iterable<String>> type =
(TypeToken<? extends Iterable<String>>)
TypeToken.of(Types.subtypeOf(new TypeToken<Iterable<String>>() {}.getType()));
- try {
- type.getSubtype(Iterable.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> type.getSubtype(Iterable.class));
}
public <T extends Iterable<String>> void testGetSubtype_fromTypeVariable() {
+ /*
+ * We'd use assertThrows here, but that causes capture() to return null under Java 8, presumably
+ * because the ThrowingRunnable lambda triggers some kind of bug in Java 8's reflection
+ * implementation.
+ */
try {
TypeToken.of(new TypeCapture<T>() {}.capture()).getSubtype(List.class);
fail();
@@ -1450,13 +1451,12 @@ public class TypeTokenTest extends TestCase {
@SuppressWarnings("unchecked") // To construct TypeToken<T> with TypeToken.of()
public <T> void testWhere_circleRejected() {
TypeToken<List<T>> type = new TypeToken<List<T>>() {};
- try {
- type.where(
- new TypeParameter<T>() {},
- (TypeToken<T>) TypeToken.of(new TypeCapture<T>() {}.capture()));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ type.where(
+ new TypeParameter<T>() {},
+ (TypeToken<T>) TypeToken.of(new TypeCapture<T>() {}.capture())));
}
public void testWhere() {
@@ -1587,11 +1587,7 @@ public class TypeTokenTest extends TestCase {
public void testMethod_notDeclaredByType() throws NoSuchMethodException {
Method sizeMethod = Map.class.getMethod("size");
- try {
- TypeToken.of(List.class).method(sizeMethod);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> TypeToken.of(List.class).method(sizeMethod));
}
public void testMethod_declaredBySuperclass() throws Exception {
@@ -1654,20 +1650,14 @@ public class TypeTokenTest extends TestCase {
public void testConstructor_notDeclaredByType() throws NoSuchMethodException {
Constructor<String> constructor = String.class.getConstructor();
- try {
- TypeToken.of(Object.class).constructor(constructor);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> TypeToken.of(Object.class).constructor(constructor));
}
public void testConstructor_declaredBySuperclass() throws NoSuchMethodException {
Constructor<Object> constructor = Object.class.getConstructor();
- try {
- TypeToken.of(String.class).constructor(constructor);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> TypeToken.of(String.class).constructor(constructor));
}
public void testConstructor_equals() throws NoSuchMethodException {
@@ -1840,19 +1830,13 @@ public class TypeTokenTest extends TestCase {
reserialize(new TypeToken<Map<String, Integer>>() {});
reserialize(new IKnowMyType<Map<? super String, ? extends int[]>>() {}.type());
reserialize(TypeToken.of(new TypeCapture<B>() {}.capture()).getTypes().rawTypes());
- try {
- SerializableTester.reserialize(TypeToken.of(new TypeCapture<B>() {}.capture()));
- fail();
- } catch (RuntimeException expected) {
- }
+ assertThrows(
+ RuntimeException.class,
+ () -> SerializableTester.reserialize(TypeToken.of(new TypeCapture<B>() {}.capture())));
}
public <A> void testSerializable_typeVariableNotSupported() {
- try {
- new ITryToSerializeMyTypeVariable<String>().go();
- fail();
- } catch (RuntimeException expected) {
- }
+ assertThrows(RuntimeException.class, () -> new ITryToSerializeMyTypeVariable<String>().go());
}
private static class ITryToSerializeMyTypeVariable<T> {
diff --git a/android/guava-tests/test/com/google/common/reflect/TypesTest.java b/android/guava-tests/test/com/google/common/reflect/TypesTest.java
index 436b2bbff..b33afce0b 100644
--- a/android/guava-tests/test/com/google/common/reflect/TypesTest.java
+++ b/android/guava-tests/test/com/google/common/reflect/TypesTest.java
@@ -18,6 +18,7 @@ package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
import static java.util.Arrays.asList;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.Lists;
import com.google.common.testing.EqualsTester;
@@ -117,11 +118,9 @@ public class TypesTest extends TestCase {
}
public void testNewParameterizedType_ownerMismatch() {
- try {
- Types.newParameterizedTypeWithOwner(Number.class, List.class, String.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Types.newParameterizedTypeWithOwner(Number.class, List.class, String.class));
}
public void testNewParameterizedType_ownerMissing() {
@@ -131,19 +130,15 @@ public class TypesTest extends TestCase {
}
public void testNewParameterizedType_invalidTypeParameters() {
- try {
- Types.newParameterizedTypeWithOwner(Map.class, Entry.class, String.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Types.newParameterizedTypeWithOwner(Map.class, Entry.class, String.class));
}
public void testNewParameterizedType_primitiveTypeParameters() {
- try {
- Types.newParameterizedTypeWithOwner(Map.class, Entry.class, int.class, int.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Types.newParameterizedTypeWithOwner(Map.class, Entry.class, int.class, int.class));
}
public void testNewArrayType() {
@@ -234,11 +229,7 @@ public class TypesTest extends TestCase {
}
public void testNewWildcardType_primitiveTypeBound() {
- try {
- Types.subtypeOf(int.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Types.subtypeOf(int.class));
}
public void testNewWildcardType_serializable() {
@@ -301,19 +292,15 @@ public class TypesTest extends TestCase {
}
public void testNewTypeVariable_primitiveTypeBound() {
- try {
- Types.newArtificialTypeVariable(List.class, "E", int.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Types.newArtificialTypeVariable(List.class, "E", int.class));
}
public void testNewTypeVariable_serializable() throws Exception {
- try {
- SerializableTester.reserialize(Types.newArtificialTypeVariable(List.class, "E"));
- fail();
- } catch (RuntimeException expected) {
- }
+ assertThrows(
+ RuntimeException.class,
+ () -> SerializableTester.reserialize(Types.newArtificialTypeVariable(List.class, "E")));
}
private static <D extends GenericDeclaration> TypeVariable<D> withBounds(
@@ -372,11 +359,9 @@ public class TypesTest extends TestCase {
}
public void testNewParameterizedTypeWithWrongNumberOfTypeArguments() {
- try {
- Types.newParameterizedType(Map.class, String.class, Integer.class, Long.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Types.newParameterizedType(Map.class, String.class, Integer.class, Long.class));
}
public void testToString() {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractChainedListenableFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractChainedListenableFutureTest.java
index 85c4e14a5..d0d8e89c8 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractChainedListenableFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractChainedListenableFutureTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.testing.MockFutureListener;
import java.util.concurrent.TimeUnit;
@@ -49,11 +50,7 @@ public abstract class AbstractChainedListenableFutureTest<T> extends TestCase {
public void testFutureGetBeforeCallback() throws Exception {
// Verify that get throws a timeout exception before the callback is called.
- try {
- resultFuture.get(1L, TimeUnit.MILLISECONDS);
- fail("The data is not yet ready, so a TimeoutException is expected");
- } catch (TimeoutException expected) {
- }
+ assertThrows(TimeoutException.class, () -> resultFuture.get(1L, TimeUnit.MILLISECONDS));
}
public void testFutureGetThrowsWrappedException() throws Exception {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractClosingFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractClosingFutureTest.java
index 8f0fde236..1afeff403 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractClosingFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractClosingFutureTest.java
@@ -30,6 +30,7 @@ import static com.google.common.util.concurrent.Uninterruptibles.getUninterrupti
import static java.util.Arrays.asList;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
@@ -722,11 +723,7 @@ public abstract class AbstractClosingFutureTest extends TestCase {
waitUntilClosed(closingFuture);
assertStillOpen(closeable2);
assertClosed(closeable1);
- try {
- capturedPeeker.get().getDone(input1);
- fail("Peeker should not be able to peek except during call.");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> capturedPeeker.get().getDone(input1));
}
public void testWhenAllComplete_call_cancelledPipeline() throws Exception {
@@ -808,11 +805,7 @@ public abstract class AbstractClosingFutureTest extends TestCase {
assertThat(getFinalValue(closingFuture)).isSameInstanceAs(closeable2);
waitUntilClosed(closingFuture);
assertClosed(closeable1, closeable2);
- try {
- capturedPeeker.get().getDone(input1);
- fail("Peeker should not be able to peek except during call.");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> capturedPeeker.get().getDone(input1));
}
public void testWhenAllComplete_callAsync_cancelledPipeline() throws Exception {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
index 9b3f0f867..ad2a676c3 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.testing.TearDown;
import com.google.common.testing.TearDownStack;
@@ -175,12 +176,9 @@ public class AbstractExecutionThreadServiceTest extends TestCase {
assertFalse(service.startUpCalled);
service.startAsync();
- try {
- service.awaitRunning();
- fail();
- } catch (IllegalStateException expected) {
- assertThat(expected).hasCauseThat().hasMessageThat().isEqualTo("kaboom!");
- }
+ IllegalStateException expected =
+ assertThrows(IllegalStateException.class, () -> service.awaitRunning());
+ assertThat(expected).hasCauseThat().hasMessageThat().isEqualTo("kaboom!");
executionThread.join();
assertTrue(service.startUpCalled);
@@ -212,14 +210,11 @@ public class AbstractExecutionThreadServiceTest extends TestCase {
ThrowOnRunService service = new ThrowOnRunService();
service.startAsync();
- try {
- service.awaitTerminated();
- fail();
- } catch (IllegalStateException expected) {
- executionThread.join();
- assertThat(expected).hasCauseThat().isEqualTo(service.failureCause());
- assertThat(expected).hasCauseThat().hasMessageThat().isEqualTo("kaboom!");
- }
+ IllegalStateException expected =
+ assertThrows(IllegalStateException.class, () -> service.awaitTerminated());
+ executionThread.join();
+ assertThat(expected).hasCauseThat().isEqualTo(service.failureCause());
+ assertThat(expected).hasCauseThat().hasMessageThat().isEqualTo("kaboom!");
assertTrue(service.shutDownCalled);
assertEquals(Service.State.FAILED, service.state());
}
@@ -229,15 +224,11 @@ public class AbstractExecutionThreadServiceTest extends TestCase {
service.throwOnShutDown = true;
service.startAsync();
- try {
- service.awaitTerminated();
- fail();
- } catch (IllegalStateException expected) {
- executionThread.join();
- assertThat(expected).hasCauseThat().isEqualTo(service.failureCause());
- assertThat(expected).hasCauseThat().hasMessageThat().isEqualTo("kaboom!");
- }
-
+ IllegalStateException expected =
+ assertThrows(IllegalStateException.class, () -> service.awaitTerminated());
+ executionThread.join();
+ assertThat(expected).hasCauseThat().isEqualTo(service.failureCause());
+ assertThat(expected).hasCauseThat().hasMessageThat().isEqualTo("kaboom!");
assertTrue(service.shutDownCalled);
assertEquals(Service.State.FAILED, service.state());
}
@@ -303,12 +294,11 @@ public class AbstractExecutionThreadServiceTest extends TestCase {
public void testServiceTimeoutOnStartUp() throws Exception {
TimeoutOnStartUp service = new TimeoutOnStartUp();
- try {
- service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
- fail();
- } catch (TimeoutException e) {
- assertThat(e.getMessage()).contains(Service.State.STARTING.toString());
- }
+ TimeoutException e =
+ assertThrows(
+ TimeoutException.class,
+ () -> service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS));
+ assertThat(e.getMessage()).contains(Service.State.STARTING.toString());
}
private class TimeoutOnStartUp extends AbstractExecutionThreadService {
@@ -377,14 +367,13 @@ public class AbstractExecutionThreadServiceTest extends TestCase {
return "Foo";
}
};
- try {
- service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
- fail("Expected timeout");
- } catch (TimeoutException e) {
- assertThat(e)
- .hasMessageThat()
- .isEqualTo("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
- }
+ TimeoutException e =
+ assertThrows(
+ TimeoutException.class,
+ () -> service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS));
+ assertThat(e)
+ .hasMessageThat()
+ .isEqualTo("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
}
private class FakeService extends AbstractExecutionThreadService implements TearDown {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java
index 9aee78029..d00f95f31 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import java.lang.reflect.Method;
import java.net.URLClassLoader;
@@ -89,12 +90,8 @@ public class AbstractFutureCancellationCauseTest extends TestCase {
assertTrue(future.isCancelled());
assertTrue(future.isDone());
assertNull(tryInternalFastPathGetFailure(future));
- try {
- future.get();
- fail("Expected CancellationException");
- } catch (CancellationException e) {
- assertNotNull(e.getCause());
- }
+ CancellationException e = assertThrows(CancellationException.class, () -> future.get());
+ assertNotNull(e.getCause());
}
public void testCancel_notDoneInterrupt() throws Exception {
@@ -103,12 +100,8 @@ public class AbstractFutureCancellationCauseTest extends TestCase {
assertTrue(future.isCancelled());
assertTrue(future.isDone());
assertNull(tryInternalFastPathGetFailure(future));
- try {
- future.get();
- fail("Expected CancellationException");
- } catch (CancellationException e) {
- assertNotNull(e.getCause());
- }
+ CancellationException e = assertThrows(CancellationException.class, () -> future.get());
+ assertNotNull(e.getCause());
}
public void testSetFuture_misbehavingFutureDoesNotThrow() throws Exception {
@@ -151,13 +144,9 @@ public class AbstractFutureCancellationCauseTest extends TestCase {
"setFuture",
future.getClass().getClassLoader().loadClass(ListenableFuture.class.getName()))
.invoke(future, badFuture);
- try {
- future.get();
- fail();
- } catch (CancellationException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
- assertThat(expected).hasCauseThat().hasMessageThat().contains(badFuture.toString());
- }
+ CancellationException expected = assertThrows(CancellationException.class, () -> future.get());
+ assertThat(expected).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
+ assertThat(expected).hasCauseThat().hasMessageThat().contains(badFuture.toString());
}
private Future<?> newFutureInstance() throws Exception {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java
index 89d92c8c4..6bf4c99d1 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java
@@ -20,6 +20,8 @@ import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_V
import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.Iterables;
@@ -97,13 +99,8 @@ public class AbstractFutureTest extends TestCase {
assertTrue(future.isDone());
assertFalse(future.wasInterrupted());
assertFalse(future.interruptTaskWasCalled);
- try {
- future.get();
- fail("Expected CancellationException");
- } catch (CancellationException e) {
- // See AbstractFutureCancellationCauseTest for how to set causes
- assertThat(e).hasCauseThat().isNull();
- }
+ CancellationException e = assertThrows(CancellationException.class, () -> future.get());
+ assertThat(e).hasCauseThat().isNull();
}
public void testCancel_notDoneInterrupt() throws Exception {
@@ -113,13 +110,8 @@ public class AbstractFutureTest extends TestCase {
assertTrue(future.isDone());
assertTrue(future.wasInterrupted());
assertTrue(future.interruptTaskWasCalled);
- try {
- future.get();
- fail("Expected CancellationException");
- } catch (CancellationException e) {
- // See AbstractFutureCancellationCauseTest for how to set causes
- assertThat(e).hasCauseThat().isNull();
- }
+ CancellationException e = assertThrows(CancellationException.class, () -> future.get());
+ assertThat(e).hasCauseThat().isNull();
}
public void testCancel_done() throws Exception {
@@ -156,12 +148,8 @@ public class AbstractFutureTest extends TestCase {
AbstractFuture<String> normalFuture = new AbstractFuture<String>() {};
normalFuture.setFuture(evilFuture);
assertTrue(normalFuture.isDone());
- try {
- normalFuture.get();
- fail();
- } catch (ExecutionException e) {
- assertThat(e).hasCauseThat().isSameInstanceAs(exception);
- }
+ ExecutionException e = assertThrows(ExecutionException.class, () -> normalFuture.get());
+ assertThat(e).hasCauseThat().isSameInstanceAs(exception);
}
public void testRemoveWaiter_interruption() throws Exception {
@@ -266,13 +254,10 @@ public class AbstractFutureTest extends TestCase {
assertThat(testFuture.toString())
.matches(
"[^\\[]+\\[status=PENDING, info=\\[cause=\\[Because this test isn't done\\]\\]\\]");
- try {
- testFuture.get(1, TimeUnit.NANOSECONDS);
- fail();
- } catch (TimeoutException e) {
- assertThat(e.getMessage()).contains("1 nanoseconds");
- assertThat(e.getMessage()).contains("Because this test isn't done");
- }
+ TimeoutException e =
+ assertThrows(TimeoutException.class, () -> testFuture.get(1, TimeUnit.NANOSECONDS));
+ assertThat(e.getMessage()).contains("1 nanoseconds");
+ assertThat(e.getMessage()).contains("Because this test isn't done");
}
public void testToString_completesDuringToString() throws Exception {
@@ -1072,6 +1057,25 @@ public class AbstractFutureTest extends TestCase {
t.join();
}
+ public void testCatchesUndeclaredThrowableFromListener() {
+ AbstractFuture<String> f = new AbstractFuture<String>() {};
+ f.set("foo");
+ f.addListener(() -> sneakyThrow(new SomeCheckedException()), directExecutor());
+ }
+
+ private static final class SomeCheckedException extends Exception {}
+
+ /** Throws an undeclared checked exception. */
+ private static void sneakyThrow(Throwable t) {
+ class SneakyThrower<T extends Throwable> {
+ @SuppressWarnings("unchecked") // intentionally unsafe for test
+ void throwIt(Throwable t) throws T {
+ throw (T) t;
+ }
+ }
+ new SneakyThrower<Error>().throwIt(t);
+ }
+
public void testTrustedGetFailure_Completed() {
SettableFuture<String> future = SettableFuture.create();
future.set("261");
@@ -1171,12 +1175,8 @@ public class AbstractFutureTest extends TestCase {
SettableFuture<String> normalFuture = SettableFuture.create();
normalFuture.setFuture(new FailFuture(exception));
assertTrue(normalFuture.isDone());
- try {
- normalFuture.get();
- fail();
- } catch (ExecutionException e) {
- assertSame(exception, e.getCause());
- }
+ ExecutionException e = assertThrows(ExecutionException.class, () -> normalFuture.get());
+ assertSame(exception, e.getCause());
}
private static void awaitUnchecked(final CyclicBarrier barrier) {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractIdleServiceTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractIdleServiceTest.java
index 0444c31be..6d4b9c9d4 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractIdleServiceTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractIdleServiceTest.java
@@ -18,6 +18,7 @@ package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.Lists;
import java.util.List;
@@ -53,12 +54,9 @@ public class AbstractIdleServiceTest extends TestCase {
}
};
assertEquals(0, service.startUpCalled);
- try {
- service.startAsync().awaitRunning();
- fail();
- } catch (RuntimeException e) {
- assertThat(e).hasCauseThat().isSameInstanceAs(exception);
- }
+ RuntimeException e =
+ assertThrows(RuntimeException.class, () -> service.startAsync().awaitRunning());
+ assertThat(e).hasCauseThat().isSameInstanceAs(exception);
assertEquals(1, service.startUpCalled);
assertEquals(Service.State.FAILED, service.state());
assertThat(service.transitionStates).containsExactly(Service.State.STARTING);
@@ -100,12 +98,9 @@ public class AbstractIdleServiceTest extends TestCase {
service.startAsync().awaitRunning();
assertEquals(1, service.startUpCalled);
assertEquals(0, service.shutDownCalled);
- try {
- service.stopAsync().awaitTerminated();
- fail();
- } catch (RuntimeException e) {
- assertThat(e).hasCauseThat().isSameInstanceAs(exception);
- }
+ RuntimeException e =
+ assertThrows(RuntimeException.class, () -> service.stopAsync().awaitTerminated());
+ assertThat(e).hasCauseThat().isSameInstanceAs(exception);
assertEquals(1, service.startUpCalled);
assertEquals(1, service.shutDownCalled);
assertEquals(Service.State.FAILED, service.state());
@@ -140,14 +135,13 @@ public class AbstractIdleServiceTest extends TestCase {
return "Foo";
}
};
- try {
- service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
- fail("Expected timeout");
- } catch (TimeoutException e) {
- assertThat(e)
- .hasMessageThat()
- .isEqualTo("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
- }
+ TimeoutException e =
+ assertThrows(
+ TimeoutException.class,
+ () -> service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS));
+ assertThat(e)
+ .hasMessageThat()
+ .isEqualTo("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
}
private static class TestService extends AbstractIdleService {
@@ -206,12 +200,9 @@ public class AbstractIdleServiceTest extends TestCase {
throw exception;
}
};
- try {
- service.startAsync().awaitRunning();
- fail();
- } catch (RuntimeException e) {
- assertThat(e).hasCauseThat().isSameInstanceAs(exception);
- }
+ RuntimeException e =
+ assertThrows(RuntimeException.class, () -> service.startAsync().awaitRunning());
+ assertThat(e).hasCauseThat().isSameInstanceAs(exception);
assertEquals(Service.State.FAILED, service.state());
}
@@ -225,12 +216,9 @@ public class AbstractIdleServiceTest extends TestCase {
}
};
service.startAsync().awaitRunning();
- try {
- service.stopAsync().awaitTerminated();
- fail();
- } catch (RuntimeException e) {
- assertThat(e).hasCauseThat().isSameInstanceAs(exception);
- }
+ RuntimeException e =
+ assertThrows(RuntimeException.class, () -> service.stopAsync().awaitTerminated());
+ assertThat(e).hasCauseThat().isSameInstanceAs(exception);
assertEquals(Service.State.FAILED, service.state());
}
}
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
index f7266b274..b3c606986 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
@@ -22,6 +22,7 @@ import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.AbstractScheduledService.Cancellable;
import com.google.common.util.concurrent.AbstractScheduledService.Scheduler;
@@ -97,11 +98,7 @@ public class AbstractScheduledServiceTest extends TestCase {
service.startAsync().awaitRunning();
service.runFirstBarrier.await();
service.runSecondBarrier.await();
- try {
- future.get();
- fail();
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> future.get());
// An execution exception holds a runtime exception (from throwables.propagate) that holds our
// original exception.
assertEquals(service.runException, service.failureCause());
@@ -111,12 +108,9 @@ public class AbstractScheduledServiceTest extends TestCase {
public void testFailOnExceptionFromStartUp() {
TestService service = new TestService();
service.startUpException = new Exception();
- try {
- service.startAsync().awaitRunning();
- fail();
- } catch (IllegalStateException e) {
- assertThat(e).hasCauseThat().isEqualTo(service.startUpException);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.startAsync().awaitRunning());
+ assertThat(e).hasCauseThat().isEqualTo(service.startUpException);
assertEquals(0, service.numberOfTimesRunCalled.get());
assertEquals(Service.State.FAILED, service.state());
}
@@ -154,12 +148,9 @@ public class AbstractScheduledServiceTest extends TestCase {
service.runFirstBarrier.await();
service.stopAsync();
service.runSecondBarrier.await();
- try {
- service.awaitTerminated();
- fail();
- } catch (IllegalStateException e) {
- assertThat(e).hasCauseThat().isEqualTo(service.shutDownException);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.awaitTerminated());
+ assertThat(e).hasCauseThat().isEqualTo(service.shutDownException);
assertEquals(Service.State.FAILED, service.state());
}
@@ -246,11 +237,7 @@ public class AbstractScheduledServiceTest extends TestCase {
}
};
- try {
- service.startAsync().awaitRunning();
- fail("Expected service to fail during startup");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.startAsync().awaitRunning());
assertTrue(executor.get().awaitTermination(100, MILLISECONDS));
}
@@ -295,14 +282,12 @@ public class AbstractScheduledServiceTest extends TestCase {
return "Foo";
}
};
- try {
- service.startAsync().awaitRunning(1, MILLISECONDS);
- fail("Expected timeout");
- } catch (TimeoutException e) {
- assertThat(e)
- .hasMessageThat()
- .isEqualTo("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
- }
+ TimeoutException e =
+ assertThrows(
+ TimeoutException.class, () -> service.startAsync().awaitRunning(1, MILLISECONDS));
+ assertThat(e)
+ .hasMessageThat()
+ .isEqualTo("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
}
private class TestService extends AbstractScheduledService {
@@ -453,11 +438,7 @@ public class AbstractScheduledServiceTest extends TestCase {
}
};
service.startAsync().awaitRunning();
- try {
- service.firstBarrier.await(5, SECONDS);
- fail();
- } catch (TimeoutException expected) {
- }
+ assertThrows(TimeoutException.class, () -> service.firstBarrier.await(5, SECONDS));
assertEquals(0, service.numIterations.get());
service.stopAsync();
service.awaitTerminated();
@@ -478,11 +459,7 @@ public class AbstractScheduledServiceTest extends TestCase {
}
};
service.startAsync().awaitRunning();
- try {
- service.firstBarrier.await(5, SECONDS);
- fail();
- } catch (TimeoutException expected) {
- }
+ assertThrows(TimeoutException.class, () -> service.firstBarrier.await(5, SECONDS));
assertEquals(0, service.numIterations.get());
service.stopAsync();
service.awaitTerminated();
@@ -639,12 +616,10 @@ public class AbstractScheduledServiceTest extends TestCase {
service.secondBarrier.await();
}
Thread.sleep(1000);
- try {
- service.stopAsync().awaitTerminated(100, SECONDS);
- fail();
- } catch (IllegalStateException e) {
- assertEquals(State.FAILED, service.state());
- }
+ IllegalStateException e =
+ assertThrows(
+ IllegalStateException.class, () -> service.stopAsync().awaitTerminated(100, SECONDS));
+ assertEquals(State.FAILED, service.state());
}
private static class TestFailingCustomScheduledService extends AbstractScheduledService {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java
index 5f4210621..e4d310331 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -449,12 +450,9 @@ public class AbstractServiceTest extends TestCase {
service.notifyFailed(new Exception("1"));
service.notifyFailed(new Exception("2"));
assertThat(service.failureCause()).hasMessageThat().isEqualTo("1");
- try {
- service.awaitRunning();
- fail();
- } catch (IllegalStateException e) {
- assertThat(e).hasCauseThat().hasMessageThat().isEqualTo("1");
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.awaitRunning());
+ assertThat(e).hasCauseThat().hasMessageThat().isEqualTo("1");
}
private class ThreadedService extends AbstractService {
@@ -531,11 +529,7 @@ public class AbstractServiceTest extends TestCase {
service.stopAsync();
assertEquals(State.TERMINATED, service.state());
- try {
- service.startAsync();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.startAsync());
assertEquals(State.TERMINATED, Iterables.getOnlyElement(listener.getStateHistory()));
}
@@ -543,13 +537,10 @@ public class AbstractServiceTest extends TestCase {
StartFailingService service = new StartFailingService();
RecordingListener listener = RecordingListener.record(service);
- try {
- service.startAsync().awaitRunning();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(EXCEPTION, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.startAsync().awaitRunning());
+ assertEquals(EXCEPTION, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
assertEquals(ImmutableList.of(State.STARTING, State.FAILED), listener.getStateHistory());
}
@@ -558,13 +549,10 @@ public class AbstractServiceTest extends TestCase {
RecordingListener listener = RecordingListener.record(service);
service.startAsync().awaitRunning();
- try {
- service.stopAsync().awaitTerminated();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(EXCEPTION, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.stopAsync().awaitTerminated());
+ assertEquals(EXCEPTION, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
assertEquals(
ImmutableList.of(State.STARTING, State.RUNNING, State.STOPPING, State.FAILED),
listener.getStateHistory());
@@ -575,13 +563,10 @@ public class AbstractServiceTest extends TestCase {
RecordingListener listener = RecordingListener.record(service);
service.startAsync();
- try {
- service.awaitRunning();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(EXCEPTION, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.awaitRunning());
+ assertEquals(EXCEPTION, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
assertEquals(
ImmutableList.of(State.STARTING, State.RUNNING, State.FAILED), listener.getStateHistory());
}
@@ -590,13 +575,10 @@ public class AbstractServiceTest extends TestCase {
StartThrowingService service = new StartThrowingService();
RecordingListener listener = RecordingListener.record(service);
- try {
- service.startAsync().awaitRunning();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(service.exception, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(service.exception);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.startAsync().awaitRunning());
+ assertEquals(service.exception, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(service.exception);
assertEquals(ImmutableList.of(State.STARTING, State.FAILED), listener.getStateHistory());
}
@@ -605,13 +587,10 @@ public class AbstractServiceTest extends TestCase {
RecordingListener listener = RecordingListener.record(service);
service.startAsync().awaitRunning();
- try {
- service.stopAsync().awaitTerminated();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(service.exception, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(service.exception);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.stopAsync().awaitTerminated());
+ assertEquals(service.exception, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(service.exception);
assertEquals(
ImmutableList.of(State.STARTING, State.RUNNING, State.STOPPING, State.FAILED),
listener.getStateHistory());
@@ -622,37 +601,23 @@ public class AbstractServiceTest extends TestCase {
RecordingListener listener = RecordingListener.record(service);
service.startAsync();
- try {
- service.awaitTerminated();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(service.exception, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(service.exception);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.awaitTerminated());
+ assertEquals(service.exception, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(service.exception);
assertEquals(
ImmutableList.of(State.STARTING, State.RUNNING, State.FAILED), listener.getStateHistory());
}
public void testFailureCause_throwsIfNotFailed() {
StopFailingService service = new StopFailingService();
- try {
- service.failureCause();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.failureCause());
service.startAsync().awaitRunning();
- try {
- service.failureCause();
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- service.stopAsync().awaitTerminated();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(EXCEPTION, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
- }
+ assertThrows(IllegalStateException.class, () -> service.failureCause());
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.stopAsync().awaitTerminated());
+ assertEquals(EXCEPTION, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
}
public void testAddListenerAfterFailureDoesntCauseDeadlock() throws InterruptedException {
@@ -912,40 +877,24 @@ public class AbstractServiceTest extends TestCase {
public void testNotifyStartedWhenNotStarting() {
AbstractService service = new DefaultService();
- try {
- service.notifyStarted();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.notifyStarted());
}
public void testNotifyStoppedWhenNotRunning() {
AbstractService service = new DefaultService();
- try {
- service.notifyStopped();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.notifyStopped());
}
public void testNotifyFailedWhenNotStarted() {
AbstractService service = new DefaultService();
- try {
- service.notifyFailed(new Exception());
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.notifyFailed(new Exception()));
}
public void testNotifyFailedWhenTerminated() {
NoOpService service = new NoOpService();
service.startAsync().awaitRunning();
service.stopAsync().awaitTerminated();
- try {
- service.notifyFailed(new Exception());
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.notifyFailed(new Exception()));
}
private static class DefaultService extends AbstractService {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java
index 5bb1cb74e..4220d873f 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java
@@ -13,6 +13,8 @@
package com.google.common.util.concurrent;
+import static org.junit.Assert.assertThrows;
+
import java.util.Arrays;
/** Unit test for {@link AtomicDoubleArray}. */
@@ -59,11 +61,7 @@ public class AtomicDoubleArrayTest extends JSR166TestCase {
/** constructor with null array throws NPE */
public void testConstructor2NPE() {
double[] a = null;
- try {
- new AtomicDoubleArray(a);
- fail();
- } catch (NullPointerException success) {
- }
+ assertThrows(NullPointerException.class, () -> new AtomicDoubleArray(a));
}
/** constructor with array is of same size and has all elements */
@@ -79,63 +77,27 @@ public class AtomicDoubleArrayTest extends JSR166TestCase {
public void testConstructorEmptyArray() {
AtomicDoubleArray aa = new AtomicDoubleArray(new double[0]);
assertEquals(0, aa.length());
- try {
- aa.get(0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.get(0));
}
/** constructor with length zero has size 0 and contains no elements */
public void testConstructorZeroLength() {
AtomicDoubleArray aa = new AtomicDoubleArray(0);
assertEquals(0, aa.length());
- try {
- aa.get(0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.get(0));
}
/** get and set for out of bound indices throw IndexOutOfBoundsException */
public void testIndexing() {
AtomicDoubleArray aa = new AtomicDoubleArray(SIZE);
for (int index : new int[] {-1, SIZE}) {
- try {
- aa.get(index);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
- try {
- aa.set(index, 1.0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
- try {
- aa.lazySet(index, 1.0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
- try {
- aa.compareAndSet(index, 1.0, 2.0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
- try {
- aa.weakCompareAndSet(index, 1.0, 2.0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
- try {
- aa.getAndAdd(index, 1.0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
- try {
- aa.addAndGet(index, 1.0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.get(index));
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.set(index, 1.0));
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.lazySet(index, 1.0));
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.compareAndSet(index, 1.0, 2.0));
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.weakCompareAndSet(index, 1.0, 2.0));
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.getAndAdd(index, 1.0));
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.addAndGet(index, 1.0));
}
}
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/AtomicsTest.java b/android/guava-tests/test/com/google/common/util/concurrent/AtomicsTest.java
index b903e6ce8..90f0f6f76 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/AtomicsTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/AtomicsTest.java
@@ -16,6 +16,8 @@
package com.google.common.util.concurrent;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.testing.NullPointerTester;
import java.util.concurrent.atomic.AtomicReferenceArray;
import junit.framework.TestCase;
@@ -44,19 +46,11 @@ public class AtomicsTest extends TestCase {
for (int i = 0; i < length; ++i) {
assertEquals(null, refArray.get(i));
}
- try {
- refArray.get(length);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> refArray.get(length));
}
public void testNewReferenceArray_withNegativeLength() throws Exception {
- try {
- Atomics.newReferenceArray(-1);
- fail();
- } catch (NegativeArraySizeException expected) {
- }
+ assertThrows(NegativeArraySizeException.class, () -> Atomics.newReferenceArray(-1));
}
public void testNewReferenceArray_withStringArray() throws Exception {
@@ -65,19 +59,11 @@ public class AtomicsTest extends TestCase {
for (int i = 0; i < array.length; ++i) {
assertEquals(array[i], refArray.get(i));
}
- try {
- refArray.get(array.length);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> refArray.get(array.length));
}
public void testNewReferenceArray_withNullArray() throws Exception {
- try {
- Atomics.newReferenceArray(null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Atomics.newReferenceArray(null));
}
public void testNullPointers() {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToFutureTest.java
index 79288eb2a..29ce341e1 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToFutureTest.java
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.ClosingFuture.ClosingCallable;
import com.google.common.util.concurrent.ClosingFuture.DeferredCloser;
@@ -39,11 +40,11 @@ public class ClosingFutureFinishToFutureTest extends AbstractClosingFutureTest {
},
executor);
FluentFuture<Closeable> unused = closingFuture.finishToFuture();
- try {
- FluentFuture<Closeable> unused2 = closingFuture.finishToFuture();
- fail("should have thrown");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> {
+ FluentFuture<Closeable> unused2 = closingFuture.finishToFuture();
+ });
}
public void testFinishToFuture_throwsAfterCallingFinishToValueAndCloser() throws Exception {
@@ -57,11 +58,11 @@ public class ClosingFutureFinishToFutureTest extends AbstractClosingFutureTest {
},
executor);
closingFuture.finishToValueAndCloser(new NoOpValueAndCloserConsumer<>(), directExecutor());
- try {
- FluentFuture<Closeable> unused = closingFuture.finishToFuture();
- fail("should have thrown");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> {
+ FluentFuture<Closeable> unused = closingFuture.finishToFuture();
+ });
}
public void testFinishToFuture_preventsFurtherDerivation() {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToValueAndCloserTest.java b/android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToValueAndCloserTest.java
index ac3cf5569..c249eca34 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToValueAndCloserTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToValueAndCloserTest.java
@@ -22,6 +22,7 @@ import static com.google.common.util.concurrent.MoreExecutors.shutdownAndAwaitTe
import static com.google.common.util.concurrent.Uninterruptibles.awaitUninterruptibly;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.ClosingFuture.ClosingCallable;
import com.google.common.util.concurrent.ClosingFuture.DeferredCloser;
@@ -61,12 +62,11 @@ public class ClosingFutureFinishToValueAndCloserTest extends AbstractClosingFutu
executor);
closingFuture.finishToValueAndCloser(
new NoOpValueAndCloserConsumer<>(), finishToValueAndCloserExecutor);
- try {
- closingFuture.finishToValueAndCloser(
- new NoOpValueAndCloserConsumer<>(), finishToValueAndCloserExecutor);
- fail("should have thrown");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () ->
+ closingFuture.finishToValueAndCloser(
+ new NoOpValueAndCloserConsumer<>(), finishToValueAndCloserExecutor));
}
public void testFinishToValueAndCloser_throwsAfterCallingFinishToFuture() throws Exception {
@@ -80,12 +80,11 @@ public class ClosingFutureFinishToValueAndCloserTest extends AbstractClosingFutu
},
executor);
FluentFuture<Closeable> unused = closingFuture.finishToFuture();
- try {
- closingFuture.finishToValueAndCloser(
- new NoOpValueAndCloserConsumer<>(), finishToValueAndCloserExecutor);
- fail("should have thrown");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () ->
+ closingFuture.finishToValueAndCloser(
+ new NoOpValueAndCloserConsumer<>(), finishToValueAndCloserExecutor));
}
@Override
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java b/android/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java
index bf388b0ba..3e88ecb11 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Joiner;
import com.google.common.util.concurrent.CycleDetectingLockFactory.Policies;
@@ -102,24 +103,15 @@ public class CycleDetectingLockFactoryTest extends TestCase {
// The opposite order should fail (Policies.THROW).
PotentialDeadlockException firstException = null;
lockB.lock();
- try {
- lockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockB -> LockA", "LockA -> LockB");
- firstException = expected;
- }
-
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> lockA.lock());
+ checkMessage(expected, "LockB -> LockA", "LockA -> LockB");
+ firstException = expected;
// Second time should also fail, with a cached causal chain.
- try {
- lockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockB -> LockA", "LockA -> LockB");
- // The causal chain should be cached.
- assertSame(firstException.getCause(), expected.getCause());
- }
-
+ expected = assertThrows(PotentialDeadlockException.class, () -> lockA.lock());
+ checkMessage(expected, "LockB -> LockA", "LockA -> LockB");
+ // The causal chain should be cached.
+ assertSame(firstException.getCause(), expected.getCause());
// lockA should work after lockB is released.
lockB.unlock();
lockA.lock();
@@ -139,12 +131,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
lockB.unlock();
// lockC -> lockA should fail.
- try {
- lockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockC -> LockA", "LockB -> LockC", "LockA -> LockB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> lockA.lock());
+ checkMessage(expected, "LockC -> LockA", "LockB -> LockC", "LockA -> LockB");
}
public void testReentrancy_noDeadlock() {
@@ -163,29 +152,18 @@ public class CycleDetectingLockFactoryTest extends TestCase {
public void testExplicitOrdering_violations() {
lock3.lock();
- try {
- lock2.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "MyOrder.THIRD -> MyOrder.SECOND");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> lock2.lock());
+ checkMessage(expected, "MyOrder.THIRD -> MyOrder.SECOND");
- try {
- lock1.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "MyOrder.THIRD -> MyOrder.FIRST");
- }
+ expected = assertThrows(PotentialDeadlockException.class, () -> lock1.lock());
+ checkMessage(expected, "MyOrder.THIRD -> MyOrder.FIRST");
lock3.unlock();
lock2.lock();
- try {
- lock1.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "MyOrder.SECOND -> MyOrder.FIRST");
- }
+ expected = assertThrows(PotentialDeadlockException.class, () -> lock1.lock());
+ checkMessage(expected, "MyOrder.SECOND -> MyOrder.FIRST");
}
public void testDifferentOrderings_noViolations() {
@@ -198,26 +176,18 @@ public class CycleDetectingLockFactoryTest extends TestCase {
lock01.lock(); // OtherOrder, ordinal() == 1
lock3.unlock();
- try {
- lock3.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(
- expected, "OtherOrder.FIRST -> MyOrder.THIRD", "MyOrder.THIRD -> OtherOrder.FIRST");
- }
-
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> lock3.lock());
+ checkMessage(
+ expected, "OtherOrder.FIRST -> MyOrder.THIRD", "MyOrder.THIRD -> OtherOrder.FIRST");
lockA.lock();
lock01.unlock();
lockB.lock();
lockA.unlock();
- try {
- lock01.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(
- expected, "LockB -> OtherOrder.FIRST", "LockA -> LockB", "OtherOrder.FIRST -> LockA");
- }
+ expected = assertThrows(PotentialDeadlockException.class, () -> lock01.lock());
+ checkMessage(
+ expected, "LockB -> OtherOrder.FIRST", "LockA -> LockB", "OtherOrder.FIRST -> LockA");
}
public void testExplicitOrdering_cycleWithUnorderedLock() {
@@ -226,16 +196,13 @@ public class CycleDetectingLockFactoryTest extends TestCase {
myLock.lock();
lock03.unlock();
- try {
- lock01.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(
- expected,
- "MyLock -> OtherOrder.FIRST",
- "OtherOrder.THIRD -> MyLock",
- "OtherOrder.FIRST -> OtherOrder.THIRD");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> lock01.lock());
+ checkMessage(
+ expected,
+ "MyLock -> OtherOrder.FIRST",
+ "OtherOrder.THIRD -> MyLock",
+ "OtherOrder.FIRST -> OtherOrder.THIRD");
}
public void testExplicitOrdering_reentrantAcquisition() {
@@ -261,11 +228,7 @@ public class CycleDetectingLockFactoryTest extends TestCase {
Lock lockB = factory.newReentrantReadWriteLock(OtherOrder.FIRST).readLock();
lockA.lock();
- try {
- lockB.lock();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> lockB.lock());
lockA.unlock();
lockB.lock();
@@ -278,12 +241,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
readLockA.unlock();
lockB.lock();
- try {
- readLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockB -> ReadWriteA", "ReadWriteA -> LockB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> readLockA.lock());
+ checkMessage(expected, "LockB -> ReadWriteA", "ReadWriteA -> LockB");
}
public void testReadLock_transitive() {
@@ -300,13 +260,10 @@ public class CycleDetectingLockFactoryTest extends TestCase {
// readLockC -> readLockA
readLockC.lock();
- try {
- readLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(
- expected, "ReadWriteC -> ReadWriteA", "LockB -> ReadWriteC", "ReadWriteA -> LockB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> readLockA.lock());
+ checkMessage(
+ expected, "ReadWriteC -> ReadWriteA", "LockB -> ReadWriteC", "ReadWriteA -> LockB");
}
public void testWriteLock_threeLockDeadLock() {
@@ -322,16 +279,13 @@ public class CycleDetectingLockFactoryTest extends TestCase {
writeLockB.unlock();
// writeLockC -> writeLockA should fail.
- try {
- writeLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(
- expected,
- "ReadWriteC -> ReadWriteA",
- "ReadWriteB -> ReadWriteC",
- "ReadWriteA -> ReadWriteB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> writeLockA.lock());
+ checkMessage(
+ expected,
+ "ReadWriteC -> ReadWriteA",
+ "ReadWriteB -> ReadWriteC",
+ "ReadWriteA -> ReadWriteB");
}
public void testWriteToReadLockDowngrading() {
@@ -343,12 +297,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
readLockA.unlock();
// lockB -> writeLockA should fail
- try {
- writeLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockB -> ReadWriteA", "ReadWriteA -> LockB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> writeLockA.lock());
+ checkMessage(expected, "LockB -> ReadWriteA", "ReadWriteA -> LockB");
}
public void testReadWriteLockDeadlock() {
@@ -359,12 +310,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
// lockB -> readLockA should fail.
lockB.lock();
- try {
- readLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockB -> ReadWriteA", "ReadWriteA -> LockB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> readLockA.lock());
+ checkMessage(expected, "LockB -> ReadWriteA", "ReadWriteA -> LockB");
}
public void testReadWriteLockDeadlock_transitive() {
@@ -381,12 +329,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
// lockC -> writeLockA should fail.
lockC.lock();
- try {
- writeLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockC -> ReadWriteA", "LockB -> LockC", "ReadWriteA -> LockB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> writeLockA.lock());
+ checkMessage(expected, "LockC -> ReadWriteA", "LockB -> LockC", "ReadWriteA -> LockB");
}
public void testReadWriteLockDeadlock_treatedEquivalently() {
@@ -397,12 +342,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
// readLockB -> writeLockA should fail.
readLockB.lock();
- try {
- writeLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "ReadWriteB -> ReadWriteA", "ReadWriteA -> ReadWriteB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> writeLockA.lock());
+ checkMessage(expected, "ReadWriteB -> ReadWriteA", "ReadWriteA -> ReadWriteB");
}
public void testDifferentLockFactories() {
@@ -417,12 +359,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
// lockD -> lockA should fail even though lockD is from a different factory.
lockD.lock();
- try {
- lockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockD -> LockA", "LockA -> LockD");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> lockA.lock());
+ checkMessage(expected, "LockD -> LockA", "LockA -> LockD");
}
public void testDifferentLockFactories_policyExecution() {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/FakeTimeLimiterTest.java b/android/guava-tests/test/com/google/common/util/concurrent/FakeTimeLimiterTest.java
index a0e063469..4eb72e3b7 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/FakeTimeLimiterTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/FakeTimeLimiterTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -51,22 +52,24 @@ public class FakeTimeLimiterTest extends TestCase {
public void testCallWithTimeout_wrapsCheckedException() throws Exception {
Exception exception = new SampleCheckedException();
- try {
- timeLimiter.callWithTimeout(callableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS);
- fail("Expected ExecutionException");
- } catch (ExecutionException e) {
- assertThat(e.getCause()).isEqualTo(exception);
- }
+ ExecutionException e =
+ assertThrows(
+ ExecutionException.class,
+ () ->
+ timeLimiter.callWithTimeout(
+ callableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS));
+ assertThat(e.getCause()).isEqualTo(exception);
}
public void testCallWithTimeout_wrapsUncheckedException() throws Exception {
Exception exception = new RuntimeException("test");
- try {
- timeLimiter.callWithTimeout(callableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS);
- fail("Expected UncheckedExecutionException");
- } catch (UncheckedExecutionException e) {
- assertThat(e.getCause()).isEqualTo(exception);
- }
+ UncheckedExecutionException e =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () ->
+ timeLimiter.callWithTimeout(
+ callableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS));
+ assertThat(e.getCause()).isEqualTo(exception);
}
public void testCallUninterruptiblyWithTimeout_propagatesReturnValue() throws Exception {
@@ -83,23 +86,24 @@ public class FakeTimeLimiterTest extends TestCase {
public void testRunWithTimeout_wrapsUncheckedException() throws Exception {
RuntimeException exception = new RuntimeException("test");
- try {
- timeLimiter.runWithTimeout(runnableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS);
- fail("Expected UncheckedExecutionException");
- } catch (UncheckedExecutionException e) {
- assertThat(e.getCause()).isEqualTo(exception);
- }
+ UncheckedExecutionException e =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () ->
+ timeLimiter.runWithTimeout(
+ runnableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS));
+ assertThat(e.getCause()).isEqualTo(exception);
}
public void testRunUninterruptiblyWithTimeout_wrapsUncheckedException() throws Exception {
RuntimeException exception = new RuntimeException("test");
- try {
- timeLimiter.runUninterruptiblyWithTimeout(
- runnableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS);
- fail("Expected UncheckedExecutionException");
- } catch (UncheckedExecutionException e) {
- assertThat(e.getCause()).isEqualTo(exception);
- }
+ UncheckedExecutionException e =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () ->
+ timeLimiter.runUninterruptiblyWithTimeout(
+ runnableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS));
+ assertThat(e.getCause()).isEqualTo(exception);
}
public static <T> Callable<T> callableThrowing(final Exception exception) {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
index ab53f5383..48d5c8e5a 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
@@ -23,6 +23,7 @@ import static com.google.common.util.concurrent.Futures.immediateFuture;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static java.util.concurrent.Executors.newScheduledThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -138,12 +139,8 @@ public class FluentFutureTest extends TestCase {
try {
FluentFuture<?> f =
FluentFuture.from(SettableFuture.create()).withTimeout(0, SECONDS, executor);
- try {
- f.get();
- fail();
- } catch (ExecutionException e) {
- assertThat(e).hasCauseThat().isInstanceOf(TimeoutException.class);
- }
+ ExecutionException e = assertThrows(ExecutionException.class, () -> f.get());
+ assertThat(e).hasCauseThat().isInstanceOf(TimeoutException.class);
} finally {
executor.shutdown();
}
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedInputs.java b/android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedInputs.java
index 27916d8a1..0ae248837 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedInputs.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedInputs.java
@@ -18,6 +18,7 @@ import static com.google.common.util.concurrent.Futures.immediateFailedFuture;
import com.google.common.annotations.GwtCompatible;
import java.util.concurrent.Future;
+import javax.annotation.CheckForNull;
/**
* Classes and futures used in {@link FuturesGetCheckedTest} and {@link FuturesGetUncheckedTest}.
@@ -58,6 +59,47 @@ final class FuturesGetCheckedInputs {
}
}
+ public static final class ExceptionWithManyConstructorsButOnlyOneThrowable extends Exception {
+ @CheckForNull private Throwable antecedent;
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(String message, String a1) {
+ super(message);
+ }
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(String message, String a1, String a2) {
+ super(message);
+ }
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(
+ String message, String a1, String a2, String a3) {
+ super(message);
+ }
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(String message, Throwable antecedent) {
+ super(message);
+ this.antecedent = antecedent;
+ }
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(
+ String message, String a1, String a2, String a3, String a4) {
+ super(message);
+ }
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(
+ String message, String a1, String a2, String a3, String a4, String a5) {
+ super(message);
+ }
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(
+ String message, String a1, String a2, String a3, String a4, String a5, String a6) {
+ super(message);
+ }
+
+ public Throwable getAntecedent() {
+ return antecedent;
+ }
+ }
+
@SuppressWarnings("unused") // we're testing that they're not used
public static final class ExceptionWithSomePrivateConstructors extends Exception {
private ExceptionWithSomePrivateConstructors(String a) {}
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java b/android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java
index 666a18929..fa615133a 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java
@@ -30,11 +30,13 @@ import static com.google.common.util.concurrent.FuturesGetCheckedInputs.RUNTIME_
import static com.google.common.util.concurrent.FuturesGetCheckedInputs.RUNTIME_EXCEPTION_FUTURE;
import static com.google.common.util.concurrent.FuturesGetCheckedInputs.UNCHECKED_EXCEPTION;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.testing.GcFinalization;
import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithBadConstructor;
import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithGoodAndBadConstructor;
import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithManyConstructors;
+import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithManyConstructorsButOnlyOneThrowable;
import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithPrivateConstructor;
import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithSomePrivateConstructors;
import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithWrongTypesConstructor;
@@ -74,57 +76,49 @@ public class FuturesGetCheckedTest extends TestCase {
public void testGetCheckedUntimed_cancelled() throws TwoArgConstructorException {
SettableFuture<String> future = SettableFuture.create();
future.cancel(true);
- try {
- getChecked(future, TwoArgConstructorException.class);
- fail();
- } catch (CancellationException expected) {
- }
+ assertThrows(
+ CancellationException.class, () -> getChecked(future, TwoArgConstructorException.class));
}
public void testGetCheckedUntimed_ExecutionExceptionChecked() {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, TwoArgConstructorException.class);
- fail();
- } catch (TwoArgConstructorException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(CHECKED_EXCEPTION);
- }
+ TwoArgConstructorException expected =
+ assertThrows(
+ TwoArgConstructorException.class,
+ () -> getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, TwoArgConstructorException.class));
+ assertThat(expected).hasCauseThat().isEqualTo(CHECKED_EXCEPTION);
}
public void testGetCheckedUntimed_ExecutionExceptionUnchecked()
throws TwoArgConstructorException {
- try {
- getChecked(FAILED_FUTURE_UNCHECKED_EXCEPTION, TwoArgConstructorException.class);
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(UNCHECKED_EXCEPTION);
- }
+ UncheckedExecutionException expected =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () -> getChecked(FAILED_FUTURE_UNCHECKED_EXCEPTION, TwoArgConstructorException.class));
+ assertThat(expected).hasCauseThat().isEqualTo(UNCHECKED_EXCEPTION);
}
public void testGetCheckedUntimed_ExecutionExceptionError() throws TwoArgConstructorException {
- try {
- getChecked(FAILED_FUTURE_ERROR, TwoArgConstructorException.class);
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isEqualTo(ERROR);
- }
+ ExecutionError expected =
+ assertThrows(
+ ExecutionError.class,
+ () -> getChecked(FAILED_FUTURE_ERROR, TwoArgConstructorException.class));
+ assertThat(expected).hasCauseThat().isEqualTo(ERROR);
}
public void testGetCheckedUntimed_ExecutionExceptionOtherThrowable() {
- try {
- getChecked(FAILED_FUTURE_OTHER_THROWABLE, TwoArgConstructorException.class);
- fail();
- } catch (TwoArgConstructorException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(OTHER_THROWABLE);
- }
+ TwoArgConstructorException expected =
+ assertThrows(
+ TwoArgConstructorException.class,
+ () -> getChecked(FAILED_FUTURE_OTHER_THROWABLE, TwoArgConstructorException.class));
+ assertThat(expected).hasCauseThat().isEqualTo(OTHER_THROWABLE);
}
public void testGetCheckedUntimed_RuntimeException() throws TwoArgConstructorException {
- try {
- getChecked(RUNTIME_EXCEPTION_FUTURE, TwoArgConstructorException.class);
- fail();
- } catch (RuntimeException expected) {
- assertEquals(RUNTIME_EXCEPTION, expected);
- }
+ RuntimeException expected =
+ assertThrows(
+ RuntimeException.class,
+ () -> getChecked(RUNTIME_EXCEPTION_FUTURE, TwoArgConstructorException.class));
+ assertEquals(RUNTIME_EXCEPTION, expected);
}
public void testGetCheckedUntimed_Error() throws TwoArgConstructorException {
@@ -139,29 +133,26 @@ public class FuturesGetCheckedTest extends TestCase {
public void testGetCheckedUntimed_badExceptionConstructor_failsEvenForSuccessfulInput()
throws Exception {
- try {
- getChecked(immediateFuture("x"), ExceptionWithBadConstructor.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> getChecked(immediateFuture("x"), ExceptionWithBadConstructor.class));
}
public void testGetCheckedUntimed_badExceptionConstructor_wrapsOriginalChecked()
throws Exception {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithBadConstructor.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithBadConstructor.class));
}
public void testGetCheckedUntimed_withGoodAndBadExceptionConstructor() throws Exception {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithGoodAndBadConstructor.class);
- fail();
- } catch (ExceptionWithGoodAndBadConstructor expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(CHECKED_EXCEPTION);
- }
+ ExceptionWithGoodAndBadConstructor expected =
+ assertThrows(
+ ExceptionWithGoodAndBadConstructor.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithGoodAndBadConstructor.class));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(CHECKED_EXCEPTION);
}
// Boring timed-get tests:
@@ -188,56 +179,59 @@ public class FuturesGetCheckedTest extends TestCase {
public void testGetCheckedTimed_cancelled() throws TwoArgConstructorException {
SettableFuture<String> future = SettableFuture.create();
future.cancel(true);
- try {
- getChecked(future, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (CancellationException expected) {
- }
+ assertThrows(
+ CancellationException.class,
+ () -> getChecked(future, TwoArgConstructorException.class, 0, SECONDS));
}
public void testGetCheckedTimed_ExecutionExceptionChecked() {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (TwoArgConstructorException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(CHECKED_EXCEPTION);
- }
+ TwoArgConstructorException expected =
+ assertThrows(
+ TwoArgConstructorException.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION, TwoArgConstructorException.class, 0, SECONDS));
+ assertThat(expected).hasCauseThat().isEqualTo(CHECKED_EXCEPTION);
}
public void testGetCheckedTimed_ExecutionExceptionUnchecked() throws TwoArgConstructorException {
- try {
- getChecked(FAILED_FUTURE_UNCHECKED_EXCEPTION, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(UNCHECKED_EXCEPTION);
- }
+ UncheckedExecutionException expected =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_UNCHECKED_EXCEPTION,
+ TwoArgConstructorException.class,
+ 0,
+ SECONDS));
+ assertThat(expected).hasCauseThat().isEqualTo(UNCHECKED_EXCEPTION);
}
public void testGetCheckedTimed_ExecutionExceptionError() throws TwoArgConstructorException {
- try {
- getChecked(FAILED_FUTURE_ERROR, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isEqualTo(ERROR);
- }
+ ExecutionError expected =
+ assertThrows(
+ ExecutionError.class,
+ () -> getChecked(FAILED_FUTURE_ERROR, TwoArgConstructorException.class, 0, SECONDS));
+ assertThat(expected).hasCauseThat().isEqualTo(ERROR);
}
public void testGetCheckedTimed_ExecutionExceptionOtherThrowable() {
- try {
- getChecked(FAILED_FUTURE_OTHER_THROWABLE, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (TwoArgConstructorException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(OTHER_THROWABLE);
- }
+ TwoArgConstructorException expected =
+ assertThrows(
+ TwoArgConstructorException.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_OTHER_THROWABLE, TwoArgConstructorException.class, 0, SECONDS));
+ assertThat(expected).hasCauseThat().isEqualTo(OTHER_THROWABLE);
}
public void testGetCheckedTimed_RuntimeException() throws TwoArgConstructorException {
- try {
- getChecked(RUNTIME_EXCEPTION_FUTURE, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (RuntimeException expected) {
- assertEquals(RUNTIME_EXCEPTION, expected);
- }
+ RuntimeException expected =
+ assertThrows(
+ RuntimeException.class,
+ () ->
+ getChecked(RUNTIME_EXCEPTION_FUTURE, TwoArgConstructorException.class, 0, SECONDS));
+ assertEquals(RUNTIME_EXCEPTION, expected);
}
public void testGetCheckedTimed_Error() throws TwoArgConstructorException {
@@ -252,101 +246,109 @@ public class FuturesGetCheckedTest extends TestCase {
public void testGetCheckedTimed_TimeoutException() {
SettableFuture<String> future = SettableFuture.create();
- try {
- getChecked(future, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (TwoArgConstructorException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(TimeoutException.class);
- }
+ TwoArgConstructorException expected =
+ assertThrows(
+ TwoArgConstructorException.class,
+ () -> getChecked(future, TwoArgConstructorException.class, 0, SECONDS));
+ assertThat(expected).hasCauseThat().isInstanceOf(TimeoutException.class);
}
public void testGetCheckedTimed_badExceptionConstructor_failsEvenForSuccessfulInput()
throws Exception {
- try {
- getChecked(immediateFuture("x"), ExceptionWithBadConstructor.class, 1, TimeUnit.SECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ getChecked(
+ immediateFuture("x"), ExceptionWithBadConstructor.class, 1, TimeUnit.SECONDS));
}
public void testGetCheckedTimed_badExceptionConstructor_wrapsOriginalChecked() throws Exception {
- try {
- getChecked(
- FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithBadConstructor.class, 1, TimeUnit.SECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION,
+ ExceptionWithBadConstructor.class,
+ 1,
+ TimeUnit.SECONDS));
}
public void testGetCheckedTimed_withGoodAndBadExceptionConstructor() {
- try {
- getChecked(
- FAILED_FUTURE_CHECKED_EXCEPTION,
- ExceptionWithGoodAndBadConstructor.class,
- 1,
- TimeUnit.SECONDS);
- fail();
- } catch (ExceptionWithGoodAndBadConstructor expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(CHECKED_EXCEPTION);
- }
+ ExceptionWithGoodAndBadConstructor expected =
+ assertThrows(
+ ExceptionWithGoodAndBadConstructor.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION,
+ ExceptionWithGoodAndBadConstructor.class,
+ 1,
+ TimeUnit.SECONDS));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(CHECKED_EXCEPTION);
}
// Edge case tests of the exception-construction code through untimed get():
@SuppressWarnings("FuturesGetCheckedIllegalExceptionType")
public void testGetCheckedUntimed_exceptionClassIsRuntimeException() {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, TwoArgConstructorRuntimeException.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, TwoArgConstructorRuntimeException.class));
}
public void testGetCheckedUntimed_exceptionClassSomePrivateConstructors() {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithSomePrivateConstructors.class);
- fail();
- } catch (ExceptionWithSomePrivateConstructors expected) {
- }
+ assertThrows(
+ ExceptionWithSomePrivateConstructors.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithSomePrivateConstructors.class));
}
@SuppressWarnings("FuturesGetCheckedIllegalExceptionType")
public void testGetCheckedUntimed_exceptionClassNoPublicConstructor()
throws ExceptionWithPrivateConstructor {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithPrivateConstructor.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithPrivateConstructor.class));
}
@SuppressWarnings("FuturesGetCheckedIllegalExceptionType")
public void testGetCheckedUntimed_exceptionClassPublicConstructorWrongType()
throws ExceptionWithWrongTypesConstructor {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithWrongTypesConstructor.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithWrongTypesConstructor.class));
}
public void testGetCheckedUntimed_exceptionClassPrefersStringConstructor() {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithManyConstructors.class);
- fail();
- } catch (ExceptionWithManyConstructors expected) {
- assertTrue(expected.usedExpectedConstructor);
- }
+ ExceptionWithManyConstructors expected =
+ assertThrows(
+ ExceptionWithManyConstructors.class,
+ () -> getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithManyConstructors.class));
+ assertTrue(expected.usedExpectedConstructor);
}
public void testGetCheckedUntimed_exceptionClassUsedInitCause() {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithoutThrowableConstructor.class);
- fail();
- } catch (ExceptionWithoutThrowableConstructor expected) {
- assertThat(expected).hasMessageThat().contains("mymessage");
- assertThat(expected).hasCauseThat().isEqualTo(CHECKED_EXCEPTION);
- }
+ ExceptionWithoutThrowableConstructor expected =
+ assertThrows(
+ ExceptionWithoutThrowableConstructor.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithoutThrowableConstructor.class));
+ assertThat(expected).hasMessageThat().contains("mymessage");
+ assertThat(expected).hasCauseThat().isEqualTo(CHECKED_EXCEPTION);
+ }
+
+ public void testPrefersConstructorWithThrowableParameter() {
+ ExceptionWithManyConstructorsButOnlyOneThrowable exception =
+ assertThrows(
+ ExceptionWithManyConstructorsButOnlyOneThrowable.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION,
+ ExceptionWithManyConstructorsButOnlyOneThrowable.class));
+ assertThat(exception).hasMessageThat().contains("mymessage");
+ assertThat(exception.getAntecedent()).isEqualTo(CHECKED_EXCEPTION);
}
// Class unloading test:
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java b/android/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
index 24990200d..e0d579249 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.Futures.transformAsync;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.Uninterruptibles.awaitUninterruptibly;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.ForwardingListenableFuture.SimpleForwardingListenableFuture;
import java.util.concurrent.CancellationException;
@@ -82,23 +83,13 @@ public class FuturesTransformAsyncTest extends AbstractChainedListenableFutureTe
public void testFutureGetThrowsCancellationIfInputCancelled() throws Exception {
inputFuture.cancel(true); // argument is ignored
- try {
- resultFuture.get();
- fail("Result future must throw CancellationException" + " if input future is cancelled.");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> resultFuture.get());
}
public void testFutureGetThrowsCancellationIfOutputCancelled() throws Exception {
inputFuture.set(SLOW_OUTPUT_VALID_INPUT_DATA);
outputFuture.cancel(true); // argument is ignored
- try {
- resultFuture.get();
- fail(
- "Result future must throw CancellationException"
- + " if function output future is cancelled.");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> resultFuture.get());
}
public void testAsyncToString() throws Exception {
@@ -111,11 +102,7 @@ public class FuturesTransformAsyncTest extends AbstractChainedListenableFutureTe
assertTrue(resultFuture.isCancelled());
assertTrue(inputFuture.isCancelled());
assertFalse(outputFuture.isCancelled());
- try {
- resultFuture.get();
- fail("Result future is cancelled and should have thrown a" + " CancellationException");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> resultFuture.get());
}
public void testFutureCancellableBeforeOutputCompletion() throws Exception {
@@ -124,11 +111,7 @@ public class FuturesTransformAsyncTest extends AbstractChainedListenableFutureTe
assertTrue(resultFuture.isCancelled());
assertFalse(inputFuture.isCancelled());
assertTrue(outputFuture.isCancelled());
- try {
- resultFuture.get();
- fail("Result future is cancelled and should have thrown a" + " CancellationException");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> resultFuture.get());
}
public void testFutureCancellableBeforeFunctionCompletion() throws Exception {
@@ -146,20 +129,10 @@ public class FuturesTransformAsyncTest extends AbstractChainedListenableFutureTe
assertTrue(resultFuture.isCancelled());
assertFalse(inputFuture.isCancelled());
assertFalse(outputFuture.isCancelled());
- try {
- resultFuture.get();
- fail("Result future is cancelled and should have thrown a" + " CancellationException");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> resultFuture.get());
funcCompletionLatch.countDown(); // allow the function to complete
- try {
- outputFuture.get();
- fail(
- "The function output future is cancelled and should have thrown a"
- + " CancellationException");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> outputFuture.get());
}
public void testFutureCancelAfterCompletion() throws Exception {
@@ -174,12 +147,8 @@ public class FuturesTransformAsyncTest extends AbstractChainedListenableFutureTe
public void testFutureGetThrowsRuntimeException() throws Exception {
BadFuture badInput = new BadFuture(Futures.immediateFuture(20));
ListenableFuture<String> chain = buildChainingFuture(badInput);
- try {
- chain.get();
- fail("Future.get must throw an exception when the input future fails.");
- } catch (ExecutionException e) {
- assertSame(RuntimeException.class, e.getCause().getClass());
- }
+ ExecutionException e = assertThrows(ExecutionException.class, () -> chain.get());
+ assertSame(RuntimeException.class, e.getCause().getClass());
}
/** Proxy to throw a {@link RuntimeException} out of the {@link #get()} method. */
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java b/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
index 6d1591354..32bbe0c25 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
@@ -16,6 +16,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.InterruptibleTask.Blocker;
import java.nio.channels.spi.AbstractInterruptibleChannel;
@@ -61,14 +62,10 @@ public final class InterruptibleTaskTest extends TestCase {
Thread runner = new Thread(task);
runner.start();
isInterruptibleRegistered.await();
- try {
- task.interruptTask();
- fail();
- } catch (RuntimeException expected) {
- assertThat(expected)
- .hasMessageThat()
- .isEqualTo("I bet you didn't think Thread.interrupt could throw");
- }
+ RuntimeException expected = assertThrows(RuntimeException.class, () -> task.interruptTask());
+ assertThat(expected)
+ .hasMessageThat()
+ .isEqualTo("I bet you didn't think Thread.interrupt could throw");
// We need to wait for the runner to exit. It used to be that the runner would get stuck in the
// busy loop when interrupt threw.
runner.join(TimeUnit.SECONDS.toMillis(10));
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java b/android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java
index fd51a7329..7b501dc3d 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
+import static org.junit.Assert.assertThrows;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
@@ -113,12 +114,9 @@ public class ListenableFutureTaskTest extends TestCase {
runLatch.await();
taskLatch.countDown();
- try {
- task.get(5, TimeUnit.SECONDS);
- fail("Should have propagated the failure.");
- } catch (ExecutionException e) {
- assertEquals(IllegalStateException.class, e.getCause().getClass());
- }
+ ExecutionException e =
+ assertThrows(ExecutionException.class, () -> task.get(5, TimeUnit.SECONDS));
+ assertEquals(IllegalStateException.class, e.getCause().getClass());
assertTrue(listenerLatch.await(5, TimeUnit.SECONDS));
assertTrue(task.isDone());
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java b/android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java
index 5c99bc881..b551ff0f8 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java
@@ -22,6 +22,7 @@ import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertThrows;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
@@ -87,11 +88,7 @@ public class ListenableFutureTester {
assertTrue(future.isDone());
assertTrue(future.isCancelled());
- try {
- future.get();
- fail("Future should throw CancellationException on cancel.");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> future.get());
}
public void testFailedFuture(@Nullable String message) throws InterruptedException {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java b/android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
index dab6d92f9..ae72e4176 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
@@ -38,6 +38,7 @@ import static com.google.common.util.concurrent.MoreExecutors.renamingDecorator;
import static com.google.common.util.concurrent.MoreExecutors.shutdownAndAwaitTermination;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -220,12 +221,7 @@ public class MoreExecutorsTest extends JSR166TestCase {
executor.shutdown();
assertTrue(executor.isShutdown());
- try {
- executor.submit(doNothingRunnable);
- fail("Should have encountered RejectedExecutionException");
- } catch (RejectedExecutionException ex) {
- // good to go
- }
+ assertThrows(RejectedExecutionException.class, () -> executor.submit(doNothingRunnable));
assertFalse(executor.isTerminated());
// WAIT #2
@@ -237,12 +233,7 @@ public class MoreExecutorsTest extends JSR166TestCase {
assertTrue(executor.awaitTermination(1, TimeUnit.SECONDS));
assertTrue(executor.awaitTermination(0, TimeUnit.SECONDS));
assertTrue(executor.isShutdown());
- try {
- executor.submit(doNothingRunnable);
- fail("Should have encountered RejectedExecutionException");
- } catch (RejectedExecutionException ex) {
- // good to go
- }
+ assertThrows(RejectedExecutionException.class, () -> executor.submit(doNothingRunnable));
assertTrue(executor.isTerminated());
otherThread.join(1000);
@@ -309,11 +300,7 @@ public class MoreExecutorsTest extends JSR166TestCase {
public void testExecuteAfterShutdown() {
ExecutorService executor = newDirectExecutorService();
executor.shutdown();
- try {
- executor.execute(EMPTY_RUNNABLE);
- fail();
- } catch (RejectedExecutionException expected) {
- }
+ assertThrows(RejectedExecutionException.class, () -> executor.execute(EMPTY_RUNNABLE));
}
public <T> void testListeningExecutorServiceInvokeAllJavadocCodeCompiles() throws Exception {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/RateLimiterTest.java b/android/guava-tests/test/com/google/common/util/concurrent/RateLimiterTest.java
index a2773ba64..112da6803 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/RateLimiterTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/RateLimiterTest.java
@@ -21,6 +21,7 @@ import static java.util.concurrent.TimeUnit.MICROSECONDS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.collect.ImmutableSet;
@@ -75,50 +76,18 @@ public class RateLimiterTest extends TestCase {
limiter.setRate(10.0);
assertEquals(10.0, limiter.getRate());
- try {
- limiter.setRate(0.0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- limiter.setRate(-10.0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> limiter.setRate(0.0));
+ assertThrows(IllegalArgumentException.class, () -> limiter.setRate(-10.0));
}
public void testAcquireParameterValidation() {
RateLimiter limiter = RateLimiter.create(999);
- try {
- limiter.acquire(0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- limiter.acquire(-1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- limiter.tryAcquire(0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- limiter.tryAcquire(-1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- limiter.tryAcquire(0, 1, SECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- limiter.tryAcquire(-1, 1, SECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> limiter.acquire(0));
+ assertThrows(IllegalArgumentException.class, () -> limiter.acquire(-1));
+ assertThrows(IllegalArgumentException.class, () -> limiter.tryAcquire(0));
+ assertThrows(IllegalArgumentException.class, () -> limiter.tryAcquire(-1));
+ assertThrows(IllegalArgumentException.class, () -> limiter.tryAcquire(0, 1, SECONDS));
+ assertThrows(IllegalArgumentException.class, () -> limiter.tryAcquire(-1, 1, SECONDS));
}
public void testSimpleWithWait() {
@@ -169,17 +138,9 @@ public class RateLimiterTest extends TestCase {
unused = RateLimiter.create(1.0, 1, NANOSECONDS);
unused = RateLimiter.create(1.0, 0, NANOSECONDS);
- try {
- RateLimiter.create(0.0, 1, NANOSECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> RateLimiter.create(0.0, 1, NANOSECONDS));
- try {
- RateLimiter.create(1.0, -1, NANOSECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> RateLimiter.create(1.0, -1, NANOSECONDS));
}
@AndroidIncompatible // difference in String.format rounding?
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java b/android/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
index cbb6c1c82..3ebff11c8 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
@@ -19,6 +19,7 @@ package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.newSequentialExecutor;
import static com.google.common.util.concurrent.Uninterruptibles.awaitUninterruptibly;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
@@ -79,11 +80,7 @@ public class SequentialExecutorTest extends TestCase {
}
public void testConstructingWithNullExecutor_fails() {
- try {
- new SequentialExecutor(null);
- fail("Should have failed with NullPointerException.");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> new SequentialExecutor(null));
}
public void testBasics() {
@@ -263,11 +260,7 @@ public class SequentialExecutorTest extends TestCase {
numCalls.incrementAndGet();
}
};
- try {
- executor.execute(task);
- fail();
- } catch (RejectedExecutionException expected) {
- }
+ assertThrows(RejectedExecutionException.class, () -> executor.execute(task));
assertEquals(0, numCalls.get());
reject.set(false);
executor.execute(task);
@@ -344,18 +337,11 @@ public class SequentialExecutorTest extends TestCase {
}
});
future.get(10, TimeUnit.SECONDS);
- try {
- executor.execute(Runnables.doNothing());
- fail();
- } catch (RejectedExecutionException expected) {
- }
+ assertThrows(RejectedExecutionException.class, () -> executor.execute(Runnables.doNothing()));
latch.countDown();
- try {
- first.get(10, TimeUnit.SECONDS);
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(RejectedExecutionException.class);
- }
+ ExecutionException expected =
+ assertThrows(ExecutionException.class, () -> first.get(10, TimeUnit.SECONDS));
+ assertThat(expected).hasCauseThat().isInstanceOf(RejectedExecutionException.class);
}
public void testToString() {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java b/android/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
index 958be1972..02815e3d1 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
@@ -16,10 +16,13 @@
package com.google.common.util.concurrent;
+import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
+import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -120,6 +123,10 @@ public class ServiceManagerTest extends TestCase {
}
public void testServiceStartupTimes() {
+ if (isWindows() && isJava8()) {
+ // Flaky there: https://github.com/google/guava/pull/6731#issuecomment-1736298607
+ return;
+ }
Service a = new NoOpDelayedService(150);
Service b = new NoOpDelayedService(353);
ServiceManager serviceManager = new ServiceManager(asList(a, b));
@@ -195,11 +202,7 @@ public class ServiceManagerTest extends TestCase {
RecordingListener listener = new RecordingListener();
manager.addListener(listener, directExecutor());
assertState(manager, Service.State.NEW, a, b, c, d, e);
- try {
- manager.startAsync().awaitHealthy();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> manager.startAsync().awaitHealthy());
assertFalse(listener.healthyCalled);
assertState(manager, Service.State.RUNNING, a, c, e);
assertEquals(ImmutableSet.of(b, d), listener.failedServices);
@@ -219,11 +222,7 @@ public class ServiceManagerTest extends TestCase {
RecordingListener listener = new RecordingListener();
manager.addListener(listener, directExecutor());
assertState(manager, Service.State.NEW, a, b);
- try {
- manager.startAsync().awaitHealthy();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> manager.startAsync().awaitHealthy());
assertTrue(listener.healthyCalled);
assertEquals(ImmutableSet.of(b), listener.failedServices);
@@ -266,19 +265,11 @@ public class ServiceManagerTest extends TestCase {
Service a = new NoOpDelayedService(50);
ServiceManager manager = new ServiceManager(asList(a));
manager.startAsync();
- try {
- manager.awaitHealthy(1, TimeUnit.MILLISECONDS);
- fail();
- } catch (TimeoutException expected) {
- }
+ assertThrows(TimeoutException.class, () -> manager.awaitHealthy(1, TimeUnit.MILLISECONDS));
manager.awaitHealthy(5, SECONDS); // no exception thrown
manager.stopAsync();
- try {
- manager.awaitStopped(1, TimeUnit.MILLISECONDS);
- fail();
- } catch (TimeoutException expected) {
- }
+ assertThrows(TimeoutException.class, () -> manager.awaitStopped(1, TimeUnit.MILLISECONDS));
manager.awaitStopped(5, SECONDS); // no exception thrown
}
@@ -291,11 +282,7 @@ public class ServiceManagerTest extends TestCase {
ServiceManager manager = new ServiceManager(asList(a));
RecordingListener listener = new RecordingListener();
manager.addListener(listener, directExecutor());
- try {
- manager.startAsync().awaitHealthy();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> manager.startAsync().awaitHealthy());
assertTrue(listener.stoppedCalled);
}
@@ -308,11 +295,7 @@ public class ServiceManagerTest extends TestCase {
ServiceManager manager = new ServiceManager(asList(a));
RecordingListener listener = new RecordingListener();
manager.addListener(listener, directExecutor());
- try {
- manager.startAsync().awaitHealthy();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> manager.startAsync().awaitHealthy());
assertFalse(listener.healthyCalled);
}
@@ -511,11 +494,7 @@ public class ServiceManagerTest extends TestCase {
logger.addHandler(logHandler);
NoOpService service = new NoOpService();
service.startAsync();
- try {
- new ServiceManager(Arrays.asList(service));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> new ServiceManager(Arrays.asList(service)));
service.stopAsync();
// Nothing was logged!
assertEquals(0, logHandler.getStoredLogRecords().size());
@@ -536,6 +515,7 @@ public class ServiceManagerTest extends TestCase {
service1.startAsync();
delegate.addListener(listener, executor);
}
+
// Delegates from here on down
@Override
public final Service startAsync() {
@@ -582,12 +562,11 @@ public class ServiceManagerTest extends TestCase {
return delegate.failureCause();
}
};
- try {
- new ServiceManager(Arrays.asList(service1, service2));
- fail();
- } catch (IllegalArgumentException expected) {
- assertThat(expected.getMessage()).contains("started transitioning asynchronously");
- }
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new ServiceManager(Arrays.asList(service1, service2)));
+ assertThat(expected.getMessage()).contains("started transitioning asynchronously");
}
/**
@@ -666,4 +645,12 @@ public class ServiceManagerTest extends TestCase {
failedServices.add(service);
}
}
+
+ private static boolean isWindows() {
+ return OS_NAME.value().startsWith("Windows");
+ }
+
+ private static boolean isJava8() {
+ return JAVA_SPECIFICATION_VERSION.value().equals("1.8");
+ }
}
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
index 105e8de04..84b5c6757 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
@@ -44,11 +45,7 @@ public class SettableFutureTest extends TestCase {
}
public void testDefaultState() throws Exception {
- try {
- future.get(5, TimeUnit.MILLISECONDS);
- fail();
- } catch (TimeoutException expected) {
- }
+ assertThrows(TimeoutException.class, () -> future.get(5, TimeUnit.MILLISECONDS));
}
public void testSetValue() throws Exception {
@@ -62,11 +59,7 @@ public class SettableFutureTest extends TestCase {
}
public void testSetFailureNull() throws Exception {
- try {
- future.setException(null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> future.setException(null));
assertFalse(future.isDone());
assertTrue(future.setException(new Exception("failure")));
tester.testFailedFuture("failure");
@@ -108,12 +101,8 @@ public class SettableFutureTest extends TestCase {
// Check that the future has been set properly.
assertTrue(future.isDone());
assertFalse(future.isCancelled());
- try {
- future.get();
- fail("Expected ExecutionException");
- } catch (ExecutionException ee) {
- assertThat(ee).hasCauseThat().isSameInstanceAs(e);
- }
+ ExecutionException ee = assertThrows(ExecutionException.class, () -> future.get());
+ assertThat(ee).hasCauseThat().isSameInstanceAs(e);
}
public void testSetFuture() throws Exception {
@@ -127,12 +116,7 @@ public class SettableFutureTest extends TestCase {
// Check that the future has been set properly.
assertFalse(future.isDone());
assertFalse(future.isCancelled());
- try {
- future.get(0, TimeUnit.MILLISECONDS);
- fail("Expected TimeoutException");
- } catch (TimeoutException expected) {
- /* expected */
- }
+ assertThrows(TimeoutException.class, () -> future.get(0, TimeUnit.MILLISECONDS));
nested.set("foo");
assertTrue(future.isDone());
assertFalse(future.isCancelled());
@@ -154,12 +138,7 @@ public class SettableFutureTest extends TestCase {
// Check that the future has been set properly.
assertFalse(future.isDone());
assertFalse(future.isCancelled());
- try {
- future.get(0, TimeUnit.MILLISECONDS);
- fail("Expected TimeoutException");
- } catch (TimeoutException expected) {
- /* expected */
- }
+ assertThrows(TimeoutException.class, () -> future.get(0, TimeUnit.MILLISECONDS));
FooChild value = new FooChild();
nested.set(value);
assertTrue(future.isDone());
@@ -173,12 +152,7 @@ public class SettableFutureTest extends TestCase {
async.setFuture(inner);
inner.cancel(true);
assertTrue(async.isCancelled());
- try {
- async.get();
- fail("Expected CancellationException");
- } catch (CancellationException expected) {
- /* expected */
- }
+ assertThrows(CancellationException.class, () -> async.get());
}
public void testCancel_resultCancelsInner_interrupted() throws Exception {
@@ -188,12 +162,7 @@ public class SettableFutureTest extends TestCase {
async.cancel(true);
assertTrue(inner.isCancelled());
assertTrue(inner.wasInterrupted());
- try {
- inner.get();
- fail("Expected CancellationException");
- } catch (CancellationException expected) {
- /* expected */
- }
+ assertThrows(CancellationException.class, () -> inner.get());
}
public void testCancel_resultCancelsInner() throws Exception {
@@ -203,12 +172,7 @@ public class SettableFutureTest extends TestCase {
async.cancel(false);
assertTrue(inner.isCancelled());
assertFalse(inner.wasInterrupted());
- try {
- inner.get();
- fail("Expected CancellationException");
- } catch (CancellationException expected) {
- /* expected */
- }
+ assertThrows(CancellationException.class, () -> inner.get());
}
public void testCancel_beforeSet() throws Exception {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/SimpleTimeLimiterTest.java b/android/guava-tests/test/com/google/common/util/concurrent/SimpleTimeLimiterTest.java
index 37ef84f66..f66b9ed47 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/SimpleTimeLimiterTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/SimpleTimeLimiterTest.java
@@ -18,6 +18,7 @@ package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Stopwatch;
import com.google.common.collect.Range;
@@ -108,11 +109,7 @@ public class SimpleTimeLimiterTest extends TestCase {
Sample proxy = service.newProxy(target, Sample.class, NOT_ENOUGH_MS, MILLISECONDS);
Stopwatch stopwatch = Stopwatch.createStarted();
- try {
- proxy.sleepThenReturnInput("x");
- fail("no exception thrown");
- } catch (UncheckedTimeoutException expected) {
- }
+ assertThrows(UncheckedTimeoutException.class, () -> proxy.sleepThenReturnInput("x"));
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(NOT_ENOUGH_MS, DELAY_MS * 2));
// Is it still computing away anyway?
@@ -126,11 +123,7 @@ public class SimpleTimeLimiterTest extends TestCase {
Sample proxy = service.newProxy(target, Sample.class, ENOUGH_MS, MILLISECONDS);
Stopwatch stopwatch = Stopwatch.createStarted();
- try {
- proxy.sleepThenThrowException();
- fail("no exception thrown");
- } catch (SampleException expected) {
- }
+ assertThrows(SampleException.class, () -> proxy.sleepThenThrowException());
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS));
}
@@ -140,11 +133,7 @@ public class SimpleTimeLimiterTest extends TestCase {
Sample proxy = service.newProxy(target, Sample.class, NOT_ENOUGH_MS, MILLISECONDS);
Stopwatch stopwatch = Stopwatch.createStarted();
- try {
- proxy.sleepThenThrowException();
- fail("no exception thrown");
- } catch (UncheckedTimeoutException expected) {
- }
+ assertThrows(UncheckedTimeoutException.class, () -> proxy.sleepThenThrowException());
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(NOT_ENOUGH_MS, DELAY_MS * 2));
}
@@ -159,20 +148,17 @@ public class SimpleTimeLimiterTest extends TestCase {
}
public void testCallWithTimeout_goodCallableWithNotEnoughTime() throws Exception {
- try {
- service.callWithTimeout(GOOD_CALLABLE, NOT_ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (TimeoutException expected) {
- }
+ assertThrows(
+ TimeoutException.class,
+ () -> service.callWithTimeout(GOOD_CALLABLE, NOT_ENOUGH_MS, MILLISECONDS));
}
public void testCallWithTimeout_badCallableWithEnoughTime() throws Exception {
- try {
- service.callWithTimeout(BAD_CALLABLE, ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (ExecutionException expected) {
- assertThat(expected.getCause()).isInstanceOf(SampleException.class);
- }
+ ExecutionException expected =
+ assertThrows(
+ ExecutionException.class,
+ () -> service.callWithTimeout(BAD_CALLABLE, ENOUGH_MS, MILLISECONDS));
+ assertThat(expected.getCause()).isInstanceOf(SampleException.class);
}
public void testCallUninterruptiblyWithTimeout_goodCallableWithEnoughTime() throws Exception {
@@ -185,20 +171,17 @@ public class SimpleTimeLimiterTest extends TestCase {
}
public void testCallUninterruptiblyWithTimeout_goodCallableWithNotEnoughTime() throws Exception {
- try {
- service.callUninterruptiblyWithTimeout(GOOD_CALLABLE, NOT_ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (TimeoutException expected) {
- }
+ assertThrows(
+ TimeoutException.class,
+ () -> service.callUninterruptiblyWithTimeout(GOOD_CALLABLE, NOT_ENOUGH_MS, MILLISECONDS));
}
public void testCallUninterruptiblyWithTimeout_badCallableWithEnoughTime() throws Exception {
- try {
- service.callUninterruptiblyWithTimeout(BAD_CALLABLE, ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (ExecutionException expected) {
- assertThat(expected.getCause()).isInstanceOf(SampleException.class);
- }
+ ExecutionException expected =
+ assertThrows(
+ ExecutionException.class,
+ () -> service.callUninterruptiblyWithTimeout(BAD_CALLABLE, ENOUGH_MS, MILLISECONDS));
+ assertThat(expected.getCause()).isInstanceOf(SampleException.class);
}
public void testRunWithTimeout_goodRunnableWithEnoughTime() throws Exception {
@@ -210,20 +193,17 @@ public class SimpleTimeLimiterTest extends TestCase {
}
public void testRunWithTimeout_goodRunnableWithNotEnoughTime() throws Exception {
- try {
- service.runWithTimeout(GOOD_RUNNABLE, NOT_ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (TimeoutException expected) {
- }
+ assertThrows(
+ TimeoutException.class,
+ () -> service.runWithTimeout(GOOD_RUNNABLE, NOT_ENOUGH_MS, MILLISECONDS));
}
public void testRunWithTimeout_badRunnableWithEnoughTime() throws Exception {
- try {
- service.runWithTimeout(BAD_RUNNABLE, ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (UncheckedExecutionException expected) {
- assertThat(expected.getCause()).isInstanceOf(SampleRuntimeException.class);
- }
+ UncheckedExecutionException expected =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () -> service.runWithTimeout(BAD_RUNNABLE, ENOUGH_MS, MILLISECONDS));
+ assertThat(expected.getCause()).isInstanceOf(SampleRuntimeException.class);
}
public void testRunUninterruptiblyWithTimeout_goodRunnableWithEnoughTime() throws Exception {
@@ -235,20 +215,17 @@ public class SimpleTimeLimiterTest extends TestCase {
}
public void testRunUninterruptiblyWithTimeout_goodRunnableWithNotEnoughTime() throws Exception {
- try {
- service.runUninterruptiblyWithTimeout(GOOD_RUNNABLE, NOT_ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (TimeoutException expected) {
- }
+ assertThrows(
+ TimeoutException.class,
+ () -> service.runUninterruptiblyWithTimeout(GOOD_RUNNABLE, NOT_ENOUGH_MS, MILLISECONDS));
}
public void testRunUninterruptiblyWithTimeout_badRunnableWithEnoughTime() throws Exception {
- try {
- service.runUninterruptiblyWithTimeout(BAD_RUNNABLE, ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (UncheckedExecutionException expected) {
- assertThat(expected.getCause()).isInstanceOf(SampleRuntimeException.class);
- }
+ UncheckedExecutionException expected =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () -> service.runUninterruptiblyWithTimeout(BAD_RUNNABLE, ENOUGH_MS, MILLISECONDS));
+ assertThat(expected.getCause()).isInstanceOf(SampleRuntimeException.class);
}
private interface Sample {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/SupplementalMonitorTest.java b/android/guava-tests/test/com/google/common/util/concurrent/SupplementalMonitorTest.java
index 5b77f9a59..62b69aec7 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/SupplementalMonitorTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/SupplementalMonitorTest.java
@@ -18,6 +18,7 @@ package com.google.common.util.concurrent;
import static com.google.common.util.concurrent.GeneratedMonitorTest.startThread;
import static com.google.common.util.concurrent.Uninterruptibles.joinUninterruptibly;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.GeneratedMonitorTest.FlagGuard;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -37,41 +38,25 @@ public class SupplementalMonitorTest extends TestCase {
public void testLeaveWithoutEnterThrowsIMSE() {
Monitor monitor = new Monitor();
- try {
- monitor.leave();
- fail("expected IllegalMonitorStateException");
- } catch (IllegalMonitorStateException expected) {
- }
+ assertThrows(IllegalMonitorStateException.class, () -> monitor.leave());
}
public void testGetWaitQueueLengthWithWrongMonitorThrowsIMSE() {
Monitor monitor1 = new Monitor();
Monitor monitor2 = new Monitor();
FlagGuard guard = new FlagGuard(monitor2);
- try {
- monitor1.getWaitQueueLength(guard);
- fail("expected IllegalMonitorStateException");
- } catch (IllegalMonitorStateException expected) {
- }
+ assertThrows(IllegalMonitorStateException.class, () -> monitor1.getWaitQueueLength(guard));
}
public void testHasWaitersWithWrongMonitorThrowsIMSE() {
Monitor monitor1 = new Monitor();
Monitor monitor2 = new Monitor();
FlagGuard guard = new FlagGuard(monitor2);
- try {
- monitor1.hasWaiters(guard);
- fail("expected IllegalMonitorStateException");
- } catch (IllegalMonitorStateException expected) {
- }
+ assertThrows(IllegalMonitorStateException.class, () -> monitor1.hasWaiters(guard));
}
public void testNullMonitorInGuardConstructorThrowsNPE() {
- try {
- new FlagGuard(null);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> new FlagGuard(null));
}
public void testIsFair() {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java b/android/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
index a3a7b8e79..09b3ec7ee 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.testing.NullPointerTester;
import java.lang.Thread.UncaughtExceptionHandler;
@@ -129,19 +130,13 @@ public class ThreadFactoryBuilderTest extends TestCase {
}
public void testPriority_tooLow() {
- try {
- builder.setPriority(Thread.MIN_PRIORITY - 1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> builder.setPriority(Thread.MIN_PRIORITY - 1));
}
public void testPriority_tooHigh() {
- try {
- builder.setPriority(Thread.MAX_PRIORITY + 1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> builder.setPriority(Thread.MAX_PRIORITY + 1));
}
public void testUncaughtExceptionHandler_custom() {
diff --git a/android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java b/android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java
index 3f91b8123..f857c6edf 100644
--- a/android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java
+++ b/android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java
@@ -20,6 +20,7 @@ import static com.google.common.util.concurrent.InterruptionUtil.repeatedlyInter
import static com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.testing.TearDown;
import com.google.common.testing.TearDownStack;
@@ -120,11 +121,9 @@ public class UninterruptibleFutureTest extends TestCase {
repeatedlyInterruptTestThread(100, tearDownStack);
- try {
- getUninterruptibly(delayedFuture, 500, TimeUnit.MILLISECONDS);
- fail("expected to time out");
- } catch (TimeoutException expected) {
- }
+ assertThrows(
+ TimeoutException.class,
+ () -> getUninterruptibly(delayedFuture, 500, TimeUnit.MILLISECONDS));
assertTrue(Thread.interrupted()); // clears the interrupt state, too
assertFalse(sleeper.completed);
@@ -217,13 +216,9 @@ public class UninterruptibleFutureTest extends TestCase {
Thread waitingThread = new Thread(wasInterrupted);
waitingThread.start();
waitingThread.interrupt();
- try {
- wasInterrupted.get();
- fail();
- } catch (ExecutionException expected) {
- assertTrue(
- expected.getCause().toString(), expected.getCause() instanceof InterruptedException);
- }
+ ExecutionException expected =
+ assertThrows(ExecutionException.class, () -> wasInterrupted.get());
+ assertTrue(expected.getCause().toString(), expected.getCause() instanceof InterruptedException);
}
public void testMakeUninterruptible_timedGetZeroTimeoutAttempted()
diff --git a/android/guava/pom.xml b/android/guava/pom.xml
index a01c5a082..077ca8705 100644
--- a/android/guava/pom.xml
+++ b/android/guava/pom.xml
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>failureaccess</artifactId>
- <version>1.0.1</version>
+ <version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
@@ -200,16 +200,6 @@
</links>
<overview>../../overview.html</overview>
</configuration>
- <executions>
- <execution>
- <id>attach-docs</id>
- </execution>
- <execution>
- <id>generate-javadoc-site-report</id>
- <phase>site</phase>
- <goals><goal>javadoc</goal></goals>
- </execution>
- </executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
diff --git a/android/guava/src/com/google/common/base/CharMatcher.java b/android/guava/src/com/google/common/base/CharMatcher.java
index 47b4ed2b1..d94580684 100644
--- a/android/guava/src/com/google/common/base/CharMatcher.java
+++ b/android/guava/src/com/google/common/base/CharMatcher.java
@@ -970,7 +970,7 @@ public abstract class CharMatcher implements Predicate<Character> {
}
/** Negation of a {@link FastMatcher}. */
- static class NegatedFastMatcher extends Negated {
+ private static class NegatedFastMatcher extends Negated {
NegatedFastMatcher(CharMatcher original) {
super(original);
@@ -1014,7 +1014,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #any()}. */
private static final class Any extends NamedFastMatcher {
- static final Any INSTANCE = new Any();
+ static final CharMatcher INSTANCE = new Any();
private Any() {
super("CharMatcher.any()");
@@ -1111,7 +1111,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #none()}. */
private static final class None extends NamedFastMatcher {
- static final None INSTANCE = new None();
+ static final CharMatcher INSTANCE = new None();
private None() {
super("CharMatcher.none()");
@@ -1227,7 +1227,7 @@ public abstract class CharMatcher implements Predicate<Character> {
static final int MULTIPLIER = 1682554634;
static final int SHIFT = Integer.numberOfLeadingZeros(TABLE.length() - 1);
- static final Whitespace INSTANCE = new Whitespace();
+ static final CharMatcher INSTANCE = new Whitespace();
Whitespace() {
super("CharMatcher.whitespace()");
@@ -1285,7 +1285,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #ascii()}. */
private static final class Ascii extends NamedFastMatcher {
- static final Ascii INSTANCE = new Ascii();
+ static final CharMatcher INSTANCE = new Ascii();
Ascii() {
super("CharMatcher.ascii()");
@@ -1359,7 +1359,7 @@ public abstract class CharMatcher implements Predicate<Character> {
return nines;
}
- static final Digit INSTANCE = new Digit();
+ static final CharMatcher INSTANCE = new Digit();
private Digit() {
super("CharMatcher.digit()", zeroes(), nines());
@@ -1369,7 +1369,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #javaDigit()}. */
private static final class JavaDigit extends CharMatcher {
- static final JavaDigit INSTANCE = new JavaDigit();
+ static final CharMatcher INSTANCE = new JavaDigit();
@Override
public boolean matches(char c) {
@@ -1385,7 +1385,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #javaLetter()}. */
private static final class JavaLetter extends CharMatcher {
- static final JavaLetter INSTANCE = new JavaLetter();
+ static final CharMatcher INSTANCE = new JavaLetter();
@Override
public boolean matches(char c) {
@@ -1401,7 +1401,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #javaLetterOrDigit()}. */
private static final class JavaLetterOrDigit extends CharMatcher {
- static final JavaLetterOrDigit INSTANCE = new JavaLetterOrDigit();
+ static final CharMatcher INSTANCE = new JavaLetterOrDigit();
@Override
public boolean matches(char c) {
@@ -1417,7 +1417,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #javaUpperCase()}. */
private static final class JavaUpperCase extends CharMatcher {
- static final JavaUpperCase INSTANCE = new JavaUpperCase();
+ static final CharMatcher INSTANCE = new JavaUpperCase();
@Override
public boolean matches(char c) {
@@ -1433,7 +1433,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #javaLowerCase()}. */
private static final class JavaLowerCase extends CharMatcher {
- static final JavaLowerCase INSTANCE = new JavaLowerCase();
+ static final CharMatcher INSTANCE = new JavaLowerCase();
@Override
public boolean matches(char c) {
@@ -1449,7 +1449,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #javaIsoControl()}. */
private static final class JavaIsoControl extends NamedFastMatcher {
- static final JavaIsoControl INSTANCE = new JavaIsoControl();
+ static final CharMatcher INSTANCE = new JavaIsoControl();
private JavaIsoControl() {
super("CharMatcher.javaIsoControl()");
@@ -1474,7 +1474,7 @@ public abstract class CharMatcher implements Predicate<Character> {
"\u0020\u00a0\u00ad\u0605\u061c\u06dd\u070f\u0891\u08e2\u1680\u180e\u200f\u202f\u2064\u206f"
+ "\u3000\uf8ff\ufeff\ufffb";
- static final Invisible INSTANCE = new Invisible();
+ static final CharMatcher INSTANCE = new Invisible();
private Invisible() {
super("CharMatcher.invisible()", RANGE_STARTS.toCharArray(), RANGE_ENDS.toCharArray());
@@ -1484,7 +1484,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #singleWidth()}. */
private static final class SingleWidth extends RangesMatcher {
- static final SingleWidth INSTANCE = new SingleWidth();
+ static final CharMatcher INSTANCE = new SingleWidth();
private SingleWidth() {
super(
diff --git a/android/guava/src/com/google/common/base/Converter.java b/android/guava/src/com/google/common/base/Converter.java
index 63f4394f4..a34c734ab 100644
--- a/android/guava/src/com/google/common/base/Converter.java
+++ b/android/guava/src/com/google/common/base/Converter.java
@@ -571,7 +571,7 @@ public abstract class Converter<A, B> implements Function<A, B> {
* "pass-through type".
*/
private static final class IdentityConverter<T> extends Converter<T, T> implements Serializable {
- static final IdentityConverter<?> INSTANCE = new IdentityConverter<>();
+ static final Converter<?, ?> INSTANCE = new IdentityConverter<>();
@Override
protected T doForward(T t) {
diff --git a/android/guava/src/com/google/common/base/Joiner.java b/android/guava/src/com/google/common/base/Joiner.java
index fe1b40a5e..acb7d8d12 100644
--- a/android/guava/src/com/google/common/base/Joiner.java
+++ b/android/guava/src/com/google/common/base/Joiner.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.CheckForNull;
@@ -129,7 +130,9 @@ public class Joiner {
@CanIgnoreReturnValue
public final <A extends Appendable> A appendTo(A appendable, @Nullable Object[] parts)
throws IOException {
- return appendTo(appendable, Arrays.asList(parts));
+ @SuppressWarnings("nullness") // TODO: b/316358623 - Remove suppression after fixing checker
+ List<?> partsList = Arrays.<@Nullable Object>asList(parts);
+ return appendTo(appendable, partsList);
}
/** Appends to {@code appendable} the string representation of each of the remaining arguments. */
@@ -179,7 +182,9 @@ public class Joiner {
*/
@CanIgnoreReturnValue
public final StringBuilder appendTo(StringBuilder builder, @Nullable Object[] parts) {
- return appendTo(builder, Arrays.asList(parts));
+ @SuppressWarnings("nullness") // TODO: b/316358623 - Remove suppression after fixing checker
+ List<?> partsList = Arrays.<@Nullable Object>asList(parts);
+ return appendTo(builder, partsList);
}
/**
@@ -219,7 +224,9 @@ public class Joiner {
* previously configured separator between each.
*/
public final String join(@Nullable Object[] parts) {
- return join(Arrays.asList(parts));
+ @SuppressWarnings("nullness") // TODO: b/316358623 - Remove suppression after fixing checker
+ List<?> partsList = Arrays.<@Nullable Object>asList(parts);
+ return join(partsList);
}
/**
diff --git a/android/guava/src/com/google/common/base/MoreObjects.java b/android/guava/src/com/google/common/base/MoreObjects.java
index 033ac3aa9..6b7600688 100644
--- a/android/guava/src/com/google/common/base/MoreObjects.java
+++ b/android/guava/src/com/google/common/base/MoreObjects.java
@@ -428,7 +428,7 @@ public final class MoreObjects {
}
// Holder object for values that might be null and/or empty.
- private static class ValueHolder {
+ static class ValueHolder {
@CheckForNull String name;
@CheckForNull Object value;
@CheckForNull ValueHolder next;
diff --git a/android/guava/src/com/google/common/base/PatternCompiler.java b/android/guava/src/com/google/common/base/PatternCompiler.java
index 6a7b620b2..32505217f 100644
--- a/android/guava/src/com/google/common/base/PatternCompiler.java
+++ b/android/guava/src/com/google/common/base/PatternCompiler.java
@@ -16,6 +16,7 @@ package com.google.common.base;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
+import com.google.errorprone.annotations.RestrictedApi;
/**
* Pluggable interface for compiling a regex pattern. By default this package uses the {@code
@@ -31,11 +32,17 @@ interface PatternCompiler {
*
* @throws IllegalArgumentException if the pattern is invalid
*/
+ @RestrictedApi(
+ explanation = "PatternCompiler is an implementation detail of com.google.common.base",
+ allowedOnPath = ".*/com/google/common/base/.*")
CommonPattern compile(String pattern);
/**
* Returns {@code true} if the regex implementation behaves like Perl -- notably, by supporting
* possessive quantifiers but also being susceptible to catastrophic backtracking.
*/
+ @RestrictedApi(
+ explanation = "PatternCompiler is an implementation detail of com.google.common.base",
+ allowedOnPath = ".*/com/google/common/base/.*")
boolean isPcreLike();
}
diff --git a/android/guava/src/com/google/common/base/Platform.java b/android/guava/src/com/google/common/base/Platform.java
index e5719cc80..c341bde9b 100644
--- a/android/guava/src/com/google/common/base/Platform.java
+++ b/android/guava/src/com/google/common/base/Platform.java
@@ -17,9 +17,6 @@ package com.google.common.base;
import com.google.common.annotations.GwtCompatible;
import java.lang.ref.WeakReference;
import java.util.Locale;
-import java.util.ServiceConfigurationError;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.annotation.CheckForNull;
@@ -31,7 +28,6 @@ import javax.annotation.CheckForNull;
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
final class Platform {
- private static final Logger logger = Logger.getLogger(Platform.class.getName());
private static final PatternCompiler patternCompiler = loadPatternCompiler();
private Platform() {}
@@ -92,10 +88,6 @@ final class Platform {
return new JdkPatternCompiler();
}
- private static void logPatternCompilerError(ServiceConfigurationError e) {
- logger.log(Level.WARNING, "Error loading regex compiler, falling back to next option", e);
- }
-
private static final class JdkPatternCompiler implements PatternCompiler {
@Override
public CommonPattern compile(String pattern) {
diff --git a/android/guava/src/com/google/common/base/Splitter.java b/android/guava/src/com/google/common/base/Splitter.java
index 7630ecae1..828b669a4 100644
--- a/android/guava/src/com/google/common/base/Splitter.java
+++ b/android/guava/src/com/google/common/base/Splitter.java
@@ -215,10 +215,11 @@ public final class Splitter {
@J2ktIncompatible
@GwtIncompatible // java.util.regex
public static Splitter on(Pattern separatorPattern) {
- return on(new JdkPattern(separatorPattern));
+ return onPatternInternal(new JdkPattern(separatorPattern));
}
- private static Splitter on(final CommonPattern separatorPattern) {
+ /** Internal utility; see {@link #on(Pattern)} instead. */
+ static Splitter onPatternInternal(final CommonPattern separatorPattern) {
checkArgument(
!separatorPattern.matcher("").matches(),
"The pattern may not match the empty string: %s",
@@ -259,7 +260,7 @@ public final class Splitter {
@J2ktIncompatible
@GwtIncompatible // java.util.regex
public static Splitter onPattern(String separatorPattern) {
- return on(Platform.compilePattern(separatorPattern));
+ return onPatternInternal(Platform.compilePattern(separatorPattern));
}
/**
diff --git a/android/guava/src/com/google/common/base/Throwables.java b/android/guava/src/com/google/common/base/Throwables.java
index 23936897d..e37a3d99d 100644
--- a/android/guava/src/com/google/common/base/Throwables.java
+++ b/android/guava/src/com/google/common/base/Throwables.java
@@ -140,18 +140,7 @@ public final class Throwables {
/**
* Propagates {@code throwable} exactly as-is, if and only if it is an instance of {@link
- * RuntimeException} or {@link Error}. Example usage:
- *
- * <pre>
- * try {
- * someMethodThatCouldThrowAnything();
- * } catch (IKnowWhatToDoWithThisException e) {
- * handle(e);
- * } catch (Throwable t) {
- * Throwables.propagateIfPossible(t);
- * throw new RuntimeException("unexpected", t);
- * }
- * </pre>
+ * RuntimeException} or {@link Error}.
*
* @deprecated Use {@link #throwIfUnchecked}, which has the same behavior but rejects {@code
* null}.
@@ -167,18 +156,10 @@ public final class Throwables {
/**
* Propagates {@code throwable} exactly as-is, if and only if it is an instance of {@link
- * RuntimeException}, {@link Error}, or {@code declaredType}. Example usage:
+ * RuntimeException}, {@link Error}, or {@code declaredType}.
*
- * <pre>
- * try {
- * someMethodThatCouldThrowAnything();
- * } catch (IKnowWhatToDoWithThisException e) {
- * handle(e);
- * } catch (Throwable t) {
- * Throwables.propagateIfPossible(t, OtherException.class);
- * throw new RuntimeException("unexpected", t);
- * }
- * </pre>
+ * <p><b>Discouraged</b> in favor of calling {@link #throwIfInstanceOf} and {@link
+ * #throwIfUnchecked}.
*
* @param throwable the Throwable to possibly propagate
* @param declaredType the single checked exception type declared by the calling method
@@ -193,10 +174,10 @@ public final class Throwables {
/**
* Propagates {@code throwable} exactly as-is, if and only if it is an instance of {@link
- * RuntimeException}, {@link Error}, {@code declaredType1}, or {@code declaredType2}. In the
- * unlikely case that you have three or more declared checked exception types, you can handle them
- * all by invoking these methods repeatedly. See usage example in {@link
- * #propagateIfPossible(Throwable, Class)}.
+ * RuntimeException}, {@link Error}, {@code declaredType1}, or {@code declaredType2}.
+ *
+ * <p><b>Discouraged</b> in favor of calling {@link #throwIfInstanceOf} and {@link
+ * #throwIfUnchecked}.
*
* @param throwable the Throwable to possibly propagate
* @param declaredType1 any checked exception type declared by the calling method
@@ -235,10 +216,11 @@ public final class Throwables {
* @param throwable the Throwable to propagate
* @return nothing will ever be returned; this return type is only for your convenience, as
* illustrated in the example above
- * @deprecated Use {@code throw e} or {@code throw new RuntimeException(e)} directly, or use a
- * combination of {@link #throwIfUnchecked} and {@code throw new RuntimeException(e)}. For
- * background on the deprecation, read <a href="https://goo.gl/Ivn2kc">Why we deprecated
- * {@code Throwables.propagate}</a>.
+ * @deprecated To preserve behavior, use {@code throw e} or {@code throw new RuntimeException(e)}
+ * directly, or use a combination of {@link #throwIfUnchecked} and {@code throw new
+ * RuntimeException(e)}. But consider whether users would be better off if your API threw a
+ * different type of exception. For background on the deprecation, read <a
+ * href="https://goo.gl/Ivn2kc">Why we deprecated {@code Throwables.propagate}</a>.
*/
@CanIgnoreReturnValue
@J2ktIncompatible
diff --git a/android/guava/src/com/google/common/base/internal/Finalizer.java b/android/guava/src/com/google/common/base/internal/Finalizer.java
index b45ec1578..e8ddf320c 100644
--- a/android/guava/src/com/google/common/base/internal/Finalizer.java
+++ b/android/guava/src/com/google/common/base/internal/Finalizer.java
@@ -153,41 +153,62 @@ public class Finalizer implements Runnable {
}
/**
- * Cleans up a single reference. Catches and logs all throwables.
+ * Cleans up the given reference and any other references already in the queue. Catches and logs
+ * all throwables.
*
- * @return true if the caller should continue, false if the associated FinalizableReferenceQueue
- * is no longer referenced.
+ * @return true if the caller should continue to wait for more references to be added to the
+ * queue, false if the associated FinalizableReferenceQueue is no longer referenced.
*/
- private boolean cleanUp(Reference<?> reference) {
+ private boolean cleanUp(Reference<?> firstReference) {
Method finalizeReferentMethod = getFinalizeReferentMethod();
if (finalizeReferentMethod == null) {
return false;
}
- do {
- /*
- * This is for the benefit of phantom references. Weak and soft references will have already
- * been cleared by this point.
- */
- reference.clear();
- if (reference == frqReference) {
- /*
- * The client no longer has a reference to the FinalizableReferenceQueue. We can stop.
- */
+ if (!finalizeReference(firstReference, finalizeReferentMethod)) {
+ return false;
+ }
+
+ /*
+ * Loop as long as we have references available so as not to waste CPU looking up the Method
+ * over and over again.
+ */
+ while (true) {
+ Reference<?> furtherReference = queue.poll();
+ if (furtherReference == null) {
+ return true;
+ }
+ if (!finalizeReference(furtherReference, finalizeReferentMethod)) {
return false;
}
+ }
+ }
- try {
- finalizeReferentMethod.invoke(reference);
- } catch (Throwable t) {
- logger.log(Level.SEVERE, "Error cleaning up after reference.", t);
- }
+ /**
+ * Cleans up the given reference. Catches and logs all throwables.
+ *
+ * @return true if the caller should continue to clean up references from the queue, false if the
+ * associated FinalizableReferenceQueue is no longer referenced.
+ */
+ private boolean finalizeReference(Reference<?> reference, Method finalizeReferentMethod) {
+ /*
+ * This is for the benefit of phantom references. Weak and soft references will have already
+ * been cleared by this point.
+ */
+ reference.clear();
+ if (reference == frqReference) {
/*
- * Loop as long as we have references available so as not to waste CPU looking up the Method
- * over and over again.
+ * The client no longer has a reference to the FinalizableReferenceQueue. We can stop.
*/
- } while ((reference = queue.poll()) != null);
+ return false;
+ }
+
+ try {
+ finalizeReferentMethod.invoke(reference);
+ } catch (Throwable t) {
+ logger.log(Level.SEVERE, "Error cleaning up after reference.", t);
+ }
return true;
}
diff --git a/android/guava/src/com/google/common/cache/CacheBuilder.java b/android/guava/src/com/google/common/cache/CacheBuilder.java
index 5d21c5b18..7e7ea25bb 100644
--- a/android/guava/src/com/google/common/cache/CacheBuilder.java
+++ b/android/guava/src/com/google/common/cache/CacheBuilder.java
@@ -568,8 +568,8 @@ public final class CacheBuilder<K, V> {
*
* @param weigher the weigher to use in calculating the weight of cache entries
* @return this {@code CacheBuilder} instance (for chaining)
- * @throws IllegalArgumentException if {@code size} is negative
- * @throws IllegalStateException if a maximum size was already set
+ * @throws IllegalStateException if a weigher was already set or {@link #maximumSize(long)} was
+ * previously called
* @since 11.0
*/
@GwtIncompatible // To be supported
diff --git a/android/guava/src/com/google/common/cache/LocalCache.java b/android/guava/src/com/google/common/cache/LocalCache.java
index 239afe204..6fb3945df 100644
--- a/android/guava/src/com/google/common/cache/LocalCache.java
+++ b/android/guava/src/com/google/common/cache/LocalCache.java
@@ -277,7 +277,8 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
// will result in random eviction behavior.
int segmentShift = 0;
int segmentCount = 1;
- while (segmentCount < concurrencyLevel && (!evictsBySize() || segmentCount * 20 <= maxWeight)) {
+ while (segmentCount < concurrencyLevel
+ && (!evictsBySize() || segmentCount * 20L <= maxWeight)) {
++segmentShift;
segmentCount <<= 1;
}
@@ -2179,12 +2180,7 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
if (createNewEntry) {
try {
- // Synchronizes on the entry to allow failing fast when a recursive load is
- // detected. This may be circumvented when an entry is copied, but will fail fast most
- // of the time.
- synchronized (e) {
- return loadSync(key, hash, loadingValueReference, loader);
- }
+ return loadSync(key, hash, loadingValueReference, loader);
} finally {
statsCounter.recordMisses(1);
}
@@ -2200,7 +2196,22 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
throw new AssertionError();
}
- checkState(!Thread.holdsLock(e), "Recursive load of: %s", key);
+ // As of this writing, the only prod ValueReference implementation for which isLoading() is
+ // true is LoadingValueReference. (Note, however, that not all LoadingValueReference instances
+ // have isLoading()==true: LoadingValueReference has a subclass, ComputingValueReference, for
+ // which isLoading() is false!) However, that might change, and we already have a *test*
+ // implementation for which it doesn't hold. So we check instanceof to be safe.
+ if (valueReference instanceof LoadingValueReference) {
+ // We check whether the thread that is loading the entry is our current thread, which would
+ // mean that we are both loading and waiting for the entry. In this case, we fail fast
+ // instead of deadlocking.
+ checkState(
+ ((LoadingValueReference<K, V>) valueReference).getLoadingThread()
+ != Thread.currentThread(),
+ "Recursive load of: %s",
+ key);
+ }
+
// don't consider expiration as we're concurrent with loading
try {
V value = valueReference.waitForValue();
@@ -3426,12 +3437,20 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
final SettableFuture<V> futureValue = SettableFuture.create();
final Stopwatch stopwatch = Stopwatch.createUnstarted();
+ final Thread loadingThread;
+
public LoadingValueReference() {
this(LocalCache.<K, V>unset());
}
+ /*
+ * TODO(cpovirk): Consider making this implementation closer to the mainline implementation.
+ * (The difference was introduced as part of Java-8-specific changes in cl/132882204, but we
+ * could probably make *some* of those changes here in the backport, too.)
+ */
public LoadingValueReference(ValueReference<K, V> oldValue) {
this.oldValue = oldValue;
+ this.loadingThread = Thread.currentThread();
}
@Override
@@ -3535,6 +3554,10 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
ReferenceQueue<V> queue, @CheckForNull V value, ReferenceEntry<K, V> entry) {
return this;
}
+
+ Thread getLoadingThread() {
+ return this.loadingThread;
+ }
}
// Queues
diff --git a/android/guava/src/com/google/common/collect/AbstractBiMap.java b/android/guava/src/com/google/common/collect/AbstractBiMap.java
index 10edc5c4c..d8566f2fe 100644
--- a/android/guava/src/com/google/common/collect/AbstractBiMap.java
+++ b/android/guava/src/com/google/common/collect/AbstractBiMap.java
@@ -19,6 +19,7 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -478,7 +479,7 @@ abstract class AbstractBiMap<K extends @Nullable Object, V extends @Nullable Obj
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- setInverse((AbstractBiMap<V, K>) stream.readObject());
+ setInverse((AbstractBiMap<V, K>) requireNonNull(stream.readObject()));
}
@GwtIncompatible // Not needed in the emulated source.
diff --git a/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java b/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
index 9a2612edf..1ca30fd09 100644
--- a/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
+++ b/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
@@ -1050,7 +1050,7 @@ abstract class AbstractMapBasedMultimap<K extends @Nullable Object, V extends @N
}
@WeakOuter
- class NavigableKeySet extends SortedKeySet implements NavigableSet<K> {
+ private final class NavigableKeySet extends SortedKeySet implements NavigableSet<K> {
NavigableKeySet(NavigableMap<K, Collection<V>> subMap) {
super(subMap);
}
@@ -1507,7 +1507,7 @@ abstract class AbstractMapBasedMultimap<K extends @Nullable Object, V extends @N
}
}
- class NavigableAsMap extends SortedAsMap implements NavigableMap<K, Collection<V>> {
+ private final class NavigableAsMap extends SortedAsMap implements NavigableMap<K, Collection<V>> {
NavigableAsMap(NavigableMap<K, Collection<V>> submap) {
super(submap);
diff --git a/android/guava/src/com/google/common/collect/CartesianList.java b/android/guava/src/com/google/common/collect/CartesianList.java
index 4c31b1299..a93fb032f 100644
--- a/android/guava/src/com/google/common/collect/CartesianList.java
+++ b/android/guava/src/com/google/common/collect/CartesianList.java
@@ -17,6 +17,8 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkElementIndex;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.math.IntMath;
import java.util.AbstractList;
import java.util.List;
@@ -132,6 +134,15 @@ final class CartesianList<E> extends AbstractList<List<E>> implements RandomAcce
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @J2ktIncompatible // serialization
+ @Override
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
diff --git a/android/guava/src/com/google/common/collect/CollectCollectors.java b/android/guava/src/com/google/common/collect/CollectCollectors.java
new file mode 100644
index 000000000..b9ae7cba0
--- /dev/null
+++ b/android/guava/src/com/google/common/collect/CollectCollectors.java
@@ -0,0 +1,473 @@
+/*
+ * Copyright (C) 2016 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.collect;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Collections.singletonMap;
+import static java.util.stream.Collectors.collectingAndThen;
+
+import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
+import com.google.common.base.Preconditions;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.LinkedHashMap;
+import java.util.TreeMap;
+import java.util.function.BinaryOperator;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.function.ToIntFunction;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/** Collectors utilities for {@code common.collect} internals. */
+@GwtCompatible
+@ElementTypesAreNonnullByDefault
+@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+@IgnoreJRERequirement // used only from APIs with Java 8 types in them
+// (not used publicly by guava-android as of this writing, but we include it in the jar as a test)
+final class CollectCollectors {
+
+ private static final Collector<Object, ?, ImmutableList<Object>> TO_IMMUTABLE_LIST =
+ Collector.of(
+ ImmutableList::builder,
+ ImmutableList.Builder::add,
+ ImmutableList.Builder::combine,
+ ImmutableList.Builder::build);
+
+ private static final Collector<Object, ?, ImmutableSet<Object>> TO_IMMUTABLE_SET =
+ Collector.of(
+ ImmutableSet::builder,
+ ImmutableSet.Builder::add,
+ ImmutableSet.Builder::combine,
+ ImmutableSet.Builder::build);
+
+ @GwtIncompatible
+ private static final Collector<Range<Comparable<?>>, ?, ImmutableRangeSet<Comparable<?>>>
+ TO_IMMUTABLE_RANGE_SET =
+ Collector.of(
+ ImmutableRangeSet::builder,
+ ImmutableRangeSet.Builder::add,
+ ImmutableRangeSet.Builder::combine,
+ ImmutableRangeSet.Builder::build);
+
+ // Lists
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ static <E> Collector<E, ?, ImmutableList<E>> toImmutableList() {
+ return (Collector) TO_IMMUTABLE_LIST;
+ }
+
+ // Sets
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() {
+ return (Collector) TO_IMMUTABLE_SET;
+ }
+
+ static <E> Collector<E, ?, ImmutableSortedSet<E>> toImmutableSortedSet(
+ Comparator<? super E> comparator) {
+ checkNotNull(comparator);
+ return Collector.of(
+ () -> new ImmutableSortedSet.Builder<E>(comparator),
+ ImmutableSortedSet.Builder::add,
+ ImmutableSortedSet.Builder::combine,
+ ImmutableSortedSet.Builder::build);
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ static <E extends Enum<E>> Collector<E, ?, ImmutableSet<E>> toImmutableEnumSet() {
+ return (Collector) EnumSetAccumulator.TO_IMMUTABLE_ENUM_SET;
+ }
+
+ private static <E extends Enum<E>>
+ Collector<E, EnumSetAccumulator<E>, ImmutableSet<E>> toImmutableEnumSetGeneric() {
+ return Collector.of(
+ EnumSetAccumulator::new,
+ EnumSetAccumulator::add,
+ EnumSetAccumulator::combine,
+ EnumSetAccumulator::toImmutableSet,
+ Collector.Characteristics.UNORDERED);
+ }
+
+ @IgnoreJRERequirement // see enclosing class (whose annotation Animal Sniffer ignores here...)
+ private static final class EnumSetAccumulator<E extends Enum<E>> {
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ static final Collector<Enum<?>, ?, ImmutableSet<? extends Enum<?>>> TO_IMMUTABLE_ENUM_SET =
+ (Collector) toImmutableEnumSetGeneric();
+
+ @CheckForNull private EnumSet<E> set;
+
+ void add(E e) {
+ if (set == null) {
+ set = EnumSet.of(e);
+ } else {
+ set.add(e);
+ }
+ }
+
+ EnumSetAccumulator<E> combine(EnumSetAccumulator<E> other) {
+ if (this.set == null) {
+ return other;
+ } else if (other.set == null) {
+ return this;
+ } else {
+ this.set.addAll(other.set);
+ return this;
+ }
+ }
+
+ ImmutableSet<E> toImmutableSet() {
+ if (set == null) {
+ return ImmutableSet.of();
+ }
+ ImmutableSet<E> ret = ImmutableEnumSet.asImmutable(set);
+ set = null; // subsequent manual manipulation of the accumulator mustn't affect ret
+ return ret;
+ }
+ }
+
+ @GwtIncompatible
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ static <E extends Comparable<? super E>>
+ Collector<Range<E>, ?, ImmutableRangeSet<E>> toImmutableRangeSet() {
+ return (Collector) TO_IMMUTABLE_RANGE_SET;
+ }
+
+ // Multisets
+
+ static <T extends @Nullable Object, E> Collector<T, ?, ImmutableMultiset<E>> toImmutableMultiset(
+ Function<? super T, ? extends E> elementFunction, ToIntFunction<? super T> countFunction) {
+ checkNotNull(elementFunction);
+ checkNotNull(countFunction);
+ return Collector.of(
+ LinkedHashMultiset::create,
+ (multiset, t) ->
+ multiset.add(checkNotNull(elementFunction.apply(t)), countFunction.applyAsInt(t)),
+ (multiset1, multiset2) -> {
+ multiset1.addAll(multiset2);
+ return multiset1;
+ },
+ (Multiset<E> multiset) -> ImmutableMultiset.copyFromEntries(multiset.entrySet()));
+ }
+
+ static <T extends @Nullable Object, E extends @Nullable Object, M extends Multiset<E>>
+ Collector<T, ?, M> toMultiset(
+ Function<? super T, E> elementFunction,
+ ToIntFunction<? super T> countFunction,
+ Supplier<M> multisetSupplier) {
+ checkNotNull(elementFunction);
+ checkNotNull(countFunction);
+ checkNotNull(multisetSupplier);
+ return Collector.of(
+ multisetSupplier,
+ (ms, t) -> ms.add(elementFunction.apply(t), countFunction.applyAsInt(t)),
+ (ms1, ms2) -> {
+ ms1.addAll(ms2);
+ return ms1;
+ });
+ }
+
+ // Maps
+
+ static <T extends @Nullable Object, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ return Collector.of(
+ ImmutableMap.Builder<K, V>::new,
+ (builder, input) -> builder.put(keyFunction.apply(input), valueFunction.apply(input)),
+ ImmutableMap.Builder::combine,
+ ImmutableMap.Builder::buildOrThrow);
+ }
+
+ static <T extends @Nullable Object, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ checkNotNull(mergeFunction);
+ return collectingAndThen(
+ Collectors.toMap(keyFunction, valueFunction, mergeFunction, LinkedHashMap::new),
+ ImmutableMap::copyOf);
+ }
+
+ static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableSortedMap<K, V>> toImmutableSortedMap(
+ Comparator<? super K> comparator,
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ checkNotNull(comparator);
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ /*
+ * We will always fail if there are duplicate keys, and the keys are always sorted by
+ * the Comparator, so the entries can come in an arbitrary order -- so we report UNORDERED.
+ */
+ return Collector.of(
+ () -> new ImmutableSortedMap.Builder<K, V>(comparator),
+ (builder, input) -> builder.put(keyFunction.apply(input), valueFunction.apply(input)),
+ ImmutableSortedMap.Builder::combine,
+ ImmutableSortedMap.Builder::buildOrThrow,
+ Collector.Characteristics.UNORDERED);
+ }
+
+ static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableSortedMap<K, V>> toImmutableSortedMap(
+ Comparator<? super K> comparator,
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ checkNotNull(comparator);
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ checkNotNull(mergeFunction);
+ return collectingAndThen(
+ Collectors.toMap(
+ keyFunction, valueFunction, mergeFunction, () -> new TreeMap<K, V>(comparator)),
+ ImmutableSortedMap::copyOfSorted);
+ }
+
+ static <T extends @Nullable Object, K, V> Collector<T, ?, ImmutableBiMap<K, V>> toImmutableBiMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ return Collector.of(
+ ImmutableBiMap.Builder<K, V>::new,
+ (builder, input) -> builder.put(keyFunction.apply(input), valueFunction.apply(input)),
+ ImmutableBiMap.Builder::combine,
+ ImmutableBiMap.Builder::buildOrThrow,
+ new Collector.Characteristics[0]);
+ }
+
+ @J2ktIncompatible
+ static <T extends @Nullable Object, K extends Enum<K>, V>
+ Collector<T, ?, ImmutableMap<K, V>> toImmutableEnumMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ return Collector.of(
+ () ->
+ new EnumMapAccumulator<K, V>(
+ (v1, v2) -> {
+ throw new IllegalArgumentException("Multiple values for key: " + v1 + ", " + v2);
+ }),
+ (accum, t) -> {
+ /*
+ * We assign these to variables before calling checkNotNull to work around a bug in our
+ * nullness checker.
+ */
+ K key = keyFunction.apply(t);
+ V newValue = valueFunction.apply(t);
+ accum.put(
+ checkNotNull(key, "Null key for input %s", t),
+ checkNotNull(newValue, "Null value for input %s", t));
+ },
+ EnumMapAccumulator::combine,
+ EnumMapAccumulator::toImmutableMap,
+ Collector.Characteristics.UNORDERED);
+ }
+
+ @J2ktIncompatible
+ static <T extends @Nullable Object, K extends Enum<K>, V>
+ Collector<T, ?, ImmutableMap<K, V>> toImmutableEnumMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ checkNotNull(mergeFunction);
+ // not UNORDERED because we don't know if mergeFunction is commutative
+ return Collector.of(
+ () -> new EnumMapAccumulator<K, V>(mergeFunction),
+ (accum, t) -> {
+ /*
+ * We assign these to variables before calling checkNotNull to work around a bug in our
+ * nullness checker.
+ */
+ K key = keyFunction.apply(t);
+ V newValue = valueFunction.apply(t);
+ accum.put(
+ checkNotNull(key, "Null key for input %s", t),
+ checkNotNull(newValue, "Null value for input %s", t));
+ },
+ EnumMapAccumulator::combine,
+ EnumMapAccumulator::toImmutableMap);
+ }
+
+ @J2ktIncompatible
+ @IgnoreJRERequirement // see enclosing class (whose annotation Animal Sniffer ignores here...)
+ private static class EnumMapAccumulator<K extends Enum<K>, V> {
+ private final BinaryOperator<V> mergeFunction;
+ @CheckForNull private EnumMap<K, V> map = null;
+
+ EnumMapAccumulator(BinaryOperator<V> mergeFunction) {
+ this.mergeFunction = mergeFunction;
+ }
+
+ void put(K key, V value) {
+ if (map == null) {
+ map = new EnumMap<>(singletonMap(key, value));
+ } else {
+ map.merge(key, value, mergeFunction);
+ }
+ }
+
+ EnumMapAccumulator<K, V> combine(EnumMapAccumulator<K, V> other) {
+ if (this.map == null) {
+ return other;
+ } else if (other.map == null) {
+ return this;
+ } else {
+ other.map.forEach(this::put);
+ return this;
+ }
+ }
+
+ ImmutableMap<K, V> toImmutableMap() {
+ return (map == null) ? ImmutableMap.<K, V>of() : ImmutableEnumMap.asImmutable(map);
+ }
+ }
+
+ @GwtIncompatible
+ static <T extends @Nullable Object, K extends Comparable<? super K>, V>
+ Collector<T, ?, ImmutableRangeMap<K, V>> toImmutableRangeMap(
+ Function<? super T, Range<K>> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ return Collector.of(
+ ImmutableRangeMap::<K, V>builder,
+ (builder, input) -> builder.put(keyFunction.apply(input), valueFunction.apply(input)),
+ ImmutableRangeMap.Builder::combine,
+ ImmutableRangeMap.Builder::build);
+ }
+
+ // Multimaps
+
+ static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableListMultimap<K, V>> toImmutableListMultimap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ checkNotNull(keyFunction, "keyFunction");
+ checkNotNull(valueFunction, "valueFunction");
+ return Collector.of(
+ ImmutableListMultimap::<K, V>builder,
+ (builder, t) -> builder.put(keyFunction.apply(t), valueFunction.apply(t)),
+ ImmutableListMultimap.Builder::combine,
+ ImmutableListMultimap.Builder::build);
+ }
+
+ static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableListMultimap<K, V>> flatteningToImmutableListMultimap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends Stream<? extends V>> valuesFunction) {
+ checkNotNull(keyFunction);
+ checkNotNull(valuesFunction);
+ return collectingAndThen(
+ flatteningToMultimap(
+ input -> checkNotNull(keyFunction.apply(input)),
+ input -> valuesFunction.apply(input).peek(Preconditions::checkNotNull),
+ MultimapBuilder.linkedHashKeys().arrayListValues()::<K, V>build),
+ ImmutableListMultimap::copyOf);
+ }
+
+ static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableSetMultimap<K, V>> toImmutableSetMultimap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ checkNotNull(keyFunction, "keyFunction");
+ checkNotNull(valueFunction, "valueFunction");
+ return Collector.of(
+ ImmutableSetMultimap::<K, V>builder,
+ (builder, t) -> builder.put(keyFunction.apply(t), valueFunction.apply(t)),
+ ImmutableSetMultimap.Builder::combine,
+ ImmutableSetMultimap.Builder::build);
+ }
+
+ static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableSetMultimap<K, V>> flatteningToImmutableSetMultimap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends Stream<? extends V>> valuesFunction) {
+ checkNotNull(keyFunction);
+ checkNotNull(valuesFunction);
+ return collectingAndThen(
+ flatteningToMultimap(
+ input -> checkNotNull(keyFunction.apply(input)),
+ input -> valuesFunction.apply(input).peek(Preconditions::checkNotNull),
+ MultimapBuilder.linkedHashKeys().linkedHashSetValues()::<K, V>build),
+ ImmutableSetMultimap::copyOf);
+ }
+
+ static <
+ T extends @Nullable Object,
+ K extends @Nullable Object,
+ V extends @Nullable Object,
+ M extends Multimap<K, V>>
+ Collector<T, ?, M> toMultimap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ Supplier<M> multimapSupplier) {
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ checkNotNull(multimapSupplier);
+ return Collector.of(
+ multimapSupplier,
+ (multimap, input) -> multimap.put(keyFunction.apply(input), valueFunction.apply(input)),
+ (multimap1, multimap2) -> {
+ multimap1.putAll(multimap2);
+ return multimap1;
+ });
+ }
+
+ static <
+ T extends @Nullable Object,
+ K extends @Nullable Object,
+ V extends @Nullable Object,
+ M extends Multimap<K, V>>
+ Collector<T, ?, M> flatteningToMultimap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends Stream<? extends V>> valueFunction,
+ Supplier<M> multimapSupplier) {
+ checkNotNull(keyFunction);
+ checkNotNull(valueFunction);
+ checkNotNull(multimapSupplier);
+ return Collector.of(
+ multimapSupplier,
+ (multimap, input) -> {
+ K key = keyFunction.apply(input);
+ Collection<V> valuesForKey = multimap.get(key);
+ valueFunction.apply(input).forEachOrdered(valuesForKey::add);
+ },
+ (multimap1, multimap2) -> {
+ multimap1.putAll(multimap2);
+ return multimap1;
+ });
+ }
+
+ private CollectCollectors() {}
+}
diff --git a/android/guava/src/com/google/common/collect/Comparators.java b/android/guava/src/com/google/common/collect/Comparators.java
index 0c79a8c29..7ada5e538 100644
--- a/android/guava/src/com/google/common/collect/Comparators.java
+++ b/android/guava/src/com/google/common/collect/Comparators.java
@@ -17,10 +17,13 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import com.google.common.annotations.GwtCompatible;
import java.util.Comparator;
import java.util.Iterator;
+import java.util.List;
+import java.util.stream.Collector;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -107,6 +110,65 @@ public final class Comparators {
}
/**
+ * Returns a {@code Collector} that returns the {@code k} smallest (relative to the specified
+ * {@code Comparator}) input elements, in ascending order, as an unmodifiable {@code List}. Ties
+ * are broken arbitrarily.
+ *
+ * <p>For example:
+ *
+ * <pre>{@code
+ * Stream.of("foo", "quux", "banana", "elephant")
+ * .collect(least(2, comparingInt(String::length)))
+ * // returns {"foo", "quux"}
+ * }</pre>
+ *
+ * <p>This {@code Collector} uses O(k) memory and takes expected time O(n) (worst-case O(n log
+ * k)), as opposed to e.g. {@code Stream.sorted(comparator).limit(k)}, which currently takes O(n
+ * log n) time and O(n) space.
+ *
+ * @throws IllegalArgumentException if {@code k < 0}
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object> Collector<T, ?, List<T>> least(
+ int k, Comparator<? super T> comparator) {
+ checkNonnegative(k, "k");
+ checkNotNull(comparator);
+ return Collector.of(
+ () -> TopKSelector.<T>least(k, comparator),
+ TopKSelector::offer,
+ TopKSelector::combine,
+ TopKSelector::topK,
+ Collector.Characteristics.UNORDERED);
+ }
+
+ /**
+ * Returns a {@code Collector} that returns the {@code k} greatest (relative to the specified
+ * {@code Comparator}) input elements, in descending order, as an unmodifiable {@code List}. Ties
+ * are broken arbitrarily.
+ *
+ * <p>For example:
+ *
+ * <pre>{@code
+ * Stream.of("foo", "quux", "banana", "elephant")
+ * .collect(greatest(2, comparingInt(String::length)))
+ * // returns {"elephant", "banana"}
+ * }</pre>
+ *
+ * <p>This {@code Collector} uses O(k) memory and takes expected time O(n) (worst-case O(n log
+ * k)), as opposed to e.g. {@code Stream.sorted(comparator.reversed()).limit(k)}, which currently
+ * takes O(n log n) time and O(n) space.
+ *
+ * @throws IllegalArgumentException if {@code k < 0}
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object> Collector<T, ?, List<T>> greatest(
+ int k, Comparator<? super T> comparator) {
+ return least(k, comparator.reversed());
+ }
+
+ /**
* Returns the minimum of the two values. If the values compare as 0, the first is returned.
*
* <p>The recommended solution for finding the {@code minimum} of some values depends on the type
diff --git a/android/guava/src/com/google/common/collect/ConcurrentHashMultiset.java b/android/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
index 723ab0696..a84e3cee7 100644
--- a/android/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
+++ b/android/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
@@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
@@ -599,7 +600,7 @@ public final class ConcurrentHashMultiset<E> extends AbstractMultiset<E> impleme
stream.defaultReadObject();
@SuppressWarnings("unchecked") // reading data stored by writeObject
ConcurrentMap<E, Integer> deserializedCountMap =
- (ConcurrentMap<E, Integer>) stream.readObject();
+ (ConcurrentMap<E, Integer>) requireNonNull(stream.readObject());
FieldSettersHolder.COUNT_MAP_FIELD_SETTER.set(this, deserializedCountMap);
}
diff --git a/android/guava/src/com/google/common/collect/ContiguousSet.java b/android/guava/src/com/google/common/collect/ContiguousSet.java
index d0792054e..539c67383 100644
--- a/android/guava/src/com/google/common/collect/ContiguousSet.java
+++ b/android/guava/src/com/google/common/collect/ContiguousSet.java
@@ -20,6 +20,7 @@ import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.DoNotCall;
import java.util.Collections;
import java.util.NoSuchElementException;
@@ -259,4 +260,13 @@ public abstract class ContiguousSet<C extends Comparable> extends ImmutableSorte
public static <E> ImmutableSortedSet.Builder<E> builder() {
throw new UnsupportedOperationException();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @J2ktIncompatible // serialization
+ @Override
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/android/guava/src/com/google/common/collect/DenseImmutableTable.java b/android/guava/src/com/google/common/collect/DenseImmutableTable.java
index 9de77c57f..a8e96e382 100644
--- a/android/guava/src/com/google/common/collect/DenseImmutableTable.java
+++ b/android/guava/src/com/google/common/collect/DenseImmutableTable.java
@@ -17,6 +17,8 @@ package com.google.common.collect;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.collect.ImmutableMap.IteratorBasedImmutableMap;
import com.google.errorprone.annotations.Immutable;
import com.google.j2objc.annotations.WeakOuter;
@@ -144,6 +146,15 @@ final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
}
};
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @J2ktIncompatible // serialization
+ @Override
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
private final class Row extends ImmutableArrayMap<C, V> {
@@ -169,6 +180,15 @@ final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
private final class Column extends ImmutableArrayMap<R, V> {
@@ -194,6 +214,15 @@ final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@WeakOuter
@@ -216,6 +245,15 @@ final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
boolean isPartialView() {
return false;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@WeakOuter
@@ -238,6 +276,15 @@ final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
boolean isPartialView() {
return false;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@Override
@@ -285,7 +332,9 @@ final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
}
@Override
- SerializedForm createSerializedForm() {
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
return SerializedForm.create(this, cellRowIndices, cellColumnIndices);
}
}
diff --git a/android/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java b/android/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java
index 181731cc4..931c3e72c 100644
--- a/android/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java
+++ b/android/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java
@@ -15,6 +15,7 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import javax.annotation.CheckForNull;
/**
@@ -83,4 +84,12 @@ final class DescendingImmutableSortedMultiset<E> extends ImmutableSortedMultiset
boolean isPartialView() {
return forward.isPartialView();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/android/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java b/android/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java
index 88c7d6b5c..10b3fa866 100644
--- a/android/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java
+++ b/android/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import javax.annotation.CheckForNull;
/**
@@ -121,4 +122,12 @@ final class DescendingImmutableSortedSet<E> extends ImmutableSortedSet<E> {
boolean isPartialView() {
return forward.isPartialView();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/android/guava/src/com/google/common/collect/EnumBiMap.java b/android/guava/src/com/google/common/collect/EnumBiMap.java
index c4b540b56..b7d297272 100644
--- a/android/guava/src/com/google/common/collect/EnumBiMap.java
+++ b/android/guava/src/com/google/common/collect/EnumBiMap.java
@@ -19,6 +19,7 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Platform.getDeclaringClassOrObjectForJ2cl;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -151,8 +152,8 @@ public final class EnumBiMap<K extends Enum<K>, V extends Enum<V>> extends Abstr
@GwtIncompatible // java.io.ObjectInputStream
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- keyTypeOrObjectUnderJ2cl = (Class<K>) stream.readObject();
- valueTypeOrObjectUnderJ2cl = (Class<V>) stream.readObject();
+ keyTypeOrObjectUnderJ2cl = (Class<K>) requireNonNull(stream.readObject());
+ valueTypeOrObjectUnderJ2cl = (Class<V>) requireNonNull(stream.readObject());
setDelegates(
new EnumMap<K, V>(keyTypeOrObjectUnderJ2cl), new EnumMap<V, K>(valueTypeOrObjectUnderJ2cl));
Serialization.populateMap(this, stream);
diff --git a/android/guava/src/com/google/common/collect/EnumHashBiMap.java b/android/guava/src/com/google/common/collect/EnumHashBiMap.java
index 33b45b95c..c7432d404 100644
--- a/android/guava/src/com/google/common/collect/EnumHashBiMap.java
+++ b/android/guava/src/com/google/common/collect/EnumHashBiMap.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -128,7 +129,7 @@ public final class EnumHashBiMap<K extends Enum<K>, V extends @Nullable Object>
@GwtIncompatible // java.io.ObjectInputStream
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- keyTypeOrObjectUnderJ2cl = (Class<K>) stream.readObject();
+ keyTypeOrObjectUnderJ2cl = (Class<K>) requireNonNull(stream.readObject());
/*
* TODO: cpovirk - Pre-size the HashMap based on the number of enum values? (But *not* based on
* the number of entries in the map, as that makes it easy for hostile inputs to trigger lots of
diff --git a/android/guava/src/com/google/common/collect/EnumMultiset.java b/android/guava/src/com/google/common/collect/EnumMultiset.java
index 493bcc73a..ee5fc9e2e 100644
--- a/android/guava/src/com/google/common/collect/EnumMultiset.java
+++ b/android/guava/src/com/google/common/collect/EnumMultiset.java
@@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.CollectPreconditions.checkRemove;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -298,7 +299,7 @@ public final class EnumMultiset<E extends Enum<E>> extends AbstractMultiset<E>
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
@SuppressWarnings("unchecked") // reading data stored by writeObject
- Class<E> localType = (Class<E>) stream.readObject();
+ Class<E> localType = (Class<E>) requireNonNull(stream.readObject());
type = localType;
enumConstants = type.getEnumConstants();
counts = new int[enumConstants.length];
diff --git a/android/guava/src/com/google/common/collect/ImmutableBiMap.java b/android/guava/src/com/google/common/collect/ImmutableBiMap.java
index 30e293ebf..d18d5b6f1 100644
--- a/android/guava/src/com/google/common/collect/ImmutableBiMap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableBiMap.java
@@ -29,7 +29,12 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
+import java.util.function.BinaryOperator;
+import java.util.function.Function;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link BiMap} whose contents will never change, with many other important properties detailed
@@ -43,6 +48,24 @@ import javax.annotation.CheckForNull;
public abstract class ImmutableBiMap<K, V> extends ImmutableMap<K, V> implements BiMap<K, V> {
/**
+ * Returns a {@link Collector} that accumulates elements into an {@code ImmutableBiMap} whose keys
+ * and values are the result of applying the provided mapping functions to the input elements.
+ * Entries appear in the result {@code ImmutableBiMap} in encounter order.
+ *
+ * <p>If the mapped keys or values contain duplicates (according to {@link
+ * Object#equals(Object)}), an {@code IllegalArgumentException} is thrown when the collection
+ * operation is performed. (This differs from the {@code Collector} returned by {@link
+ * Collectors#toMap(Function, Function)}, which throws an {@code IllegalStateException}.)
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K, V> Collector<T, ?, ImmutableBiMap<K, V>> toImmutableBiMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ return CollectCollectors.toImmutableBiMap(keyFunction, valueFunction);
+ }
+
+ /**
* Returns the empty bimap.
*
* <p><b>Performance note:</b> the instance returned is a singleton.
@@ -591,4 +614,42 @@ public abstract class ImmutableBiMap<K, V> extends ImmutableMap<K, V> implements
private void readObject(ObjectInputStream stream) throws InvalidObjectException {
throw new InvalidObjectException("Use SerializedForm");
}
+
+ /**
+ * Not supported. Use {@link #toImmutableBiMap} instead. This method exists only to hide {@link
+ * ImmutableMap#toImmutableMap(Function, Function)} from consumers of {@code ImmutableBiMap}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableBiMap#toImmutableBiMap}.
+ */
+ @Deprecated
+ @DoNotCall("Use toImmutableBiMap")
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. This method does not make sense for {@code BiMap}. This method exists only to
+ * hide {@link ImmutableMap#toImmutableMap(Function, Function, BinaryOperator)} from consumers of
+ * {@code ImmutableBiMap}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated
+ */
+ @Deprecated
+ @DoNotCall("Use toImmutableBiMap")
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ throw new UnsupportedOperationException();
+ }
+
+ private static final long serialVersionUID = 0xdecaf;
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableCollection.java b/android/guava/src/com/google/common/collect/ImmutableCollection.java
index 4ef25aa78..1da069a2f 100644
--- a/android/guava/src/com/google/common/collect/ImmutableCollection.java
+++ b/android/guava/src/com/google/common/collect/ImmutableCollection.java
@@ -21,6 +21,7 @@ import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.ObjectArrays.checkElementsNotNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotCall;
@@ -170,6 +171,11 @@ import org.checkerframework.checker.nullness.qual.Nullable;
// TODO(kevinb): I think we should push everything down to "BaseImmutableCollection" or something,
// just to do everything we can to emphasize the "practically an interface" nature of this class.
public abstract class ImmutableCollection<E> extends AbstractCollection<E> implements Serializable {
+ /*
+ * We expect SIZED (and SUBSIZED, if applicable) to be added by the spliterator factory methods.
+ * These are properties of the collection as a whole; SIZED and SUBSIZED are more properties of
+ * the spliterator implementation.
+ */
ImmutableCollection() {}
@@ -361,6 +367,7 @@ public abstract class ImmutableCollection<E> extends AbstractCollection<E> imple
}
@J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
Object writeReplace() {
// We serialize by default to ImmutableList, the simplest thing that works.
return new ImmutableList.SerializedForm(toArray());
@@ -549,4 +556,6 @@ public abstract class ImmutableCollection<E> extends AbstractCollection<E> imple
return this;
}
}
+
+ private static final long serialVersionUID = 0xdecaf;
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableList.java b/android/guava/src/com/google/common/collect/ImmutableList.java
index f201a437e..940bf96c2 100644
--- a/android/guava/src/com/google/common/collect/ImmutableList.java
+++ b/android/guava/src/com/google/common/collect/ImmutableList.java
@@ -26,6 +26,7 @@ import static com.google.common.collect.ObjectArrays.checkElementsNotNull;
import static com.google.common.collect.RegularImmutableList.EMPTY;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotCall;
@@ -40,6 +41,7 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.RandomAccess;
+import java.util.stream.Collector;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -60,6 +62,17 @@ import org.checkerframework.checker.nullness.qual.Nullable;
@ElementTypesAreNonnullByDefault
public abstract class ImmutableList<E> extends ImmutableCollection<E>
implements List<E>, RandomAccess {
+
+ /**
+ * Returns a {@code Collector} that accumulates the input elements into a new {@code
+ * ImmutableList}, in encounter order.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <E> Collector<E, ?, ImmutableList<E>> toImmutableList() {
+ return CollectCollectors.toImmutableList();
+ }
+
/**
* Returns the empty immutable list. This list behaves and performs comparably to {@link
* Collections#emptyList}, and is preferable mainly for consistency and maintainability of your
@@ -413,6 +426,12 @@ public abstract class ImmutableList<E> extends ImmutableCollection<E>
* Returns an immutable list of the elements between the specified {@code fromIndex}, inclusive,
* and {@code toIndex}, exclusive. (If {@code fromIndex} and {@code toIndex} are equal, the empty
* immutable list is returned.)
+ *
+ * <p><b>Note:</b> in almost all circumstances, the returned {@link ImmutableList} retains a
+ * strong reference to {@code this}, which may prevent the original list from being garbage
+ * collected. If you want the original list to be eligible for garbage collection, you should
+ * create and use a copy of the sub list (e.g., {@code
+ * ImmutableList.copyOf(originalList.subList(...))}).
*/
@Override
public ImmutableList<E> subList(int fromIndex, int toIndex) {
@@ -482,6 +501,15 @@ public abstract class ImmutableList<E> extends ImmutableCollection<E>
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
/**
@@ -631,6 +659,15 @@ public abstract class ImmutableList<E> extends ImmutableCollection<E>
boolean isPartialView() {
return forwardList.isPartialView();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@Override
@@ -677,6 +714,7 @@ public abstract class ImmutableList<E> extends ImmutableCollection<E>
@Override
@J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
Object writeReplace() {
return new SerializedForm(toArray());
}
@@ -810,4 +848,6 @@ public abstract class ImmutableList<E> extends ImmutableCollection<E>
return asImmutableList(contents, size);
}
}
+
+ private static final long serialVersionUID = 0xcafebabe;
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableListMultimap.java b/android/guava/src/com/google/common/collect/ImmutableListMultimap.java
index fbc8ce2f5..deab19d8a 100644
--- a/android/guava/src/com/google/common/collect/ImmutableListMultimap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableListMultimap.java
@@ -16,6 +16,8 @@
package com.google.common.collect;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
@@ -31,7 +33,11 @@ import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.function.Function;
+import java.util.stream.Collector;
+import java.util.stream.Stream;
import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link ListMultimap} whose contents will never change, with many other important properties
@@ -47,6 +53,78 @@ import javax.annotation.CheckForNull;
@ElementTypesAreNonnullByDefault
public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V>
implements ListMultimap<K, V> {
+ /**
+ * Returns a {@link Collector} that accumulates elements into an {@code ImmutableListMultimap}
+ * whose keys and values are the result of applying the provided mapping functions to the input
+ * elements.
+ *
+ * <p>For streams with defined encounter order (as defined in the Ordering section of the {@link
+ * java.util.stream} Javadoc), that order is preserved, but entries are <a
+ * href="ImmutableMultimap.html#iteration">grouped by key</a>.
+ *
+ * <p>Example:
+ *
+ * <pre>{@code
+ * static final Multimap<Character, String> FIRST_LETTER_MULTIMAP =
+ * Stream.of("banana", "apple", "carrot", "asparagus", "cherry")
+ * .collect(toImmutableListMultimap(str -> str.charAt(0), str -> str.substring(1)));
+ *
+ * // is equivalent to
+ *
+ * static final Multimap<Character, String> FIRST_LETTER_MULTIMAP =
+ * new ImmutableListMultimap.Builder<Character, String>()
+ * .put('b', "anana")
+ * .putAll('a', "pple", "sparagus")
+ * .putAll('c', "arrot", "herry")
+ * .build();
+ * }</pre>
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableListMultimap<K, V>> toImmutableListMultimap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ return CollectCollectors.toImmutableListMultimap(keyFunction, valueFunction);
+ }
+
+ /**
+ * Returns a {@code Collector} accumulating entries into an {@code ImmutableListMultimap}. Each
+ * input element is mapped to a key and a stream of values, each of which are put into the
+ * resulting {@code Multimap}, in the encounter order of the stream and the encounter order of the
+ * streams of values.
+ *
+ * <p>Example:
+ *
+ * <pre>{@code
+ * static final ImmutableListMultimap<Character, Character> FIRST_LETTER_MULTIMAP =
+ * Stream.of("banana", "apple", "carrot", "asparagus", "cherry")
+ * .collect(
+ * flatteningToImmutableListMultimap(
+ * str -> str.charAt(0),
+ * str -> str.substring(1).chars().mapToObj(c -> (char) c));
+ *
+ * // is equivalent to
+ *
+ * static final ImmutableListMultimap<Character, Character> FIRST_LETTER_MULTIMAP =
+ * ImmutableListMultimap.<Character, Character>builder()
+ * .putAll('b', Arrays.asList('a', 'n', 'a', 'n', 'a'))
+ * .putAll('a', Arrays.asList('p', 'p', 'l', 'e'))
+ * .putAll('c', Arrays.asList('a', 'r', 'r', 'o', 't'))
+ * .putAll('a', Arrays.asList('s', 'p', 'a', 'r', 'a', 'g', 'u', 's'))
+ * .putAll('c', Arrays.asList('h', 'e', 'r', 'r', 'y'))
+ * .build();
+ * }
+ * }</pre>
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableListMultimap<K, V>> flatteningToImmutableListMultimap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends Stream<? extends V>> valuesFunction) {
+ return CollectCollectors.flatteningToImmutableListMultimap(keyFunction, valuesFunction);
+ }
/**
* Returns the empty multimap.
@@ -194,6 +272,13 @@ public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V>
return this;
}
+ @CanIgnoreReturnValue
+ @Override
+ Builder<K, V> combine(ImmutableMultimap.Builder<K, V> other) {
+ super.combine(other);
+ return this;
+ }
+
/**
* {@inheritDoc}
*
@@ -218,13 +303,6 @@ public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V>
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() {
@@ -397,7 +475,7 @@ public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V>
int tmpSize = 0;
for (int i = 0; i < keyCount; i++) {
- Object key = stream.readObject();
+ Object key = requireNonNull(stream.readObject());
int valueCount = stream.readInt();
if (valueCount <= 0) {
throw new InvalidObjectException("Invalid value count " + valueCount);
@@ -405,7 +483,7 @@ public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V>
ImmutableList.Builder<Object> valuesBuilder = ImmutableList.builder();
for (int j = 0; j < valueCount; j++) {
- valuesBuilder.add(stream.readObject());
+ valuesBuilder.add(requireNonNull(stream.readObject()));
}
builder.put(key, valuesBuilder.build());
tmpSize += valueCount;
diff --git a/android/guava/src/com/google/common/collect/ImmutableMap.java b/android/guava/src/com/google/common/collect/ImmutableMap.java
index 94484a0d5..79b39b7ad 100644
--- a/android/guava/src/com/google/common/collect/ImmutableMap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableMap.java
@@ -23,6 +23,7 @@ import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotCall;
@@ -45,6 +46,10 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
+import java.util.function.BinaryOperator;
+import java.util.function.Function;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -66,6 +71,44 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
/**
+ * Returns a {@link Collector} that accumulates elements into an {@code ImmutableMap} whose keys
+ * and values are the result of applying the provided mapping functions to the input elements.
+ * Entries appear in the result {@code ImmutableMap} in encounter order.
+ *
+ * <p>If the mapped keys contain duplicates (according to {@link Object#equals(Object)}, an {@code
+ * IllegalArgumentException} is thrown when the collection operation is performed. (This differs
+ * from the {@code Collector} returned by {@link Collectors#toMap(Function, Function)}, which
+ * throws an {@code IllegalStateException}.)
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ return CollectCollectors.toImmutableMap(keyFunction, valueFunction);
+ }
+
+ /**
+ * Returns a {@link Collector} that accumulates elements into an {@code ImmutableMap} whose keys
+ * and values are the result of applying the provided mapping functions to the input elements.
+ *
+ * <p>If the mapped keys contain duplicates (according to {@link Object#equals(Object)}), the
+ * values are merged using the specified merging function. If the merging function returns {@code
+ * null}, then the collector removes the value that has been computed for the key thus far (though
+ * future occurrences of the key would reinsert it).
+ *
+ * <p>Entries will appear in the encounter order of the first occurrence of the key.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ return CollectCollectors.toImmutableMap(keyFunction, valueFunction, mergeFunction);
+ }
+
+ /**
* Returns the empty map. This map behaves and performs comparably to {@link
* Collections#emptyMap}, and is preferable mainly for consistency and maintainability of your
* code.
@@ -727,6 +770,15 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
public UnmodifiableIterator<Entry<K, V>> iterator() {
return entryIterator();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
return new EntrySetImpl();
}
@@ -735,6 +787,15 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
ImmutableCollection<V> createValues() {
return new ImmutableMapValues<>(this);
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
ImmutableMap() {}
@@ -1016,6 +1077,15 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
}
};
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@Override
@@ -1133,4 +1203,6 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
private void readObject(ObjectInputStream stream) throws InvalidObjectException {
throw new InvalidObjectException("Use SerializedForm");
}
+
+ private static final long serialVersionUID = 0xdecaf;
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java b/android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java
index 3732e2dfe..27a4c2c33 100644
--- a/android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java
+++ b/android/guava/src/com/google/common/collect/ImmutableMapEntrySet.java
@@ -68,6 +68,15 @@ abstract class ImmutableMapEntrySet<K, V> extends ImmutableSet<Entry<K, V>> {
ImmutableList<Entry<K, V>> createAsList() {
return entries;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
ImmutableMapEntrySet() {}
diff --git a/android/guava/src/com/google/common/collect/ImmutableMapKeySet.java b/android/guava/src/com/google/common/collect/ImmutableMapKeySet.java
index 056a35141..cd9f4accf 100644
--- a/android/guava/src/com/google/common/collect/ImmutableMapKeySet.java
+++ b/android/guava/src/com/google/common/collect/ImmutableMapKeySet.java
@@ -62,8 +62,9 @@ final class ImmutableMapKeySet<K, V> extends IndexedImmutableSet<K> {
return true;
}
- @GwtIncompatible // serialization
@Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
Object writeReplace() {
return new KeySetSerializedForm<K>(map);
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableMapValues.java b/android/guava/src/com/google/common/collect/ImmutableMapValues.java
index ba868d1b9..0ddf84ffe 100644
--- a/android/guava/src/com/google/common/collect/ImmutableMapValues.java
+++ b/android/guava/src/com/google/common/collect/ImmutableMapValues.java
@@ -88,6 +88,15 @@ final class ImmutableMapValues<K, V> extends ImmutableCollection<V> {
public int size() {
return entryList.size();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableMultimap.java b/android/guava/src/com/google/common/collect/ImmutableMultimap.java
index e4ad391f5..597d0be27 100644
--- a/android/guava/src/com/google/common/collect/ImmutableMultimap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableMultimap.java
@@ -576,6 +576,15 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V
return false;
}
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
+
private static final long serialVersionUID = 0;
}
@@ -757,6 +766,15 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V
return true;
}
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
+
@J2ktIncompatible // serialization
private static final long serialVersionUID = 0;
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableMultiset.java b/android/guava/src/com/google/common/collect/ImmutableMultiset.java
index ecb8ae45b..b5e2e347e 100644
--- a/android/guava/src/com/google/common/collect/ImmutableMultiset.java
+++ b/android/guava/src/com/google/common/collect/ImmutableMultiset.java
@@ -33,6 +33,9 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
+import java.util.function.Function;
+import java.util.function.ToIntFunction;
+import java.util.stream.Collector;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -56,6 +59,34 @@ import org.checkerframework.checker.nullness.qual.Nullable;
@ElementTypesAreNonnullByDefault
public abstract class ImmutableMultiset<E> extends ImmutableMultisetGwtSerializationDependencies<E>
implements Multiset<E> {
+
+ /**
+ * Returns a {@code Collector} that accumulates the input elements into a new {@code
+ * ImmutableMultiset}. Elements iterate in order by the <i>first</i> appearance of that element in
+ * encounter order.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <E> Collector<E, ?, ImmutableMultiset<E>> toImmutableMultiset() {
+ return CollectCollectors.toImmutableMultiset(Function.identity(), e -> 1);
+ }
+
+ /**
+ * Returns a {@code Collector} that accumulates elements into an {@code ImmutableMultiset} whose
+ * elements are the result of applying {@code elementFunction} to the inputs, with counts equal to
+ * the result of applying {@code countFunction} to the inputs.
+ *
+ * <p>If the mapped elements contain duplicates (according to {@link Object#equals}), the first
+ * occurrence in encounter order appears in the resulting multiset, with count equal to the sum of
+ * the outputs of {@code countFunction.applyAsInt(t)} for each {@code t} mapped to that element.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, E> Collector<T, ?, ImmutableMultiset<E>> toImmutableMultiset(
+ Function<? super T, ? extends E> elementFunction, ToIntFunction<? super T> countFunction) {
+ return CollectCollectors.toImmutableMultiset(elementFunction, countFunction);
+ }
+
/**
* Returns the empty immutable multiset.
*
@@ -636,4 +667,6 @@ public abstract class ImmutableMultiset<E> extends ImmutableMultisetGwtSerializa
return new RegularImmutableMultiset<E>(contents);
}
}
+
+ private static final long serialVersionUID = 0xdecaf;
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableRangeMap.java b/android/guava/src/com/google/common/collect/ImmutableRangeMap.java
index 710c8916e..72c70b1ae 100644
--- a/android/guava/src/com/google/common/collect/ImmutableRangeMap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableRangeMap.java
@@ -33,7 +33,10 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
+import java.util.function.Function;
+import java.util.stream.Collector;
import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link RangeMap} whose contents will never change, with many other important properties
@@ -50,6 +53,19 @@ public class ImmutableRangeMap<K extends Comparable<?>, V> implements RangeMap<K
new ImmutableRangeMap<>(ImmutableList.<Range<Comparable<?>>>of(), ImmutableList.of());
/**
+ * Returns a {@code Collector} that accumulates the input elements into a new {@code
+ * ImmutableRangeMap}. As in {@link Builder}, overlapping ranges are not permitted.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K extends Comparable<? super K>, V>
+ Collector<T, ?, ImmutableRangeMap<K, V>> toImmutableRangeMap(
+ Function<? super T, Range<K>> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ return CollectCollectors.toImmutableRangeMap(keyFunction, valueFunction);
+ }
+
+ /**
* Returns an empty immutable range map.
*
* <p><b>Performance note:</b> the instance returned is a singleton.
@@ -339,6 +355,14 @@ public class ImmutableRangeMap<K extends Comparable<?>, V> implements RangeMap<K
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
final ImmutableRangeMap<K, V> outer = this;
return new ImmutableRangeMap<K, V>(subRanges, values.subList(lowerIndex, upperIndex)) {
@@ -350,6 +374,14 @@ public class ImmutableRangeMap<K extends Comparable<?>, V> implements RangeMap<K
return ImmutableRangeMap.of();
}
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableRangeSet.java b/android/guava/src/com/google/common/collect/ImmutableRangeSet.java
index 844c1c1dc..7d08c89e3 100644
--- a/android/guava/src/com/google/common/collect/ImmutableRangeSet.java
+++ b/android/guava/src/com/google/common/collect/ImmutableRangeSet.java
@@ -38,6 +38,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
+import java.util.stream.Collector;
import javax.annotation.CheckForNull;
/**
@@ -59,6 +60,18 @@ public final class ImmutableRangeSet<C extends Comparable> extends AbstractRange
new ImmutableRangeSet<>(ImmutableList.of(Range.<Comparable<?>>all()));
/**
+ * Returns a {@code Collector} that accumulates the input elements into a new {@code
+ * ImmutableRangeSet}. As in {@link Builder}, overlapping ranges are not permitted and adjacent
+ * ranges will be merged.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <E extends Comparable<? super E>>
+ Collector<Range<E>, ?, ImmutableRangeSet<E>> toImmutableRangeSet() {
+ return CollectCollectors.toImmutableRangeSet();
+ }
+
+ /**
* Returns an empty immutable range set.
*
* <p><b>Performance note:</b> the instance returned is a singleton.
@@ -355,6 +368,14 @@ public final class ImmutableRangeSet<C extends Comparable> extends AbstractRange
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@Override
@@ -474,6 +495,15 @@ public final class ImmutableRangeSet<C extends Comparable> extends AbstractRange
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableSet.java b/android/guava/src/com/google/common/collect/ImmutableSet.java
index 6d9f167bc..c4631804d 100644
--- a/android/guava/src/com/google/common/collect/ImmutableSet.java
+++ b/android/guava/src/com/google/common/collect/ImmutableSet.java
@@ -38,6 +38,7 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.Set;
import java.util.SortedSet;
+import java.util.stream.Collector;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -51,6 +52,19 @@ import org.checkerframework.checker.nullness.qual.Nullable;
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
public abstract class ImmutableSet<E> extends ImmutableCollection<E> implements Set<E> {
+
+ /**
+ * Returns a {@code Collector} that accumulates the input elements into a new {@code
+ * ImmutableSet}. Elements appear in the resulting set in the encounter order of the stream; if
+ * the stream contains duplicates (according to {@link Object#equals(Object)}), only the first
+ * duplicate in encounter order will appear in the result.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() {
+ return CollectCollectors.toImmutableSet();
+ }
+
/**
* Returns the empty immutable set. Preferred over {@link Collections#emptySet} for code
* consistency, and because the return type conveys the immutability guarantee.
@@ -605,4 +619,6 @@ public abstract class ImmutableSet<E> extends ImmutableCollection<E> implements
}
}
}
+
+ private static final long serialVersionUID = 0xdecaf;
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java b/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java
index 354a7c55f..022a3d409 100644
--- a/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -36,7 +37,11 @@ import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.function.Function;
+import java.util.stream.Collector;
+import java.util.stream.Stream;
import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link SetMultimap} whose contents will never change, with many other important properties
@@ -56,6 +61,87 @@ import javax.annotation.CheckForNull;
@ElementTypesAreNonnullByDefault
public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V>
implements SetMultimap<K, V> {
+ /**
+ * Returns a {@link Collector} that accumulates elements into an {@code ImmutableSetMultimap}
+ * whose keys and values are the result of applying the provided mapping functions to the input
+ * elements.
+ *
+ * <p>For streams with defined encounter order (as defined in the Ordering section of the {@link
+ * java.util.stream} Javadoc), that order is preserved, but entries are <a
+ * href="ImmutableMultimap.html#iteration">grouped by key</a>.
+ *
+ * <p>Example:
+ *
+ * <pre>{@code
+ * static final Multimap<Character, String> FIRST_LETTER_MULTIMAP =
+ * Stream.of("banana", "apple", "carrot", "asparagus", "cherry")
+ * .collect(toImmutableSetMultimap(str -> str.charAt(0), str -> str.substring(1)));
+ *
+ * // is equivalent to
+ *
+ * static final Multimap<Character, String> FIRST_LETTER_MULTIMAP =
+ * new ImmutableSetMultimap.Builder<Character, String>()
+ * .put('b', "anana")
+ * .putAll('a', "pple", "sparagus")
+ * .putAll('c', "arrot", "herry")
+ * .build();
+ * }</pre>
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableSetMultimap<K, V>> toImmutableSetMultimap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ return CollectCollectors.toImmutableSetMultimap(keyFunction, valueFunction);
+ }
+
+ /**
+ * Returns a {@code Collector} accumulating entries into an {@code ImmutableSetMultimap}. Each
+ * input element is mapped to a key and a stream of values, each of which are put into the
+ * resulting {@code Multimap}, in the encounter order of the stream and the encounter order of the
+ * streams of values.
+ *
+ * <p>Example:
+ *
+ * <pre>{@code
+ * static final ImmutableSetMultimap<Character, Character> FIRST_LETTER_MULTIMAP =
+ * Stream.of("banana", "apple", "carrot", "asparagus", "cherry")
+ * .collect(
+ * flatteningToImmutableSetMultimap(
+ * str -> str.charAt(0),
+ * str -> str.substring(1).chars().mapToObj(c -> (char) c));
+ *
+ * // is equivalent to
+ *
+ * static final ImmutableSetMultimap<Character, Character> FIRST_LETTER_MULTIMAP =
+ * ImmutableSetMultimap.<Character, Character>builder()
+ * .putAll('b', Arrays.asList('a', 'n', 'a', 'n', 'a'))
+ * .putAll('a', Arrays.asList('p', 'p', 'l', 'e'))
+ * .putAll('c', Arrays.asList('a', 'r', 'r', 'o', 't'))
+ * .putAll('a', Arrays.asList('s', 'p', 'a', 'r', 'a', 'g', 'u', 's'))
+ * .putAll('c', Arrays.asList('h', 'e', 'r', 'r', 'y'))
+ * .build();
+ *
+ * // after deduplication, the resulting multimap is equivalent to
+ *
+ * static final ImmutableSetMultimap<Character, Character> FIRST_LETTER_MULTIMAP =
+ * ImmutableSetMultimap.<Character, Character>builder()
+ * .putAll('b', Arrays.asList('a', 'n'))
+ * .putAll('a', Arrays.asList('p', 'l', 'e', 's', 'a', 'r', 'g', 'u'))
+ * .putAll('c', Arrays.asList('a', 'r', 'o', 't', 'h', 'e', 'y'))
+ * .build();
+ * }
+ * }</pre>
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableSetMultimap<K, V>> flatteningToImmutableSetMultimap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends Stream<? extends V>> valuesFunction) {
+ return CollectCollectors.flatteningToImmutableSetMultimap(keyFunction, valuesFunction);
+ }
/**
* Returns the empty multimap.
@@ -467,6 +553,15 @@ public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V>
boolean isPartialView() {
return false;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
private static <V> ImmutableSet<V> valueSet(
@@ -530,7 +625,7 @@ public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V>
int tmpSize = 0;
for (int i = 0; i < keyCount; i++) {
- Object key = stream.readObject();
+ Object key = requireNonNull(stream.readObject());
int valueCount = stream.readInt();
if (valueCount <= 0) {
throw new InvalidObjectException("Invalid value count " + valueCount);
@@ -538,7 +633,7 @@ public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V>
ImmutableSet.Builder<Object> valuesBuilder = valuesBuilder(valueComparator);
for (int j = 0; j < valueCount; j++) {
- valuesBuilder.add(stream.readObject());
+ valuesBuilder.add(requireNonNull(stream.readObject()));
}
ImmutableSet<Object> valueSet = valuesBuilder.build();
if (valueSet.size() != valueCount) {
diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedMap.java b/android/guava/src/com/google/common/collect/ImmutableSortedMap.java
index 15c384eb7..985624968 100644
--- a/android/guava/src/com/google/common/collect/ImmutableSortedMap.java
+++ b/android/guava/src/com/google/common/collect/ImmutableSortedMap.java
@@ -23,6 +23,7 @@ import static com.google.common.collect.Maps.keyOrNull;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotCall;
@@ -35,6 +36,10 @@ import java.util.Map;
import java.util.NavigableMap;
import java.util.SortedMap;
import java.util.TreeMap;
+import java.util.function.BinaryOperator;
+import java.util.function.Function;
+import java.util.stream.Collector;
+import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -57,8 +62,48 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*/
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
-public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxverideShim<K, V>
+public final class ImmutableSortedMap<K, V> extends ImmutableMap<K, V>
implements NavigableMap<K, V> {
+ /**
+ * Returns a {@link Collector} that accumulates elements into an {@code ImmutableSortedMap} whose
+ * keys and values are the result of applying the provided mapping functions to the input
+ * elements. The generated map is sorted by the specified comparator.
+ *
+ * <p>If the mapped keys contain duplicates (according to the specified comparator), an {@code
+ * IllegalArgumentException} is thrown when the collection operation is performed. (This differs
+ * from the {@code Collector} returned by {@link Collectors#toMap(Function, Function)}, which
+ * throws an {@code IllegalStateException}.)
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableSortedMap<K, V>> toImmutableSortedMap(
+ Comparator<? super K> comparator,
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ return CollectCollectors.toImmutableSortedMap(comparator, keyFunction, valueFunction);
+ }
+
+ /**
+ * Returns a {@link Collector} that accumulates elements into an {@code ImmutableSortedMap} whose
+ * keys and values are the result of applying the provided mapping functions to the input
+ * elements.
+ *
+ * <p>If the mapped keys contain duplicates (according to the comparator), the values are merged
+ * using the specified merging function. Entries will appear in the encounter order of the first
+ * occurrence of the key.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableSortedMap<K, V>> toImmutableSortedMap(
+ Comparator<? super K> comparator,
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ return CollectCollectors.toImmutableSortedMap(
+ comparator, keyFunction, valueFunction, mergeFunction);
+ }
/*
* TODO(kevinb): Confirm that ImmutableSortedMap is faster to construct and
@@ -823,6 +868,15 @@ public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxveride
public int size() {
return ImmutableSortedMap.this.size();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
@@ -830,6 +884,15 @@ public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxveride
ImmutableMap<K, V> map() {
return ImmutableSortedMap.this;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
return isEmpty() ? ImmutableSet.<Entry<K, V>>of() : new EntrySet();
}
@@ -1146,4 +1209,292 @@ public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxveride
// This class is never actually serialized directly, but we have to make the
// warning go away (and suppressing would suppress for all nested classes too)
private static final long serialVersionUID = 0;
+
+ /**
+ * Not supported. Use {@link #toImmutableSortedMap}, which offers better type-safety, instead.
+ * This method exists only to hide {@link ImmutableMap#toImmutableMap} from consumers of {@code
+ * ImmutableSortedMap}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedMap#toImmutableSortedMap}.
+ */
+ @DoNotCall("Use toImmutableSortedMap")
+ @Deprecated
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. Use {@link #toImmutableSortedMap}, which offers better type-safety, instead.
+ * This method exists only to hide {@link ImmutableMap#toImmutableMap} from consumers of {@code
+ * ImmutableSortedMap}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedMap#toImmutableSortedMap}.
+ */
+ @DoNotCall("Use toImmutableSortedMap")
+ @Deprecated
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. Use {@link #naturalOrder}, which offers better type-safety, instead. This method
+ * exists only to hide {@link ImmutableMap#builder} from consumers of {@code ImmutableSortedMap}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedMap#naturalOrder}, which offers better type-safety.
+ */
+ @DoNotCall("Use naturalOrder")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap.Builder<K, V> builder() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported for ImmutableSortedMap.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Not supported for ImmutableSortedMap.
+ */
+ @DoNotCall("Use naturalOrder (which does not accept an expected size)")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap.Builder<K, V> builderWithExpectedSize(int expectedSize) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain a non-{@code Comparable}
+ * key.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this dummy
+ * version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass a key of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass a key of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls to will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(
+ K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(
+ K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(
+ K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(
+ K k1,
+ V v1,
+ K k2,
+ V v2,
+ K k3,
+ V v3,
+ K k4,
+ V v4,
+ K k5,
+ V v5,
+ K k6,
+ V v6,
+ K k7,
+ V v7,
+ K k8,
+ V v8) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(
+ K k1,
+ V v1,
+ K k2,
+ V v2,
+ K k3,
+ V v3,
+ K k4,
+ V v4,
+ K k5,
+ V v5,
+ K k6,
+ V v6,
+ K k7,
+ V v7,
+ K k8,
+ V v8,
+ K k9,
+ V v9) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(
+ K k1,
+ V v1,
+ K k2,
+ V v2,
+ K k3,
+ V v3,
+ K k4,
+ V v4,
+ K k5,
+ V v5,
+ K k6,
+ V v6,
+ K k7,
+ V v7,
+ K k8,
+ V v8,
+ K k9,
+ V v9,
+ K k10,
+ V v10) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
+ *
+ * @deprecated Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
+ */
+ @DoNotCall("ImmutableSortedMap.ofEntries not currently available; use ImmutableSortedMap.copyOf")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> ofEntries(
+ Entry<? extends K, ? extends V>... entries) {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java b/android/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java
deleted file mode 100644
index 9b40f556f..000000000
--- a/android/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright (C) 2009 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.collect;
-
-import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
-
-/**
- * "Overrides" the {@link ImmutableMap} static methods that lack {@link ImmutableSortedMap}
- * equivalents with deprecated, exception-throwing versions. See {@link
- * ImmutableSortedSetFauxverideShim} for details.
- *
- * @author Chris Povirk
- */
-@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-abstract class ImmutableSortedMapFauxverideShim<K, V> extends ImmutableMap<K, V> {
- /**
- * Not supported. Use {@link ImmutableSortedMap#naturalOrder}, which offers better type-safety,
- * instead. This method exists only to hide {@link ImmutableMap#builder} from consumers of {@code
- * ImmutableSortedMap}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Use {@link ImmutableSortedMap#naturalOrder}, which offers better type-safety.
- */
- @DoNotCall("Use naturalOrder")
- @Deprecated
- public static <K, V> ImmutableSortedMap.Builder<K, V> builder() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported for ImmutableSortedMap.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Not supported for ImmutableSortedMap.
- */
- @DoNotCall("Use naturalOrder (which does not accept an expected size)")
- @Deprecated
- public static <K, V> ImmutableSortedMap.Builder<K, V> builderWithExpectedSize(int expectedSize) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain a non-{@code Comparable}
- * key.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this dummy
- * version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass a key of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object)}.</b>
- */
- @DoNotCall("Pass a key of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls to will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9,
- K k10,
- V v10) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
- *
- * @deprecated Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
- */
- @DoNotCall("ImmutableSortedMap.ofEntries not currently available; use ImmutableSortedMap.copyOf")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> ofEntries(
- Entry<? extends K, ? extends V>... entries) {
- throw new UnsupportedOperationException();
- }
-
- // No copyOf() fauxveride; see ImmutableSortedSetFauxverideShim.
-}
diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedMultiset.java b/android/guava/src/com/google/common/collect/ImmutableSortedMultiset.java
index ba6cb4313..3660ca596 100644
--- a/android/guava/src/com/google/common/collect/ImmutableSortedMultiset.java
+++ b/android/guava/src/com/google/common/collect/ImmutableSortedMultiset.java
@@ -33,7 +33,11 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
+import java.util.function.Function;
+import java.util.function.ToIntFunction;
+import java.util.stream.Collector;
import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link SortedMultiset} whose contents will never change, with many other important properties
@@ -53,11 +57,72 @@ import javax.annotation.CheckForNull;
*/
@GwtIncompatible // hasn't been tested yet
@ElementTypesAreNonnullByDefault
-public abstract class ImmutableSortedMultiset<E> extends ImmutableSortedMultisetFauxverideShim<E>
+public abstract class ImmutableSortedMultiset<E> extends ImmutableMultiset<E>
implements SortedMultiset<E> {
// TODO(lowasser): GWT compatibility
/**
+ * Returns a {@code Collector} that accumulates the input elements into a new {@code
+ * ImmutableMultiset}. Elements are sorted by the specified comparator.
+ *
+ * <p><b>Warning:</b> {@code comparator} should be <i>consistent with {@code equals}</i> as
+ * explained in the {@link Comparator} documentation.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <E> Collector<E, ?, ImmutableSortedMultiset<E>> toImmutableSortedMultiset(
+ Comparator<? super E> comparator) {
+ return toImmutableSortedMultiset(comparator, Function.identity(), e -> 1);
+ }
+
+ /**
+ * Returns a {@code Collector} that accumulates elements into an {@code ImmutableSortedMultiset}
+ * whose elements are the result of applying {@code elementFunction} to the inputs, with counts
+ * equal to the result of applying {@code countFunction} to the inputs.
+ *
+ * <p>If the mapped elements contain duplicates (according to {@code comparator}), the first
+ * occurrence in encounter order appears in the resulting multiset, with count equal to the sum of
+ * the outputs of {@code countFunction.applyAsInt(t)} for each {@code t} mapped to that element.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, E>
+ Collector<T, ?, ImmutableSortedMultiset<E>> toImmutableSortedMultiset(
+ Comparator<? super E> comparator,
+ Function<? super T, ? extends E> elementFunction,
+ ToIntFunction<? super T> countFunction) {
+ checkNotNull(comparator);
+ checkNotNull(elementFunction);
+ checkNotNull(countFunction);
+ return Collector.of(
+ () -> TreeMultiset.create(comparator),
+ (multiset, t) -> mapAndAdd(t, multiset, elementFunction, countFunction),
+ (multiset1, multiset2) -> {
+ multiset1.addAll(multiset2);
+ return multiset1;
+ },
+ (Multiset<E> multiset) -> copyOfSortedEntries(comparator, multiset.entrySet()));
+ }
+
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // helper for toImmutableSortedMultiset
+ /*
+ * If we make these calls inline inside toImmutableSortedMultiset, we get an Animal Sniffer error,
+ * despite the @IgnoreJRERequirement annotation there. My assumption is that, because javac
+ * generates a synthetic method for the body of the lambda, the actual method calls that Animal
+ * Sniffer is flagging don't appear inside toImmutableSortedMultiset but rather inside that
+ * synthetic method. By moving those calls to a named method, we're able to apply
+ * @IgnoreJRERequirement somewhere that it will help.
+ */
+ private static <T extends @Nullable Object, E> void mapAndAdd(
+ T t,
+ Multiset<E> multiset,
+ Function<? super T, ? extends E> elementFunction,
+ ToIntFunction<? super T> countFunction) {
+ multiset.add(checkNotNull(elementFunction.apply(t)), countFunction.applyAsInt(t));
+ }
+
+ /**
* Returns the empty immutable sorted multiset.
*
* <p><b>Performance note:</b> the instance returned is a singleton.
@@ -681,4 +746,162 @@ public abstract class ImmutableSortedMultiset<E> extends ImmutableSortedMultiset
private void readObject(ObjectInputStream stream) throws InvalidObjectException {
throw new InvalidObjectException("Use SerializedForm");
}
+
+ /**
+ * Not supported. Use {@link #toImmutableSortedMultiset} instead. This method exists only to hide
+ * {@link ImmutableMultiset#toImmutableMultiset} from consumers of {@code
+ * ImmutableSortedMultiset}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset}.
+ */
+ @DoNotCall("Use toImmutableSortedMultiset.")
+ @Deprecated
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <E> Collector<E, ?, ImmutableMultiset<E>> toImmutableMultiset() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. Use {@link #toImmutableSortedMultiset} instead. This method exists only to hide
+ * {@link ImmutableMultiset#toImmutableMultiset} from consumers of {@code
+ * ImmutableSortedMultiset}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset}.
+ */
+ @DoNotCall("Use toImmutableSortedMultiset.")
+ @Deprecated
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, E> Collector<T, ?, ImmutableMultiset<E>> toImmutableMultiset(
+ Function<? super T, ? extends E> elementFunction, ToIntFunction<? super T> countFunction) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. Use {@link #naturalOrder}, which offers better type-safety, instead. This method
+ * exists only to hide {@link ImmutableMultiset#builder} from consumers of {@code
+ * ImmutableSortedMultiset}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better type-safety.
+ */
+ @DoNotCall("Use naturalOrder.")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset.Builder<E> builder() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
+ * Comparable} element.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#of(Comparable)}.</b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset<E> of(E element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
+ * Comparable} element.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#of(Comparable, Comparable)}.</b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset<E> of(E e1, E e2) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
+ * Comparable} element.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable)}.</b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
+ * Comparable} element.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable)}. </b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
+ * Comparable} element.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable)} .
+ * </b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4, E e5) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
+ * Comparable} element.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable,
+ * Comparable, Comparable...)} . </b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset<E> of(
+ E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain non-{@code
+ * Comparable} elements.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#copyOf(Comparable[])}.</b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ // The usage of "Z" here works around bugs in Javadoc (JDK-8318093) and JDiff.
+ public static <Z> ImmutableSortedMultiset<Z> copyOf(Z[] elements) {
+ throw new UnsupportedOperationException();
+ }
+
+ private static final long serialVersionUID = 0xdecaf;
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java b/android/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java
deleted file mode 100644
index c8a7ed782..000000000
--- a/android/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2011 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.collect;
-
-import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
-
-/**
- * "Overrides" the {@link ImmutableMultiset} static methods that lack {@link
- * ImmutableSortedMultiset} equivalents with deprecated, exception-throwing versions. This prevents
- * accidents like the following:
- *
- * <pre>{@code
- * List<Object> objects = ...;
- * // Sort them:
- * Set<Object> sorted = ImmutableSortedMultiset.copyOf(objects);
- * // BAD CODE! The returned multiset is actually an unsorted ImmutableMultiset!
- * }</pre>
- *
- * <p>While we could put the overrides in {@link ImmutableSortedMultiset} itself, it seems clearer
- * to separate these "do not call" methods from those intended for normal use.
- *
- * @author Louis Wasserman
- */
-@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-abstract class ImmutableSortedMultisetFauxverideShim<E> extends ImmutableMultiset<E> {
- /**
- * Not supported. Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better
- * type-safety, instead. This method exists only to hide {@link ImmutableMultiset#builder} from
- * consumers of {@code ImmutableSortedMultiset}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better type-safety.
- */
- @DoNotCall("Use naturalOrder.")
- @Deprecated
- public static <E> ImmutableSortedMultiset.Builder<E> builder() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
- * Comparable} element.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#of(Comparable)}.</b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> of(E element) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
- * Comparable} element.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#of(Comparable, Comparable)}.</b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> of(E e1, E e2) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
- * Comparable} element.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable)}.</b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
- * Comparable} element.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable)}. </b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
- * Comparable} element.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable)} .
- * </b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4, E e5) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
- * Comparable} element.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable,
- * Comparable, Comparable...)} . </b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> of(
- E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain non-{@code
- * Comparable} elements.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass parameters of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#copyOf(Comparable[])}.</b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> copyOf(E[] elements) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * We would like to include an unsupported "<E> copyOf(Iterable<E>)" here, providing only the
- * properly typed "<E extends Comparable<E>> copyOf(Iterable<E>)" in ImmutableSortedMultiset (and
- * likewise for the Iterator equivalent). However, due to a change in Sun's interpretation of the
- * JLS (as described at http://bugs.sun.com/view_bug.do?bug_id=6182950), the OpenJDK 7 compiler
- * available as of this writing rejects our attempts. To maintain compatibility with that version
- * and with any other compilers that interpret the JLS similarly, there is no definition of
- * copyOf() here, and the definition in ImmutableSortedMultiset matches that in
- * ImmutableMultiset.
- *
- * The result is that ImmutableSortedMultiset.copyOf() may be called on non-Comparable elements.
- * We have not discovered a better solution. In retrospect, the static factory methods should
- * have gone in a separate class so that ImmutableSortedMultiset wouldn't "inherit"
- * too-permissive factory methods from ImmutableMultiset.
- */
-}
diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedSet.java b/android/guava/src/com/google/common/collect/ImmutableSortedSet.java
index cf814d712..c6a57824f 100644
--- a/android/guava/src/com/google/common/collect/ImmutableSortedSet.java
+++ b/android/guava/src/com/google/common/collect/ImmutableSortedSet.java
@@ -36,6 +36,7 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.NavigableSet;
import java.util.SortedSet;
+import java.util.stream.Collector;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -60,8 +61,22 @@ import org.checkerframework.checker.nullness.qual.Nullable;
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
-public abstract class ImmutableSortedSet<E> extends ImmutableSortedSetFauxverideShim<E>
+public abstract class ImmutableSortedSet<E> extends ImmutableSet<E>
implements NavigableSet<E>, SortedIterable<E> {
+ /**
+ * Returns a {@code Collector} that accumulates the input elements into a new {@code
+ * ImmutableSortedSet}, ordered by the specified comparator.
+ *
+ * <p>If the elements contain duplicates (according to the comparator), only the first duplicate
+ * in encounter order will appear in the result.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <E> Collector<E, ?, ImmutableSortedSet<E>> toImmutableSortedSet(
+ Comparator<? super E> comparator) {
+ return CollectCollectors.toImmutableSortedSet(comparator);
+ }
+
static <E> RegularImmutableSortedSet<E> emptySet(Comparator<? super E> comparator) {
if (Ordering.natural().equals(comparator)) {
return (RegularImmutableSortedSet<E>) RegularImmutableSortedSet.NATURAL_EMPTY_SET;
@@ -763,4 +778,154 @@ public abstract class ImmutableSortedSet<E> extends ImmutableSortedSetFauxveride
Object writeReplace() {
return new SerializedForm<E>(comparator, toArray());
}
+
+ /**
+ * Not supported. Use {@link #toImmutableSortedSet} instead. This method exists only to hide
+ * {@link ImmutableSet#toImmutableSet} from consumers of {@code ImmutableSortedSet}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedSet#toImmutableSortedSet}.
+ */
+ @DoNotCall("Use toImmutableSortedSet")
+ @Deprecated
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. Use {@link #naturalOrder}, which offers better type-safety, instead. This method
+ * exists only to hide {@link ImmutableSet#builder} from consumers of {@code ImmutableSortedSet}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedSet#naturalOrder}, which offers better type-safety.
+ */
+ @DoNotCall("Use naturalOrder")
+ @Deprecated
+ public static <E> ImmutableSortedSet.Builder<E> builder() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. This method exists only to hide {@link ImmutableSet#builderWithExpectedSize}
+ * from consumers of {@code ImmutableSortedSet}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Not supported by ImmutableSortedSet.
+ */
+ @DoNotCall("Use naturalOrder (which does not accept an expected size)")
+ @Deprecated
+ public static <E> ImmutableSortedSet.Builder<E> builderWithExpectedSize(int expectedSize) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
+ * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#of(Comparable)}.</b>
+ */
+ @DoNotCall("Pass a parameter of type Comparable")
+ @Deprecated
+ public static <E> ImmutableSortedSet<E> of(E element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
+ * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#of(Comparable, Comparable)}.</b>
+ */
+ @DoNotCall("Pass parameters of type Comparable")
+ @Deprecated
+ public static <E> ImmutableSortedSet<E> of(E e1, E e2) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
+ * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#of(Comparable, Comparable, Comparable)}.</b>
+ */
+ @DoNotCall("Pass parameters of type Comparable")
+ @Deprecated
+ public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
+ * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable)}. </b>
+ */
+ @DoNotCall("Pass parameters of type Comparable")
+ @Deprecated
+ public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
+ * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#of( Comparable, Comparable, Comparable, Comparable, Comparable)}. </b>
+ */
+ @DoNotCall("Pass parameters of type Comparable")
+ @Deprecated
+ public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
+ * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable, Comparable,
+ * Comparable, Comparable...)}. </b>
+ */
+ @DoNotCall("Pass parameters of type Comparable")
+ @Deprecated
+ public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain non-{@code Comparable}
+ * elements.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#copyOf(Comparable[])}.</b>
+ */
+ @DoNotCall("Pass parameters of type Comparable")
+ @Deprecated
+ // The usage of "Z" here works around bugs in Javadoc (JDK-8318093) and JDiff.
+ public static <Z> ImmutableSortedSet<Z> copyOf(Z[] elements) {
+ throw new UnsupportedOperationException();
+ }
+
+ private static final long serialVersionUID = 0xdecaf;
}
diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java b/android/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java
deleted file mode 100644
index ca19d79db..000000000
--- a/android/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (C) 2009 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.collect;
-
-import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
-
-/**
- * "Overrides" the {@link ImmutableSet} static methods that lack {@link ImmutableSortedSet}
- * equivalents with deprecated, exception-throwing versions. This prevents accidents like the
- * following:
- *
- * <pre>{@code
- * List<Object> objects = ...;
- * // Sort them:
- * Set<Object> sorted = ImmutableSortedSet.copyOf(objects);
- * // BAD CODE! The returned set is actually an unsorted ImmutableSet!
- * }</pre>
- *
- * <p>While we could put the overrides in {@link ImmutableSortedSet} itself, it seems clearer to
- * separate these "do not call" methods from those intended for normal use.
- *
- * @author Chris Povirk
- */
-@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-abstract class ImmutableSortedSetFauxverideShim<E> extends ImmutableSet<E> {
- /**
- * Not supported. Use {@link ImmutableSortedSet#naturalOrder}, which offers better type-safety,
- * instead. This method exists only to hide {@link ImmutableSet#builder} from consumers of {@code
- * ImmutableSortedSet}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Use {@link ImmutableSortedSet#naturalOrder}, which offers better type-safety.
- */
- @DoNotCall("Use naturalOrder")
- @Deprecated
- public static <E> ImmutableSortedSet.Builder<E> builder() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. This method exists only to hide {@link ImmutableSet#builderWithExpectedSize}
- * from consumers of {@code ImmutableSortedSet}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Not supported by ImmutableSortedSet.
- */
- @DoNotCall("Use naturalOrder (which does not accept an expected size)")
- @Deprecated
- public static <E> ImmutableSortedSet.Builder<E> builderWithExpectedSize(int expectedSize) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
- * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
- * ImmutableSortedSet#of(Comparable)}.</b>
- */
- @DoNotCall("Pass a parameter of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> of(E element) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
- * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedSet#of(Comparable, Comparable)}.</b>
- */
- @DoNotCall("Pass parameters of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> of(E e1, E e2) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
- * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedSet#of(Comparable, Comparable, Comparable)}.</b>
- */
- @DoNotCall("Pass parameters of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
- * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable)}. </b>
- */
- @DoNotCall("Pass parameters of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
- * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedSet#of( Comparable, Comparable, Comparable, Comparable, Comparable)}. </b>
- */
- @DoNotCall("Pass parameters of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
- * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable, Comparable,
- * Comparable, Comparable...)}. </b>
- */
- @DoNotCall("Pass parameters of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain non-{@code Comparable}
- * elements.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass parameters of type {@code Comparable} to use {@link
- * ImmutableSortedSet#copyOf(Comparable[])}.</b>
- */
- @DoNotCall("Pass parameters of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> copyOf(E[] elements) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * We would like to include an unsupported "<E> copyOf(Iterable<E>)" here,
- * providing only the properly typed
- * "<E extends Comparable<E>> copyOf(Iterable<E>)" in ImmutableSortedSet (and
- * likewise for the Iterator equivalent). However, due to a change in Sun's
- * interpretation of the JLS (as described at
- * http://bugs.sun.com/view_bug.do?bug_id=6182950), the OpenJDK 7 compiler
- * available as of this writing rejects our attempts. To maintain
- * compatibility with that version and with any other compilers that interpret
- * the JLS similarly, there is no definition of copyOf() here, and the
- * definition in ImmutableSortedSet matches that in ImmutableSet.
- *
- * The result is that ImmutableSortedSet.copyOf() may be called on
- * non-Comparable elements. We have not discovered a better solution. In
- * retrospect, the static factory methods should have gone in a separate class
- * so that ImmutableSortedSet wouldn't "inherit" too-permissive factory
- * methods from ImmutableSet.
- */
-}
diff --git a/android/guava/src/com/google/common/collect/ImmutableTable.java b/android/guava/src/com/google/common/collect/ImmutableTable.java
index 9c45e361f..91c9f71a6 100644
--- a/android/guava/src/com/google/common/collect/ImmutableTable.java
+++ b/android/guava/src/com/google/common/collect/ImmutableTable.java
@@ -32,7 +32,11 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.function.BinaryOperator;
+import java.util.function.Function;
+import java.util.stream.Collector;
import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* A {@link Table} whose contents will never change, with many other important properties detailed
@@ -50,6 +54,45 @@ public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V>
implements Serializable {
/**
+ * Returns a {@code Collector} that accumulates elements into an {@code ImmutableTable}. Each
+ * input element is mapped to one cell in the returned table, with the rows, columns, and values
+ * generated by applying the specified functions.
+ *
+ * <p>The returned {@code Collector} will throw a {@code NullPointerException} at collection time
+ * if the row, column, or value functions return null on any input.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, R, C, V>
+ Collector<T, ?, ImmutableTable<R, C, V>> toImmutableTable(
+ Function<? super T, ? extends R> rowFunction,
+ Function<? super T, ? extends C> columnFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ return TableCollectors.toImmutableTable(rowFunction, columnFunction, valueFunction);
+ }
+
+ /**
+ * Returns a {@code Collector} that accumulates elements into an {@code ImmutableTable}. Each
+ * input element is mapped to one cell in the returned table, with the rows, columns, and values
+ * generated by applying the specified functions. If multiple inputs are mapped to the same row
+ * and column pair, they will be combined with the specified merging function in encounter order.
+ *
+ * <p>The returned {@code Collector} will throw a {@code NullPointerException} at collection time
+ * if the row, column, value, or merging functions return null on any input.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, R, C, V>
+ Collector<T, ?, ImmutableTable<R, C, V>> toImmutableTable(
+ Function<? super T, ? extends R> rowFunction,
+ Function<? super T, ? extends C> columnFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ return TableCollectors.toImmutableTable(
+ rowFunction, columnFunction, valueFunction, mergeFunction);
+ }
+
+ /**
* Returns an empty immutable table.
*
* <p><b>Performance note:</b> the instance returned is a singleton.
@@ -396,9 +439,6 @@ public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V>
throw new UnsupportedOperationException();
}
- /** Creates the common serialized form for this table. */
- abstract SerializedForm createSerializedForm();
-
/**
* Serialized type for all ImmutableTable instances. It captures the logical contents and
* preserves iteration order of all views.
@@ -454,9 +494,9 @@ public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V>
private static final long serialVersionUID = 0;
}
- final Object writeReplace() {
- return createSerializedForm();
- }
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ abstract Object writeReplace();
@GwtIncompatible // serialization
@J2ktIncompatible
diff --git a/android/guava/src/com/google/common/collect/IndexedImmutableSet.java b/android/guava/src/com/google/common/collect/IndexedImmutableSet.java
index 25aae94e8..805f15bec 100644
--- a/android/guava/src/com/google/common/collect/IndexedImmutableSet.java
+++ b/android/guava/src/com/google/common/collect/IndexedImmutableSet.java
@@ -18,6 +18,7 @@ package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import org.checkerframework.checker.nullness.qual.Nullable;
@GwtCompatible(emulated = true)
@@ -53,6 +54,24 @@ abstract class IndexedImmutableSet<E> extends ImmutableSet<E> {
public int size() {
return IndexedImmutableSet.this.size();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/android/guava/src/com/google/common/collect/Iterators.java b/android/guava/src/com/google/common/collect/Iterators.java
index 0699202fe..009a41cef 100644
--- a/android/guava/src/com/google/common/collect/Iterators.java
+++ b/android/guava/src/com/google/common/collect/Iterators.java
@@ -42,7 +42,6 @@ import java.util.Deque;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
@@ -1056,47 +1055,40 @@ public final class Iterators {
*/
@SafeVarargs
public static <T extends @Nullable Object> UnmodifiableIterator<T> forArray(T... array) {
- return forArray(array, 0, array.length, 0);
+ return forArrayWithPosition(array, 0);
}
/**
- * Returns a list iterator containing the elements in the specified range of {@code array} in
- * order, starting at the specified index.
+ * Returns a list iterator containing the elements in the specified {@code array} in order,
+ * starting at the specified {@code position}.
*
* <p>The {@code Iterable} equivalent of this method is {@code
- * Arrays.asList(array).subList(offset, offset + length).listIterator(index)}.
+ * Arrays.asList(array).listIterator(position)}.
*/
- static <T extends @Nullable Object> UnmodifiableListIterator<T> forArray(
- T[] array, int offset, int length, int index) {
- checkArgument(length >= 0);
- int end = offset + length;
-
- // Technically we should give a slightly more descriptive error on overflow
- Preconditions.checkPositionIndexes(offset, end, array.length);
- Preconditions.checkPositionIndex(index, length);
- if (length == 0) {
+ static <T extends @Nullable Object> UnmodifiableListIterator<T> forArrayWithPosition(
+ T[] array, int position) {
+ if (array.length == 0) {
+ Preconditions.checkPositionIndex(position, array.length); // otherwise checked in ArrayItr
return emptyListIterator();
}
- return new ArrayItr<>(array, offset, length, index);
+ return new ArrayItr<>(array, position);
}
private static final class ArrayItr<T extends @Nullable Object>
extends AbstractIndexedListIterator<T> {
- static final UnmodifiableListIterator<Object> EMPTY = new ArrayItr<>(new Object[0], 0, 0, 0);
+ static final UnmodifiableListIterator<Object> EMPTY = new ArrayItr<>(new Object[0], 0);
private final T[] array;
- private final int offset;
- ArrayItr(T[] array, int offset, int length, int index) {
- super(length, index);
+ ArrayItr(T[] array, int position) {
+ super(array.length, position);
this.array = array;
- this.offset = offset;
}
@Override
@ParametricNullness
protected T get(int index) {
- return array[offset + index];
+ return array[index];
}
}
@@ -1107,24 +1099,36 @@ public final class Iterators {
*/
public static <T extends @Nullable Object> UnmodifiableIterator<T> singletonIterator(
@ParametricNullness T value) {
- return new UnmodifiableIterator<T>() {
- boolean done;
+ return new SingletonIterator<>(value);
+ }
- @Override
- public boolean hasNext() {
- return !done;
- }
+ private static final class SingletonIterator<T extends @Nullable Object>
+ extends UnmodifiableIterator<T> {
+ private static final Object SENTINEL = new Object();
- @Override
- @ParametricNullness
- public T next() {
- if (done) {
- throw new NoSuchElementException();
- }
- done = true;
- return value;
+ private Object valueOrSentinel;
+
+ SingletonIterator(T value) {
+ this.valueOrSentinel = value;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return valueOrSentinel != SENTINEL;
+ }
+
+ @Override
+ @ParametricNullness
+ public T next() {
+ if (valueOrSentinel == SENTINEL) {
+ throw new NoSuchElementException();
}
- };
+ // The field held either a T or SENTINEL, and it turned out not to be SENTINEL.
+ @SuppressWarnings("unchecked")
+ T t = (T) valueOrSentinel;
+ valueOrSentinel = SENTINEL;
+ return t;
+ }
}
/**
@@ -1444,9 +1448,4 @@ public final class Iterators {
toRemove = null;
}
}
-
- /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
- static <T extends @Nullable Object> ListIterator<T> cast(Iterator<T> iterator) {
- return (ListIterator<T>) iterator;
- }
}
diff --git a/android/guava/src/com/google/common/collect/LinkedHashMultimap.java b/android/guava/src/com/google/common/collect/LinkedHashMultimap.java
index 0d9dc0694..7247fc55f 100644
--- a/android/guava/src/com/google/common/collect/LinkedHashMultimap.java
+++ b/android/guava/src/com/google/common/collect/LinkedHashMultimap.java
@@ -189,11 +189,11 @@ public final class LinkedHashMultimap<K extends @Nullable Object, V extends @Nul
* frameworks like Android that define post-construct hooks like Activity.onCreate, etc.
*/
- @CheckForNull ValueSetLink<K, V> predecessorInValueSet;
- @CheckForNull ValueSetLink<K, V> successorInValueSet;
+ @CheckForNull private ValueSetLink<K, V> predecessorInValueSet;
+ @CheckForNull private ValueSetLink<K, V> successorInValueSet;
- @CheckForNull ValueEntry<K, V> predecessorInMultimap;
- @CheckForNull ValueEntry<K, V> successorInMultimap;
+ @CheckForNull private ValueEntry<K, V> predecessorInMultimap;
+ @CheckForNull private ValueEntry<K, V> successorInMultimap;
ValueEntry(
@ParametricNullness K key,
diff --git a/android/guava/src/com/google/common/collect/LinkedListMultimap.java b/android/guava/src/com/google/common/collect/LinkedListMultimap.java
index 74ac4c1f3..f5b566f95 100644
--- a/android/guava/src/com/google/common/collect/LinkedListMultimap.java
+++ b/android/guava/src/com/google/common/collect/LinkedListMultimap.java
@@ -105,7 +105,7 @@ public class LinkedListMultimap<K extends @Nullable Object, V extends @Nullable
* ValueForKeyIterator} in constant time.
*/
- private static final class Node<K extends @Nullable Object, V extends @Nullable Object>
+ static final class Node<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMapEntry<K, V> {
@ParametricNullness final K key;
@ParametricNullness V value;
diff --git a/android/guava/src/com/google/common/collect/Lists.java b/android/guava/src/com/google/common/collect/Lists.java
index 047575b57..e59f60aae 100644
--- a/android/guava/src/com/google/common/collect/Lists.java
+++ b/android/guava/src/com/google/common/collect/Lists.java
@@ -766,6 +766,15 @@ public final class Lists {
public int size() {
return string.length();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
private static final class CharSequenceAsList extends AbstractList<Character> {
diff --git a/android/guava/src/com/google/common/collect/Maps.java b/android/guava/src/com/google/common/collect/Maps.java
index 9a3852047..0664f5dab 100644
--- a/android/guava/src/com/google/common/collect/Maps.java
+++ b/android/guava/src/com/google/common/collect/Maps.java
@@ -65,6 +65,8 @@ import java.util.SortedSet;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.function.BinaryOperator;
+import java.util.stream.Collector;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -178,6 +180,48 @@ public final class Maps {
}
/**
+ * Returns a {@link Collector} that accumulates elements into an {@code ImmutableMap} whose keys
+ * and values are the result of applying the provided mapping functions to the input elements. The
+ * resulting implementation is specialized for enum key types. The returned map and its views will
+ * iterate over keys in their enum definition order, not encounter order.
+ *
+ * <p>If the mapped keys contain duplicates, an {@code IllegalArgumentException} is thrown when
+ * the collection operation is performed. (This differs from the {@code Collector} returned by
+ * {@link java.util.stream.Collectors#toMap(java.util.function.Function,
+ * java.util.function.Function) Collectors.toMap(Function, Function)}, which throws an {@code
+ * IllegalStateException}.)
+ */
+ @J2ktIncompatible
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K extends Enum<K>, V>
+ Collector<T, ?, ImmutableMap<K, V>> toImmutableEnumMap(
+ java.util.function.Function<? super T, ? extends K> keyFunction,
+ java.util.function.Function<? super T, ? extends V> valueFunction) {
+ return CollectCollectors.toImmutableEnumMap(keyFunction, valueFunction);
+ }
+
+ /**
+ * Returns a {@link Collector} that accumulates elements into an {@code ImmutableMap} whose keys
+ * and values are the result of applying the provided mapping functions to the input elements. The
+ * resulting implementation is specialized for enum key types. The returned map and its views will
+ * iterate over keys in their enum definition order, not encounter order.
+ *
+ * <p>If the mapped keys contain duplicates, the values are merged using the specified merging
+ * function.
+ */
+ @J2ktIncompatible
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, K extends Enum<K>, V>
+ Collector<T, ?, ImmutableMap<K, V>> toImmutableEnumMap(
+ java.util.function.Function<? super T, ? extends K> keyFunction,
+ java.util.function.Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ return CollectCollectors.toImmutableEnumMap(keyFunction, valueFunction, mergeFunction);
+ }
+
+ /**
* Creates a <i>mutable</i>, empty {@code HashMap} instance.
*
* <p><b>Note:</b> if mutability is not required, use {@link ImmutableMap#of()} instead.
diff --git a/android/guava/src/com/google/common/collect/MinMaxPriorityQueue.java b/android/guava/src/com/google/common/collect/MinMaxPriorityQueue.java
index 877d6bc0b..0dfa2b2fc 100644
--- a/android/guava/src/com/google/common/collect/MinMaxPriorityQueue.java
+++ b/android/guava/src/com/google/common/collect/MinMaxPriorityQueue.java
@@ -521,7 +521,7 @@ public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
* sake they are stored interleaved on alternate heap levels in the same array (MMPQ.queue).
*/
@WeakOuter
- private class Heap {
+ class Heap {
final Ordering<E> ordering;
@SuppressWarnings("nullness:initialization.field.uninitialized")
diff --git a/android/guava/src/com/google/common/collect/MoreCollectors.java b/android/guava/src/com/google/common/collect/MoreCollectors.java
new file mode 100644
index 000000000..02b254d2d
--- /dev/null
+++ b/android/guava/src/com/google/common/collect/MoreCollectors.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2016 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.collect;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Collections.emptyList;
+
+import com.google.common.annotations.GwtCompatible;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Optional;
+import java.util.stream.Collector;
+import javax.annotation.CheckForNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/**
+ * Collectors not present in {@code java.util.stream.Collectors} that are not otherwise associated
+ * with a {@code com.google.common} type.
+ *
+ * @author Louis Wasserman
+ */
+@GwtCompatible
+@ElementTypesAreNonnullByDefault
+@SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+@IgnoreJRERequirement // Users will use this only if they're already using streams.
+final class MoreCollectors {
+
+ /*
+ * TODO(lowasser): figure out if we can convert this to a concurrent AtomicReference-based
+ * collector without breaking j2cl?
+ */
+ private static final Collector<Object, ?, Optional<Object>> TO_OPTIONAL =
+ Collector.of(
+ ToOptionalState::new,
+ ToOptionalState::add,
+ ToOptionalState::combine,
+ ToOptionalState::getOptional,
+ Collector.Characteristics.UNORDERED);
+
+ /**
+ * A collector that converts a stream of zero or one elements to an {@code Optional}.
+ *
+ * @throws IllegalArgumentException if the stream consists of two or more elements.
+ * @throws NullPointerException if any element in the stream is {@code null}.
+ * @return {@code Optional.of(onlyElement)} if the stream has exactly one element (must not be
+ * {@code null}) and returns {@code Optional.empty()} if it has none.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> Collector<T, ?, Optional<T>> toOptional() {
+ return (Collector) TO_OPTIONAL;
+ }
+
+ private static final Object NULL_PLACEHOLDER = new Object();
+
+ private static final Collector<@Nullable Object, ?, @Nullable Object> ONLY_ELEMENT =
+ Collector.<@Nullable Object, ToOptionalState, @Nullable Object>of(
+ ToOptionalState::new,
+ (state, o) -> state.add((o == null) ? NULL_PLACEHOLDER : o),
+ ToOptionalState::combine,
+ state -> {
+ Object result = state.getElement();
+ return (result == NULL_PLACEHOLDER) ? null : result;
+ },
+ Collector.Characteristics.UNORDERED);
+
+ /**
+ * A collector that takes a stream containing exactly one element and returns that element. The
+ * returned collector throws an {@code IllegalArgumentException} if the stream consists of two or
+ * more elements, and a {@code NoSuchElementException} if the stream is empty.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T extends @Nullable Object> Collector<T, ?, T> onlyElement() {
+ return (Collector) ONLY_ELEMENT;
+ }
+
+ /**
+ * This atrocity is here to let us report several of the elements in the stream if there were more
+ * than one, not just two.
+ */
+ private static final class ToOptionalState {
+ static final int MAX_EXTRAS = 4;
+
+ @CheckForNull Object element;
+ List<Object> extras;
+
+ ToOptionalState() {
+ element = null;
+ extras = emptyList();
+ }
+
+ IllegalArgumentException multiples(boolean overflow) {
+ StringBuilder sb =
+ new StringBuilder().append("expected one element but was: <").append(element);
+ for (Object o : extras) {
+ sb.append(", ").append(o);
+ }
+ if (overflow) {
+ sb.append(", ...");
+ }
+ sb.append('>');
+ throw new IllegalArgumentException(sb.toString());
+ }
+
+ void add(Object o) {
+ checkNotNull(o);
+ if (element == null) {
+ this.element = o;
+ } else if (extras.isEmpty()) {
+ // Replace immutable empty list with mutable list.
+ extras = new ArrayList<>(MAX_EXTRAS);
+ extras.add(o);
+ } else if (extras.size() < MAX_EXTRAS) {
+ extras.add(o);
+ } else {
+ throw multiples(true);
+ }
+ }
+
+ ToOptionalState combine(ToOptionalState other) {
+ if (element == null) {
+ return other;
+ } else if (other.element == null) {
+ return this;
+ } else {
+ if (extras.isEmpty()) {
+ // Replace immutable empty list with mutable list.
+ extras = new ArrayList<>();
+ }
+ extras.add(other.element);
+ extras.addAll(other.extras);
+ if (extras.size() > MAX_EXTRAS) {
+ extras.subList(MAX_EXTRAS, extras.size()).clear();
+ throw multiples(true);
+ }
+ return this;
+ }
+ }
+
+ @IgnoreJRERequirement // see enclosing class (whose annotation Animal Sniffer ignores here...)
+ Optional<Object> getOptional() {
+ if (extras.isEmpty()) {
+ return Optional.ofNullable(element);
+ } else {
+ throw multiples(false);
+ }
+ }
+
+ Object getElement() {
+ if (element == null) {
+ throw new NoSuchElementException();
+ } else if (extras.isEmpty()) {
+ return element;
+ } else {
+ throw multiples(false);
+ }
+ }
+ }
+
+ private MoreCollectors() {}
+}
diff --git a/android/guava/src/com/google/common/collect/Multimaps.java b/android/guava/src/com/google/common/collect/Multimaps.java
index ea4148801..34d56b077 100644
--- a/android/guava/src/com/google/common/collect/Multimaps.java
+++ b/android/guava/src/com/google/common/collect/Multimaps.java
@@ -51,6 +51,8 @@ import java.util.NavigableSet;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.SortedSet;
+import java.util.stream.Collector;
+import java.util.stream.Stream;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -73,6 +75,100 @@ public final class Multimaps {
private Multimaps() {}
/**
+ * Returns a {@code Collector} accumulating entries into a {@code Multimap} generated from the
+ * specified supplier. The keys and values of the entries are the result of applying the provided
+ * mapping functions to the input elements, accumulated in the encounter order of the stream.
+ *
+ * <p>Example:
+ *
+ * <pre>{@code
+ * static final ListMultimap<Character, String> FIRST_LETTER_MULTIMAP =
+ * Stream.of("banana", "apple", "carrot", "asparagus", "cherry")
+ * .collect(
+ * toMultimap(
+ * str -> str.charAt(0),
+ * str -> str.substring(1),
+ * MultimapBuilder.treeKeys().arrayListValues()::build));
+ *
+ * // is equivalent to
+ *
+ * static final ListMultimap<Character, String> FIRST_LETTER_MULTIMAP;
+ *
+ * static {
+ * FIRST_LETTER_MULTIMAP = MultimapBuilder.treeKeys().arrayListValues().build();
+ * FIRST_LETTER_MULTIMAP.put('b', "anana");
+ * FIRST_LETTER_MULTIMAP.put('a', "pple");
+ * FIRST_LETTER_MULTIMAP.put('a', "sparagus");
+ * FIRST_LETTER_MULTIMAP.put('c', "arrot");
+ * FIRST_LETTER_MULTIMAP.put('c', "herry");
+ * }
+ * }</pre>
+ *
+ * <p>To collect to an {@link ImmutableMultimap}, use either {@link
+ * ImmutableSetMultimap#toImmutableSetMultimap} or {@link
+ * ImmutableListMultimap#toImmutableListMultimap}.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <
+ T extends @Nullable Object,
+ K extends @Nullable Object,
+ V extends @Nullable Object,
+ M extends Multimap<K, V>>
+ Collector<T, ?, M> toMultimap(
+ java.util.function.Function<? super T, ? extends K> keyFunction,
+ java.util.function.Function<? super T, ? extends V> valueFunction,
+ java.util.function.Supplier<M> multimapSupplier) {
+ return CollectCollectors.<T, K, V, M>toMultimap(keyFunction, valueFunction, multimapSupplier);
+ }
+
+ /**
+ * Returns a {@code Collector} accumulating entries into a {@code Multimap} generated from the
+ * specified supplier. Each input element is mapped to a key and a stream of values, each of which
+ * are put into the resulting {@code Multimap}, in the encounter order of the stream and the
+ * encounter order of the streams of values.
+ *
+ * <p>Example:
+ *
+ * <pre>{@code
+ * static final ListMultimap<Character, Character> FIRST_LETTER_MULTIMAP =
+ * Stream.of("banana", "apple", "carrot", "asparagus", "cherry")
+ * .collect(
+ * flatteningToMultimap(
+ * str -> str.charAt(0),
+ * str -> str.substring(1).chars().mapToObj(c -> (char) c),
+ * MultimapBuilder.linkedHashKeys().arrayListValues()::build));
+ *
+ * // is equivalent to
+ *
+ * static final ListMultimap<Character, Character> FIRST_LETTER_MULTIMAP;
+ *
+ * static {
+ * FIRST_LETTER_MULTIMAP = MultimapBuilder.linkedHashKeys().arrayListValues().build();
+ * FIRST_LETTER_MULTIMAP.putAll('b', Arrays.asList('a', 'n', 'a', 'n', 'a'));
+ * FIRST_LETTER_MULTIMAP.putAll('a', Arrays.asList('p', 'p', 'l', 'e'));
+ * FIRST_LETTER_MULTIMAP.putAll('c', Arrays.asList('a', 'r', 'r', 'o', 't'));
+ * FIRST_LETTER_MULTIMAP.putAll('a', Arrays.asList('s', 'p', 'a', 'r', 'a', 'g', 'u', 's'));
+ * FIRST_LETTER_MULTIMAP.putAll('c', Arrays.asList('h', 'e', 'r', 'r', 'y'));
+ * }
+ * }</pre>
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <
+ T extends @Nullable Object,
+ K extends @Nullable Object,
+ V extends @Nullable Object,
+ M extends Multimap<K, V>>
+ Collector<T, ?, M> flatteningToMultimap(
+ java.util.function.Function<? super T, ? extends K> keyFunction,
+ java.util.function.Function<? super T, ? extends Stream<? extends V>> valueFunction,
+ java.util.function.Supplier<M> multimapSupplier) {
+ return CollectCollectors.<T, K, V, M>flatteningToMultimap(
+ keyFunction, valueFunction, multimapSupplier);
+ }
+
+ /**
* Creates a new {@code Multimap} backed by {@code map}, whose internal value collections are
* generated by {@code factory}.
*
@@ -187,8 +283,8 @@ public final class Multimaps {
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- factory = (Supplier<? extends Collection<V>>) stream.readObject();
- Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject();
+ factory = (Supplier<? extends Collection<V>>) requireNonNull(stream.readObject());
+ Map<K, Collection<V>> map = (Map<K, Collection<V>>) requireNonNull(stream.readObject());
setMap(map);
}
@@ -273,8 +369,8 @@ public final class Multimaps {
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- factory = (Supplier<? extends List<V>>) stream.readObject();
- Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject();
+ factory = (Supplier<? extends List<V>>) requireNonNull(stream.readObject());
+ Map<K, Collection<V>> map = (Map<K, Collection<V>>) requireNonNull(stream.readObject());
setMap(map);
}
@@ -381,8 +477,8 @@ public final class Multimaps {
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- factory = (Supplier<? extends Set<V>>) stream.readObject();
- Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject();
+ factory = (Supplier<? extends Set<V>>) requireNonNull(stream.readObject());
+ Map<K, Collection<V>> map = (Map<K, Collection<V>>) requireNonNull(stream.readObject());
setMap(map);
}
@@ -475,9 +571,9 @@ public final class Multimaps {
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- factory = (Supplier<? extends SortedSet<V>>) stream.readObject();
+ factory = (Supplier<? extends SortedSet<V>>) requireNonNull(stream.readObject());
valueComparator = factory.get().comparator();
- Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject();
+ Map<K, Collection<V>> map = (Map<K, Collection<V>>) requireNonNull(stream.readObject());
setMap(map);
}
diff --git a/android/guava/src/com/google/common/collect/Multisets.java b/android/guava/src/com/google/common/collect/Multisets.java
index 8bcc639ab..9cebe58f4 100644
--- a/android/guava/src/com/google/common/collect/Multisets.java
+++ b/android/guava/src/com/google/common/collect/Multisets.java
@@ -39,6 +39,10 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.function.ToIntFunction;
+import java.util.stream.Collector;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -60,6 +64,31 @@ public final class Multisets {
private Multisets() {}
/**
+ * Returns a {@code Collector} that accumulates elements into a multiset created via the specified
+ * {@code Supplier}, whose elements are the result of applying {@code elementFunction} to the
+ * inputs, with counts equal to the result of applying {@code countFunction} to the inputs.
+ * Elements are added in encounter order.
+ *
+ * <p>If the mapped elements contain duplicates (according to {@link Object#equals}), the element
+ * will be added more than once, with the count summed over all appearances of the element.
+ *
+ * <p>Note that {@code stream.collect(toMultiset(function, e -> 1, supplier))} is equivalent to
+ * {@code stream.map(function).collect(Collectors.toCollection(supplier))}.
+ *
+ * <p>To collect to an {@link ImmutableMultiset}, use {@link
+ * ImmutableMultiset#toImmutableMultiset}.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <T extends @Nullable Object, E extends @Nullable Object, M extends Multiset<E>>
+ Collector<T, ?, M> toMultiset(
+ Function<? super T, E> elementFunction,
+ ToIntFunction<? super T> countFunction,
+ Supplier<M> multisetSupplier) {
+ return CollectCollectors.toMultiset(elementFunction, countFunction, multisetSupplier);
+ }
+
+ /**
* Returns an unmodifiable view of the specified multiset. Query operations on the returned
* multiset "read through" to the specified multiset, and attempts to modify the returned multiset
* result in an {@link UnsupportedOperationException}.
@@ -1145,7 +1174,7 @@ public final class Multisets {
}
private static final class DecreasingCount implements Comparator<Entry<?>> {
- static final DecreasingCount INSTANCE = new DecreasingCount();
+ static final Comparator<Entry<?>> INSTANCE = new DecreasingCount();
@Override
public int compare(Entry<?> entry1, Entry<?> entry2) {
diff --git a/android/guava/src/com/google/common/collect/RegularContiguousSet.java b/android/guava/src/com/google/common/collect/RegularContiguousSet.java
index 9c2e5a26f..8159d107b 100644
--- a/android/guava/src/com/google/common/collect/RegularContiguousSet.java
+++ b/android/guava/src/com/google/common/collect/RegularContiguousSet.java
@@ -143,6 +143,15 @@ final class RegularContiguousSet<C extends Comparable> extends ContiguousSet<C>
checkElementIndex(i, size());
return domain.offset(first(), i);
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
} else {
return super.createAsList();
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableAsList.java b/android/guava/src/com/google/common/collect/RegularImmutableAsList.java
index e344db1ea..928506e44 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableAsList.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableAsList.java
@@ -18,6 +18,7 @@ package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -89,4 +90,13 @@ class RegularImmutableAsList<E> extends ImmutableAsList<E> {
public E get(int index) {
return delegateList.get(index);
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableBiMap.java b/android/guava/src/com/google/common/collect/RegularImmutableBiMap.java
index 2ee752ceb..0188e6367 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableBiMap.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableBiMap.java
@@ -17,6 +17,8 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -120,4 +122,13 @@ final class RegularImmutableBiMap<K, V> extends ImmutableBiMap<K, V> {
boolean isPartialView() {
return false;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableList.java b/android/guava/src/com/google/common/collect/RegularImmutableList.java
index baf1d66ed..e7aedc972 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableList.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableList.java
@@ -20,6 +20,8 @@ import static com.google.common.base.Preconditions.checkElementIndex;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -85,4 +87,13 @@ class RegularImmutableList<E> extends ImmutableList<E> {
}
// TODO(lowasser): benchmark optimizations for equals() and see if they're worthwhile
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableMap.java b/android/guava/src/com/google/common/collect/RegularImmutableMap.java
index d6d214b65..100e06129 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableMap.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableMap.java
@@ -22,6 +22,7 @@ import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import java.util.AbstractMap;
@@ -435,6 +436,14 @@ final class RegularImmutableMap<K, V> extends ImmutableMap<K, V> {
public boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
@@ -458,6 +467,15 @@ final class RegularImmutableMap<K, V> extends ImmutableMap<K, V> {
public int size() {
return size;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@Override
@@ -495,6 +513,13 @@ final class RegularImmutableMap<K, V> extends ImmutableMap<K, V> {
public int size() {
return size;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
static final class KeySet<K> extends ImmutableSet<K> {
@@ -535,6 +560,15 @@ final class RegularImmutableMap<K, V> extends ImmutableMap<K, V> {
public int size() {
return map.size();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@SuppressWarnings("unchecked")
@@ -548,6 +582,15 @@ final class RegularImmutableMap<K, V> extends ImmutableMap<K, V> {
return false;
}
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
+
// This class is never actually serialized directly, but we have to make the
// warning go away (and suppressing would suppress for all nested classes too)
@J2ktIncompatible // serialization
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableMultiset.java b/android/guava/src/com/google/common/collect/RegularImmutableMultiset.java
index 6fbc099c8..0e59465ad 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableMultiset.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableMultiset.java
@@ -16,6 +16,7 @@ package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.collect.Multiset.Entry;
import com.google.common.primitives.Ints;
import com.google.errorprone.annotations.concurrent.LazyInit;
@@ -93,6 +94,15 @@ class RegularImmutableMultiset<E> extends ImmutableMultiset<E> {
public int size() {
return contents.size();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@Override
@@ -130,8 +140,9 @@ class RegularImmutableMultiset<E> extends ImmutableMultiset<E> {
private static final long serialVersionUID = 0;
}
- @GwtIncompatible
@Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
Object writeReplace() {
return new SerializedForm(this);
}
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableSet.java b/android/guava/src/com/google/common/collect/RegularImmutableSet.java
index 2382ef62e..790aa6453 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableSet.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableSet.java
@@ -17,6 +17,8 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -120,4 +122,13 @@ final class RegularImmutableSet<E> extends ImmutableSet<E> {
boolean isHashCodeFast() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java b/android/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java
index 3b6d79c44..1ece0a0a9 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java
@@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkPositionIndexes;
import static com.google.common.collect.BoundType.CLOSED;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.primitives.Ints;
import java.util.Comparator;
@@ -124,4 +125,12 @@ final class RegularImmutableSortedMultiset<E> extends ImmutableSortedMultiset<E>
boolean isPartialView() {
return offset > 0 || length < cumulativeCounts.length - 1;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableSortedSet.java b/android/guava/src/com/google/common/collect/RegularImmutableSortedSet.java
index ef0fbb378..d31572cf7 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableSortedSet.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableSortedSet.java
@@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import java.util.Collection;
import java.util.Collections;
@@ -319,4 +320,13 @@ final class RegularImmutableSortedSet<E> extends ImmutableSortedSet<E> {
? emptySet(reversedOrder)
: new RegularImmutableSortedSet<E>(elements.reverse(), reversedOrder);
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/android/guava/src/com/google/common/collect/RegularImmutableTable.java b/android/guava/src/com/google/common/collect/RegularImmutableTable.java
index 337f123b6..03def2cbc 100644
--- a/android/guava/src/com/google/common/collect/RegularImmutableTable.java
+++ b/android/guava/src/com/google/common/collect/RegularImmutableTable.java
@@ -18,6 +18,8 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.j2objc.annotations.WeakOuter;
import java.util.Collections;
import java.util.Comparator;
@@ -69,6 +71,15 @@ abstract class RegularImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
boolean isPartialView() {
return false;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
abstract V getValue(int iterationIndex);
@@ -94,6 +105,15 @@ abstract class RegularImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
static <R, C, V> RegularImmutableTable<R, C, V> forCells(
@@ -181,4 +201,10 @@ abstract class RegularImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
newValue,
existingValue);
}
+
+ // redeclare to satisfy our test for b/310253115
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ abstract Object writeReplace();
}
diff --git a/android/guava/src/com/google/common/collect/Sets.java b/android/guava/src/com/google/common/collect/Sets.java
index 1f433f4b6..60578e6d0 100644
--- a/android/guava/src/com/google/common/collect/Sets.java
+++ b/android/guava/src/com/google/common/collect/Sets.java
@@ -50,6 +50,7 @@ import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.stream.Collector;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -140,6 +141,17 @@ public final class Sets {
}
/**
+ * Returns a {@code Collector} that accumulates the input elements into a new {@code ImmutableSet}
+ * with an implementation specialized for enums. Unlike {@link ImmutableSet#toImmutableSet}, the
+ * resulting set will iterate over elements in their enum definition order, not encounter order.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <E extends Enum<E>> Collector<E, ?, ImmutableSet<E>> toImmutableEnumSet() {
+ return CollectCollectors.toImmutableEnumSet();
+ }
+
+ /**
* Returns a new, <i>mutable</i> {@code EnumSet} instance containing the given elements in their
* natural order. This method behaves identically to {@link EnumSet#copyOf(Collection)}, but also
* accepts non-{@code Collection} iterables and empty iterables.
@@ -1374,6 +1386,15 @@ public final class Sets {
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
return new CartesianSet<E>(axes, new CartesianList<E>(listAxes));
}
@@ -1415,7 +1436,11 @@ public final class Sets {
CartesianSet<?> that = (CartesianSet<?>) object;
return this.axes.equals(that.axes);
}
- return super.equals(object);
+ if (object instanceof Set) {
+ Set<?> that = (Set<?>) object;
+ return this.size() == that.size() && this.containsAll(that);
+ }
+ return false;
}
@Override
@@ -1637,6 +1662,7 @@ public final class Sets {
if (bitToFlip == index.size()) {
return endOfData();
}
+
/*
* The current set in sorted order looks like
* {firstSetBit, firstSetBit + 1, ..., bitToFlip - 1, ...}
diff --git a/android/guava/src/com/google/common/collect/SingletonImmutableSet.java b/android/guava/src/com/google/common/collect/SingletonImmutableSet.java
index 088cb802f..15db1c5e5 100644
--- a/android/guava/src/com/google/common/collect/SingletonImmutableSet.java
+++ b/android/guava/src/com/google/common/collect/SingletonImmutableSet.java
@@ -17,6 +17,8 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.base.Preconditions;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -80,4 +82,13 @@ final class SingletonImmutableSet<E> extends ImmutableSet<E> {
public String toString() {
return '[' + element.toString() + ']';
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/android/guava/src/com/google/common/collect/SingletonImmutableTable.java b/android/guava/src/com/google/common/collect/SingletonImmutableTable.java
index cfaeadb41..6f839ceb4 100644
--- a/android/guava/src/com/google/common/collect/SingletonImmutableTable.java
+++ b/android/guava/src/com/google/common/collect/SingletonImmutableTable.java
@@ -19,6 +19,8 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import java.util.Map;
/**
@@ -77,7 +79,9 @@ class SingletonImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
}
@Override
- SerializedForm createSerializedForm() {
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
return SerializedForm.create(this, new int[] {0}, new int[] {0});
}
}
diff --git a/android/guava/src/com/google/common/collect/SparseImmutableTable.java b/android/guava/src/com/google/common/collect/SparseImmutableTable.java
index 44881fde7..f7222b120 100644
--- a/android/guava/src/com/google/common/collect/SparseImmutableTable.java
+++ b/android/guava/src/com/google/common/collect/SparseImmutableTable.java
@@ -17,6 +17,8 @@ package com.google.common.collect;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.Immutable;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -130,7 +132,9 @@ final class SparseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
}
@Override
- SerializedForm createSerializedForm() {
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
Map<C, Integer> columnKeyToIndex = Maps.indexMap(columnKeySet());
int[] cellColumnIndices = new int[cellSet().size()];
int i = 0;
diff --git a/android/guava/src/com/google/common/collect/StandardTable.java b/android/guava/src/com/google/common/collect/StandardTable.java
index e039877a9..d13ef1254 100644
--- a/android/guava/src/com/google/common/collect/StandardTable.java
+++ b/android/guava/src/com/google/common/collect/StandardTable.java
@@ -821,7 +821,7 @@ class StandardTable<R, C, V> extends AbstractTable<R, C, V> implements Serializa
}
@WeakOuter
- class EntrySet extends TableSet<Entry<R, Map<C, V>>> {
+ private final class EntrySet extends TableSet<Entry<R, Map<C, V>>> {
@Override
public Iterator<Entry<R, Map<C, V>>> iterator() {
return Maps.asMapEntryIterator(
@@ -910,7 +910,7 @@ class StandardTable<R, C, V> extends AbstractTable<R, C, V> implements Serializa
}
@WeakOuter
- class ColumnMapEntrySet extends TableSet<Entry<C, Map<R, V>>> {
+ private final class ColumnMapEntrySet extends TableSet<Entry<C, Map<R, V>>> {
@Override
public Iterator<Entry<C, Map<R, V>>> iterator() {
return Maps.asMapEntryIterator(
diff --git a/android/guava/src/com/google/common/collect/Synchronized.java b/android/guava/src/com/google/common/collect/Synchronized.java
index a53a1f5af..57b7d4966 100644
--- a/android/guava/src/com/google/common/collect/Synchronized.java
+++ b/android/guava/src/com/google/common/collect/Synchronized.java
@@ -326,8 +326,8 @@ final class Synchronized {
: new SynchronizedList<E>(list, mutex);
}
- private static class SynchronizedList<E extends @Nullable Object>
- extends SynchronizedCollection<E> implements List<E> {
+ static class SynchronizedList<E extends @Nullable Object> extends SynchronizedCollection<E>
+ implements List<E> {
SynchronizedList(List<E> delegate, @CheckForNull Object mutex) {
super(delegate, mutex);
}
@@ -423,7 +423,7 @@ final class Synchronized {
private static final long serialVersionUID = 0;
}
- private static class SynchronizedRandomAccessList<E extends @Nullable Object>
+ static final class SynchronizedRandomAccessList<E extends @Nullable Object>
extends SynchronizedList<E> implements RandomAccess {
SynchronizedRandomAccessList(List<E> list, @CheckForNull Object mutex) {
super(list, mutex);
@@ -440,7 +440,7 @@ final class Synchronized {
return new SynchronizedMultiset<E>(multiset, mutex);
}
- private static class SynchronizedMultiset<E extends @Nullable Object>
+ static final class SynchronizedMultiset<E extends @Nullable Object>
extends SynchronizedCollection<E> implements Multiset<E> {
@CheckForNull transient Set<E> elementSet;
@CheckForNull transient Set<Multiset.Entry<E>> entrySet;
@@ -537,7 +537,7 @@ final class Synchronized {
return new SynchronizedMultimap<>(multimap, mutex);
}
- private static class SynchronizedMultimap<K extends @Nullable Object, V extends @Nullable Object>
+ static class SynchronizedMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedObject implements Multimap<K, V> {
@CheckForNull transient Set<K> keySet;
@CheckForNull transient Collection<V> valuesCollection;
@@ -724,7 +724,7 @@ final class Synchronized {
return new SynchronizedListMultimap<>(multimap, mutex);
}
- private static class SynchronizedListMultimap<
+ static final class SynchronizedListMultimap<
K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedMultimap<K, V> implements ListMultimap<K, V> {
SynchronizedListMultimap(ListMultimap<K, V> delegate, @CheckForNull Object mutex) {
@@ -768,8 +768,7 @@ final class Synchronized {
return new SynchronizedSetMultimap<>(multimap, mutex);
}
- private static class SynchronizedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
+ static class SynchronizedSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedMultimap<K, V> implements SetMultimap<K, V> {
@CheckForNull transient Set<Map.Entry<K, V>> entrySet;
@@ -825,7 +824,7 @@ final class Synchronized {
return new SynchronizedSortedSetMultimap<>(multimap, mutex);
}
- private static class SynchronizedSortedSetMultimap<
+ static final class SynchronizedSortedSetMultimap<
K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedSetMultimap<K, V> implements SortedSetMultimap<K, V> {
SynchronizedSortedSetMultimap(SortedSetMultimap<K, V> delegate, @CheckForNull Object mutex) {
@@ -892,7 +891,7 @@ final class Synchronized {
}
}
- private static class SynchronizedAsMapEntries<
+ static final class SynchronizedAsMapEntries<
K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedSet<Map.Entry<K, Collection<V>>> {
SynchronizedAsMapEntries(
@@ -999,7 +998,7 @@ final class Synchronized {
return new SynchronizedMap<>(map, mutex);
}
- private static class SynchronizedMap<K extends @Nullable Object, V extends @Nullable Object>
+ static class SynchronizedMap<K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedObject implements Map<K, V> {
@CheckForNull transient Set<K> keySet;
@CheckForNull transient Collection<V> values;
@@ -1202,8 +1201,7 @@ final class Synchronized {
return new SynchronizedBiMap<>(bimap, mutex, null);
}
- @VisibleForTesting
- static class SynchronizedBiMap<K extends @Nullable Object, V extends @Nullable Object>
+ static final class SynchronizedBiMap<K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedMap<K, V> implements BiMap<K, V>, Serializable {
@CheckForNull private transient Set<V> valueSet;
@RetainedWith @CheckForNull private transient BiMap<V, K> inverse;
@@ -1250,7 +1248,7 @@ final class Synchronized {
private static final long serialVersionUID = 0;
}
- private static class SynchronizedAsMap<K extends @Nullable Object, V extends @Nullable Object>
+ static final class SynchronizedAsMap<K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedMap<K, Collection<V>> {
@CheckForNull transient Set<Map.Entry<K, Collection<V>>> asMapEntrySet;
@CheckForNull transient Collection<Collection<V>> asMapValues;
@@ -1297,7 +1295,7 @@ final class Synchronized {
private static final long serialVersionUID = 0;
}
- private static class SynchronizedAsMapValues<V extends @Nullable Object>
+ static final class SynchronizedAsMapValues<V extends @Nullable Object>
extends SynchronizedCollection<Collection<V>> {
SynchronizedAsMapValues(Collection<Collection<V>> delegate, @CheckForNull Object mutex) {
super(delegate, mutex);
@@ -1319,8 +1317,8 @@ final class Synchronized {
@GwtIncompatible // NavigableSet
@VisibleForTesting
- static class SynchronizedNavigableSet<E extends @Nullable Object> extends SynchronizedSortedSet<E>
- implements NavigableSet<E> {
+ static final class SynchronizedNavigableSet<E extends @Nullable Object>
+ extends SynchronizedSortedSet<E> implements NavigableSet<E> {
SynchronizedNavigableSet(NavigableSet<E> delegate, @CheckForNull Object mutex) {
super(delegate, mutex);
}
@@ -1463,7 +1461,8 @@ final class Synchronized {
@GwtIncompatible // NavigableMap
@VisibleForTesting
- static class SynchronizedNavigableMap<K extends @Nullable Object, V extends @Nullable Object>
+ static final class SynchronizedNavigableMap<
+ K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedSortedMap<K, V> implements NavigableMap<K, V> {
SynchronizedNavigableMap(NavigableMap<K, V> delegate, @CheckForNull Object mutex) {
@@ -1664,7 +1663,7 @@ final class Synchronized {
}
@GwtIncompatible // works but is needed only for NavigableMap
- private static class SynchronizedEntry<K extends @Nullable Object, V extends @Nullable Object>
+ static final class SynchronizedEntry<K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedObject implements Map.Entry<K, V> {
SynchronizedEntry(Map.Entry<K, V> delegate, @CheckForNull Object mutex) {
@@ -1719,8 +1718,8 @@ final class Synchronized {
return (queue instanceof SynchronizedQueue) ? queue : new SynchronizedQueue<E>(queue, mutex);
}
- private static class SynchronizedQueue<E extends @Nullable Object>
- extends SynchronizedCollection<E> implements Queue<E> {
+ static class SynchronizedQueue<E extends @Nullable Object> extends SynchronizedCollection<E>
+ implements Queue<E> {
SynchronizedQueue(Queue<E> delegate, @CheckForNull Object mutex) {
super(delegate, mutex);
@@ -1775,8 +1774,8 @@ final class Synchronized {
return new SynchronizedDeque<E>(deque, mutex);
}
- private static final class SynchronizedDeque<E extends @Nullable Object>
- extends SynchronizedQueue<E> implements Deque<E> {
+ static final class SynchronizedDeque<E extends @Nullable Object> extends SynchronizedQueue<E>
+ implements Deque<E> {
SynchronizedDeque(Deque<E> delegate, @CheckForNull Object mutex) {
super(delegate, mutex);
@@ -1918,7 +1917,7 @@ final class Synchronized {
return new SynchronizedTable<>(table, mutex);
}
- private static final class SynchronizedTable<
+ static final class SynchronizedTable<
R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedObject implements Table<R, C, V> {
diff --git a/android/guava/src/com/google/common/collect/TableCollectors.java b/android/guava/src/com/google/common/collect/TableCollectors.java
index 9e71d80ab..64ee1d587 100644
--- a/android/guava/src/com/google/common/collect/TableCollectors.java
+++ b/android/guava/src/com/google/common/collect/TableCollectors.java
@@ -93,7 +93,7 @@ final class TableCollectors {
java.util.function.Function<? super T, ? extends C> columnFunction,
java.util.function.Function<? super T, ? extends V> valueFunction,
java.util.function.Supplier<I> tableSupplier) {
- return toTable(
+ return TableCollectors.<T, R, C, V, I>toTable(
rowFunction,
columnFunction,
valueFunction,
diff --git a/android/guava/src/com/google/common/collect/Tables.java b/android/guava/src/com/google/common/collect/Tables.java
index 513404de1..cca3d0c3a 100644
--- a/android/guava/src/com/google/common/collect/Tables.java
+++ b/android/guava/src/com/google/common/collect/Tables.java
@@ -33,6 +33,8 @@ import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
+import java.util.function.BinaryOperator;
+import java.util.stream.Collector;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -52,6 +54,63 @@ public final class Tables {
private Tables() {}
/**
+ * Returns a {@link Collector} that accumulates elements into a {@code Table} created using the
+ * specified supplier, whose cells are generated by applying the provided mapping functions to the
+ * input elements. Cells are inserted into the generated {@code Table} in encounter order.
+ *
+ * <p>If multiple input elements map to the same row and column, an {@code IllegalStateException}
+ * is thrown when the collection operation is performed.
+ *
+ * <p>To collect to an {@link ImmutableTable}, use {@link ImmutableTable#toImmutableTable}.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <
+ T extends @Nullable Object,
+ R extends @Nullable Object,
+ C extends @Nullable Object,
+ V extends @Nullable Object,
+ I extends Table<R, C, V>>
+ Collector<T, ?, I> toTable(
+ java.util.function.Function<? super T, ? extends R> rowFunction,
+ java.util.function.Function<? super T, ? extends C> columnFunction,
+ java.util.function.Function<? super T, ? extends V> valueFunction,
+ java.util.function.Supplier<I> tableSupplier) {
+ return TableCollectors.<T, R, C, V, I>toTable(
+ rowFunction, columnFunction, valueFunction, tableSupplier);
+ }
+
+ /**
+ * Returns a {@link Collector} that accumulates elements into a {@code Table} created using the
+ * specified supplier, whose cells are generated by applying the provided mapping functions to the
+ * input elements. Cells are inserted into the generated {@code Table} in encounter order.
+ *
+ * <p>If multiple input elements map to the same row and column, the specified merging function is
+ * used to combine the values. Like {@link
+ * java.util.stream.Collectors#toMap(java.util.function.Function, java.util.function.Function,
+ * BinaryOperator, java.util.function.Supplier)}, this Collector throws a {@code
+ * NullPointerException} on null values returned from {@code valueFunction}, and treats nulls
+ * returned from {@code mergeFunction} as removals of that row/column pair.
+ */
+ @SuppressWarnings({"AndroidJdkLibsChecker", "Java7ApiChecker"})
+ @IgnoreJRERequirement // Users will use this only if they're already using streams.
+ static <
+ T extends @Nullable Object,
+ R extends @Nullable Object,
+ C extends @Nullable Object,
+ V extends @Nullable Object,
+ I extends Table<R, C, V>>
+ Collector<T, ?, I> toTable(
+ java.util.function.Function<? super T, ? extends R> rowFunction,
+ java.util.function.Function<? super T, ? extends C> columnFunction,
+ java.util.function.Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction,
+ java.util.function.Supplier<I> tableSupplier) {
+ return TableCollectors.<T, R, C, V, I>toTable(
+ rowFunction, columnFunction, valueFunction, mergeFunction, tableSupplier);
+ }
+
+ /**
* Returns an immutable cell with the specified row key, column key, and value.
*
* <p>The returned cell is serializable.
@@ -602,7 +661,7 @@ public final class Tables {
return new UnmodifiableRowSortedMap<>(table);
}
- static final class UnmodifiableRowSortedMap<
+ private static final class UnmodifiableRowSortedMap<
R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
extends UnmodifiableTable<R, C, V> implements RowSortedTable<R, C, V> {
diff --git a/android/guava/src/com/google/common/collect/TopKSelector.java b/android/guava/src/com/google/common/collect/TopKSelector.java
index 9cc916e43..24fa85ded 100644
--- a/android/guava/src/com/google/common/collect/TopKSelector.java
+++ b/android/guava/src/com/google/common/collect/TopKSelector.java
@@ -231,6 +231,13 @@ final class TopKSelector<
buffer[j] = tmp;
}
+ TopKSelector<T> combine(TopKSelector<T> other) {
+ for (int i = 0; i < other.bufferSize; i++) {
+ this.offer(uncheckedCastNullableTToT(other.buffer[i]));
+ }
+ return this;
+ }
+
/**
* Adds each member of {@code elements} as a candidate for the top {@code k} elements. This
* operation takes amortized linear time in the length of {@code elements}.
diff --git a/android/guava/src/com/google/common/collect/TransformedListIterator.java b/android/guava/src/com/google/common/collect/TransformedListIterator.java
index 66b42e4c6..22b4b7c42 100644
--- a/android/guava/src/com/google/common/collect/TransformedListIterator.java
+++ b/android/guava/src/com/google/common/collect/TransformedListIterator.java
@@ -36,7 +36,7 @@ abstract class TransformedListIterator<F extends @Nullable Object, T extends @Nu
}
private ListIterator<? extends F> backingIterator() {
- return Iterators.cast(backingIterator);
+ return (ListIterator<? extends F>) backingIterator;
}
@Override
diff --git a/android/guava/src/com/google/common/collect/TreeMultiset.java b/android/guava/src/com/google/common/collect/TreeMultiset.java
index f3367ef9a..c25385f1d 100644
--- a/android/guava/src/com/google/common/collect/TreeMultiset.java
+++ b/android/guava/src/com/google/common/collect/TreeMultiset.java
@@ -1076,7 +1076,7 @@ public final class TreeMultiset<E extends @Nullable Object> extends AbstractSort
stream.defaultReadObject();
@SuppressWarnings("unchecked")
// reading data stored by writeObject
- Comparator<? super E> comparator = (Comparator<? super E>) stream.readObject();
+ Comparator<? super E> comparator = (Comparator<? super E>) requireNonNull(stream.readObject());
Serialization.getFieldSetter(AbstractSortedMultiset.class, "comparator").set(this, comparator);
Serialization.getFieldSetter(TreeMultiset.class, "range")
.set(this, GeneralRange.all(comparator));
diff --git a/android/guava/src/com/google/common/escape/Platform.java b/android/guava/src/com/google/common/escape/Platform.java
index dc6610c04..67efe4551 100644
--- a/android/guava/src/com/google/common/escape/Platform.java
+++ b/android/guava/src/com/google/common/escape/Platform.java
@@ -14,6 +14,8 @@
package com.google.common.escape;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.GwtCompatible;
/**
@@ -28,7 +30,8 @@ final class Platform {
/** Returns a thread-local 1024-char array. */
static char[] charBufferFromThreadLocal() {
- return DEST_TL.get();
+ // requireNonNull accommodates Android's @RecentlyNullable annotation on ThreadLocal.get
+ return requireNonNull(DEST_TL.get());
}
/**
diff --git a/android/guava/src/com/google/common/eventbus/Dispatcher.java b/android/guava/src/com/google/common/eventbus/Dispatcher.java
index 412bb789e..44f7c46ba 100644
--- a/android/guava/src/com/google/common/eventbus/Dispatcher.java
+++ b/android/guava/src/com/google/common/eventbus/Dispatcher.java
@@ -15,6 +15,7 @@
package com.google.common.eventbus;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.collect.Queues;
import java.util.Iterator;
@@ -97,7 +98,8 @@ abstract class Dispatcher {
void dispatch(Object event, Iterator<Subscriber> subscribers) {
checkNotNull(event);
checkNotNull(subscribers);
- Queue<Event> queueForThread = queue.get();
+ // requireNonNull accommodates Android's @RecentlyNullable annotation on ThreadLocal.get
+ Queue<Event> queueForThread = requireNonNull(queue.get());
queueForThread.offer(new Event(event, subscribers));
if (!dispatching.get()) {
diff --git a/android/guava/src/com/google/common/graph/StandardMutableValueGraph.java b/android/guava/src/com/google/common/graph/StandardMutableValueGraph.java
index 0ea641a5b..1ad474083 100644
--- a/android/guava/src/com/google/common/graph/StandardMutableValueGraph.java
+++ b/android/guava/src/com/google/common/graph/StandardMutableValueGraph.java
@@ -24,6 +24,7 @@ import static com.google.common.graph.Graphs.checkNonNegative;
import static com.google.common.graph.Graphs.checkPositive;
import static java.util.Objects.requireNonNull;
+import com.google.common.collect.ImmutableList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import javax.annotation.CheckForNull;
@@ -136,17 +137,21 @@ final class StandardMutableValueGraph<N, V> extends StandardValueGraph<N, V>
}
}
- for (N successor : connections.successors()) {
+ for (N successor : ImmutableList.copyOf(connections.successors())) {
// requireNonNull is safe because the node is a successor.
requireNonNull(nodeConnections.getWithoutCaching(successor)).removePredecessor(node);
+ requireNonNull(connections.removeSuccessor(successor));
--edgeCount;
}
if (isDirected()) { // In undirected graphs, the successor and predecessor sets are equal.
- for (N predecessor : connections.predecessors()) {
+ // Since views are returned, we need to copy the predecessors that will be removed.
+ // Thus we avoid modifying the underlying view while iterating over it.
+ for (N predecessor : ImmutableList.copyOf(connections.predecessors())) {
// requireNonNull is safe because the node is a predecessor.
checkState(
requireNonNull(nodeConnections.getWithoutCaching(predecessor)).removeSuccessor(node)
!= null);
+ connections.removePredecessor(predecessor);
--edgeCount;
}
}
diff --git a/android/guava/src/com/google/common/hash/BloomFilter.java b/android/guava/src/com/google/common/hash/BloomFilter.java
index d8b0690a7..557d05593 100644
--- a/android/guava/src/com/google/common/hash/BloomFilter.java
+++ b/android/guava/src/com/google/common/hash/BloomFilter.java
@@ -530,6 +530,7 @@ public final class BloomFilter<T extends @Nullable Object> implements Predicate<
* @throws IOException if the InputStream throws an {@code IOException}, or if its data does not
* appear to be a BloomFilter serialized using the {@linkplain #writeTo(OutputStream)} method.
*/
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public static <T extends @Nullable Object> BloomFilter<T> readFrom(
InputStream in, Funnel<? super T> funnel) throws IOException {
checkNotNull(in, "InputStream");
@@ -554,7 +555,9 @@ public final class BloomFilter<T extends @Nullable Object> implements Predicate<
}
return new BloomFilter<T>(dataArray, numHashFunctions, funnel, strategy);
- } catch (RuntimeException e) {
+ } catch (IOException e) {
+ throw e;
+ } catch (Exception e) { // sneaky checked exception
String message =
"Unable to deserialize BloomFilter from InputStream."
+ " strategyOrdinal: "
@@ -566,4 +569,6 @@ public final class BloomFilter<T extends @Nullable Object> implements Predicate<
throw new IOException(message, e);
}
}
+
+ private static final long serialVersionUID = 0xdecaf;
}
diff --git a/android/guava/src/com/google/common/io/BaseEncoding.java b/android/guava/src/com/google/common/io/BaseEncoding.java
index 50a8ff7e4..c176d0b00 100644
--- a/android/guava/src/com/google/common/io/BaseEncoding.java
+++ b/android/guava/src/com/google/common/io/BaseEncoding.java
@@ -433,7 +433,7 @@ public abstract class BaseEncoding {
return BASE16;
}
- private static final class Alphabet {
+ static final class Alphabet {
private final String name;
// this is meant to be immutable -- don't modify it!
private final char[] chars;
diff --git a/android/guava/src/com/google/common/io/TempFileCreator.java b/android/guava/src/com/google/common/io/TempFileCreator.java
index 966323599..769761280 100644
--- a/android/guava/src/com/google/common/io/TempFileCreator.java
+++ b/android/guava/src/com/google/common/io/TempFileCreator.java
@@ -16,17 +16,22 @@ package com.google.common.io;
import static com.google.common.base.StandardSystemProperty.JAVA_IO_TMPDIR;
import static com.google.common.base.StandardSystemProperty.USER_NAME;
+import static com.google.common.base.Throwables.throwIfUnchecked;
import static java.nio.file.attribute.AclEntryFlag.DIRECTORY_INHERIT;
import static java.nio.file.attribute.AclEntryFlag.FILE_INHERIT;
import static java.nio.file.attribute.AclEntryType.ALLOW;
import static java.nio.file.attribute.PosixFilePermissions.asFileAttribute;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.j2objc.annotations.J2ObjCIncompatible;
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.nio.file.FileSystems;
import java.nio.file.Paths;
import java.nio.file.attribute.AclEntry;
@@ -98,6 +103,20 @@ abstract class TempFileCreator {
return new JavaIoCreator();
}
+ /**
+ * Creates the permissions normally used for Windows filesystems, looking up the user afresh, even
+ * if previous calls have initialized the {@code PermissionSupplier} fields.
+ *
+ * <p>This lets us test the effects of different values of the {@code user.name} system property
+ * without needing a separate VM or classloader.
+ */
+ @IgnoreJRERequirement // used only when Path is available (and only from tests)
+ @VisibleForTesting
+ static void testMakingUserPermissionsFromScratch() throws IOException {
+ // All we're testing is whether it throws.
+ FileAttribute<?> unused = JavaNioCreator.userPermissions().get();
+ }
+
@IgnoreJRERequirement // used only when Path is available
private static final class JavaNioCreator extends TempFileCreator {
@Override
@@ -150,7 +169,7 @@ abstract class TempFileCreator {
UserPrincipal user =
FileSystems.getDefault()
.getUserPrincipalLookupService()
- .lookupPrincipalByName(USER_NAME.value());
+ .lookupPrincipalByName(getUsername());
ImmutableList<AclEntry> acl =
ImmutableList.of(
AclEntry.newBuilder()
@@ -179,6 +198,62 @@ abstract class TempFileCreator {
};
}
}
+
+ private static String getUsername() {
+ /*
+ * https://github.com/google/guava/issues/6634: ProcessHandle has more accurate information,
+ * but that class isn't available under all environments that we support. We use it if
+ * available and fall back if not.
+ */
+ String fromSystemProperty = requireNonNull(USER_NAME.value());
+
+ try {
+ Class<?> processHandleClass = Class.forName("java.lang.ProcessHandle");
+ Class<?> processHandleInfoClass = Class.forName("java.lang.ProcessHandle$Info");
+ Class<?> optionalClass = Class.forName("java.util.Optional");
+ /*
+ * We don't *need* to use reflection to access Optional: It's available on all JDKs we
+ * support, and Android code won't get this far, anyway, because ProcessHandle is
+ * unavailable. But given how much other reflection we're using, we might as well use it
+ * here, too, so that we don't need to also suppress an AndroidApiChecker error.
+ */
+
+ Method currentMethod = processHandleClass.getMethod("current");
+ Method infoMethod = processHandleClass.getMethod("info");
+ Method userMethod = processHandleInfoClass.getMethod("user");
+ Method orElseMethod = optionalClass.getMethod("orElse", Object.class);
+
+ Object current = currentMethod.invoke(null);
+ Object info = infoMethod.invoke(current);
+ Object user = userMethod.invoke(info);
+ return (String) requireNonNull(orElseMethod.invoke(user, fromSystemProperty));
+ } catch (ClassNotFoundException runningUnderAndroidOrJava8) {
+ /*
+ * I'm not sure that we could actually get here for *Android*: I would expect us to enter
+ * the POSIX code path instead. And if we tried this code path, we'd have trouble unless we
+ * were running under a new enough version of Android to support NIO.
+ *
+ * So this is probably just the "Windows Java 8" case. In that case, if we wanted *another*
+ * layer of fallback before consulting the system property, we could try
+ * com.sun.security.auth.module.NTSystem.
+ *
+ * But for now, we use the value from the system property as our best guess.
+ */
+ return fromSystemProperty;
+ } catch (InvocationTargetException e) {
+ throwIfUnchecked(e.getCause()); // in case it's an Error or something
+ return fromSystemProperty; // should be impossible
+ } catch (NoSuchMethodException shouldBeImpossible) {
+ return fromSystemProperty;
+ } catch (IllegalAccessException shouldBeImpossible) {
+ /*
+ * We don't merge these into `catch (ReflectiveOperationException ...)` or an equivalent
+ * multicatch because ReflectiveOperationException isn't available under Android:
+ * b/124188803
+ */
+ return fromSystemProperty;
+ }
+ }
}
private static final class JavaIoCreator extends TempFileCreator {
diff --git a/android/guava/src/com/google/common/net/HostAndPort.java b/android/guava/src/com/google/common/net/HostAndPort.java
index a27eb65ff..0ec28198c 100644
--- a/android/guava/src/com/google/common/net/HostAndPort.java
+++ b/android/guava/src/com/google/common/net/HostAndPort.java
@@ -209,7 +209,7 @@ public final class HostAndPort implements Serializable {
/**
* Parses a bracketed host-port string, throwing IllegalArgumentException if parsing fails.
*
- * @param hostPortString the full bracketed host-port specification. Post might not be specified.
+ * @param hostPortString the full bracketed host-port specification. Port might not be specified.
* @return an array with 2 strings: host and port, in that order.
* @throws IllegalArgumentException if parsing the bracketed host-port string fails.
*/
diff --git a/android/guava/src/com/google/common/net/HttpHeaders.java b/android/guava/src/com/google/common/net/HttpHeaders.java
index 4c1f865b5..714cb313c 100644
--- a/android/guava/src/com/google/common/net/HttpHeaders.java
+++ b/android/guava/src/com/google/common/net/HttpHeaders.java
@@ -855,6 +855,25 @@ public final class HttpHeaders {
* @since 32.0.0
*/
public static final String OBSERVE_BROWSING_TOPICS = "Observe-Browsing-Topics";
+
+ /**
+ * The HTTP <a
+ * href="https://wicg.github.io/turtledove/#handling-direct-from-seller-signals">{@code
+ * Sec-Ad-Auction-Fetch}</a> header field name.
+ *
+ * @since 33.0.0
+ */
+ public static final String SEC_AD_AUCTION_FETCH = "Sec-Ad-Auction-Fetch";
+
+ /**
+ * The HTTP <a
+ * href="https://wicg.github.io/turtledove/#handling-direct-from-seller-signals">{@code
+ * Ad-Auction-Signals}</a> header field name.
+ *
+ * @since 33.0.0
+ */
+ public static final String AD_AUCTION_SIGNALS = "Ad-Auction-Signals";
+
/**
* The HTTP <a href="https://tools.ietf.org/html/rfc8586">{@code CDN-Loop}</a> header field name.
*
diff --git a/android/guava/src/com/google/common/net/InetAddresses.java b/android/guava/src/com/google/common/net/InetAddresses.java
index 6d8309381..540a21986 100644
--- a/android/guava/src/com/google/common/net/InetAddresses.java
+++ b/android/guava/src/com/google/common/net/InetAddresses.java
@@ -16,6 +16,7 @@ package com.google.common.net;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
@@ -409,7 +410,8 @@ public final class InetAddresses {
checkNotNull(ip);
if (ip instanceof Inet4Address) {
// For IPv4, Java's formatting is good enough.
- return ip.getHostAddress();
+ // requireNonNull accommodates Android's @RecentlyNullable annotation on getHostAddress
+ return requireNonNull(ip.getHostAddress());
}
checkArgument(ip instanceof Inet6Address);
byte[] bytes = ip.getAddress();
diff --git a/android/guava/src/com/google/common/net/MediaType.java b/android/guava/src/com/google/common/net/MediaType.java
index c7da53491..99d47dca7 100644
--- a/android/guava/src/com/google/common/net/MediaType.java
+++ b/android/guava/src/com/google/common/net/MediaType.java
@@ -1052,15 +1052,13 @@ public final class MediaType {
Tokenizer tokenizer = new Tokenizer(input);
try {
String type = tokenizer.consumeToken(TOKEN_MATCHER);
- tokenizer.consumeCharacter('/');
+ consumeSeparator(tokenizer, '/');
String subtype = tokenizer.consumeToken(TOKEN_MATCHER);
ImmutableListMultimap.Builder<String, String> parameters = ImmutableListMultimap.builder();
while (tokenizer.hasMore()) {
- tokenizer.consumeTokenIfPresent(LINEAR_WHITE_SPACE);
- tokenizer.consumeCharacter(';');
- tokenizer.consumeTokenIfPresent(LINEAR_WHITE_SPACE);
+ consumeSeparator(tokenizer, ';');
String attribute = tokenizer.consumeToken(TOKEN_MATCHER);
- tokenizer.consumeCharacter('=');
+ consumeSeparator(tokenizer, '=');
String value;
if ('"' == tokenizer.previewChar()) {
tokenizer.consumeCharacter('"');
@@ -1086,6 +1084,12 @@ public final class MediaType {
}
}
+ private static void consumeSeparator(Tokenizer tokenizer, char c) {
+ tokenizer.consumeTokenIfPresent(LINEAR_WHITE_SPACE);
+ tokenizer.consumeCharacter(c);
+ tokenizer.consumeTokenIfPresent(LINEAR_WHITE_SPACE);
+ }
+
private static final class Tokenizer {
final String input;
int position = 0;
diff --git a/android/guava/src/com/google/common/primitives/Doubles.java b/android/guava/src/com/google/common/primitives/Doubles.java
index 81bf104ce..ce491bc98 100644
--- a/android/guava/src/com/google/common/primitives/Doubles.java
+++ b/android/guava/src/com/google/common/primitives/Doubles.java
@@ -287,7 +287,7 @@ public final class Doubles extends DoublesMethodsForWeb {
private static final class DoubleConverter extends Converter<String, Double>
implements Serializable {
- static final DoubleConverter INSTANCE = new DoubleConverter();
+ static final Converter<String, Double> INSTANCE = new DoubleConverter();
@Override
protected Double doForward(String value) {
diff --git a/android/guava/src/com/google/common/primitives/Floats.java b/android/guava/src/com/google/common/primitives/Floats.java
index d7f156b1e..c42f2f1ee 100644
--- a/android/guava/src/com/google/common/primitives/Floats.java
+++ b/android/guava/src/com/google/common/primitives/Floats.java
@@ -284,7 +284,7 @@ public final class Floats extends FloatsMethodsForWeb {
private static final class FloatConverter extends Converter<String, Float>
implements Serializable {
- static final FloatConverter INSTANCE = new FloatConverter();
+ static final Converter<String, Float> INSTANCE = new FloatConverter();
@Override
protected Float doForward(String value) {
diff --git a/android/guava/src/com/google/common/primitives/Ints.java b/android/guava/src/com/google/common/primitives/Ints.java
index cbd81fb12..8932af267 100644
--- a/android/guava/src/com/google/common/primitives/Ints.java
+++ b/android/guava/src/com/google/common/primitives/Ints.java
@@ -335,7 +335,7 @@ public final class Ints extends IntsMethodsForWeb {
private static final class IntConverter extends Converter<String, Integer>
implements Serializable {
- static final IntConverter INSTANCE = new IntConverter();
+ static final Converter<String, Integer> INSTANCE = new IntConverter();
@Override
protected Integer doForward(String value) {
diff --git a/android/guava/src/com/google/common/primitives/Longs.java b/android/guava/src/com/google/common/primitives/Longs.java
index ce6a6fa39..f50ee01ca 100644
--- a/android/guava/src/com/google/common/primitives/Longs.java
+++ b/android/guava/src/com/google/common/primitives/Longs.java
@@ -438,7 +438,7 @@ public final class Longs {
}
private static final class LongConverter extends Converter<String, Long> implements Serializable {
- static final LongConverter INSTANCE = new LongConverter();
+ static final Converter<String, Long> INSTANCE = new LongConverter();
@Override
protected Long doForward(String value) {
diff --git a/android/guava/src/com/google/common/primitives/Shorts.java b/android/guava/src/com/google/common/primitives/Shorts.java
index 85ffd3ba8..e7cc8538b 100644
--- a/android/guava/src/com/google/common/primitives/Shorts.java
+++ b/android/guava/src/com/google/common/primitives/Shorts.java
@@ -335,7 +335,7 @@ public final class Shorts extends ShortsMethodsForWeb {
private static final class ShortConverter extends Converter<String, Short>
implements Serializable {
- static final ShortConverter INSTANCE = new ShortConverter();
+ static final Converter<String, Short> INSTANCE = new ShortConverter();
@Override
protected Short doForward(String value) {
diff --git a/android/guava/src/com/google/common/reflect/Invokable.java b/android/guava/src/com/google/common/reflect/Invokable.java
index 236c29627..ca405566f 100644
--- a/android/guava/src/com/google/common/reflect/Invokable.java
+++ b/android/guava/src/com/google/common/reflect/Invokable.java
@@ -16,14 +16,11 @@ package com.google.common.reflect;
import static com.google.common.base.Preconditions.checkNotNull;
-import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import com.google.errorprone.annotations.DoNotCall;
import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.AnnotatedType;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
@@ -119,13 +116,14 @@ public abstract class Invokable<T, R> implements AnnotatedElement, Member {
}
/** See {@link java.lang.reflect.AccessibleObject#trySetAccessible()}. */
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public final boolean trySetAccessible() {
// We can't call accessibleObject.trySetAccessible since that was added in Java 9 and this code
// should work on Java 8. So we emulate it this way.
try {
accessibleObject.setAccessible(true);
return true;
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
return false;
}
}
@@ -278,7 +276,7 @@ public abstract class Invokable<T, R> implements AnnotatedElement, Member {
Type[] parameterTypes = getGenericParameterTypes();
Annotation[][] annotations = getParameterAnnotations();
@Nullable Object[] annotatedTypes =
- ANNOTATED_TYPE_EXISTS ? getAnnotatedParameterTypes() : new Object[parameterTypes.length];
+ new Object[parameterTypes.length];
ImmutableList.Builder<Parameter> builder = ImmutableList.builder();
for (int i = 0; i < parameterTypes.length; i++) {
builder.add(
@@ -343,10 +341,6 @@ public abstract class Invokable<T, R> implements AnnotatedElement, Member {
abstract Type[] getGenericParameterTypes();
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker"})
- @IgnoreJRERequirement
- abstract AnnotatedType[] getAnnotatedParameterTypes();
-
/** This should never return a type that's not a subtype of Throwable. */
abstract Type[] getGenericExceptionTypes();
@@ -354,22 +348,6 @@ public abstract class Invokable<T, R> implements AnnotatedElement, Member {
abstract Type getGenericReturnType();
- /**
- * Returns the {@link AnnotatedType} for the return type.
- *
- * <p>This method will fail if run under an Android VM.
- *
- * @since NEXT for guava-android (available since 14.0 in guava-jre)
- * @deprecated This method does not work under Android VMs. It is safe to use from guava-jre, but
- * this copy in guava-android is not safe to use.
- */
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker"})
- @DoNotCall("fails under Android VMs; do not use from guava-android")
- @Deprecated
- @IgnoreJRERequirement
- @Beta
- public abstract AnnotatedType getAnnotatedReturnType();
-
static class MethodInvokable<T> extends Invokable<T, Object> {
final Method method;
@@ -397,21 +375,6 @@ public abstract class Invokable<T, R> implements AnnotatedElement, Member {
}
@Override
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker"})
- @IgnoreJRERequirement
- AnnotatedType[] getAnnotatedParameterTypes() {
- return method.getAnnotatedParameterTypes();
- }
-
- @Override
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker", "DoNotCall"})
- @DoNotCall
- @IgnoreJRERequirement
- public AnnotatedType getAnnotatedReturnType() {
- return method.getAnnotatedReturnType();
- }
-
- @Override
Type[] getGenericExceptionTypes() {
return method.getGenericExceptionTypes();
}
@@ -489,21 +452,6 @@ public abstract class Invokable<T, R> implements AnnotatedElement, Member {
}
@Override
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker"})
- @IgnoreJRERequirement
- AnnotatedType[] getAnnotatedParameterTypes() {
- return constructor.getAnnotatedParameterTypes();
- }
-
- @Override
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker", "DoNotCall"})
- @DoNotCall
- @IgnoreJRERequirement
- public AnnotatedType getAnnotatedReturnType() {
- return constructor.getAnnotatedReturnType();
- }
-
- @Override
Type[] getGenericExceptionTypes() {
return constructor.getGenericExceptionTypes();
}
diff --git a/android/guava/src/com/google/common/reflect/Parameter.java b/android/guava/src/com/google/common/reflect/Parameter.java
index c69ae734c..a0c6d7b1b 100644
--- a/android/guava/src/com/google/common/reflect/Parameter.java
+++ b/android/guava/src/com/google/common/reflect/Parameter.java
@@ -15,15 +15,11 @@
package com.google.common.reflect;
import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.Objects.requireNonNull;
-import com.google.common.annotations.Beta;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
-import com.google.errorprone.annotations.DoNotCall;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.AnnotatedType;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -42,7 +38,7 @@ public final class Parameter implements AnnotatedElement {
private final ImmutableList<Annotation> annotations;
/**
- * An {@link AnnotatedType} instance, or {@code null} under Android VMs (possible only when using
+ * An {@code AnnotatedType} instance, or {@code null} under Android VMs (possible only when using
* the Android flavor of Guava). The field is declared with a type of {@code Object} to avoid
* compatibility problems on Android VMs. The corresponding accessor method, however, can have the
* more specific return type as long as users are careful to guard calls to it with version checks
@@ -131,24 +127,6 @@ public final class Parameter implements AnnotatedElement {
return cast;
}
- /**
- * Returns the {@link AnnotatedType} of the parameter.
- *
- * <p>This method will fail if run under an Android VM.
- *
- * @since NEXT for guava-android (available since 25.1 in guava-jre)
- * @deprecated This method does not work under Android VMs. It is safe to use from guava-jre, but
- * this copy in guava-android is not safe to use.
- */
- @Beta
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker"})
- @Deprecated
- @DoNotCall("fails under Android VMs; do not use from guava-android")
- @IgnoreJRERequirement
- public AnnotatedType getAnnotatedType() {
- return requireNonNull((AnnotatedType) annotatedType);
- }
-
@Override
public boolean equals(@CheckForNull Object obj) {
if (obj instanceof Parameter) {
diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java b/android/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java
index e5df53835..8fa650028 100644
--- a/android/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java
@@ -108,8 +108,8 @@ abstract class AbstractCatchingFuture<
+ e.getClass()
+ " without a cause");
}
- } catch (RuntimeException | Error e) { // this includes cancellation exception
- throwable = e;
+ } catch (Throwable t) { // this includes CancellationException and sneaky checked exception
+ throwable = t;
}
if (throwable == null) {
diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java b/android/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
index b06647ea3..43d4e5d5d 100644
--- a/android/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
+++ b/android/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
@@ -23,7 +23,6 @@ import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* Base class for services that can implement {@link #startUp}, {@link #run} and {@link #shutDown}
@@ -37,8 +36,7 @@ import java.util.logging.Logger;
@J2ktIncompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractExecutionThreadService implements Service {
- private static final Logger logger =
- Logger.getLogger(AbstractExecutionThreadService.class.getName());
+ private static final LazyLogger logger = new LazyLogger(AbstractExecutionThreadService.class);
/* use AbstractService for state management */
private final Service delegate =
@@ -65,10 +63,12 @@ public abstract class AbstractExecutionThreadService implements Service {
// TODO(lukes): if guava ever moves to java7, this would be a good
// candidate for a suppressed exception, or maybe we could generalize
// Closer.Suppressor
- logger.log(
- Level.WARNING,
- "Error while attempting to shut down the service after failure.",
- ignored);
+ logger
+ .get()
+ .log(
+ Level.WARNING,
+ "Error while attempting to shut down the service after failure.",
+ ignored);
}
notifyFailed(t);
return;
diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractFuture.java b/android/guava/src/com/google/common/util/concurrent/AbstractFuture.java
index 6dc7a6b39..a0ddc4d2e 100644
--- a/android/guava/src/com/google/common/util/concurrent/AbstractFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/AbstractFuture.java
@@ -42,7 +42,6 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.concurrent.locks.LockSupport;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -141,8 +140,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
}
}
- // Logger to log exceptions caught when running listeners.
- private static final Logger log = Logger.getLogger(AbstractFuture.class.getName());
+ static final LazyLogger log = new LazyLogger(AbstractFuture.class);
// A heuristic for timed gets. If the remaining timeout is less than this, spin instead of
// blocking. This value is what AbstractQueuedSynchronizer uses.
@@ -157,7 +155,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
try {
helper = new UnsafeAtomicHelper();
- } catch (RuntimeException | Error unsafeFailure) {
+ } catch (Exception | Error unsafeFailure) { // sneaky checked exception
thrownUnsafeFailure = unsafeFailure;
// catch absolutely everything and fall through to our 'SafeAtomicHelper'
// The access control checks that ARFU does means the caller class has to be AbstractFuture
@@ -170,7 +168,8 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
newUpdater(AbstractFuture.class, Waiter.class, "waiters"),
newUpdater(AbstractFuture.class, Listener.class, "listeners"),
newUpdater(AbstractFuture.class, Object.class, "value"));
- } catch (RuntimeException | Error atomicReferenceFieldUpdaterFailure) {
+ } catch (Exception // sneaky checked exception
+ | Error atomicReferenceFieldUpdaterFailure) {
// Some Android 5.0.x Samsung devices have bugs in JDK reflection APIs that cause
// getDeclaredField to throw a NoSuchFieldException when the field is definitely there.
// For these users fallback to a suboptimal implementation, based on synchronized. This will
@@ -189,9 +188,12 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
// Log after all static init is finished; if an installed logger uses any Futures methods, it
// shouldn't break in cases where reflection is missing/broken.
if (thrownAtomicReferenceFieldUpdaterFailure != null) {
- log.log(Level.SEVERE, "UnsafeAtomicHelper is broken!", thrownUnsafeFailure);
- log.log(
- Level.SEVERE, "SafeAtomicHelper is broken!", thrownAtomicReferenceFieldUpdaterFailure);
+ log.get().log(Level.SEVERE, "UnsafeAtomicHelper is broken!", thrownUnsafeFailure);
+ log.get()
+ .log(
+ Level.SEVERE,
+ "SafeAtomicHelper is broken!",
+ thrownAtomicReferenceFieldUpdaterFailure);
}
}
@@ -864,14 +866,16 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
// since all we are doing is unpacking a completed future which should be fast.
try {
future.addListener(valueToSet, DirectExecutor.INSTANCE);
- } catch (RuntimeException | Error t) {
+ } catch (Throwable t) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
+ //
// addListener has thrown an exception! SetFuture.run can't throw any exceptions so this
// must have been caused by addListener itself. The most likely explanation is a
// misconfigured mock. Try to switch to Failure.
Failure failure;
try {
failure = new Failure(t);
- } catch (RuntimeException | Error oomMostLikely) {
+ } catch (Exception | Error oomMostLikely) { // sneaky checked exception
failure = Failure.FALLBACK_INSTANCE;
}
// Note: The only way this CAS could fail is if cancel() has raced with us. That is ok.
@@ -966,7 +970,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
cancellation));
}
return new Cancellation(false, cancellation);
- } catch (RuntimeException | Error t) {
+ } catch (Exception | Error t) { // sneaky checked exception
return new Failure(t);
}
}
@@ -1190,6 +1194,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
return null;
}
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private void addPendingString(StringBuilder builder) {
// Capture current builder length so it can be truncated if this future ends up completing while
// the toString is being calculated
@@ -1206,7 +1211,9 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
String pendingDescription;
try {
pendingDescription = Strings.emptyToNull(pendingToString());
- } catch (RuntimeException | StackOverflowError e) {
+ } catch (Exception | StackOverflowError e) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
+ //
// Don't call getMessage or toString() on the exception, in case the exception thrown by the
// subclass is implemented with bugs similar to the subclass.
pendingDescription = "Exception thrown from implementation: " + e.getClass();
@@ -1225,6 +1232,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
}
}
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private void addDoneString(StringBuilder builder) {
try {
V value = getUninterruptibly(this);
@@ -1235,7 +1243,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
builder.append("FAILURE, cause=[").append(e.getCause()).append("]");
} catch (CancellationException e) {
builder.append("CANCELLED"); // shouldn't be reachable
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
builder.append("UNKNOWN, cause=[").append(e.getClass()).append(" thrown from get()]");
}
}
@@ -1259,6 +1267,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
}
/** Helper for printing user supplied objects into our toString method. */
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private void appendUserObject(StringBuilder builder, @CheckForNull Object o) {
// This is some basic recursion detection for when people create cycles via set/setFuture or
// when deep chains of futures exist resulting in a StackOverflowException. We could detect
@@ -1270,7 +1279,9 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
} else {
builder.append(o);
}
- } catch (RuntimeException | StackOverflowError e) {
+ } catch (Exception | StackOverflowError e) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
+ //
// Don't call getMessage or toString() on the exception, in case the exception thrown by the
// user object is implemented with bugs similar to the user object.
builder.append("Exception thrown from implementation: ").append(e.getClass());
@@ -1281,17 +1292,22 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
* Submits the given runnable to the given {@link Executor} catching and logging all {@linkplain
* RuntimeException runtime exceptions} thrown by the executor.
*/
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private static void executeListener(Runnable runnable, Executor executor) {
try {
executor.execute(runnable);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// Log it and keep going -- bad runnable and/or executor. Don't punish the other runnables if
// we're given a bad one. We only catch RuntimeException because we want Errors to propagate
// up.
- log.log(
- Level.SEVERE,
- "RuntimeException while executing runnable " + runnable + " with executor " + executor,
- e);
+ log.get()
+ .log(
+ Level.SEVERE,
+ "RuntimeException while executing runnable "
+ + runnable
+ + " with executor "
+ + executor,
+ e);
}
}
@@ -1371,8 +1387,6 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
UNSAFE = unsafe;
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
- } catch (RuntimeException e) {
- throw e;
}
}
diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java b/android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java
index 0b7d34e6b..594496884 100644
--- a/android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java
+++ b/android/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java
@@ -37,7 +37,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -102,7 +101,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
@J2ktIncompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractScheduledService implements Service {
- private static final Logger logger = Logger.getLogger(AbstractScheduledService.class.getName());
+ private static final LazyLogger logger = new LazyLogger(AbstractScheduledService.class);
/**
* A scheduler defines the policy for how the {@link AbstractScheduledService} should run its
@@ -209,10 +208,12 @@ public abstract class AbstractScheduledService implements Service {
shutDown();
} catch (Exception ignored) {
restoreInterruptIfIsInterruptedException(ignored);
- logger.log(
- Level.WARNING,
- "Error while attempting to shut down the service after failure.",
- ignored);
+ logger
+ .get()
+ .log(
+ Level.WARNING,
+ "Error while attempting to shut down the service after failure.",
+ ignored);
}
notifyFailed(t);
// requireNonNull is safe now, just as it was above.
@@ -564,7 +565,9 @@ public abstract class AbstractScheduledService implements Service {
lock.lock();
try {
toReturn = initializeOrUpdateCancellationDelegate(schedule);
- } catch (RuntimeException | Error e) {
+ } catch (Throwable e) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
+ //
// If an exception is thrown by the subclass then we need to make sure that the service
// notices and transitions to the FAILED state. We do it by calling notifyFailed directly
// because the service does not monitor the state of the future so if the exception is not
diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java b/android/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
index 5581b5fae..3c5f30b63 100644
--- a/android/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
@@ -66,6 +66,7 @@ abstract class AbstractTransformFuture<
}
@Override
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public final void run() {
ListenableFuture<? extends I> localInputFuture = inputFuture;
F localFunction = function;
@@ -104,7 +105,7 @@ abstract class AbstractTransformFuture<
// Set the cause of the exception as this future's exception.
setException(e.getCause());
return;
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// Bug in inputFuture.get(). Propagate to the output Future so that its consumers don't hang.
setException(e);
return;
diff --git a/android/guava/src/com/google/common/util/concurrent/AggregateFuture.java b/android/guava/src/com/google/common/util/concurrent/AggregateFuture.java
index ec96cbb89..353477416 100644
--- a/android/guava/src/com/google/common/util/concurrent/AggregateFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/AggregateFuture.java
@@ -30,7 +30,6 @@ import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -44,7 +43,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
@ElementTypesAreNonnullByDefault
abstract class AggregateFuture<InputT extends @Nullable Object, OutputT extends @Nullable Object>
extends AggregateFutureState<OutputT> {
- private static final Logger logger = Logger.getLogger(AggregateFuture.class.getName());
+ private static final LazyLogger logger = new LazyLogger(AggregateFuture.class);
/**
* The input futures. After {@link #init}, this field is read only by {@link #afterDone()} (to
@@ -230,7 +229,7 @@ abstract class AggregateFuture<InputT extends @Nullable Object, OutputT extends
(throwable instanceof Error)
? "Input Future failed with Error"
: "Got more than one input Future failure. Logging failures after the first";
- logger.log(SEVERE, message, throwable);
+ logger.get().log(SEVERE, message, throwable);
}
@Override
@@ -268,7 +267,7 @@ abstract class AggregateFuture<InputT extends @Nullable Object, OutputT extends
collectOneValue(index, getDone(future));
} catch (ExecutionException e) {
handleException(e.getCause());
- } catch (RuntimeException | Error t) {
+ } catch (Throwable t) { // sneaky checked exception
handleException(t);
}
}
diff --git a/android/guava/src/com/google/common/util/concurrent/AggregateFutureState.java b/android/guava/src/com/google/common/util/concurrent/AggregateFutureState.java
index 7bdec0135..5816abf05 100644
--- a/android/guava/src/com/google/common/util/concurrent/AggregateFutureState.java
+++ b/android/guava/src/com/google/common/util/concurrent/AggregateFutureState.java
@@ -25,7 +25,6 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -51,7 +50,7 @@ abstract class AggregateFutureState<OutputT extends @Nullable Object>
private static final AtomicHelper ATOMIC_HELPER;
- private static final Logger log = Logger.getLogger(AggregateFutureState.class.getName());
+ private static final LazyLogger log = new LazyLogger(AggregateFutureState.class);
static {
AtomicHelper helper;
@@ -61,7 +60,7 @@ abstract class AggregateFutureState<OutputT extends @Nullable Object>
new SafeAtomicHelper(
newUpdater(AggregateFutureState.class, Set.class, "seenExceptions"),
newUpdater(AggregateFutureState.class, "remaining"));
- } catch (RuntimeException | Error reflectionFailure) {
+ } catch (Throwable reflectionFailure) { // sneaky checked exception
// Some Android 5.0.x Samsung devices have bugs in JDK reflection APIs that cause
// getDeclaredField to throw a NoSuchFieldException when the field is definitely there.
// For these users fallback to a suboptimal implementation, based on synchronized. This will
@@ -73,7 +72,7 @@ abstract class AggregateFutureState<OutputT extends @Nullable Object>
// Log after all static init is finished; if an installed logger uses any Futures methods, it
// shouldn't break in cases where reflection is missing/broken.
if (thrownReflectionFailure != null) {
- log.log(Level.SEVERE, "SafeAtomicHelper is broken!", thrownReflectionFailure);
+ log.get().log(Level.SEVERE, "SafeAtomicHelper is broken!", thrownReflectionFailure);
}
}
@@ -159,7 +158,7 @@ abstract class AggregateFutureState<OutputT extends @Nullable Object>
}
private static final class SafeAtomicHelper extends AtomicHelper {
- final AtomicReferenceFieldUpdater<AggregateFutureState<?>, Set<Throwable>>
+ final AtomicReferenceFieldUpdater<AggregateFutureState<?>, @Nullable Set<Throwable>>
seenExceptionsUpdater;
final AtomicIntegerFieldUpdater<AggregateFutureState<?>> remainingCountUpdater;
@@ -169,7 +168,7 @@ abstract class AggregateFutureState<OutputT extends @Nullable Object>
AtomicReferenceFieldUpdater seenExceptionsUpdater,
AtomicIntegerFieldUpdater remainingCountUpdater) {
this.seenExceptionsUpdater =
- (AtomicReferenceFieldUpdater<AggregateFutureState<?>, Set<Throwable>>)
+ (AtomicReferenceFieldUpdater<AggregateFutureState<?>, @Nullable Set<Throwable>>)
seenExceptionsUpdater;
this.remainingCountUpdater =
(AtomicIntegerFieldUpdater<AggregateFutureState<?>>) remainingCountUpdater;
diff --git a/android/guava/src/com/google/common/util/concurrent/ClosingFuture.java b/android/guava/src/com/google/common/util/concurrent/ClosingFuture.java
index 43157c7a4..c43074b3c 100644
--- a/android/guava/src/com/google/common/util/concurrent/ClosingFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/ClosingFuture.java
@@ -32,6 +32,7 @@ import static com.google.common.util.concurrent.Futures.getDone;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static com.google.common.util.concurrent.Futures.nonCancellationPropagating;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
+import static com.google.common.util.concurrent.Platform.restoreInterruptIfIsInterruptedException;
import static java.util.logging.Level.FINER;
import static java.util.logging.Level.SEVERE;
import static java.util.logging.Level.WARNING;
@@ -47,7 +48,6 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotMock;
import com.google.j2objc.annotations.RetainedWith;
import java.io.Closeable;
-import java.io.IOException;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.concurrent.Callable;
@@ -58,7 +58,6 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -196,7 +195,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
// TODO(dpb): GWT compatibility.
public final class ClosingFuture<V extends @Nullable Object> {
- private static final Logger logger = Logger.getLogger(ClosingFuture.class.getName());
+ private static final LazyLogger logger = new LazyLogger(ClosingFuture.class);
/**
* An object that can capture objects to be closed later, when a {@link ClosingFuture} pipeline is
@@ -678,7 +677,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
*
* <p>After calling this method, you may not call {@link #finishToFuture()}, {@link
* #finishToValueAndCloser(ValueAndCloserConsumer, Executor)}, or any other derivation method on
- * this {@code ClosingFuture}.
+ * the original {@code ClosingFuture} instance.
*
* @param function transforms the value of this step to the value of the derived step
* @param executor executor to run the function in
@@ -771,7 +770,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
*
* <p>After calling this method, you may not call {@link #finishToFuture()}, {@link
* #finishToValueAndCloser(ValueAndCloserConsumer, Executor)}, or any other derivation method on
- * this {@code ClosingFuture}.
+ * the original {@code ClosingFuture} instance.
*
* @param function transforms the value of this step to a {@code ClosingFuture} with the value of
* the derived step
@@ -862,7 +861,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
*
* <p>After calling this method, you may not call {@link #finishToFuture()}, {@link
* #finishToValueAndCloser(ValueAndCloserConsumer, Executor)}, or any other derivation method on
- * this {@code ClosingFuture}.
+ * the original {@code ClosingFuture} instance.
*
* @param exceptionType the exception type that triggers use of {@code fallback}. The exception
* type is matched against this step's exception. "This step's exception" means the cause of
@@ -955,7 +954,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
*
* <p>After calling this method, you may not call {@link #finishToFuture()}, {@link
* #finishToValueAndCloser(ValueAndCloserConsumer, Executor)}, or any other derivation method on
- * this {@code ClosingFuture}.
+ * the original {@code ClosingFuture} instance.
*
* @param exceptionType the exception type that triggers use of {@code fallback}. The exception
* type is matched against this step's exception. "This step's exception" means the cause of
@@ -1012,13 +1011,13 @@ public final class ClosingFuture<V extends @Nullable Object> {
*
* <p>After calling this method, you may not call {@link
* #finishToValueAndCloser(ValueAndCloserConsumer, Executor)}, this method, or any other
- * derivation method on this {@code ClosingFuture}.
+ * derivation method on the original {@code ClosingFuture} instance.
*
* @return a {@link Future} that represents the final value or exception of the pipeline
*/
public FluentFuture<V> finishToFuture() {
if (compareAndUpdateState(OPEN, WILL_CLOSE)) {
- logger.log(FINER, "will close {0}", this);
+ logger.get().log(FINER, "will close {0}", this);
future.addListener(
new Runnable() {
@Override
@@ -1057,7 +1056,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
* receiver can store the {@link ValueAndCloser} outside the receiver for later synchronous use.
*
* <p>After calling this method, you may not call {@link #finishToFuture()}, this method again, or
- * any other derivation method on this {@code ClosingFuture}.
+ * any other derivation method on the original {@code ClosingFuture} instance.
*
* @param consumer a callback whose method will be called (using {@code executor}) when this
* operation is done
@@ -1118,7 +1117,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
*/
@CanIgnoreReturnValue
public boolean cancel(boolean mayInterruptIfRunning) {
- logger.log(FINER, "cancelling {0}", this);
+ logger.get().log(FINER, "cancelling {0}", this);
boolean cancelled = future.cancel(mayInterruptIfRunning);
if (cancelled) {
close();
@@ -1127,7 +1126,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
}
private void close() {
- logger.log(FINER, "closing {0}", this);
+ logger.get().log(FINER, "closing {0}", this);
closeables.close();
}
@@ -2131,7 +2130,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
@Override
protected void finalize() {
if (state.get().equals(OPEN)) {
- logger.log(SEVERE, "Uh oh! An open ClosingFuture has leaked and will close: {0}", this);
+ logger.get().log(SEVERE, "Uh oh! An open ClosingFuture has leaked and will close: {0}", this);
FluentFuture<V> unused = finishToFuture();
}
}
@@ -2145,14 +2144,27 @@ public final class ClosingFuture<V extends @Nullable Object> {
() -> {
try {
closeable.close();
- } catch (IOException | RuntimeException e) {
- logger.log(WARNING, "thrown by close()", e);
+ } catch (Exception e) {
+ /*
+ * In guava-jre, any kind of Exception may be thrown because `closeable` has type
+ * `AutoCloseable`.
+ *
+ * In guava-android, the only kinds of Exception that may be thrown are
+ * RuntimeException and IOException because `closeable` has type `Closeable`—except
+ * that we have to account for sneaky checked exception.
+ */
+ restoreInterruptIfIsInterruptedException(e);
+ logger.get().log(WARNING, "thrown by close()", e);
}
});
} catch (RejectedExecutionException e) {
- if (logger.isLoggable(WARNING)) {
- logger.log(
- WARNING, String.format("while submitting close to %s; will close inline", executor), e);
+ if (logger.get().isLoggable(WARNING)) {
+ logger
+ .get()
+ .log(
+ WARNING,
+ String.format("while submitting close to %s; will close inline", executor),
+ e);
}
closeQuietly(closeable, directExecutor());
}
diff --git a/android/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java b/android/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java
index 0ec799cc4..6e2ae47a3 100644
--- a/android/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java
+++ b/android/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java
@@ -41,7 +41,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
/**
@@ -211,7 +210,7 @@ public class CycleDetectingLockFactory {
WARN {
@Override
public void handlePotentialDeadlock(PotentialDeadlockException e) {
- logger.log(Level.SEVERE, "Detected potential deadlock", e);
+ logger.get().log(Level.SEVERE, "Detected potential deadlock", e);
}
},
@@ -447,7 +446,7 @@ public class CycleDetectingLockFactory {
//////// Implementation /////////
- private static final Logger logger = Logger.getLogger(CycleDetectingLockFactory.class.getName());
+ private static final LazyLogger logger = new LazyLogger(CycleDetectingLockFactory.class);
final Policy policy;
@@ -711,7 +710,8 @@ public class CycleDetectingLockFactory {
*/
private void aboutToAcquire(CycleDetectingLock lock) {
if (!lock.isAcquiredByCurrentThread()) {
- ArrayList<LockGraphNode> acquiredLockList = acquiredLocks.get();
+ // requireNonNull accommodates Android's @RecentlyNullable annotation on ThreadLocal.get
+ ArrayList<LockGraphNode> acquiredLockList = requireNonNull(acquiredLocks.get());
LockGraphNode node = lock.getLockGraphNode();
node.checkAcquiredLocks(policy, acquiredLockList);
acquiredLockList.add(node);
@@ -725,7 +725,8 @@ public class CycleDetectingLockFactory {
*/
private static void lockStateChanged(CycleDetectingLock lock) {
if (!lock.isAcquiredByCurrentThread()) {
- ArrayList<LockGraphNode> acquiredLockList = acquiredLocks.get();
+ // requireNonNull accommodates Android's @RecentlyNullable annotation on ThreadLocal.get
+ ArrayList<LockGraphNode> acquiredLockList = requireNonNull(acquiredLocks.get());
LockGraphNode node = lock.getLockGraphNode();
// Iterate in reverse because locks are usually locked/unlocked in a
// LIFO order.
diff --git a/android/guava/src/com/google/common/util/concurrent/ExecutionList.java b/android/guava/src/com/google/common/util/concurrent/ExecutionList.java
index 645817c4a..10b933aa1 100644
--- a/android/guava/src/com/google/common/util/concurrent/ExecutionList.java
+++ b/android/guava/src/com/google/common/util/concurrent/ExecutionList.java
@@ -21,7 +21,6 @@ import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.concurrent.GuardedBy;
import java.util.concurrent.Executor;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
/**
@@ -45,7 +44,7 @@ import javax.annotation.CheckForNull;
@ElementTypesAreNonnullByDefault
public final class ExecutionList {
/** Logger to log exceptions caught when running runnables. */
- private static final Logger log = Logger.getLogger(ExecutionList.class.getName());
+ private static final LazyLogger log = new LazyLogger(ExecutionList.class);
/**
* The runnable, executor pairs to execute. This acts as a stack threaded through the {@link
@@ -140,17 +139,22 @@ public final class ExecutionList {
* Submits the given runnable to the given {@link Executor} catching and logging all {@linkplain
* RuntimeException runtime exceptions} thrown by the executor.
*/
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private static void executeListener(Runnable runnable, Executor executor) {
try {
executor.execute(runnable);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// Log it and keep going -- bad runnable and/or executor. Don't punish the other runnables if
// we're given a bad one. We only catch RuntimeException because we want Errors to propagate
// up.
- log.log(
- Level.SEVERE,
- "RuntimeException while executing runnable " + runnable + " with executor " + executor,
- e);
+ log.get()
+ .log(
+ Level.SEVERE,
+ "RuntimeException while executing runnable "
+ + runnable
+ + " with executor "
+ + executor,
+ e);
}
}
diff --git a/android/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java b/android/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
index 1c16cfb14..0f8a17894 100644
--- a/android/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
+++ b/android/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
@@ -77,12 +77,13 @@ public final class FakeTimeLimiter implements TimeLimiter {
}
@Override
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public void runWithTimeout(Runnable runnable, long timeoutDuration, TimeUnit timeoutUnit) {
checkNotNull(runnable);
checkNotNull(timeoutUnit);
try {
runnable.run();
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
throw new UncheckedExecutionException(e);
} catch (Error e) {
throw new ExecutionError(e);
diff --git a/android/guava/src/com/google/common/util/concurrent/Futures.java b/android/guava/src/com/google/common/util/concurrent/Futures.java
index 39b6dfeb7..5715f0a9f 100644
--- a/android/guava/src/com/google/common/util/concurrent/Futures.java
+++ b/android/guava/src/com/google/common/util/concurrent/Futures.java
@@ -510,7 +510,8 @@ public final class Futures extends GwtFuturesCatchingSpecialization {
private O applyTransformation(I input) throws ExecutionException {
try {
return function.apply(input);
- } catch (RuntimeException | Error t) {
+ } catch (Throwable t) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
throw new ExecutionException(t);
}
}
@@ -1091,7 +1092,8 @@ public final class Futures extends GwtFuturesCatchingSpecialization {
} catch (ExecutionException e) {
callback.onFailure(e.getCause());
return;
- } catch (RuntimeException | Error e) {
+ } catch (Throwable e) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
callback.onFailure(e);
return;
}
@@ -1167,10 +1169,10 @@ public final class Futures extends GwtFuturesCatchingSpecialization {
*
* <p>Instances of {@code exceptionClass} are created by choosing an arbitrary public constructor
* that accepts zero or more arguments, all of type {@code String} or {@code Throwable}
- * (preferring constructors with at least one {@code String}) and calling the constructor via
- * reflection. If the exception did not already have a cause, one is set by calling {@link
- * Throwable#initCause(Throwable)} on it. If no such constructor exists, an {@code
- * IllegalArgumentException} is thrown.
+ * (preferring constructors with at least one {@code String}, then preferring constructors with at
+ * least one {@code Throwable}) and calling the constructor via reflection. If the exception did
+ * not already have a cause, one is set by calling {@link Throwable#initCause(Throwable)} on it.
+ * If no such constructor exists, an {@code IllegalArgumentException} is thrown.
*
* @throws X if {@code get} throws any checked exception except for an {@code ExecutionException}
* whose cause is not itself a checked exception
@@ -1219,10 +1221,10 @@ public final class Futures extends GwtFuturesCatchingSpecialization {
*
* <p>Instances of {@code exceptionClass} are created by choosing an arbitrary public constructor
* that accepts zero or more arguments, all of type {@code String} or {@code Throwable}
- * (preferring constructors with at least one {@code String}) and calling the constructor via
- * reflection. If the exception did not already have a cause, one is set by calling {@link
- * Throwable#initCause(Throwable)} on it. If no such constructor exists, an {@code
- * IllegalArgumentException} is thrown.
+ * (preferring constructors with at least one {@code String}, then preferring constructors with at
+ * least one {@code Throwable}) and calling the constructor via reflection. If the exception did
+ * not already have a cause, one is set by calling {@link Throwable#initCause(Throwable)} on it.
+ * If no such constructor exists, an {@code IllegalArgumentException} is thrown.
*
* @throws X if {@code get} throws any checked exception except for an {@code ExecutionException}
* whose cause is not itself a checked exception
diff --git a/android/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java b/android/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java
index 9be9e21e8..0a4e7bd43 100644
--- a/android/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java
+++ b/android/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java
@@ -21,7 +21,6 @@ import static java.util.Arrays.asList;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
import com.google.common.collect.Ordering;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.lang.ref.WeakReference;
@@ -184,7 +183,7 @@ final class FuturesGetChecked {
try {
Exception unused = newWithCause(exceptionClass, new Exception());
return true;
- } catch (RuntimeException | Error e) {
+ } catch (Throwable t) { // sneaky checked exception
return false;
}
}
@@ -193,7 +192,7 @@ final class FuturesGetChecked {
// getConstructors() guarantees this as long as we don't modify the array.
@SuppressWarnings({"unchecked", "rawtypes"})
List<Constructor<X>> constructors = (List) Arrays.asList(exceptionClass.getConstructors());
- for (Constructor<X> constructor : preferringStrings(constructors)) {
+ for (Constructor<X> constructor : preferringStringsThenThrowables(constructors)) {
X instance = newFromConstructor(constructor, cause);
if (instance != null) {
if (instance.getCause() == null) {
@@ -209,17 +208,22 @@ final class FuturesGetChecked {
cause);
}
- private static <X extends Exception> List<Constructor<X>> preferringStrings(
+ private static <X extends Exception> List<Constructor<X>> preferringStringsThenThrowables(
List<Constructor<X>> constructors) {
- return WITH_STRING_PARAM_FIRST.sortedCopy(constructors);
+ return WITH_STRING_PARAM_THEN_WITH_THROWABLE_PARAM.sortedCopy(constructors);
}
- private static final Ordering<Constructor<?>> WITH_STRING_PARAM_FIRST =
+ // TODO: b/296487962 - Consider defining a total order over constructors.
+ private static final Ordering<List<Class<?>>> ORDERING_BY_CONSTRUCTOR_PARAMETER_LIST =
Ordering.natural()
- .onResultOf(
- (Function<Constructor<?>, Boolean>)
- input -> asList(input.getParameterTypes()).contains(String.class))
+ .onResultOf((List<Class<?>> params) -> params.contains(String.class))
+ .compound(
+ Ordering.natural()
+ .onResultOf((List<Class<?>> params) -> params.contains(Throwable.class)))
.reverse();
+ private static final Ordering<Constructor<?>> WITH_STRING_PARAM_THEN_WITH_THROWABLE_PARAM =
+ ORDERING_BY_CONSTRUCTOR_PARAMETER_LIST.onResultOf(
+ constructor -> asList(constructor.getParameterTypes()));
@CheckForNull
private static <X> X newFromConstructor(Constructor<X> constructor, Throwable cause) {
diff --git a/android/guava/src/com/google/common/util/concurrent/ImmediateFuture.java b/android/guava/src/com/google/common/util/concurrent/ImmediateFuture.java
index f09816c4e..62ae63eaa 100644
--- a/android/guava/src/com/google/common/util/concurrent/ImmediateFuture.java
+++ b/android/guava/src/com/google/common/util/concurrent/ImmediateFuture.java
@@ -22,7 +22,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -33,7 +32,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
class ImmediateFuture<V extends @Nullable Object> implements ListenableFuture<V> {
static final ListenableFuture<?> NULL = new ImmediateFuture<@Nullable Object>(null);
- private static final Logger log = Logger.getLogger(ImmediateFuture.class.getName());
+ private static final LazyLogger log = new LazyLogger(ImmediateFuture.class);
@ParametricNullness private final V value;
@@ -42,18 +41,23 @@ class ImmediateFuture<V extends @Nullable Object> implements ListenableFuture<V>
}
@Override
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public void addListener(Runnable listener, Executor executor) {
checkNotNull(listener, "Runnable was null.");
checkNotNull(executor, "Executor was null.");
try {
executor.execute(listener);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// ListenableFuture's contract is that it will not throw unchecked exceptions, so log the bad
// runnable and/or executor and swallow it.
- log.log(
- Level.SEVERE,
- "RuntimeException while executing runnable " + listener + " with executor " + executor,
- e);
+ log.get()
+ .log(
+ Level.SEVERE,
+ "RuntimeException while executing runnable "
+ + listener
+ + " with executor "
+ + executor,
+ e);
}
}
diff --git a/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java b/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java
index 6f33c5032..effa8ef59 100644
--- a/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java
+++ b/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java
@@ -23,6 +23,7 @@ import com.google.j2objc.annotations.ReflectionSupport;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.AbstractOwnableSynchronizer;
import java.util.concurrent.locks.LockSupport;
+import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@GwtCompatible(emulated = true)
@@ -234,6 +235,7 @@ abstract class InterruptibleTask<T extends @Nullable Object>
}
@VisibleForTesting
+ @CheckForNull
Thread getOwner() {
return super.getExclusiveOwnerThread();
}
diff --git a/android/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java b/android/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java
index 33403c978..eb3a24707 100644
--- a/android/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java
+++ b/android/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java
@@ -19,7 +19,6 @@ import static com.google.common.util.concurrent.Uninterruptibles.getUninterrupti
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -162,10 +161,11 @@ public final class JdkFutureAdapters {
* to return a proper ListenableFuture instead of using listenInPoolThread.
*/
getUninterruptibly(delegate);
- } catch (ExecutionException | RuntimeException | Error e) {
- // (including CancellationException)
+ } catch (Throwable t) {
+ // (including CancellationException and sneaky checked exception)
// The task is presumably done, run the listeners.
- // TODO(cpovirk): Do *something* in case of Error (and maybe RuntimeException)?
+ // TODO(cpovirk): Do *something* in case of Error (and maybe
+ // non-CancellationException, non-ExecutionException exceptions)?
}
executionList.execute();
});
diff --git a/android/guava/src/com/google/common/util/concurrent/LazyLogger.java b/android/guava/src/com/google/common/util/concurrent/LazyLogger.java
new file mode 100644
index 000000000..9ae0f784e
--- /dev/null
+++ b/android/guava/src/com/google/common/util/concurrent/LazyLogger.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2023 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.common.util.concurrent;
+
+import com.google.common.annotations.GwtCompatible;
+import java.util.logging.Logger;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/** A holder for a {@link Logger} that is initialized only when requested. */
+@GwtCompatible
+@ElementTypesAreNonnullByDefault
+final class LazyLogger {
+ private final String loggerName;
+ private volatile @Nullable Logger logger;
+
+ LazyLogger(Class<?> ownerOfLogger) {
+ this.loggerName = ownerOfLogger.getName();
+ }
+
+ Logger get() {
+ /*
+ * We use double-checked locking. We could the try racy single-check idiom, but that would
+ * depend on Logger not contain mutable state.
+ *
+ * We could use Suppliers.memoizingSupplier here, but I micro-optimized to this implementation
+ * to avoid the extra class for the lambda (and maybe more for memoizingSupplier itself) and the
+ * indirection.
+ *
+ * One thing to *avoid* is a change to make each Logger user use memoizingSupplier directly:
+ * That may introduce an extra class for each lambda (currently a dozen).
+ */
+ Logger local = logger;
+ if (local != null) {
+ return local;
+ }
+ synchronized (this) {
+ local = logger;
+ if (local != null) {
+ return local;
+ }
+ return logger = Logger.getLogger(loggerName);
+ }
+ }
+}
diff --git a/android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java b/android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
index 4ef7ed36c..e6284e1c7 100644
--- a/android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
+++ b/android/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
@@ -27,7 +27,6 @@ import java.util.List;
import java.util.Queue;
import java.util.concurrent.Executor;
import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* A list of listeners for implementing a concurrency friendly observable object.
@@ -58,7 +57,7 @@ import java.util.logging.Logger;
@ElementTypesAreNonnullByDefault
final class ListenerCallQueue<L> {
// TODO(cpovirk): consider using the logger associated with listener.getClass().
- private static final Logger logger = Logger.getLogger(ListenerCallQueue.class.getName());
+ private static final LazyLogger logger = new LazyLogger(ListenerCallQueue.class);
// TODO(chrisn): promote AppendOnlyCollection for use here.
private final List<PerListenerQueue<L>> listeners =
@@ -159,6 +158,7 @@ final class ListenerCallQueue<L> {
* Dispatches all listeners {@linkplain #enqueue enqueued} prior to this call, serially and in
* order.
*/
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
void dispatch() {
boolean scheduleEventRunner = false;
synchronized (this) {
@@ -170,22 +170,25 @@ final class ListenerCallQueue<L> {
if (scheduleEventRunner) {
try {
executor.execute(this);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// reset state in case of an error so that later dispatch calls will actually do something
synchronized (this) {
isThreadScheduled = false;
}
// Log it and keep going.
- logger.log(
- Level.SEVERE,
- "Exception while running callbacks for " + listener + " on " + executor,
- e);
+ logger
+ .get()
+ .log(
+ Level.SEVERE,
+ "Exception while running callbacks for " + listener + " on " + executor,
+ e);
throw e;
}
}
}
@Override
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public void run() {
boolean stillRunning = true;
try {
@@ -206,12 +209,14 @@ final class ListenerCallQueue<L> {
// Always run while _not_ holding the lock, to avoid deadlocks.
try {
nextToRun.call(listener);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// Log it and keep going.
- logger.log(
- Level.SEVERE,
- "Exception while executing callback: " + listener + " " + nextLabel,
- e);
+ logger
+ .get()
+ .log(
+ Level.SEVERE,
+ "Exception while executing callback: " + listener + " " + nextLabel,
+ e);
}
}
} finally {
diff --git a/android/guava/src/com/google/common/util/concurrent/Monitor.java b/android/guava/src/com/google/common/util/concurrent/Monitor.java
index 5542b0bd5..8ba45d49f 100644
--- a/android/guava/src/com/google/common/util/concurrent/Monitor.java
+++ b/android/guava/src/com/google/common/util/concurrent/Monitor.java
@@ -1013,7 +1013,8 @@ public final class Monitor {
private boolean isSatisfied(Guard guard) {
try {
return guard.isSatisfied();
- } catch (RuntimeException | Error throwable) {
+ } catch (Throwable throwable) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
signalAllWaiters();
throw throwable;
}
diff --git a/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java b/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java
index dba374014..cbf051e72 100644
--- a/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java
+++ b/android/guava/src/com/google/common/util/concurrent/MoreExecutors.java
@@ -678,7 +678,8 @@ public final class MoreExecutors {
public void run() {
try {
delegate.run();
- } catch (RuntimeException | Error t) {
+ } catch (Throwable t) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
setException(t);
throw t;
}
@@ -706,7 +707,10 @@ public final class MoreExecutors {
* An implementation of {@link ExecutorService#invokeAny} for {@link ListeningExecutorService}
* implementations.
*/
- @SuppressWarnings("GoodTime") // should accept a java.time.Duration
+ @SuppressWarnings({
+ "GoodTime", // should accept a java.time.Duration
+ "CatchingUnchecked", // sneaky checked exception
+ })
@J2ktIncompatible
@GwtIncompatible
@ParametricNullness
@@ -769,7 +773,9 @@ public final class MoreExecutors {
return f.get();
} catch (ExecutionException eex) {
ee = eex;
- } catch (RuntimeException rex) {
+ } catch (InterruptedException iex) {
+ throw iex;
+ } catch (Exception rex) { // sneaky checked exception
ee = new ExecutionException(rex);
}
}
diff --git a/android/guava/src/com/google/common/util/concurrent/SequentialExecutor.java b/android/guava/src/com/google/common/util/concurrent/SequentialExecutor.java
index c842d7e07..ebc33178d 100644
--- a/android/guava/src/com/google/common/util/concurrent/SequentialExecutor.java
+++ b/android/guava/src/com/google/common/util/concurrent/SequentialExecutor.java
@@ -31,7 +31,6 @@ import java.util.Deque;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
/**
@@ -52,7 +51,7 @@ import javax.annotation.CheckForNull;
@GwtIncompatible
@ElementTypesAreNonnullByDefault
final class SequentialExecutor implements Executor {
- private static final Logger log = Logger.getLogger(SequentialExecutor.class.getName());
+ private static final LazyLogger log = new LazyLogger(SequentialExecutor.class);
enum WorkerRunningState {
/** Runnable is not running and not queued for execution */
@@ -136,7 +135,8 @@ final class SequentialExecutor implements Executor {
try {
executor.execute(worker);
- } catch (RuntimeException | Error t) {
+ } catch (Throwable t) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
synchronized (queue) {
boolean removed =
(workerRunningState == IDLE || workerRunningState == QUEUING)
@@ -202,6 +202,7 @@ final class SequentialExecutor implements Executor {
* will still be present. If the composed Executor is an ExecutorService, it can respond to
* shutdown() by returning tasks queued on that Thread after {@link #worker} drains the queue.
*/
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private void workOnQueue() {
boolean interruptedDuringTask = false;
boolean hasSetRunning = false;
@@ -235,8 +236,8 @@ final class SequentialExecutor implements Executor {
interruptedDuringTask |= Thread.interrupted();
try {
task.run();
- } catch (RuntimeException e) {
- log.log(Level.SEVERE, "Exception while executing runnable " + task, e);
+ } catch (Exception e) { // sneaky checked exception
+ log.get().log(Level.SEVERE, "Exception while executing runnable " + task, e);
} finally {
task = null;
}
diff --git a/android/guava/src/com/google/common/util/concurrent/ServiceManager.java b/android/guava/src/com/google/common/util/concurrent/ServiceManager.java
index dd4828cb8..38727f504 100644
--- a/android/guava/src/com/google/common/util/concurrent/ServiceManager.java
+++ b/android/guava/src/com/google/common/util/concurrent/ServiceManager.java
@@ -62,7 +62,6 @@ import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* A manager for monitoring and controlling a set of {@linkplain Service services}. This class
@@ -122,7 +121,7 @@ import java.util.logging.Logger;
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ServiceManager implements ServiceManagerBridge {
- private static final Logger logger = Logger.getLogger(ServiceManager.class.getName());
+ private static final LazyLogger logger = new LazyLogger(ServiceManager.class);
private static final ListenerCallQueue.Event<Listener> HEALTHY_EVENT =
new ListenerCallQueue.Event<Listener>() {
@Override
@@ -205,10 +204,13 @@ public final class ServiceManager implements ServiceManagerBridge {
if (copy.isEmpty()) {
// Having no services causes the manager to behave strangely. Notably, listeners are never
// fired. To avoid this we substitute a placeholder service.
- logger.log(
- Level.WARNING,
- "ServiceManager configured with no services. Is your application configured properly?",
- new EmptyServiceManagerWarning());
+ logger
+ .get()
+ .log(
+ Level.WARNING,
+ "ServiceManager configured with no services. Is your application configured"
+ + " properly?",
+ new EmptyServiceManagerWarning());
copy = ImmutableList.<Service>of(new NoOpService());
}
this.state = new ServiceManagerState(copy);
@@ -275,7 +277,7 @@ public final class ServiceManager implements ServiceManagerBridge {
// service or listener). Our contract says it is safe to call this method if
// all services were NEW when it was called, and this has already been verified above, so we
// don't propagate the exception.
- logger.log(Level.WARNING, "Unable to start Service " + service, e);
+ logger.get().log(Level.WARNING, "Unable to start Service " + service, e);
}
}
return this;
@@ -661,7 +663,7 @@ public final class ServiceManager implements ServiceManagerBridge {
// N.B. if we miss the STARTING event then we may never record a startup time.
stopwatch.stop();
if (!(service instanceof NoOpService)) {
- logger.log(Level.FINE, "Started {0} in {1}.", new Object[] {service, stopwatch});
+ logger.get().log(Level.FINE, "Started {0} in {1}.", new Object[] {service, stopwatch});
}
}
// Queue our listeners
@@ -750,7 +752,7 @@ public final class ServiceManager implements ServiceManagerBridge {
if (state != null) {
state.transitionService(service, NEW, STARTING);
if (!(service instanceof NoOpService)) {
- logger.log(Level.FINE, "Starting {0}.", service);
+ logger.get().log(Level.FINE, "Starting {0}.", service);
}
}
}
@@ -776,10 +778,12 @@ public final class ServiceManager implements ServiceManagerBridge {
ServiceManagerState state = this.state.get();
if (state != null) {
if (!(service instanceof NoOpService)) {
- logger.log(
- Level.FINE,
- "Service {0} has terminated. Previous state was: {1}",
- new Object[] {service, from});
+ logger
+ .get()
+ .log(
+ Level.FINE,
+ "Service {0} has terminated. Previous state was: {1}",
+ new Object[] {service, from});
}
state.transitionService(service, from, TERMINATED);
}
@@ -793,10 +797,12 @@ public final class ServiceManager implements ServiceManagerBridge {
// there is a higher likelihood that the cause will be in the logs.
boolean log = !(service instanceof NoOpService);
if (log) {
- logger.log(
- Level.SEVERE,
- "Service " + service + " has failed in the " + from + " state.",
- failure);
+ logger
+ .get()
+ .log(
+ Level.SEVERE,
+ "Service " + service + " has failed in the " + from + " state.",
+ failure);
}
state.transitionService(service, from, FAILED);
}
diff --git a/android/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java b/android/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java
index 1dc1094d4..9890c89d6 100644
--- a/android/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java
+++ b/android/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java
@@ -21,7 +21,6 @@ import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.Locale;
-import java.util.logging.Logger;
/**
* Factories for {@link UncaughtExceptionHandler} instances.
@@ -57,7 +56,7 @@ public final class UncaughtExceptionHandlers {
@VisibleForTesting
static final class Exiter implements UncaughtExceptionHandler {
- private static final Logger logger = Logger.getLogger(Exiter.class.getName());
+ private static final LazyLogger logger = new LazyLogger(Exiter.class);
private final Runtime runtime;
@@ -68,9 +67,13 @@ public final class UncaughtExceptionHandlers {
@Override
public void uncaughtException(Thread t, Throwable e) {
try {
- logger.log(
- SEVERE, String.format(Locale.ROOT, "Caught an exception in %s. Shutting down.", t), e);
- } catch (RuntimeException | Error errorInLogging) {
+ logger
+ .get()
+ .log(
+ SEVERE,
+ String.format(Locale.ROOT, "Caught an exception in %s. Shutting down.", t),
+ e);
+ } catch (Throwable errorInLogging) { // sneaky checked exception
// If logging fails, e.g. due to missing memory, at least try to log the
// message and the cause for the failed logging.
System.err.println(e.getMessage());
diff --git a/android/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java b/android/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java
index e728822a8..fd176780e 100644
--- a/android/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java
+++ b/android/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java
@@ -42,13 +42,13 @@ public final class PublicSuffixPatterns {
/** If a hostname is contained as a key in this map, it is a public suffix. */
public static final ImmutableMap<String, PublicSuffixType> EXACT =
TrieParser.parseTrie(
- "a&0&0trk9--nx?27qjf--nx?e9ebgn--nx?nbb0c7abgm--nx??1&2oa08--nx?apg6qpcbgm--nx?hbbgm--nx?rdceqa08--nx??2&8ugbgm--nx?eyh3la2ckx--nx?qbd9--nx??3&2wqq1--nx?60a0y8--nx??4x1d77xrck--nx?6&1f4a3abgm--nx?2yqyn--nx?5b06t--nx?axq--nx?ec7q--nx?lbgw--nx??883xnn--nx?9d2c24--nx?a&a?it??b!.&gro?lim?moc?sr,t&en?opsgolb,?ude?vog??abila?c?ihsot?m?n??c!.&b&a?m?n??c&b?g?q??ep?fn?k&s?y??ln?no?oc,p&i-on,ohsdaerpsym,?sn?t&n?opsgolb,?un?ysrab,?i&ma?r&emarp?fa??sroc??naiva?s??d&ats?n&eit?oh??om?sa?tl??eg?f&c?ob??g!emo?naripi?oy??hskihs?i&dem!.remarf,?hs?k!on??sa!.snduolc,??jnin?k&aso?dov?ede?usto??l!.&c,gro?moc?ofni?r&ep?nb,?t&en?ni??ude?vog??irgnahs?le&nisiuc?rbmuder???m!.&ca?gro?oc?sserp?ten?vog??ahokoy?e00sf7vqn--nx?m??n!.&ac?cc?eman?gro?ibom?loohcs?moc?ni?o&c?fni?rp??r&d?o??s&u?w??vt?xm??av?is?olecrab?tea??p!.&bog?ca?d&em?ls??g&ni?ro??mo&c?n??oba?ten?ude??c?g7hyabgm--nx?ra!.&461e?6pi?iru?nru?rdda-ni?siri???s??q!.&eman?gro?hcs?lim?moc?t&en?opsgolb,?ude?vog???r&az?emac?f4a3abgm--nx?n!d5uhf8le58r4w--nx??u&kas?tan???s!.&bup?dem?gro?hcs?moc?ten?ude?vog??ac!.uban.iu,?iv??t&ad?elhta?led?oyot??u!.&a&cinniv?emirc?i&hzhziropaz?stynniv??s&edo?sedo??tlay?vatlop??bs?cc,d&argovorik?o!roghzu??tl,?e&hzhziropaz?i,nvir?t??f&i?ni,?g&l?ro??hk?i&stvinrehc?ykstyn&lemhk?vypork???k&c?m?s&nagul?t&enod?ul??v&iknarf-onavi?orteporp&end?ind?????l&iponret?opotsa&bes?ves??p??m&k?oc?s?yrk??n&c?d?i?osrehk?v?ylov??o&c,nvor??p&d?p,z??r&c?imotihz?k?ymotyhz??sk?t&en?l?z??ude?v:c?e&alokin?ik??i&alokym?hinrehc?krahk?vl?yk??k?l?o&g!inrehc??krahk??r?,xc,y&ikstinlemhk?mus?s&akrehc?sakrehc?tvonrehc???z&ib,u????v!aj?bb?et?iv??waniko?x&a?iacal??yogan?z&.&bew?c&a?i&n?rga???gro?l&im?oohcs??m&on?t??o&c!.topsgolb,?gn??radnorg?sin?t&en?la??ude?vog?wal??zip!.korgn,???b&00ave5a9iabgm--nx?1&25qhx--nx?68quv--nx?e2kc1--nx??2xtbgm--nx?3&b2kcc--nx?jca1d--nx??4&6&1rfz--nx?qif--nx??96rzc--nx??88uvor--nx?a&0dc4xbgm--nx?c?her?n?ra?t??b!.&erots?gro?moc?o&c?fni??ten?ude?v&og?t??zib??a??c&j?s??d&hesa08--nx?mi??g?l!.&gro?moc?ten?ude?vog??m??s!.&gro?moc?ten?ude?vog???tc-retarebsnegmrev--nx?u&lc!.&elej,snduolc,ysrab,?smas??p!.ysrab,??wp-gnutarebsnegmrev--nx??c&1&1q54--nx?hbgw--nx??2e9c2czf--nx?4&4ub1km--nx?a1e--nx?byj9q--nx?erd5a9b1kcb--nx??8&4xx2g--nx?c9jrb2h--nx??9jr&b&2h--nx?54--nx?9s--nx??c&eg--nx?h3--nx?s2--nx???a!.&gro?lim?moc?rrd,ten?ude?vog??3a09--nx!.&ca1o--nx?gva1c--nx?h&ca1o--nx?za09--nx??ta1d--nx?ua08--nx????b&a?b?ci?f76a0c7ylqbgm--nx?sh??c!.&eugaelysatnaf,gnipparcs,liamwt,nwaps.secnatsni,revres-emag,s&nduolc,otohpym,seccaptf,?xsc,?0atf7b45--nx?a1l--nx??e!.&21k?bog?dem?esab,gro?l&aiciffo,im??moc?nif?o&fni?rp??ten?ude?vog??beuq?n?smoc??fdh?i&l&buperananab?ohtac??n&agro?ilc?osanap??sum?tic??l!.&gro?moc?oc?ten?ude?vog?yo,?l??m!.&mt?ossa??p1akcq--nx??n!.&mon?ossa??i?p??relcel?s!.&gro?moc?ten?ude?vog???t!.&e&m,w,?hc,?s?w??v!.&e0,gro?lim?moc?ten?ude?v&g:.d,,og????wp?yn??d&2urzc--nx?3&1wrpk--nx?c&4b11--nx?9jrcpf--nx???5xq55--nx?697uto--nx?75yrpk--nx?9ctdvkce--nx?a!.mon?d?er?olnwod??b2babgm--nx?c!.vog?g9a2g2b0ae0chclc--nx??e&m!bulc??r!k??sopxe?timil?w??fc?g!.&ude?vog???h&d3tbgm--nx?p?t??i!.&ased?bew?ca?etrof,hcs?lim?o&c!.topsgolb,?g??palf,ro?sepnop?ten?ym?zib??b?ordna?p?rdam??l&iub?og?row??m!.&ed,ot,pj,t&a,opsgolb,???n&a&b?l!.citats:.&setis,ved,?,raas???ob?uf??o&of?rp??r&a&c&tiderc?yalcrab??ugnav??ef506w4b--nx?k!.&oc,ude,?jh3a1habgm--nx??of??s!.&dem?gro?moc?ofni?ten?ude?v&og?t???m!kcrem???t!.topsgolb,excwkcc--nx?l??uolc!.&a&bura-vnej.&1ti,abura.rue.1ti,?tcepsrep,xo:.&ku,nt,?,?b&dnevar,ewilek:.sc,,?citsalej.piv,drayknil,elej,gnitsohdnert.&ed,hc,?letemirp:.ku,,m&edaid,ialcer.&ac,ku,su,??n&evueluk,woru,?r&epolroov,o&pav,tnemele,??tenraxa.1-se,ululetoj,wcs.&gnilebaltrams,koobelacs,latemerab.&1-&rap-rf,sma-ln,?2-rap-rf,?rap-rf.&3s,cnf:.snoitcnuf,,etisbew-3s,mhw,s8k:.sedon,,?s&8k,ecnatsni.&bup,virp,?ma-ln.&3s,etisbew-3s,mhw,s8k:.sedon,,??waw-lp.&3s,etisbew-3s,s8k:.sedon,,??xelpciffart,yawocne.ue,??za5cbgn--nx??e&1&53wlf--nx?7a1hbbgm--nx?ta3kg--nx??2a6a1b6b1i--nx?3ma0e1cvr--nx?418txh--nx?707b0e3--nx?a!.&ca?gro?hcs?lim?oc?t&en?opsgolb,?vog??09--nx??b!.&ca?etisbew321,gnitsohbew,nevueluk.yxorpze,pohsdaerpsym,snoitulostsohretni.duolc,topsgolb,?ortal?ut!uoy???c&0krbd4--nx!.&a2qbd8--nx?b8adbeh--nx?c6ytdgbd4--nx?d8lhbd5--nx???a&lp!.oc,?ps!.&lla4sx,rebu,tsafym,?artxe??sla??i!ffo??n&a&d?iler?nif?rusni!efil?srelevart???eics!.oby,??rofria??d!.&1sndnyd,42pi-nyd,7erauqs,amil4,b&ow-nrefeilgitsng--nx,rb-ni,vz-nelletsebgitsng--nx,?decalpb,e&daregtmueart,luhcsvresi,mohsnd,nihcamyek,tiesbew321,?hcierebsnoissuksid,keegnietsi,lsd-ni,m&oc,rofttalpluhcs,?n&-i-g-o-l,aw-ym,e&lletsebgitsnüg,sgnutiel,?i&emtsi,lreb-n&i,yd,??norblieh-sh.ti.segap,oitatsksid-ygolonys,pv&-n&i,yd,?nyd,?refeilgitsnüg,?orp-ytinummoc,p&h21,iog:ol,,ohsdaerpsym,?r&e&ntrapdeeps.remotsuc,su&-lautriv,lautriv,?t&adpusnd,tub-ni,uor-ym,?vres&-e&bucl,mohym,?bew-emoh:.nyd,,luhcs,??ogiv-&niem,ym,??s&d-&onys,ygolonys,?nd&-&dd,nufiat,sehcsimanyd,tenretni,yard,?isoc.nyd,ps,yard,?oper-&nvs,tig,?sndd:.&nyd,sndnyd,?,?topsgolb,vresi-&niem,tset,?xi2,y&awetag-&llawerif,ym,?srab,tic-amil,?zten&mitbel,sadtretteuf,??art!.oby,?i&sdoow?ug??on--nx??e!.&bil?dem?eif?gro?irp?kiir?moc!.topsgolb,?pia?ude?vog??ei?ffoc?gg?r&f?ged???f&a&c?s??il??g!.&gro?lim?moc?t&en?vp??ude?vog??a&f?gtrom?p!.&3xlh,detalsnart,grebedoc,kselp,sndp,tengam,xlh,y&cvrp,kcor,???rots?yov??elloc?na&hcxe?ro!.hcet,??roeg?ug??i!.&pohsdaerpsym,topsgolb,vog??tilop?v&bba?om???j!.&fo,gro?oc?ten???k!.&c&a?s??e&m?n??ibom?o&c!.topsgolb,?fni?g??ro??i&b?l?n???l&a&dmrif?s!rof???b&a?i&b?dua???c&aro?ric??dnik?g!oog??i&bom?ms??l&asal?erauqa??ppa?uhcs?yts!efil???m!.&4&32i,p&ct,v,??66c,ailisarb,b&dnevar,g-raegelif,?ca?duolcsd,e&d-raegelif,i&-raegelif,lpad:.tsohlacol,,?pcm,?g&ro?s-raegelif,?hctilg,kcatsegde,noitatsksid,o&bmoy,c?t&nigol,poh,??p&i&on,snart.etis,?j-raegelif,ohbew,?r&aegelif,idcm,ofsnd,?s&dym,ndd,ti?umhol,?t&en?s&acdnuos,ohon,??u&a-raegelif,de??v&irp?og??y&golonys,olpedew,srab,??a&g?n!.&reh.togrof,sih.togrof,???em?i&rp?twohs??orhc?w??n!goloc?i&lno!.&egats-oree,oree,ysrab,??w??o!.&derno:.gnigats,,ecivres,knilemoh,?hp?latipac?ts&der?e&gdirb?rif???z!.&66duolc,amil,sh,???ruoblem??om?p!.&bog?gro?lim?mo&c?n??t&en?opsgolb,?ude??irg?yks??r!.&mo&c?n??ossa?topsgolb,?a&c!htlaeh??pmoc?wtfos??bc?eh?if?ots!.&e&rawpohs,saberots,?yflles,??taeht?u&ces?sni?t&inruf?necca??za???s!.&a!bap.us,disnim321,?b!ibnal?rofmok??c!a??d!b?n&arb?ubroflanummok???e?f!noc,?g!ro??h!f??i!trap??k!shf??l?m!oc,t??n!mygskurbrutan??o?p!ohsdaerpsym,p??r!owebdluocti,?s!serp?yspoi,?t!opsgolb,?u?vhf?w?x!uvmok??y?z??a&c?el?hc??i&er?urc??nesemoh?roh?uoh??t&a&d?ts&e!laer??lla???is!.&e&lej,nilnigol,r&etnim,ocevon,?winmo,?k&rowtenoilof,wnf,?laicosnepo,n&eyb,oyc,?spvtsaf,thrs,xulel,ysrab,?bew!.remarf,??ov?ra?t&ioled?ol??utitsni??u&lb?qi&nilc?tuob???v!.&21e?b&ew?ib?og??ce&r?t??erots?gro?lim?m&o&c?n??rif??o&c?fni??rar?stra?t&en?ni??ude?vog??as?e3gerb2h--nx?i&l!.xlh,?rd?ssergorp??ol??w&kct--nx?r??xul?y!.&gro?lim?moc?ten?ude?vog????f&0f3rkcg--nx?198xim--nx?280xim--nx?7vqn--nx?a!.&gro?moc?ten?ude?vog???b!.vog?wa9bgm--nx??c!.topsgolb,a1p--nx!.&a14--nx,b8lea1j--nx,c&avc0aaa08--nx,ma09--nx,?f&a1a09--nx,ea1j--nx,?gva1c--nx,nha1h--nx,pda1j--nx,zila1h--nx,??ns??ea1j--nx?g?iam?l&a1d--nx?og??n!.&bew?cer?erots?m&oc?rif??ofni?re&hto?p??stra?ten???orp?p!.&gro?moc?ude???rus?t!.hcs,w??vd7ckaabgm--nx?w!.&hcs,zib,???g&2&4wq55--nx?8zrf6--nx??3&44sd3--nx?91w6j--nx!.&a5wqmg--nx?d&22svcw--nx?5xq55--nx??gla0do--nx?m1qtxm--nx?vta0cu--nx????455ses--nx?5mzt5--nx?69vqhr--nx?7&8a4d5a4prebgm--nx?rb2c--nx??a!.&gro?mo&c?n??oc?ten??vd??b!.&0?1?2?3?4?5?6?7?8?9?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t!opsgolb,?u?v?w?x?y!srab,?z???c!b?za9a0cbgm--nx??e!.&eman?gro?ics?lim?moc!.topsgolb,?nue?ten?ude?vog??a??g!.&ayc,gro?lenap:.nomead,,oc?saak,ten???i&a?v??k!.&g&olb,ro??ku,lim?moc?oi,pj,su,ten?ude?v&og?t,???m!.&drp?gro?lim?m&o&c?n??t??oc?ude?vog??pk??n!.&dtl,eman?gro?hcs?i!bom??l&im?oc,?m&oc!.topsgolb,?rif,?neg,ogn,ten?ude?vog??aw?i!b!mulp??car?d&art?dew??h&sif?tolc??k&iv?oo&b?c???ls?n&aelc?iart??p!pohs??re&enigne?tac??t&ad?ekram?hgil?lusnoc?neg?ov?soh!.tfarcnepo,??vi&g?l???o!s??u&rehcisrev?smas?tarebsnegömrev???o&d?lb?og!.&duolc,etalsnart,???r&2n084qlj--nx?ebmoolb?o!.&77ndc.c:sr,,a&remacytirucesym,t&neimip,sivretla,?z,?bew-llams,d&ab-yrev-si,e&sufnocsim,vas-si,?nuof-si,oog-yrev-si,uolc&arfniarodef,mw,??e&a,cin-yrev-si,grof&loot,peh,?l&as-4-ffuts,poeparodef,?m&-morf,agevres,ohruoyslles,?n&ozdop,uma.elet,?r&ehwongniogyldlob,iwym,uces-77ndc.nigiro.lss,?t&adidnac-a-si,is&-ybboh,golb,???fehc-a-si,golbymdaer,k&eeg-a&-si,si,?h,nut,?l&i&amwt,ve-yrev-si,?lawerif&-ym,ym,?sd-ni,?m&acssecca,edom-elbac,?n&af&blm,cfu,egelloc,lfn,s&citlec-a-si,niurb-a-si,tap-a-si,?xos-a-si,?ibptth,o&itatsksid,rviop,?p&j,v-ni,??o&jodsnd,tp&az,oh,??p&i&-on,fles,?o&hbew,tksedeerf,?tf&e&moh,vres,?ym,??r&e&gatop,ppepteews,su-xunil-a-si,?gmtrec,vdmac,?s&a&ila&nyd,snd,?nymsd,?b&alfmw,bevres,?d&ikcet.3s,ylimaf,?eirfotatophcuoc,j,koob-daer,ltbup,nd&-won,deerf,emoh,golb,kcud,mood,nyd:.&emoh,og,?,ps,rvd,tog,uolc,?s&a-skcik,ndd,?tnemhcattaomb,u,?t&ce&jorparodef.&duolc,gts.so.ppa,so.ppa,?riderbew,?e&ews-yrev-si,nretni&ehtfodne,fodne,??hgink-a-si,oi-allizom,s&ixetn&od,seod,?o&h-emag,l-si,?rifyam,??ue:.&a&-q,c,?cm,dc,e&b,d,e,i,m,s,?g&b,n,?hc,i&f,s,?k&d,m,s,u,?l&a,i,n,p,?n&c,i,?o&n,r,ssa,?pj,r&f,g,h,k,t,?s&e,i:rap,,u,?t&a,en,i,l,m,ni,p,?u&a,de,h,l,r,?vl,y&c,m,?z&c,n,??,vresnyd,x&inuemoh,unilemoh,?y&limafxut,srab,???ub&mah?oj???s!.&delacsne,gro?moc?rep?t&en?opsgolb,?ude?vog??gb639j43us5--nx??t?u!.&c&a?s??en?gro?moc?o&c?g??ro?topsgolb,??v!.ta,a1c--nx??wsa08--nx??h&0ee5a3ld2ckx--nx?4wc3o--nx!.&a&2xyc3o--nx?3j0hc3m--nx?ve4b3c0oc21--nx??id1kzuc3h--nx?l8bxi8ifc21--nx?rb0ef1c21--nx???8&8yvfe--nx?a7maabgm--nx??b!.&gro?moc?ten?ude?vog??mg??c!.&7erauqs,amil4,duolc-drayknil,etisbew321,gniksnd,p&h21,ohsdaerpsym,?sndtog,topsgolb,wolf.e&a.1pla,nigneppa,?xi2,ytic-amil,?aoc?et?ir!euz??r&aes?uhc??sob?taw!s???d0sbgp--nx?f&2lpbgm--nx?k??g!.&gro?lim?moc?ude?vog???m!a1j--nx??ocir?p!.&gro?i?lim?moc?ogn?ten?ude?vog???s!.&g&nabhsah,ro??l&im?xv,?m&oc?roftalp.&cb,su,tne,ue,??pib,ten",
- "?vog?won,yolpedew,?a&c?nom??i&d?f?ri???t!.&ca?enilno,im?ni?o&c?g??pohs,ro?ten??iaf!.oby,?laeh!.arh,?orxer?rae??vo!.lopdren,?zb??i&3tupk--nx?7a0oi--nx?a!.&ffo?gro?moc?ten?uwu,?1p--nx?bud?dnuyh?tnihc??b!.&gro?moc?oc?ro?ude??ahduba?o!m!.&duolcsd,ysrab,???s??c!.&ayb-tropora--nx?ca?d&e?m??esserp?gro?ln,moc?nif,o&c?g?ssa??ro?t&en?ni?roporéa??ude?vuog??cug?t??d&dk?ua??e&bhf--nx?piat??f!.&aw5-nenikkh--nx,dnala?i&ki,spak,?mroftalpduolc.if,nenikkäh,pohsdaerpsym,retnecatad.&omed,saap,?topsgolb,uvisitok321,yd,?onas??g!.&d&om?tl??gro?moc?ude?vog???h&c&atih?ra??s&abodoy?ibustim???juohs?k!.&gro?moc?ofni?ten?ude?vog?zib??b4gc--nx?iw!.remarf,?nisleh?s?uzus??l!.&aac,topsgolb,?drahcir?iamsi??maim?n!.&b&ew?og??ca?gro?lim?mo&c?n??ni?o&c?fni??pp?t&en?ni??ude?zib??airpic?i&hgrobmal?m??re??om?rarref?s!.&egaptig,ppatig,topsgolb,?ed??t&i&c?nifni??rahb??ut?v!.&21k?gro?moc?oc?ten???wik?xa&rp?t??yf??j&6pqgza9iabgm--nx?8da1tabbgl--nx?b!.&acirfa?eto?gro?m&oc?siruot??o&c!e??fni?noce?rga?tser??russa?s&etcetihcra?risiol?tacova??t&en?naruatser?opsgolb,?ude?vinu?yenom???d?f!.&ca?eman?gro?lim?moc?o&fni?rp??ten?vog?zib???nj?s?t!.&bew?c&a?in??eman?gro?lim?moc?o&c?g??t&en?ni?set??ude?vog?zib???yqx94qit--nx??k&8uxp3--nx?924tcf--nx?arfel?c&a&bdeef?lb??ebdnul?ilc?reme??d!.&e&disemmejh321,rots,?ger,mrif,oc,pohsdaerpsym,topsgolb,zib,?t??e&es?samet??h!.&a&4ya0cu--nx?5wqmg--nx??b3qa0do--nx?cni,d&2&2svcw--nx?3rvcl--nx??5xq55--nx?tl,?g&a0nt--nx?la0do--nx?ro??i&050qmg--nx?7a0oi--nx?xa0km--nx??m&1qtxm--nx?oc??npqic--nx?saaces,t&en?opsgolb,?ude?v&di?og?ta0cu--nx??xva0fz--nx?人&个?個?箇??司公?府政?絡&網?网??織&組?组??织&組?组??络&網?网??育&敎?教???n??i&tsob?vdnas??l!.&bew?c&a?os??dtl?gro?hcs?letoh?moc?nssa?ogn?prg?t&en?ni??ude?vog??at?cd?is??m!.&eman?fni?gro?moc?t&en?opsgolb,?ude?vog???n&ab!cfdh?etats?mmoc?t&en?fos??u??i!l!.&noyc,pepym,??p???oob?p!.&b&ew?og??gro?kog?m&af?oc??nog?ofni?pog?sog?ten?ude?vog?zib???row!ten!.&htumiza,nolt,o&c,vra,????s!.topsgolb,?t?u!.&c&a?lp??dtl?e&cilop?m??gro!.&gul:g,,sgul,yr&ettoly&lkeew,tiniffa,?tneelffar,???lenap-tnednepedni,n&noc,oissimmoc-&layor,tnednepedni,??o&c!.&bunsorter.tsuc,en&ilnoysrab,ozgniebllew,?krametyb.&hd,mv,?omida,p&i-on,ohsdaerpsym,?t&fihsreyal.j,opsgolb,?vres-hn,ysrab,??rpoc,?psoh,shn?t&en?nmyp,seuqni-tnednepedni,?vog!.&eci&ffoemoh,vres,?ipa,ngiapmac,??weiver-tnednepedni,y&riuqni-&cilbup,tnednepedni,?srab,????l&04sr4w--nx?a!.&gro?lim?moc?t&en?opsgolb,?ude?vog??bolg?c?ed?g!el??i&c&nanif!.oc,lpl??os??romem?tnedurp??n&if?oitanretni??t&i&gid!.sppaduolc:.nodnol,,?p&ac?soh???ned?ot??utum!nretsewhtron???c!.&bog?lim?oc?topsgolb,vog???dil?e&datic?n&ahc?nahc!rehtaew???t!ria?tam??vart??f&8f&pbgo--nx?tbgm--nx??a?n??g!.&gro?moc?oc?ten?ude?xx,zib,??h&d?op??i!.&21k?ca?fdi?gro?inum?oc!.&egapvar,redrotibat,t&ibatym,opsgolb,???ten?vog??a&f?m&e?g?toh???m?r??l&a&b&esab?t&eksab!.&sua,zn,??oof???c?mt??e&d?hs??ihmailliw?j??m!.&esserp?gro?moc?ten?ude?v&og?uog????n!.&etisbew321,no&med,rtsic,?oc,pohsdaerpsym,retsulc-gnitsoh,topsgolb,vog,yalphk,?o??o&a?btuf?l!.gmo,?o&c!.&ed,rotnemele,??hcs??rit?u??p!.&a&cin&diws?gel??d&g,ortso?urawon??i&dem?mraw?nydg,?k&elo&guld?rtso??slopolam?tsu?ytsyrut??l&ip?o&kzs?w&-awolats?oksnok????n&erapohs,img?zcel,?rog&-ai&bab?nelej??j?z??syn?tsaim?w&a&l&eib?i?o??zsraw??o&namil?tainop,??z&eiwolaib?mol???c&e&iw&alselob?o&nsos?rtso???le&im?zrogz???orw,p??d&em,ia?ragrats?uolc&inu,sds,??e&c&i&lrog?w&ilg,o&hc&arats?orp??klop?tak????yzreibok??i&csjuoniws?ksromop?saldop??l&ahdop?opo??napokaz,t&atselaer?iselpmis,?z&romop?swozam???g&alble?ezrbo&lok?nrat??ro??hcyzrblaw?i&csomohcurein?grat?klawus??k&e&rut?walcolw??in&byr?diws,sark,?le?o&nas?tsylaib??rob&el?lam??s&als?jazel?nadg,puls?rowezrp???l&colw?e&r?vart??i&am?m???m&o&c?dar?n?tyb??s&g?iruot??t!a???n&a&gaz?nzop,?i&bul?cezczs?lbul,molow?nok?zd&eb?obeiws???uleiw?y&tzslo?z&rtek?seic????o&c,fni?k&celo?zdolk??lkan?n&leim?pek?t&uk?yzczs??z&copo?eing?rowaj???rga?tua?w&ejarg?ogarm???p&e&eb,lks!emoh,??klwwortso?ohs!-ecremmoce,daerpsym,??romophcaz?sos?t&aiwop?en?opos,ra,sezc??ude?v&irp?og!.&a&io?p?s!w???bni&p?w??ci?dtiw?e&ko?ss&p?w???fiw?g&imu?u??hiiw?m&igu?rio?u!o???nds!ipz??o&ks?p!pu??s?wtsorats??p&a?sp!mk?pk?wk??u&m?p??wk?z??r&hcso?ksw?p?s??s&i?oiw?u?zu??talusnok?w&gzr?i&p?rg?w??m?o&o?pu??u!imzw???z&kw?ouw?????w&a&l&corw?sizdow??w??o&golg?k&ark,ul?zsurp??r&az?gew??t&rabul,sugua??z&coks?sezr????xes?y&buzsak?d&azczseib?ikseb??hcyt?n&jes?lod-zreimizak??pal?r&ogt?uzam??walup?zutrak??z&am-awar?c&aprak?iwol?zsogdyb??dalezc?ib?s&i&lak?p??uklo????l??r&as?f?s??s!.&gro?moc?ten?ude?vog???t!.vog??ubnatsi?x3b689qq6--nx?yc5rb54--nx??m&00tsb3--nx?1qtxm--nx?981rvj--nx?a!.&aayn,enummoc?gro?moc?o&c?idar,ken,?t&en?opsgolb,??c!bew??dretsma?e&rts?t!.&citsalej,esruocsid,???fma?xq--nx??b!.&gro?moc?ten?ude?vog??i??c!.&moc?oc?ten?vog???d!.&gro?moc?ten?ude?vog???f!.&gro?moc?oidar,ten?ude??i??g!vu96d8syzf--nx??h?i!.&ca?gro?moc?o&c!.&clp?dtl???r,?t&en?t??vt??k?rbg4--nx??k!.&drp?e&rianiretev?sserp??gro?lim?m&o&c?n??t??nicedem?ossa?pooc?s&eriaton?neicamrahp?sa??ude?v&og?uog????l&if?ohkcots??o!.&dem?gro?m&oc?uesum??o&c?rp??ten?ude?vog??b?c!.&0x,2aq,3pmevres,5sndd,a&c&-morf,ir&bafno,fa,??g&-morf,oy-sehcaet,?i-morf,m&-morf,all&-a-si,amai,??p&-morf,c-a-si,?r&emacytirucesym,odih,?s,tadtsudgniht,v-morf,w-morf,z,?b&ew&-sndnyd,arukas,draiw.segap,ottad,?ildts.ipa,?c&amytirucesemoh,d-morf,esyrcs,itsalej.omed,n&-morf,vym,?p&kroweht,ytirucesemoh,?q,rievres,s-morf,?d&aerotffuts,e&calpb,ifitrec-&si,ton-si,?llortnocduolc,rewopenignepw:.sj,,tsohecapsppa,?i&-morf,rgevissam.saap,?m-morf,n&-morf,abeht-htiw-si,?s-morf,uolc&-noitatsyalp,hr,iafaw.&d&ej,yr,?nol,?meaeboda,nevia,panqym:-&ahpla,ved,?,smetsystuo,tekcilc,ved&j,pw,??vreser,wetomer,?e&butuoyhtiw,ciffo-sndnyd,d:-morf,o&celgoog,n&il.srebmem,neve.&1-&su,ue,?2-&su,ue,?3-&su,ue,?4-&su,ue,????,erf&-sndnyd,sndd,?filflahevres,g&de-yltsaf,nahcxeevres,?i&hcet-a-si,p-sekil,?k&auqevres,irtsretnuocevres,?l&bitpa-no,googhtiw,?m&agevres,ina-otni-si,oh-&sndnyd,ta-sndnyd,??n&-morf,ilno&-evreser,ysrab,?og-si,?r&alfduolcyrt,ehwynanohtyp:.ue,,ihcec,?srun-a-si,t&i&nuarepo,s&-ybboh,aloy,elpmis,tipohs,xiw,??omer-sndnyd,upmocsma,ysgolb,?v&als-elcibuc-a-si,i&lsndd,tavresnoc-a-si,??z&amkcar,eelg,iig,??fehc-a-si,g&ni&gats-&raeghtua,swennwot,?ksndd,robsikrow,tsoh-bt.etis,?o&fgp,lb&-sndnyd,sihtsetirw,???h&n-morf,o-morf,?i&fiwehtno,h-morf,kiw-sndnyd,m-morf,p&aerocne,detsoh,?r-morf,w-morf,z&ihcppa,nilppa,??jn-morf,k&a&-morf,erfocsic,?cils-si,eeg&-a&-si,si,?sndd,?h,latsnaebcitsale:.&1-&htuos-pa,lartnec-&ac,ue,?ts&ae&-&as,su,?ht&ron-pa,uos-pa,??ew-&su,ue,vog-su,???2-ts&ae&-su,ht&ron-pa,uos-pa,??ew-&su,ue,??3-ts&aehtron-pa,ew-ue,??,o-morf,r&adhtiwtliub,ow&-&sndnyd,ta-sndnyd,?ten-orehkcats,??sedal,u,?l&a&-morf,colottad,rebil-a-si,?f-morf,i&-morf,am&-sndnyd,detsohpw,??l&ecelffaw,uf-ytnuob:.a&hpla,teb,?,?ppmswa,ru-&elpmis,taen,?ssukoreh,xegap,?m&n-morf,pml.ppa,rofe&pyt.orp,rerac-htlaeh,?sacrasevres,uirarret-yltsaf,?n&a&cilbuper-a-si,f&-sllub-a-si,racsan-a-si,?i&cisum-a-si,ratrebil-a-si,?tarukas,?c,dc&hsums,umpw,xirtrepmi,?eerg-a-si,i&-morf,jod,?m-morf,o&ehtnaptog,isam-al-a-tse,r&italik,tap-el-tse,?s&iam-al-a-tse,replausunu,??pj,t-morf,?o&bordym,c,hce-namtsop,jodsnd,m&-morf,ed-baltlow,?n:iloxip,,ttadym,?p&2pevres,aelutym,i&-sndnyd,fles,ogol,ruoy&esol,hctid,?ym&eerf,teg,??ohsdaerpsym,pa&-rettalp,anis:piv,,esaberif,k1,lortnocduolc,oifilauq,r&aegyks,oetem:.ue,,?t&ilmaerts,norfegap,?ukoreh,?t&fevres,thevres,??r&081,a:-morf,tskcor-a-si,,b,e&d&iv&erp-yb-detsoh.saap,orpnwo,?ner&.ppa,no,??e&bevres,nigne-na-si,?ggolb-a-si,h&caet-a-si,pargotohp-a-si,?krow-drah-a-si,n&gised-a-si,ia&rtlanosrep-a-si,tretne-na-si,??p&acsdnal-a-si,eekkoob-a-si,?retac-a-si,subq,tn&ecysrab,iap-a-si,uh-a-si,?vres&-&ki.&cpj-rev-duolcj,duolcj,?s&ndnyd,pvtsaf,??inim,nmad,sak,?y&alp-a-si,wal-a-si,?zilibomdeepsegap,?g,ituob,k,mgrp.nex,o&-morf,sivdalaicnanif-a-si,t&areleccalabolgswa,c&a-na-si,od-a-si,?susaym,??p-morf,u&as-o-nyd,e&tsoh.&duolc-gar,hc-duolc-gar,?ugolb-nom-tse,?omuhevres,??s&a&apod,ila&nyd,snd,?nymsd,vnacremarf,?bbevres,ci&p&-sndnyd,evres,?tcatytiruces,?dylimaf,e&cived-anelab,itilitu3,lahw-eht-sevas,mag-otni-si,t&i&iis,sro,?yskciuq,??fpi-&eralfduolc,fc,?i&ht2tniop,pa&elgoog,tneltneg,??jfac,k&-morf,aerf-ten,colb&egrof,pohsym,??m&-morf,cxolb,?n&d&-pmet,dyard,golb,htiwssem,mood,tog,?kselp,nyd,ootrac-otni-si,?o&-xobeerf,xobeerf,?ppa&-avnac,raeghtua,t&ikria,neg,??r&ac-otni-si,e&ntrap-paelut,tsohmaerd,??s&e&l-rof-slles,rtca-na-si,?ibodym,?tsaeb-cihtym.&a&llicno,zno,?ilay,lacarac,re&gitnef,motsuc,?sv,toleco,x:n&ihps,yl,?,?u,wanozama.&1-&ht&ron-ue.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??uos-&em.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??fa.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??pa&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,??ue.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,????la&nretxe-3s,rtnec-&ac&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,??ue&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,????ts&ae&-&as&-&3s,etisbew-3s,?.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??kcatslaud.3s,??pa.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??su:-etisbew-3s,.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??kcatslaud.3s,yawetag-scitylana,?,?ht&ron-pa&-&3s,etisbew-3s,?.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??kcatslaud.3s,yawetag-scitylana,??uos-pa&-&3s,etisbew-3s,?.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??kcatslaud.3s,????ew-&su&-&3s,etisbew-3s,?.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,???ue&-&3s,etisbew-3s,?.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??kcatslaud.3s,yawetag-scitylana,??vog-su-&3s,spif-3s,????2-ts&ae&-su&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,yawetag-scitylana,??ht&ron-pa&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,??uos-pa&-&3s,etisbew-3s,?.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??kcatslaud.3s,????ew-&su&-&3s,etisbew-3s,?.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??yawetag-scitylana,??ue&-3",
- "s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,????3&-ts&aehtron-pa.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??ew-ue&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,???s,??yasdrocsid,?t&arcomed-a-si,c&-morf,etedatad.&ecnatsni,omed,??eel&-si,rebu-si,?hgilfhtiwletoh,i:batym,,m-morf,n&atnuocca-na-si,e&duts-a-si,r-ot-ecaps,tnocresu&buhtig,e&capsppa,donil.pi,lbavresbo.citats,?pl,???ops&edoc,golb,ppa,?s&i&hcrana-&a-si,na-si,?laicos-a-si,pareht-a-si,tra-na-si,xetn&od,seod,??oh&piym,sfn,??u&-morf,nyekcoh-asi,?v-morf,?u&-rof-slles,4,a-sppatikria,e,h,oynahtretramssi,r:ug-a-si,,?v&n-morf,rdlf,w-morf,?w&o&lpwons-yrt,zok,?ww100,?x&bsbf.sppa,em,i&nuemoh,rtrepmi,?obaniateb,t-morf,unilemoh,?y&a&bnx:.&2u,lacol-2u,?,l&erottad,pezam,?wetag-llawerif,?dnacsekil,fipohsym,k&-morf,niksisnd,?rot&ceridevitcaym,sitk,?u:goo,,w-morf,x&alagkeeg,orp&hsilbup,mapson.duolc,???zesdrocsid,?inu??m?or?tsla??p!.&eman,nwo,??raf!.jrots,etats??s?t!.&gro?lim?mo&c?n??oc?ten?ude?vog???u&esum?rof??z!.&ca?gro?hcs?lim?moc?o&c?fni??ten?ude?vog?zib????n&315rmi--nx?a&brud?cilbuper?f?grompj?hkaga?idraug?m?ol?ssin?u&hix?qna??varac?yalo??b!.&gro?moc?oc,ten?ude?vog??c??c!.&ah?bh?c&a?s??d&5xq55--nx?g?s?uolctnatsni,?eh?g&la0do--nx?ro??h&a?q?s??i&7a0oi--nx?h??j&b?f?t?x?z??kh?l&h?im?j??m&n?oc!.swanozama.&1-htron-nc.3s,be.1-&htron-nc,tsewhtron-nc,????n&h?l?s?y??om?qc?s&g?j?ppa-avnac,?t&cennockciuq.tcerid,en??ude?vog?wt?x&g?j?n?s??z&g?x??司公?絡網?络网??b??d&g!.ypnc,?ka??e&drag?erg?fuak?gawsklov?hctik?i&libommi?w??m?po?r!ednaalv??sier?ves??g!.&ca?gro?moc?ten?ude?vog??is&ed!.ssb,?irev???h!.&bog?cc,gro?lim?moc?ten?ude???i!.&ac?bew,c&a?in??dni?e&m?sabapus,?g&5?6?p?ro??i&a?hled??ku?l&evart?im??m&a?oc?rif??n&c?eg??o&c?fni?i?rp??p&ooc?u??r&ahib?d?e??s&c?er?nduolc,senisub?u??t&arajug?en!retni??ni?opsgolb,sop??ude?v&og?t??ysrab,zib??elknivlac?griv?ks?lreb?p?v?w?x??k!.&gro?ten?ude?vog???l&eok?ocnil??m!.&cyn,gro?ude?vog???o&dnol?i&hsaf?n&o?utiderc??siv!orue??t&a&cude!.oc,?dnuof?tsyalp??c&etorp?u&a?rtsnoc?????kin?las?mrom?nac?p&q?uoc??s&iam?pe?scire??t&ron?sob??zama??p!.&gro?oc?ten?ude?vog??k??r&e&c?yab??op!.eidni,??s!.&gro?moc?osrep?t&opsgolb,ra??ude?v&inu?uog????t!.&d&ni?uolcegnaro,?gro?ltni?m&oc!nim??siruot??nif?o&fni?srep??sne?t&an?en??vog??m??u&f?r!.&bdnevar,lper,retropno,s&h,revres,?tnempoleved,??stad?xamay?y??v!.&a&lnos?ohhnah&k?t???c&a?ouhphnib?uhphniv??di?e&man?rtneb?uhneihtauht??g&n&a&boac?ig&ah?cab?n&a?ei&k?t???uah??nad?rtcos?uqneyut??o&dmal?hpiah?lhniv?nkad?ud&hnib?iah????ro??h&ni&b&aoh?gnauq?hnin?iaht??d&hnib?man??mihcohohphnaht?n&cab?gnauq?yat??tah?vart??tlaeh??i&a!bney?coal?gngnauq?laig?ngnod??onah?rtgnauq??kalkad?m&an&ah?gnauq??oc?utnok??n&a&ehgn?gnol?kcab?uhthni&b?n???e&ibneid?y&gnuh?u&gniaht?hp????osgnal??o&fni?ht&nac?uhp??i?rp??pahtgnod?t&en?ni?opsgolb,?u&a&hcial?mac?tgnuv-airab??de?eilcab??vog?zib???wo&rc?t!epac????o&76i4orfy--nx?a!.&bp?de?go?oc?ti?vg??boat??b!.&a&ci&sum?tilop??i&c&arcomed?neic??golo&ce?ncet??m&edaca?onoce??rt&ap?sudni??vilob??n&egidni?icidem??serpme?tsiver?vitarepooc??b&ew?og??dulas?e&rbmon?tr&a?op&ed?snart????g&olb?ro??ikiw?l&a&noi&canirulp?seforp??rutan??im??moc?o&fni?lbeup?rga?tneimivom??saiciton?t&askt?en?ni??ude?vt??h?iew?olg??c!.&bew?cer?dr&c,rac,?esabapus,gro?ipym,l&im?per:.di,,?m&o&c!.topsgolb,?n??rif??ofni?s&egap&dael,l,?tra??t&4n,en?ilperdellawerif:.di,,ni??ude?vog??a?e?in?mara?s&edarb?ic???d!.&b&ew?og??dls?gro?lim?moc?t&en?ra??ude?vog??agoba?if?zd7acbgm--nx??e&c?d&iv?or???f!ni!.&e&g&delwonk-fo-l&errab,lerrab,?ellocevoli,?ht-skorg,rom-rof-ereh,tadpusn:d,,?llatiswonk,macrvd,ofni-v,p&i&-on,fles,?ohbew,?ruo-rof,s&iht-skorg,nd&-cimanyd,nyd,uolc,??tsrifyam,ysrab,zmurof,???g&el?n!am?ib???hwsohw?i!.&35nyd,8302,a&minifed,tad-b,?b&altig,uhtig,?czh,d&in,raobelgaeb,u&olc&iaznab.ppa,ropav,?rd,??e&c&apsinu.1rf-duolc,ivedniser,?donppad.sndnyd,egipa,lej,nilnigol,sufxob,t&i&beulb,snoehtnap,?newtu,ybeeb.saap,??gni&gatsniser.secived,tsohytsoh,?ilpu,k&coregrof.di,orgn:.&as,ni,p&a,j,?su,u&a,e,??,ramytefasresworb,?moc?n&aicisum,mtsp:.kcom,,yded,?ot&oq,pyrctfihs,?p&opilol,pa&-arusah,e&nalpkcab,tybeeb.1dkes,???r&e&tsneum-hf,vres&cisab,lautriv,??ial.sppa,?s&codehtdaer,gnihtbew,nemeis-om,pparevelc,t&acdnas,ekcit,??t&e&kcubtib,notorp,?i&belet,detfihs,gude,kecaps,?raedon.egats,s&ohg,udgniht.&cersid.&dvreser,tsuc,?dorp.tsuc,gnitset.&dvreser,tsuc,?ved.&dvreser,tsuc,????vgib.0ku,whs,x&bslprbv.g,cq,rotide,?y&olpedew,srab,??b?d&ar?u&a?ts???j?r?syhp??j!.&eman?gro?hcs?lim?moc?ten?ude?vog???ll&ag?o??m!.&gro?moc?ten?ude?vog??g?il?mi?orp??n!.&a&0&b-ekhgnark--nx?c-iehsrgev--nx?g-lksedlig--nx?k-negnanvk--nx??1&p-nedragy--nx?q-&asierrs--nx?grebsnt--nx?lado-rs--nx?n&egnidl--nx?orf-rs--nx??regnayh--nx?ssofenh--nx??r-datsgrt--nx?s-ladrjts--nx?v-y&senner--nx?vrejks--nx???3g-datsobegh--nx?4&5-&dnaleprj--nx?goksnerl--nx?tednalyh--nx??6-neladnjm--nx?s-&antouvachb--nx?impouvtalm--nx??y-&agrjnevvad--nx?ikhvlaraeb--nx???7k-antouvacchb--nx?8&k-rekie-erv--nx?l-ladrua-rs--nx?m-darehsdrk--nx??a!.sg??bct-eimeuvejsemn--nx?d&do?iisevvad?lov?narts?uas??f&1-&l--nx?s--nx??2-h--nx??g&10aq0-ineve--nx?av?ev?lot?r&ajn&evvad?u??ájn&evvad?u????h?iz-lf--nx?j&ddadab?sel??k&el?hoj&sarak?šárák??iiv&ag&na&el?g??ŋ&ael?ág???ran???l&f?lahrevo?o&ms?s??sennev?t-&ilm--nx?tom--nx??u&-edr--nx?s??øms??muar?n&0-tsr--nx?2-dob--nx?5-&asir--nx?tals--nx??a&r!-i-om?f?t??t??douvsatvid?kiv?m&os?øs??n&od?ød??ra?sen?t&aouvatheig?ouv&a&c&ch&ab?áb??h&ab?áb???n??i&ag?ág??sa&mo?ttvid??án???z-rey--nx?ær&f?t???o&p-&ladr--nx?sens--nx??q-nagv--nx?r-asns--nx?s-kjks--nx?v-murb--nx?w-&anr&f--nx?t--nx??ublk--nx???ppol?q&0-t&baol--nx?soum--nx?veib--nx??x-&ipphl--nx?r&embh--nx?imph--nx???y-tinks--nx??r&f-atsr--nx?g-&an&ms--nx?nd--nx??e&drf--nx?ngs--nx??murs--nx?netl--nx?olmb--nx?sorr--nx??h-&a&lms--nx?yrf--nx??emjt--nx??i&-&lboh--nx?rsir--nx?y&d&ar--nx?na--nx??ksa--nx?lem--nx?r&ul--nx?yd--nx????stu??j-&drav--nx?rolf--nx?sdav--nx??kua?l-&drojf--nx?lares--nx??m-tlohr--nx?n-esans--nx?olf?p-sdnil--nx?s-ladrl--nx?tih?v-rvsyt--nx??s&a&ns?ons??i&ar?er&dron?r&os?øs???ár??la&g?h??mor!t??sir?uf?åns??t&koulo&nka?ŋká??la?p-raddjb--nx?r-agrjnu--nx?s&aefr&ammah?ámmáh??orf?r&o?ø???u-vreiks--nx??u&h-dnusel--nx?i-&drojfk--nx?vleslm--nx??j-ekerom--nx?k-rekrem--nx?u-&dnalr--nx?goksr--nx?sensk--nx??v-nekyr--nx?w-&k&abrd--nx?ivjg--nx??oryso--nx??y-y&dnas--nx?mrak--nx?n&art--nx?nif--nx??reva--nx??z-smort--nx??v!.sg?ledatskork?reiks??wh-antouvn--nx?x&9-dlofts--nx.aoq-relv--nx?d-nmaherk--nx?f-dnalnks--nx?h-neltloh--nx?i-drgeppo--nx?j-gve&gnal--nx?lreb--nx??m-negnilr--nx?n-drojfvk--nx??y&7-ujdaehal--nx?8-antouvig--nx?b-&dlofrs--nx?goksmr--nx?kivryr--nx?retslj--nx??e-nejsom--nx?f-y&krajb--nx?re&dni--nx?tso--nx??stivk--nx??g-regark--nx?orf?ørf??z9-drojfstb--nx??b&25-akiivagael--nx?53ay7-olousech--nx?a&iy-gv--nx?le-tl&b--nx?s--nx??n0-ydr--nx??c&0-dnal-erdns--nx?z-netot-erts--nx??g&g-regnarav-rs--nx?o-nejssendnas--nx??ju-erdils-ertsy--nx?nj-dnalh-goksrua--nx?q&q-ladsmor-go-erm--nx.&ari-yreh--nx?ednas??s-neslahsladrjts--nx???ca&4s-atsaefrmmh--nx?8m-dnusynnrb--nx?il-tl--nx?le-slg--nx?n5-rdib--nx?op-drgl--nx?uw-ynnrb--nx??d&a&qx-tggrv--nx?reh!nnivk?sd&ork?ørk??uas??ts&e&bi?kkar?llyh?nnan??g&ort?ørt??k&alf?irderf??levev?mirg?obeg&ah?æh??r&ah?ejg????barm-jdddb--nx?ie!rah?s&etivk?ladman???lof&r&os?øs??ts&ev.ednas?o.relav?ø.relåv???n&a&l&-erd&n&os?øs??ron??adroh.so?dron.&a&g5-b--nx?ri-yreh--nx??ob?y&oreh?øreh??øb??e&m!lejh??pr&oj?øj??vi??gyb?n&aks?åks??o&h-goksrua?rf??r&o?ua?ø??tros?øh-goksrua??rts!e&devt?lab?mloh???s&ellil?naitsirk?rof???u&l!os??s!d&im?lejt??e&guah?l&a?å???kkoh?lavk?naitsirk?r&af?eg&e?ie???tef?y&onnorb?ønnørb?????r&a&blavs!.sg??g&eppo?la???o&j&f&a!dniv?k?vk??die?e&dnas?kkelf??llins?r&iel?ots??s&lab?t&ab?åb??yt??å!k??ævk??les??ts??åg&eppo?lå???ureksub.sen??e&ayb-yrettn--nx?d&ar?isemmejh321,lom?r&of?øf??år??g&gyr?nats??i&meuv&ejsem&aan?åån??sekaal??rjea??j&d&ef?oks??les??k&er&aom?åom??hgna&ark?årk??iregnir?kot!s??s&ig?uaf???l&bmab?kyb?l&av?ehtats??oh??m&it?ojt?øjt??n&arg?g&os?øs??meh?reil?te?ummok?yrb??r&dils-erts&ev?y&o?ø???ua?vod??sa&ans?åns??t&robraa?spaav??urg??f&62ats-ugsrop--nx?a&10-ujvrekkhr--nx?7k-tajjrv-attm--nx??o!.sg?h??s!.sg??v!.sg???g&5aly-yr&n--nx?v--nx??a&llor?ve&gnal?lreb???n&av!snellu??org??oks&die?m&or?ør??ner&ol?øl??r&o?ø???r&eb!adnar?edyps?s&die?elf?gnok?n&ot?øt????obspras??uahatsla?åve&gnal?lreb???h&0alu-ysm--nx?7&4ay8-akiivagg--nx?5ay7-atkoulok--nx??a!.sg???i&e&hsr&agev?ågev??rf??k&h&avlaraeb?ávlaraeb??s??lm&a?å??mpouvtal&am?ám??pph&al?ál??rrounaddleid?ssaneve?ššáneve??j&0aoq-ysgv--nx?94bawh-akhojrk--nx??k&a&b&ord?ørd??jks?lleis??iv!aklejps?l&am?evs?u??mag?nel?ojg?r&a&l?n??epok?iel?y&or?ør???s&ah?kel?om??øjg??kabene?ojsarak?ram&deh.&aoq-relv--nx?rel&av?åv??so??e&let.&ag5-b--nx?ob?øb??ra???åjks??l&a!d&anrus?d&numurb?ron??e&gnard?nte?s&meh?sin??ttin??g&is?nyl??kro?l&em?l&ejfttah?of??u&ag-ertdim?s???n&am?era?gos?i&b?nroh?r??kos?nus?oj??o-&dron?r&os?øs???ppo?r&a!l?nram??e&gne?l?v??is?o&jts?ts??u&a-&dron?r&os?øs???h??å?æl?øjts??s&e&jg?nivk?ryf??kav?mor-go-er&om.&ednas?yoreh??øm.&ednas?yøreh???uag??t&las?rajh?suan??v&l&a?e-rots??u-go-eron??yt??ksedlig?res&a?å???bib&eklof?seklyf??es!dah??h!.sg??i&m?syrt??l&ejf?ov&etsua?gnit?ksa?sdie???n!.sg??o!.sg?boh?g?h??r!.sg??å!ksedlig??øboh??m&a&rah?vk??f!.sg??h!.sg??i&e&h&dnort?rtsua?ssej??rkrejb??ksa??ol?t!.sg??u&dom?esum?r&ab?drejg?evle?os?uh?æb?øs??ttals???n&a&g&av?okssman?åv??jlis?or?r&g?rev???e&d&do&sen?ton??lah?r&agy&o?ø??ojfsam???g&iets?n&a&l&as?lab??n&avk?ævk??t&arg?ddosen??v&al?essov???i&d&ol?øl??l&ar?ær???yl??reb??iks?k&srot?y&or?ør???l&a&d&gnos?n&er?ojm?øjm??om??tloh??ug?åtloh??mmard?ojs&om?sendnas??ppolg?s&lahsladr&ojts?øjts??o??t&o&l?t-erts&ev?o?ø???roh?øl??vly&kkys?nav??yam-naj!.sg??øjs&om?sendnas???g&orf?ujb??i&dnaort?vnarg??kob?ladendua?maherk&a?å??n&it?urgsrop??orf-&dron?r&os?øs???r&aieb?evats??sfev?uaks?yrts??o&6axi-ygvtsev--nx?c,d&ob?rav??ievs?kssouf?l&m&ob?øb??ous&adna?ech&ac?áč???so!.sg???msdeks?niekotuak?r&egark?olf?y&oso?øso???s&dav?mort???p&ed?ohsdaerpsym,p&akdron?elk???r&a&d&dj&ab?áb??iab??jtif?luag?mah?vsyt??",
- "e&gn&a&k&iel?ro??merb?n&at?mas??rav-r&os?øs??srop?talf?v&ats?el??y&oh?øh???ivsgnok??il?jkniets?k&a&nvej?rem?s&gnir?nellu???ie-er&den?v&o?ø???ram?sa?årem??la&jf?vh??m&b&ah?áh??mahellil??nnul?ts&l&oj?øj??ul??y&o?ø???imp&ah?áh??m!.sg??osir?t!.sg??ádiáb?ævsyt?øsir??s&adnil?en&dnas?e&dga?k&ri&b?k??som??ve??me&h?jg??nroh-go-ejve?s&a?ednil?k&o?ø??of?yt?å??tsev??gv?hf?igaval?o&r&or?ør??sman??so&fen&oh?øh??m?v??uh&lem?sreka.sen??å!dnil???t&a&baol?g&aov?grav??jjr&av-attam?áv-attám??l&a&b?s??ás??soum?ts?v&eib?our???e&dnaly&oh?øh??f?s&nyt?rokomsdeks?sen??vtpiks??in&aks?áks??loh&ar?år??n!.sg??o&m&a?å??psgolb,?s!.sg?efremmah?or?ør??terdi?á&baol?ggráv?lá&b?s??soum?veib???u&b!.sg?alk?e&dna?gnir?nner??les?ælk??dra&b?eb??g&nasrop?vi?ŋásrop??j&daehal&a?á??jedub?v&arekkhar?árekkhár???ksiouf?n&diaegadvoug?taed???v&irp?lesl&am?åm???y&b&essen?nart?sebel?tsev??o&d&ar?na!s??or??gavtsev?k&rajb?sa??lem?mrak?n&art?n&if?orb???r&a&mah?n?v??e&dni?t&so?ton??va??ul?yd??s&am?enner?gav?lrak?tivk??vrejks??ø&d&ar?na!s??ør??gåvtsev?k&rajb?sa??lem?mrak?n&art?n&if?ørb???r&e&dni?t&so?tøn??va??ul?yd?æ&n?v???s&enner?gåv?tivk?åm??vrejks???á&slág?tlá?vreiks??å&gåv?h?jddådåb?lf??ø&d&ob?rav??r&egark?olf??s&dav?mort????aki?i&sac?tal??u??o&b?f?g?hay?o?ttat??r!.&cer?erots?gro?m&o&c?n??rif?t??o&c,fni??pohs,stra?t&n?opsgolb,?www?ysrab,?e&a!.&a&ac?cgd?idem??bulc!orea??ci&ffartria?taborea??e&cn&a&l&lievrus-ria?ubma??netniam?rusni??erefnoc??gnahcxe?mordorea?ni&gne?lria?zagam??rawtfos??gni&d&art?ilg!arap?gnah???l&dnahdnuorg?ledom??noollab?retac?sael?t&lusnoc?uhcarap??vidyks??hcraeser?l&anruoj?euf?icnuoc?ortnoc!-ciffart-ria???n&gised?oi&nu?t&a&cifitrec?ercer?gi&tsevni-tnedicca?van??i&cossa!-regnessap??valivic??redef??cudorp?neverp-tnedicca????ograc?p&ihsnoipmahc?uorg!gnikrow???r&e&dart?enigne?korb?niart?trahc??o&htua?tacude???s&citsigol?e&civres?r??krow?serp!xe??tnega??t&farcr&ia?otor??hgil&f?orcim??liubemoh?n&atlusnoc?e&duts?m&esuma?n&iatretne?revog??piuqe????olip?ropria?si&lanruoj?tneics???w&erc?ohs??y&cnegreme?dobper?tefas????rref?z??p!.&a&aa?ca?pc??dem?ecartsnd.icb,gne?r&ab?uj??snduolc,t&acova?cca?hcer??wal?ysrab,???s!.&em?gro?hcs,moc?ten?ude?vog???t!.&0x,116,ayo,gro?lim?moc?nayn,sulpnpv,t&cennockciuq.tcerid,en??ude?v&dr,og???o&hp?m?v?yk??tol?ua??v&iv?lov??xas?ykot??p&a&ehc?g?m?s??eej?g!.&gro?ibom?moc?ossa?ppa,ten?ude???i&r!.nalc,?v?z??j!.&0o0o,a&3&5xq6f--nx?xqi0ostn--nx??5wtb6--nx?85uwuu--nx?9xtlk--nx?ad,b&ats,ihc!.&a&bihciakoy?don?ma&him?ye&ragan?tat???r&a&bom?gan?hihci??u&agedos?kas?ustak???s&os?ufomihs??t&amihcay?iran??w&a&g&im&anah?o??omak??kihci?zustum??ihsak??y&agamak?imonihci???e&akas?nagot??i&azni?esohc?h&asa?s&abanuf?ohc???ka&to?zok??musi?orihs?r&akihabihsokoy?o&dim?tak??ukujuk??usihs??nano&hc?yk??o&d&iakustoy?ustam??hsonhot?k&a&rihs?t??iba??nihsaran?sobimanim?tas&arihsimao?imot??uhc?yihcay??u&kujno?s&ayaru?t&imik?tuf???zarasik?????c&cah,ed,?g&as!.&a&gas?m&a&tamah?yik??ihsak??rat?t&a&gatik?hatik??ira!ihsin????e&kaira?nimimak??i&akneg?g&aruyk?o??h&c&amo?uo??siorihs??kaznak?modukuf?ra&gonihsoy?mi???nezih?u&k&at?ohuok??s&ot?tarak?????ihs!.&a&kok?m&a&hagan?yirom??ihsakat??rabiam?wagoton??e&miharot?nokih??houyr?i&azaihsin?esok?kustakat?moihsagih??na&mihcahimo?nok??o&hsia?mag?t&asoyot?ok?tir???us&ay?t&asuk?o??????k&aso!.&a&d&awihsik?eki??k&a&noyot?s&akaayahihc?oihsagih???oadat?uziak??m&ayas!akaso??odak??r&a&bustam?wihsak??ediijuf??t&akarih?i&k?us???wag&ayen?odoyihsagih???e&son?tawanojihs??honim?i&akas?h&cugirom?s&ayabadnot?i&a&kat?t??n??oyimusihsagih???k&a&rabi?sim??ustakat??muzi?r&ijat?otamuk???nan&ak?n&ah?es???o&ay?n&a&ganihcawak?simuzi?tak??eba?ikibah?oyot??t&anim?iad?omamihs??uhc??ust&oimuzi?tes????ou&kuf!.&a&d&amay?eos??g&no?ok?usak??hiku?k&awayim?uzii??ma&kan?y&asih?im???rawak?t&a&gon?ka&h?num?t???umo??wa&g&a&kan?nay?t??ias??ko!rih???y&ihsa?usak???e&m&ay?uruk??taruk?us??i&a&nohs?raihcat??goruk?h&cukuf?s&a&gih?hukuy??in???k&a&gako?muzim??iust?o?ustani??m&anim?otihsoynihs?u??r&ogo?ugasas??usu??ne&siek?zu&b?kihc???o&gukihc?h&ak?ot?ukihc??j&ono?ukihc??kayim?nihsukihc?to?uhc??u&fiazad?gnihs?stoyot????zihs!.&a&bmetog?d&amihs?eijuf?ihsoy?omihs??kouzihs?mihsim?ra&biah?honikam??tawi?wa&g&ekak?ukik??kijuf??yimonijuf??i&a&ra?sok??hcamirom?juf?kaz&eamo?ustam??ma&nnak?ta??nukonuzi?orukuf??nohenawak?o&nosus?ti??u&stamamah?z&a&mun?wak??i!ay?i&hs&agih?in??manim??mihs????????m&a&tias!.&a&d&ihsoy?ot?usah??k&a&dih?sa??o&arihs?s???m&a&tias?y&as?o&rom?tah??ustamihsagih???i&hsagurust?jawak??uri??ni?wa&g&e&ko?man??ikot?o??k&ara?i&hsoy?mak???ru?zorokot??y&a&g&amuk?ihsok?otah??kuf??imo??ziin??e&bakusak?ogawak?sogo?ttas?zokoy??i&baraw?h&cugawak?s&oyim?ubustam???iroy?k&ato?ihs?u&k?stawi???m&akoyr?i&hsoy?juf??uziimak???naznar?o&dakas?ihsay?jnoh?n&a&go?nim??imijuf?nah?oy??r&ihsayim?otagan??t&asim!ak??igus?omatik??zak??u&bihcihc!ihsagih??sonuok?ynah????y&ak&aw!.&a&d&ira?notimak??kadih?ma&h&arihs?im??y&a&kaw?tik??oduk???ru&ustakihcan?y??sauy?wa&g&a&dira?zok??orih??konik??yok?zok??e&banat?dawi??i&garustak?jiat?mani??naniak?o&bog?nimik?t&asim?omihs&ah?uk????ugnihs???o!.&a&jos?koasak?m&ay&ako?ust??ihsayah??r&abi?ukawaihsin??wi&aka?nam???e&gakay?kaw??i&gan?h&cu&kasa?otes??sahakat??k&asim?ihsaruk??miin??n&anemuk?ezib??o&hsotas?jnihs?n&amat?imagak??ohs?uhcibik?????ot!.&a&damay?got?koakat?may&etat?ot??nahoj?riat?waki&inakan?reman???eb&ayo?oruk??i&h&asa?ciimak?sahanuf??kuzanu?m&an&i?ot??ih???nezuyn?otnan?u&hcuf?stimukuf?z&imi?ou???????ihs&o&gak!.&a&m&ayuok?ihsogak??si?yonak??e&banawak?n&at&akan?imanim??uka??tomoonihsin??i&adnesamustas?k&azarukam?oih??m&ama?uzi??usuy??nesi?o&knik?os?tomustam??uzimurat???rih!.&a&ka&n?s??m&ayukuf?i&hsorihihsagih?j&ate?imakikaso????r&a&bohs?h&ekat?im???es??tiak?wiad??e&kato?ruk??i&h&ci&akustah?mono?nihs??s&inares?oyim???manimasa?uk??negokikesnij?o&gnoh?namuk??uhcuf????uk&ot!.&a&bihci?mi&hsu&kot?stamok??m??wagakan??egihsustam?i&gum?h&coganas?soyim??kijaw?m&anim?uzia??ukihsihs??nan&a?iak??o&nati?turan????uf!.&a&batuf?m&a&to?y&enak?irok???ihs&im?ukuf??os?uko??r&aboihsatik?uganat??ta&katik?mawak?rih??w&a&g&akus?emas?uy??k&a&mat?rihs?sa??ihsi??nah??ohs???e&gnabuzia?iman?ta&d?tii???i&adnab?enet?hs&agih?iimagak??k&a&wi?zimuzi??ubay??minuk?r&ook?ustamay???nihsiat?o&g&etomo?ihsin?nan?omihs??no!duruf?rih??rihsawani?ta&may?simuzia???u&rahim?stamakawuzia?zia&ihsin?nay???????nug!.&a&bawak?doyihc?k&anna?oi&hsoy?juf?mot???m&ayakat?ustagaihsagih??n&ihsatak?nak??r&ahonagan?nak?o?u&kati?mamat???t&amun?inomihs?o??w&akubihs?iem?ohs???i&hsa&beam?yabetat??kas&akat?esi??m&akanim?uzio??ogamust?rodim??o&jonakan?n&eu?oyikust??tnihs??u&komnan?stasuk?yrik????rep,?n&ibmab,nog,ob,?ppacihc,ra&n!.&a&bihsak?d&akatotamay?u!o???guraki?m&ay&atik&imak?omihs??irokotamay??oki??ra&hihsak?n??wa&geson?knet???e&kayim?ozamay?sog?ustim??i&a&rukas?wak??garustak?h&ciomihs?sinawak??jo?ka&mnak?toruk??makawak?nos?r&net?otakat?ugeh???o&d&na?oyo??gnas?jnihs?nihsoy!ihsagih??tomarawat?yrok????rikik,?t&ag&amay!.&a&dihsio?k&atarihs?ourust??may&a&kan?rum??enak?onimak??rukho?ta&ga&may?nuf??hakat?kas??wa&g&ekas?orumam??ki&hsin?m??z&anabo?enoy?ot???zuy??e&agas?bonamay?dii?nihsagih?o??i&a&gan?nohs??h&asa?sinawak??nugo??o&dnet?jnihs?ynan??ukohak???iin!.&a&ga?k&ium?oagan??munou!imanim??t&a&bihs?giin??ioy??w&a&gioti?kikes?zuy??irak??yijo??e&kustim?mabust??i&aniat?hcamakot?kaz&awihsak?omuzi??m&a&gat?karum??o???n&anust?esog??o&das?ihcot?jnas?k&ihay?oym??mak?naga?ries??u&ories?steoj?????i&k&a!.&a&go?k&asok?oimak??t&ago!rihcah??ika!atik???w&aki?oyk???e&mojog?natim?suranihsagih?t&ado?okoy???i&hsoyirom?magatak?naokimak??nesiad?o&hakin?jnoh!iruy??nuzak?rihson?tasi&juf?m??yjnoh??u&kobmes?oppah????in,?o!.&a&dakatognub?m&asah?ihsemih??su?t&ekat?i&h?o????e&onokok?ustimak??i&jih?k&asinuk?ias?usu??mukust??onoognub?u&fuy?juk?ppeb?suk?????nayn,?wa&ga&k!.&a&mihsoan?rihotok?waga&kihsagih?ya???emaguram?i&j&nonak?ustnez??kunas?monihcu??o&hsonot?nnam?yotim??u&st&amakat?odat??zatu????nak!.&a&dustam?kus&okoy?tarih??maz?nibe?r&a&gihsaimanim?h&esi?imagas??wa&do?guy???u&im?kamak???tikamay?wa&k&ia?oyik?umas??sijuf??yimonin??e&nokah?saya??i&akan?esiak?gusta?hsuz?kasagihc?o?ukust??o&nadah?sio?tamay?????kihsi!.&a&danihcu?gak?kihs?mijaw?t&abust?ikawak??wazanak??i&gurust?hcionon?mon?ukah??nasukah?o&anan?ton!akan???u&kohak?stamok?z&imana?us?????niko!.&a&han?m&arat?ijemuk?uru??n&e&dak?zi??no??ra&hihsin?rih??wa&kihsi?niko??yehi?zonig??e&osaru?seay??i&hsagih?jomihs?k&a&gihsi?not??ihsakot??m&a&ginuk?kihsug?maz??igo?otekat??nuga!noy???n&a&moti?timoy?wonig??i&jikan?k???o&gan?jnan?tiad&atik?imanim???u&botom?kusug&akan!atik??imot??rab&anoy?eah??????yp,zomim,?bus,c&204ugv--nx?462a0t7--nx?678z7vq5d--nx?94ptr5--nx?a?mpopilol,?d&-2,17sql1--nx?3thr--nx?5&20xbz--nx?40sj5--nx??7&87tlk--nx?ptlk--nx??861ti4--nx?a?e!tfarcdnah,?n&eirf&lrig,yob,?om,?ooftac,?e&16thr--nx?5&1a4m2--nx?9ny7k--nx??damydaer,eweep,garotsarukas.&10ksi.3s,20ksi.3s,?i&bmoz,m!.&a&bot?k&asustam?uzus??m&a&him?y&emak?im???ihs??nawuk?wi&em?k???e&bani?ogawak?si!imanim???i&arataw?gusim?h&asa?ciakkoy??k&a&mat?sosik?t??iat??raban??o&dat?hik?n&amuk?ihseru?o&du?mok????ust????kilbew,lasrepus,mihe!.&a&m&a&h&ataway?iin??yustam??ij&awu?imak???taki!man???ebot?i&anoh?kasam?rabami??n&ania?egokamuk?oot??o&jias?kihcu?nustam?uhcukokihs?yi!es???u&kohik?zo????n!.&arukas,lapo,n&erukom,riheg,?omomus,stnim,teniesa.resu,xob-liam,yrovi,zapot,?amihs!.&a&d&amah?ho?usam??kustay?m&a?ihsoni&hsin?ko???wakih??e&namihs?ustam??i&g&aka?usay??konikak?mikih??nannu?o&mu&kay?zi!ihsagih?uko???nawust?tasim??u&stog?yamat????nep,?rotsnoihsaf,srev,t&awi!.&a&bahay?d&amay?on??koirom?t&a&honat?katnezukir??imus??w&as&ijuf?uzim??ihs???e&hon&i&hci?n??uk??tawi??i&a&duf?murak?wak??h&custo?si&amak?ukuzihs???j&oboj?uk??k&a&m&anah?uzuk??sagenak??esonihci??m&akatik?uzia&rih?wi????o&kayim?no&rih?t??tanufo??uhso???isarap,saman,tococ,?ulbybab,?g&3zsiu--nx?71qstn--nx?l?olblooc,?h&03pv23--nx?13ynr--nx?22tsiu--nx?61qqle--nx?o-hu,sulb,?i&54urkm--nx?azosbew,ced,g&ayim!.&a&dukak?m&a&goihs?kihs??ihsustam!ihsagih??unawi??r&awago?iho??ta&bihs?rum??w&a&gano?kuruf??iat??y&imot?ukaw???e&mot?nimes??i&hsiorihs?ka&monihsi?s&awak?o???mak?r&ataw?o&muram?tan????o&az?jagat?t&asim?",
- "omamay???u&fir?k&irnasimanim?uhsakihcihs?????ihcot!.&a&g&a&h?kihsa??ust??kom?m&ay&o?usarak??unak??r&a&boihsusan?watho??iho?ukas??t&akihsin?iay??wa&konimak?zenakat??y&imonustu?oihs???e&iiju?kustomihs?nufawi??i&akihci?g&etom?ihcot?on???o&k&ihsam?kin??nas?sioruk?tab??u&bim?san?????h&c&ia!.&a&dnah?m&a!h&akat?im??yuni??ihs&ibot?ust???r&a&hat?tihs??ik?u&ihsagih?kawi???t&ihc?o&k?yot???wa&koyot?zani??yi&monihci?rak???e&inak?k&aoyot?usa??manokot?noyot??i&a&gusak?kot?sia??eot?h&asairawo?cugo?s&ahoyot?oyim???k&a&mok?zako??ihssi??motay?rogamag??n&an&ikeh?ok??ihssin??o&got?ihsin?jna?rihsnihs?suf?tes??u&bo?raho?s&oyik?takihs??yrihc?zah????ok!.&a&dusay?kadih?mayotom?r&ah&im?usuy??umakan??sot!ihsin??wa&g&atik?odoyin??k&as?o????i&esieg?hco!k??jamu?k&a!sus??usto??ma&gak?k??rahan??o&mukus?n&i?ust!ihsagih???torum?yot!o???u&koknan?zimihsasot????ugamay!.&a&m&ayukot?ihso??toyot??e&bu?subat??i&gah?kesonomihs?nukawi?rakih??nanuhs?otagan?u&ba?foh?otim?stamaduk?uy?????s&anamay!.&a&dihsoyijuf?mayabat?r&ahoneu?ustakihsin??w&a&k&ayah?ijuf??suran??ohs???egusok?i&ak?h&cimakan?s&anamay?od???k&asarin?u&feuf?sto????o&k&akanamay?ihcugawakijuf??nihso?t&asimawakihci?ukoh??uhc??spla-imanim?u&b&nan?onim??fok?hsok?rust????ubon,??ix,ka&rabi!.&a&bukust?gok?kan!ihcatih??m&a&sak?timo?wi??ihsak?ustomihs??ni?r&a&hihcu?way??u&agimusak?ihcust???t&ag&amay?eman??oihcatih??w&ag&arukas?o??os??yi&moihcatih?rom???e&bomot?dirot?not?tadomihs??i&a&k&as?ot??rao??esukihc?gahakat?h&asa?catih??k&a&rabi?saguyr??ihsani?uy??ma?rukustamat??o&dnab?giad?him?kati?rihsijuf?soj?t&asorihs?im??yihcay??u&fius?kihsu?simak????sagan!.&a&m&abo?ihsust??natawak?r&abamihs?u&mo?ustam???wijihc?yahasi??i&akias?hies?k&asagan?i??masah??neznu?o&besas?darih?t&eso?og!imaknihs????ust&igot?onihcuk?uf????zayim!.&a&biihs?guyh?k&oebon?ustorom??mihsuk?r&emihsin?uatik??ta&katik?mim??wag&atik?odak??ya??e&banakat?sakog??i&hsayabok?kaza&kat?yim??m&animawak?ot&inuk?nihs????nanihcin?o&j&ik?onokayim??n&ibe?ust??tias??urahakat????ro&cep,moa!.&a&dawot?turust?wasim??e&hon&ihc&ah?ihs??nas?og?ukor??sario??i&anarih?ganayati?hsioruk?jehon?kasorih?makihsah?nawo?r&amodakan?omoa???o&gnihs?kkat??u&ragust?stum????ttot!.&a&r&ahawak?uotok??sa&kaw?sim???egok?irottot?nanihcin?o&ganoy?nih?tanimiakas??u&bnan?z&ay?ihc??????ukuf!.&a&deki?gurust?ma&bo?h&akat?im??yustak??sakaw??eabas?i&akas?ho?jiehie?ukuf??nezihce!imanim??ono????k&26rtl8--nx?4&3qtr5--nx?ytjd--nx??522tin--nx?797ti4--nx?ci&gid,ht,sevol,?ee,limybab,n&at,upatilol,??l&33ussp--nx?e&ccabew.&resu,sr,?llarap,?lik,oof,rigetuc,?m&11tqqq--nx?41s3c--nx?ef,sioge,?n&30sql1--nx?65zqhe--nx?a&ebyllej,i&lognom,viv,??iam,n7p7qrt0--nx?o&o&las,mflah,?ruk,staw,??o&131rot--nx?7qrbk--nx?aic,c?d&iakkoh!.&a&deki?gakihset?hcebihs?k&adih?u&fib?narihs???m&ayiruk?hot?ihs&orihatik?ukuf??oras?usta??r&ib&a!ka??o?uruf??ozo?u&gakihsagih?oyot???sakim?ta&gikust?mun??w&a&ga&k&an?uf??nus!imak???k&aru?i&h&asa?sagih??kat?mak??omihs?um??zimawi??ine?oyk??yot??e&a&mustam?nan??b&a&kihs?yak??o&noroh?to???ian?k&ihsam?ufoto??nakami?ppoko!ihsin??sotihc?tad!okah??uonikat??i&a&bib?mokamot?n&a&k&kaw?oroh??wi??eomak?ihsatu?okik?usta&moruk?sakan????eib?h&c&ioy?u&bmek?irihs???s&ase?ekka?oknar?uesom???jufirihsir?k&amamihs?i&at?n???m&atik?otoyot??oa&kihs?rihs??r&a&hs?kihsi?mot??ihs&aba?ir??otarib???n&a&hctuk?rorum?se?tokahs??uber??o&kayot?m&ire?ukay??naruf!ima&k?nim???orih?r&ih&ibo?suk??o&bah?h&i&b?hsimak??sa??pnan?yan??umen??t&asoyik?eko?ukoh???u&bassa?kotnihs?m&assaw?uo??pp&akiin?en&ioto?nuk??ip??rato?s&akat?t&eb&e?i&a?hs!a??robon??m&e?o&m?takan???no&h?tamah??o&mik?s?t??u&kir?ppihc?st???onihsnihs?ufuras??uaru??yru!koh??zimihs!ok?????nu,?g!iti,oyh!.&a&bmat?dnas?gusak?k&at?o&oyot?y??uzarakat??m&ayasas?irah??wa&g&ani?okak??k&i&hci?mak??oy???yi&hsa?monihsin???i&asak?hs&aka?i&at?nawak???j&awa!imanim??emih??k&a&goa?s&agama?ukuf??wihsin??i&hsog?m???mati?oia?rogimak??n&annas?esnonihs??o&gasa!kat??ka?n&ikat?o?ustat??rihsay?sihs?tomus?yas??u&bay?gnihs?????hih,konip,l&bs,ik,?mol,nagan!.&a&bukah?d&a&w?yim??e&ki?u??ii??k&a&s&ay?uki??zus??ihsoo?ousay??m&ay&akat?ii??i&hsukufosik?jii??ukihc??n&i!hsetat??uzii??r&ah?ugot??saim?t&agamay?oyim??w&a&g&a&kan?n??o??kustam?ziurak??onim!imanim??u&koo?s!omihs????ya&ko?rih???e&akas?nagamok?subo??i&gakat?h&asa?c&a!mo!nanihs???uonamay??sukagot??k&a&kas?mimanim?to??ia&atik?imanim??oa?uzihcom??m&akawak?ijuf?o!t???r&ato?ijoihs?omakat???n&ana?esnoawazon??o&hukas?n&a&gan?kan??i&hc?muza??ustat??romok?si&gan?k??tomustam??u&k&as?ohukihc??stamega????o&b,m,pac,?to&mamuk!.&a&gamay?rahihsin?sukama!imak??tamanim??enufim?i&hcukik?k&ihsam?u??nugo!imanim??romakat??o&ara?rihsustay?sa?t&amay?om&amuk?us??u!koyg???yohc??u&sagan?zo????yk!.&a&bmatoyk?k&ies?oemak?uzaw??mayi&h&cukuf?sagih??muk??nihsamay?rawatiju?t&away?ik???e&ba&nat!oyk??ya??di?ni??i&ju?kazamayo?manim??natnan?o&gnatoyk?kum?mak?rihsamayimanim?y&gakan?ka&koagan?s??oj???u&ruziam?z&ayim?ik??????wtc1--nx?ykot!.&a&d&i&hcam?mus??oyihc??k&atim?ihsustak??m&a&t!uko??yarumihsa&gih?sum???i&hs&agoa?ika?o!t??uzuok??ren???r&a&honih?wasago??iadok?umah??ssuf?t&ik?o??wa&g&anihs?ode??k&ara?ihcat???y&agates?ubihs???e&amok?donih?m&o?urukihsagih??soyik??i&enagok?gani?h&ca&da?tinuk??sabati??j&nubukok?oihcah??manigus??o&huzim?jihcah?n&akan?ih!sasum??urika??rugem?t&a&mayihsagih?nim??iat?ok??uhc?yknub??u&fohc?hcuf?kujnihs?????p&a&ehc,rc,?o&hs&eht,iiawak,yub,?lf,p&evol,ydnac,?rd&kcab,niar,???r&2xro6--nx?atselttil,e&d&nu,wohc,?h,ilf,pp&ep,irts,u,?t&aerg,tib,??g!r,?ks,o!on,?ufekaf,?s&9nvfe--nx?dom,p&ihc,oo,?remagten,sikhcnerf,u&bloohcs,ruci,srev,?xvp4--nx??t&a&cyssup,obgip,?e&rces,vlev,?hginyad,netnocresu,opsgolb,sidas,u&b,ollihc,??u&4rvp8--nx?fig!.&a&d&eki?ih??kimot?m&ayakat?ihsah??ne?raha&gi&kes?makak??sak??taga&may?tik??wa&g&ibi?ustakan??karihs!ihsagih????e&katim?uawak??i&gohakas?hc&apna?uonaw??k&ago?es?ot??m&anuzim?ijat??nak?urat??nanig?o&dog?jug?makonim?nim?roy?sihcih??u&fig?s&otom?t&amasak?oay??????hc,pup,stoknot,ynup,?wonsetihw,x&5ytlk--nx?irtam,?y&adynnus,dr,knarc,l&oh,rig,?moolg,ob,pp&ih,olf,?rgn&a,uh,?u6d27srjd--nx?vaeh,?z&72thr--nx?e&ej,lur,??井福?京東?分大?取鳥?口山?城&宮?茨??媛愛?山&富?岡?歌和??岡&福?静??島&児鹿?広?徳?福??崎&宮?長??川&奈神?石?香??庫兵?形山?手岩?木栃?本熊?根島?梨山?森青?潟新?玉埼?田秋?知&愛?高??縄沖?良奈?葉千?賀&佐?滋??道海北?都京?重三?野長?阜岐?阪大?馬群???k!.&art?gro?moc?per?ude?vog???l&eh?l??m!.uj,ac?j??nd?o&g?h&pih?s!.&esab,xilpoh,ysrab,???lnud?oc?t!.&lldtn,snd-won,???pa!.&0mroftalp,a&rusah,ted,?bew:erif,,e&erf-korgn,gatskrelc,kalfwons:.kniletavirp,,niln&igol,okoob,?tupmocegde,virdhsalfno,?ilressem,k&orgn,relc,?le&crev,napysae,?maerdepyt,n&aecolatigidno,ur:.a,,?poon,r&cne,emarf,?t&i&belet,lmaerts,?xenw,?yfilten,??ra&a?hs??u&ekam?llag?org!.esruocsid,cts?kouk?nayalo???vsr?xece4ibgm--nx??q&a!3a9y--nx??g?i!.&gro?lim?moc?ten?ude?vog???m?se??r&a!.&a&cisum?sanes??bog?gro?l&autum?im??moc!.topsgolb,?pooc?rut?t&e&b?n??ni??ude?vog??4d5a4prebgm--nx?b?c?eydoog?los?t&at?s!uen???ugaj??b!.&21g?a&b&a&coros?iuc??itiruc??cnogoas?dicerapa?gniram?i&naiog?ramatnas??n&erom?irdnol??op?p&acam?irolf?ma&j?s???rief?tsivaob??b!aj?ib?mi?sb??c&ba?e&r?t??js?sp?t!e???d&em?mb?n&f?i??rt??e&dnarganipmac?ficer?ht?llivnioj?rdnaotnas??f&dj?ed?gg?n&e?i???g&e&l!.&a&b,m,p,?bp,c&a,s,?e&c,p,s,?fd,gm,ip,jr,la,ma,nr,o&g,r,t,?p&a,s,?r&p,r,?s&e,m,r,?tm,??s??l&s?z??n&c?e?o??ol!b?f?v??pp?ro??hvp?i&du?kiw?nana?oretin?r&c?eurab??sp?te?xat??l&at&an?rof??el?im?sq??m&a?da?e&gatnoc?leb??f?ic?oc!.&duolclautriv.elacs.sresu,etiselpmis,topsgolb,???nce?o&ariebir?c&e?narboir?saso??d&o?ranreboas??e&g?t??i&b?dar?ecam?r??rp?t&a?erpoir???p&er?m!e?t??ooc?pa?se??qra?r&af?ga?o&davlas?j??tn?ut??s&a&ixac?mlap?nipmac??ed?u&anam?j?m???t&am?e&d?n?v??nc?o&f?n??ra?sf??u&caug9?de?ja?rg??v&da?ed?og!.&a&b?m?p??bp?c&a?s??e&c?p?s??fd?gm?ip?jr?la?ma?nr?o&g?r?t??p&a?s??r&p?r??s&e?m?r??tm???rs?t??xiv?z&hb?ls?o&c?f?????c!.&as?ca?de?if?o&c?g??ro???e&bew?ccos?dnik?e&b?n&igne?oip??rac??gni&arg?rheob??h&cor?sok?t&aew?orb???itnorf?k&col?o&p?rb???l&aed?ffeahcs??mal?nes?pinuj?t&a&eht?rebsnegömrev??law?nec?s&acnal?nom?ubkcolb??upmoc??v&o&csid?rdnal??resbo??wulksretlow?ywal?zifp??f!.&aterg?bew&-no,etis321,?drp?e&c&itsuj-reissiuh?narf-ne-setsitned-sneigrurihc,?lipuog,rianiretev??hny,i&cc?rgabmahc??m&o&c?n??t??n&eicamrahp?icedem??ossa?pohsdaerpsym,s&e&lbatpmoc-strepxe?riaton?tsitned-sneigrurihc?uova??o&-x&bf,obeerf,?x&bf,obeerf,???t&acova?o&or-ne,psgolb,?r&epxe-ertemoeg?op!orea????vuog?xobided,?avc7ylqbgm--nx?s??g!.&etiselpmis,gro?moc?t&en?opsgolb,?ude?vog???h!.&e&erf,man??mo&c?rf??topsgolb,zi??ur??i!.&a&61f4a3abgm--nx?rf4a3abgm--nx??ca?di?gro?hcs?oc?ten?vog?نار&يا?یا???a&h?per??ew?lf??k!.&c&a?s??e&n?p?r??gk?iggnoeyg?kub&gn&oeyg?uhc??noej??l&im?uoes??man&gn&oeyg?uhc??noej??n&as&lu?ub??o&e&hcni?jead??wgnag???o&c?g??ro?s&e?h?m??topsgolb,u&gead?j&ej?gnawg????cilf??l!.&gro?moc?ten?ude?vog???m!.&topsgolb,vog???n!.&gro?moc?ofni?ten?ude?vog?zib???o&htua?odtnorf?t&c&a?od??laer???p!.&alsi?ca?eman?forp?gro?moc?o&fni?rp??t&en?se??ude?vog?zib???s?t!.&21k?bew?cn!.vog??eman?gro?kst?l&e&b?t??im?op??moc!.topsgolb,?neg?ofni?pek?rd?sbb?ten?ude?v&a?og?t??zib??f?m??ubad?vd??s&8sqif--nx?9zqif--nx?a!.vog?birappnb?gev?lliv?mtsirhc?s??b!.&ew,gro?moc?ten?ude?vog??c?oj?s?u??c&i&hparg?p?t&sigolyrrek?ylana???od??d&a?d?ik?l?n&iwriaf?omaid??oogemoh?rac??e!.&b&ewim321,og??gro?mo&c!.topsgolb,?n??pohsdaerpsym,ude??civres!.enilnigol,?d&d2bgm--nx?oc??h&ctaw?guh??i&lppus?rtsudni?treporp!yrrek???jaiv?l&aw?cycrotom?gnis?pats??m&ag?oh?reh??nut?ohs?picer?r&it?ut&cip!.7331,?nev???s&i&rpretne?urc??ruoc??taicossa?vig??g!nidloh??h5c822qif--nx?i!.&ekacpuc,gro?moc?t&en?ni?opsgolb,?ude?vog??a09--nx?nnet?rap?targ??k&c&or!.&ecapsbew,snddym,ytic-amil,??us??hxda08--nx?row??l!.&c&a?s??ed,gro?o&c?fni??ten?ude?vog?zib??a&ed?tner??e&ssurb?toh!yrrek???lahsram?m?oot??m!.&bal,etisinim,gro?moc?ten?ude?vog??b?etsys!.tniopthgink,?ialc??n&a&f?gorf?ol??i&a&grab?mod??giro??o&it&acav?cudorp?ulos??puoc???o&dnoc?geuj?ppaz?t&ohp!.remarf,?ua???p!.&ces?gro?moc?olp?ten?ude?vog??i&hsralohcs?lihp?t??u??r!.&au,ca?gro?ni?oc?topsgolb,ude?vog?xo,yldnerb.pohs,?a&c?p?tiug??c?e&dliub!.etisduolc,?erac?gor?levart?mraf?n&niw?trap??wolf??ot&cartnoc?omatat??pj?uot??s!.&em?gro?hcs?moc?ten?ude?vog?zib??alg?e&n&isub",
- "!.oc,?tif??rp!xe!nacirema???xnal??iws??t&a&e&b?ytic??ob??ek&cit?ram??fig?h&cay?gilf??n&atnuocca?e&mt&rapa?sevni??ve!.&nibook,oc,????rap??u!.&a&c!.&21k?bil?cc???g!.&21k?bil?cc???i!.&21k?bil?cc???l!.&21k?bil?cc???m!.&21k!.&hcorap?rthc?tvp???bil?cc???p!.&21k?bil?cc???si?v!.&21k?bil?cc???w!.&21k?bil?cc????c&d!.&21k?bil?cc???n!.&21k?bil?cc???s!.&21k?bil?cc????d&e&f?lacsne.xhp,?i!.&21k?bil?cc???m!.&21k?bil?cc???n!.&bil?cc???s!.&bil?cc???u&olcrim,rd,??e&d!.&21k?bil,cc???las-4-&dnal,ffuts,?m!.&21k?bil?cc???n!.&21k?bil?cc????h&n!.&21k?bil?cc???o!.&21k?bil?cc????i&h!.&bil?cc???m!.&21k?bil?c&c?et??goc?n&eg?otae??robra-nna?sum?tsd?wanethsaw???nd?r!.&bil?cc???v!.&21k?bil?cc???w!.&21k?bil?cc????jn!.&21k?bil?cc???k&a!.&21k?bil?cc???o!.&21k?bil?cc????l&a!.&21k?bil?cc???f!.&21k?bil?cc???i!.&21k?bil?cc????mn!.&21k?bil?cc???n&afflog,i!.&21k?bil?cc???m!.&21k?bil?cc???sn?t!.&21k?bil?cc????o&c!.&21k?bil?cc???m!.&21k?bil?cc???ttniop,?p&ion,rettalp,?r&a!.&21k?bil?cc???o!.&21k?bil?cc???p!.&21k?bil?cc????s&a!.&21k?bil?cc???dik?k!.&21k?bil?cc???m!.&21k?bil?cc???nd&deerf,uolc,??t&c!.&21k?bil?cc???m!.&21k?bil?cc???u!.&21k?bil?cc???v!.&21k?bil?cc????ug!.&21k?bil?cc???v&n!.&21k?bil?cc???w!.cc???x&ohparg,t!.&21k?bil?cc????y&b-si,k!.&21k?bil?cc???n!.&21k?bil?cc???w!.&21k?bil?cc????za!.&21k?bil?cc????ah!uab??bria?col?e!.ytrap.resu,?ineserf?lp?xe&l?n???vt?w!.&66duolc,gro?moc?s&ndnyd,tepym,?ten?ude?vog??a?e&iver?n!.elbaeciton,??odniw??y&alcrab?ot???t&0srzc--nx?a!.&amil4,ca!.hts??etiesbew321,gni&liamerutuf,tsoherutuf,?o&c!.topsgolb,?fni,?p&h21,ohsdaerpsym,?r&euefknuf.neiw,o??v&g?irp,?xi2,ytic-amil,zib,?c?e!s??hc?l!asite??mami?rcomed??b!.&gro?moc?ten?ude?vog??b?gl??c&atnoc?e&les?rid!txen????dimhcs?e!.&eman?gro?moc?ofni?ten?ude?vog?zib??b?em?grat?id?k&circ?ram??n!.&0rab,1rab,2rab,5inu,6vnyd,7&7ndc.r,erauqs,?a&l&-morf,moob,?minifed,remacytirucesym,tadsyawla,z,?b&boi,g,lyltsaf:.pam,,?c&i&nagro-gnitae,tats-oieboda,?paidemym,?d&e&calpb,ziamaka,?hiamaka,irgevissam.saap.&1-&gs,nol,rf,yn,?2-&nol,yn,??nab-eht-ni,uolc&meaeboda,nievas.c&di-etsedron,itsalej,?xednay:.e&garots,tisbew,?,??e&c&narusnihtlaehezitavirp,rofelacs.j,?gd&eiamaka,irbtib,?ht-no-eciffo,l&acs&liat.ateb,noom,?ibom-eruza,?m&ecnuob,itnuroieboda,ohtanyd,tcerider,?n&ilno-evreser,ozdop,?rehurht,s:abapus,,ti&s-repparcs,usegde,?zam&aym,kcar,??f&aeletis,crs.&cos,resu,?ehc-a-si,?g&ni&gats-&d&eziamaka,hiamaka,?e&gdeiamaka,tiusegde,?iamaka,nigiroiamaka,yekegde,?reesnes,sirkcilc,tsohnnylf,?olbevres,?iamaka,k&catsvano,eeg-a&-si,si,?u,?l&acolottad,iamwt,meteh,s&d-ni,s-77ndc,??m&ac&asac,ih,?urofniem,?n&a&f&agp,lhn,?i&bed,llerk,??dcduabkcalb,i:giroiamaka,,pv-ni,?o&c-morf,duppa,jodsnd,rp-ytinummoc,ttadym,?p&i&-&etsef,on,?emoh,fles,nwo,?j,mac-dnab-ta,o&-oidar-mah,h&bew,sdaerpsym,??pa&duolc,egde,?tfe&moh,vres,?usnd,?r&e&tsulcyduolc,vres-xnk,?vdslennahc:.u,,?s&a&ila&nyd,snd,?nymsd,?bbevres,dylimaf,e&gde-ndc,rauqs,suohsyub,t&isbeweruza,ys,??k&catstsaf,ekokohcs,?n&d&-won,aka,d,golb,npv,?oitcnufduolc,?ppacitatseruza:.&1,2:suts&ae,ew,?,3,aisatsae,eporuetsew,sulartnec,?,s&a-skcik,ecca&-citats,duolc,??t,?t&adies,ce&ffeym,jorprot:.segap,,lespohs,?e&nretnifodne,smem,?farcenimevres,i-&ekorb,s&eod,lles,teg,??n&essidym,orfduolc,?r0p3l3t,s&ixetnod,oh&-spv:.citsalej.&cir,lta,sjn,?,gnik,???u&h,nyd,r:eakust.citsalej,,?ved-naissalta.dorp.ndc,x&inuemoh,spym,tsale.&1ots-slj,2ots-slj,3ots-slj,?unilemoh,?y&awetag-llawerif,ekegde,ffijduolc:.&ed-1arf,su-1tsew,?,ltsaf.&dorp.&a,labolg,?lss.&a,b,labolg,?pam,slteerf,?n&-morf,ofipi,?srab,?z&a-morf,tirfym,???p?tcip?v??f&ig?osorcim??g!.&bog?dni?ed,g&olb,ro??lim?moc?ot,ten?ude???h!.&dem?gro?l&er?op??m&oc?rif??o&fni?rp?s&rep?sa???po&hs?oc??t&en?luda?ra??ude?vuog???i!.&a&2n-loritds--nx?7e-etsoaellav--nx?8&c-aneseclrof--nx?i-lrofanesec--nx??at?b?c!cul??dv?i&blo&-oipmet?oipmet??cserb?drabmol?g&gof?urep??l&gup?i&cis?me&-oigger?oigger???uig&-&aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf???aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf????n&a&brev?cul?pmac?tac??idras?obrac&-saiselgi?saiselgi??resi??otsip?r&b&alac!-oigger?oigger??mu??dna&-&attelrab-inart?inart-attelrab??attelrabinart?inartattelrab?ssela??epmi?ugil??tnelav&-obiv?obiv??vap?z&e&nev?ps&-al?al???irog???l&iuqa!l??leib??m&or?rap??n!acsot?e&dom?is?sec&-&ilrof?ìlrof??ilrof?ìlrof???g&amor&-ailime?ailime??edras?olob??i&ssem?tal??ne!var??o&cna?merc?rev?vas???oneg?p?r!a&csep?rr&ac&-assam?assam??ef??von??etam?tsailgo!-lled?lled???s!ip?sam&-ararrac?ararrac??u&caris?gar???t!a&cilisab?recam??resac?soa!-&d&-&ellav?lav??ellav?lav??ellav??d&-&ellav?lav??ellav?lav??ellav??te&lrab&-&airdna-inart?inart-airdna??airdnainart?inartairdna??ssinatlac???udap?v!o&dap?neg?tnam???zn&airb&-a&lled-e-aznom?znom??a&lledeaznom?znom??eaznom??e&c&aip?iv??soc?top??om???b&-&23,46,61,?3c-lorit-ds-onitnert--nx?be-etsoa&-ellav--nx?dellav--nx??c!f-anesec-lrof--nx?m-lrof-anesec--nx??he-etsoa-d-ellav--nx?m!u??o2-loritds-nezob--nx?sn-loritds&-nasl&ab--nx?ub--nx??nitnert--nx??v!6-lorit-dsnitnert--nx?7-loritds&-nitnert--nx?onitnert--nx???z&r-lorit-ds&-nitnert--nx?onitnert--nx??s-loritds-onitnert--nx???c&f?is?l?m?p?r?v??d&p?u!olcnys,??e&c!cel?inev?nerolf??f?g!apemoh321,ida&-&a&-onitnert?onitnert??otla!-onitnert?onitnert???a&-onitnert?onitnert??otla!-on&azlob?itnert??onitnert????hcram?l?m!or??n&idu?o&n&edrop?isorf??torc???p?r?s&erav?ilom??t!nomeip?s&eirt?oa!-&d-e&ellav?éllav??e&ellav?éllav???de&ellav?éllav??e&ellav?éllav?????v?znerif??g&a?b?f?il?o?p?r?up?vf??hc?i&b?c?dol?f?l!lecrev?opan?rof&-anesec?anesec???m?n&a&part?rt&-attelrab-airdna?attelrabairdna???imir?ret??p?r!a&b?ilgac?ssas???s!idnirb??t&ei&hc?r??sa??v??l&a!c??b?c?o&m?rit&-&d&eus&-&nitnert?onitnert??nitnert?onitnert??us&-&nitnert?onitnert??nitnert?onitnert??üs&-&nitnert?onitnert??nitnert?onitnert???s&-onitnert?onitnert???d&eus!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??us&-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??üs!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert???s&-onitnert?onitnert?????m&ac?f?i!t.nepo.citsalej.duolc,?ol?r??n&a!lim?sl&ab?ub???b?c?e!en.cj,v?zob??irut?m!p??p?r?t??o&a!v??b!retiv??c!cel??enuc?g!ivor??i&dem&-onadipmac?onadipmac??pmet&-aiblo?aiblo??rdnos?zal??l?m!a&greb?ret??oc?re&f?lap???n!a&dipmac&-oidem?oidem??lim?tsiro?zlob??ecip&-ilocsa?ilocsa??i&bru&-orasep?orasep??lleva?rot?tnert??r&elas?ovil??ulleb??p?r!a&sep&-onibru?onibru??znatac??oun??s!ivert?sabopmac??t!arp?e&nev?ssorg??n&arat?e&girga?rt?veneb????zz&era?urba???p&a?ohsdaerpsym,s?t??qa?r&a!m?s??b!a??c?f?g?k?me?o?p?s?t?v??s&a&b?iselgi&-ainobrac?ainobrac???b?c?elpan?i?m?o&t?x&bi,obdaili,??s?t?v??t&a?b?c?l?m?nomdeip?o!psgolb,?p?v??u&de?l?n?p??v&a?og?p?s?t?v??y&drabmol?ellav&-atsoa?atsoa??licis?nacsut??z&al?b?c?p??ìlrof&-anesec?anesec???derc?er?f?m?utni??je3a3abgm--nx?kh?l!.&topsgolb,vog??uda??m!.&gro?moc!.topsgolb,?ten?ude???n&a&morockivdnas?ruatser?tnuocca??e&g?m&eganam!.retuor,?piuqe??r??i!.ue?m?opdlog??opud?uocsid??o&b?cs!.&ude,vog:.ecivres,,??d?g?h?j?oferab?p&edemoh?s???p!.&bewanigap321,emon?gro?lbup?moc?t&en?ni?opsgolb,?ude?vog???r&a!m&law?s???epxe?op&er?pus!.ysrab,?s???s!.&a&daxiabme?rarik,?e&motoas?picnirp?rots??gro?lim?moc?o&c?dalusnoc?hon,?ten?ude??a&cmoc?f??e&b?r?uq??i!rolf?tned??o&h!.&duolc&p,rim,?e&lej,tiseerf,?flah,l&enapysae,rupmet,?s&pvtsaf,seccaduolc,?tsafym,vedumpw,??p!sua???urt??t!.&eman?gro?ibom?levart?m&oc?uesum??o&c?fni?r&ea?p???pooc?sboj?t&en?ni??ude?vog?zib??ayh?n?o!bba?irram???uognah?xen?y!.gro,?ztej??u&2&5te9--nx?yssp--nx??a!.&a&s?w??civ?d&i?lq??fnoc?gro?moc!.&pohsdaerpsym,stelduolc.lem,topsgolb,??nsa?ofni?sat?t&ca?en?n??ude!.&a&s?w??ci&lohtac?v??dlq?sat?t&ca?n??wsn!.sloohcs????vog!.&a&s?w??civ?dlq?sat???wsn?zo??ti??c!.&fni?gro?moc?ten?ude?vog??i??d&e!.tir.segap-tig,?iab??e!.&dcym,enozgniebllew,noitatsksid,odagod.citsalej,s&nd&ps,uolc,?ppatikria,?ysrab,??g!.&bew?gro?m&aug?oc??ofni?ten?ude?vog???h!.&0002?a&citore?idem?kitore??edszot?gro?ilus?letoh?m&alker?lif?t?urof??naltagni?o&c?ediv?fni?levynok?nisac??pohs?rarga?s&a&kal?zatu??emag?wen??t&lob?opsgolb,rops??virp?xe&s?zs??ytic?zsagoj??os?sut??l!.&etisbew321,topsgolb,??m!.&ca?gro?moc?oc?ro?ten?vog???n!.&duolcesirpretne,eni&esrem,m,?tenkcahs,?em!.ysrab,??o&ggnaw?y!c???r!.&3kl,a&i&kymlak,rikhsab,vodrom,?yegyda,?bps,ca,duolcrim,e&niram,rpcm,?g&bc,nitsohurger.citsalej,ro,?ianatsuk,k&ihclan,s&m,rogitayp,??li&amdlc.bh,m,?moc,natsegad,onijym,pp,ri&b,d&cm:.spv,,orue,?midalv,?s&ar,itym,?t&en,ias321,ni,opsgolb,set,?u&4an,de,?vo&g,n,?ynzorg,zakvakidalv,?myc?p?ug??s!.&a&d&golov,nagarak,?gulak,i&groeg,kymlak,lerak,nemra,rikhsab,ssakahk,vodrom,zahkba,?lut,rahkub,vut,yegyda,znep,?bps,da&baghsa,rgonilest,?gunel,i&anatsuk,hcos,ovan,ttailgot,?k&alhsygnam,ihclan,s&legnahkra,m,n&a&mrum,yrb,?i&buytka,nbo,??tiort,vorkop,??l&ocarak,ybmaj,?na&gruk,jiabreza,ts&egad,hkazak-&htron,tsae,???ovonavi,r&adonsark,imidalv,?t&enxe,nek&hsat,mihc,??vo&hsalab,n,?ynzorg,z&akvakidalv,emret,??t&amok?i&juf?masih????v!.&em,g&olb,ro??moc?nc,ten?ude?ved,??ykuyr??v&b?c!.&emon?gro?moc?t&ni?opsgolb,?ude???ed!.&2r,ated,e&docotua,erf-korgn,nilnigol,?gnigats-oned,hcetaidem,korgn,lecrev,o&ned,tpyrctfihs,?ppa-rettalp,s&egap,rekrow,?vr&esi,uc,?weiverpbuhtig,ylf,??ih?l!.&di?fnoc?gro?lim?moc?nsa?ten?ude?vog???m!.&eman?gro?lim?m&oc?uesum??o&fni?r&ea?p???pooc?t&en?ni??ude?vog?zib???o&g?m??rt?s!.&bog?der?gro?moc?ude???t!.&arukas,bew-eht-no,morf,naht-&esrow,retteb,?sndnyd,?d?i?won??uqhv--nx??w&a!.moc?hs?l??b!.&gro?oc???c!.&gro?moc?ten?ude??cp??e&iver!.oby,?n?s??g?k!.&bme?dni?gro?moc?ten?ude?vog???m!.&ca?gro?m&oc?uesum??oc?pooc?t&en?ni??ude?vog?zib??b??o&csom?h!s??n?w??p!.&344x,de?en?o&c?g??ro?snduolc,ualeb???r!.&ca?gro?lim?oc?pooc?ten?vog??n??t!.&a46oa0fz--nx?b&82wrzc--nx?ulc??emag?gro?l&im?ru,?moc!.reliamym,?t&en?opsgolb,?ude?v&di?og?ta0cu--nx??zibe?業商?織組?路網???z!.&ca?gro?lim?oc?vog????x&a!.&cm,eb,gg,s&e,u,?tac,ue,yx,?t??c!.&hta,ofni,vog???e&d&ef?nay??ma!nab??rof?s??ilften?jt?m!.&bog?gro?moc?t&en?opsgolb,?ude??g?ma2ibgy--nx??o&b!x??f?rex??rbgn--nx?s!.vog??x&am&jt?kt??x???y&4punu--nx?7rr03--nx?a&d!i&loh?rfkcalb??ot!.emyfilauqerp,??g?lp?p!ila??rot?ssin?wdaorb??b!.&duolcym,fo?hcetai",
- "dem,lim?moc!.topsgolb,?vog??ab?gur??c!.&ca?dtl?gro?lim?m&oc!.&ecrofelacs.j,topsgolb,??t??orp?s&egolke?serp??ten?vog?zib??amrahp?nega??d&dadog?uts??e&kcoh?ltneb?n&dys?om?rotta??snikcm??g!.&eb,gro?moc?oc?ten?ude?vog??olonhcet!.oc,?rene??hpargotohp?id?k!.&gro?moc?ten?ude??s??l!.&clp?d&em?i??gro?hcs?moc?ten?ude?vog??f?imaf!nacirema??l&a?il??ppus??m!.&eman?gro?lim?moc?t&en?opsgolb,?ude?vog?zib??edaca!.laiciffo,?ra??n&a&ffit?pmoc??os??o&j?s??p!.&gro?lim?moc?pooc?ten?ude?vog???r&e&corg?grus?llag?viled??lewej?otcerid?tnuoc?uxul??s!.&gro?lim?moc?ten?ude?vog??pil??t&efas?i&c?ledif?n&ifx?ummoc!.&bdnevar,gon,murofym,???r&ahc?uces??srevinu??laer?r&ap!.oby,?eporp??uaeb??u!.&bug?gro?lim?moc!.topsgolb,?ten?ude??b!tseb???van!dlo??xes??z&a!.&eman?gro?lim?moc?o&fni?rp??pp?t&en?ni??ude?vog?zib???b!.&az,gro?jsg,moc?ten?ude?vog???c!.&4e,inum.duolc.&rsu,tlf,?m&laer,urtnecatem.motsuc,?oc,topsgolb,??d!.&cos?gro?lop?m&oc?t??ossa?t&en?ra??ude?vog???ib!.&duolcsd,e&ht-rof,mos-rof,rom-rof,?izoj,liartevitca,nafamm,p&i&-on,fles,?ohbew,tfym,?retteb-rof,snd&nyd,uolc,?xro,?g??k!.&duolcj,gro?lim?moc?t&en?ropeletzak.saapu,?ude?vog???m!.&ca?gro?lim?oc?ten?ude?v&da?og????n!.&asq-irom--nx?ca?gro?htlaeh?i&r&c?o&am?ām???wi!k???keeg?l&im?oohcs??neg?oc!.topsgolb,?t&en?nemailrap?vog???a!niflla???rawhcs?s!.&ca?gro?oc???t!.&c&a?s??e&m?n??ibom?l&etoh?im??o&c?fni?g??ro?vt???u!.&gro?moc?oc?ten??rwon??yx!.&e&nozlacol,tisgolb,?gnitfarc,otpaz,??zub??λε?υε?авксом?брс!.&гро?до?ка?р&бо?п!у?????г&б?ро??дкм?зақ?итед?килотак?леб?мок?н&йално?ом??рку?сур!.&арамас,бпс,гро,зиб,ичос,ксм,м&ок,ырк,?рим,я,??тйас?фр?юе?յահ?לארשי!.&בושי?הימדקא?ל&הצ?שממ????םוק?اي&روس?سيلم?ناتيروم??بر&ع?غملا??ة&كبش?ي&دوعسلا?روس??یدوعسلا??ت&ا&راما?لاصتا??را&ب?ڀ?ھب???ر&ئازجلا?ازاب?صم?طق??سنوت?عقوم?قارع?ك&تيب?يلوثاك??موك?ن&ا&تس&كاپ?کاپ??دوس?ر&يا?یا??مع?يلعلا??درالا?ميلا?ي&رحبلا?طسلف???ه&ارمه?يدوعسلا??وكمارا?يبظوبا?ۃیدوعسلا?टेन?त&राभ?ोराभ??नठगंस?मॉक?्मतराभ?ত&রাভ?ৰাভ??ালংাব?ਤਰਾਭ?તરાભ?ତରାଭ?ாயித்நஇ?ைக்ஙலஇ?்ரூப்பக்ஙிச?్తరాభ?ತರಾಭ?ംതരാഭ?ාකංල?มอค?ยทไ!.&จิกรุธ?ต็นเ?ร&ก์คงอ?าหท??ลาบฐัร?าษกึศ???ວາລ?ეგ?なんみ?アトス?トンイポ?ドウラク?ムコ?ル&グーグ?ーセ??ン&ゾマア?ョシッァフ??业企?东广?乐娱?你爱我?信中?务政?动移?博微?卦八?厅餐?司公?品食?善慈?团集?国中?國中?址网?坡加新?城商?尚时?山佛?店&商?网?酒大里嘉??府政?康健?息信?戏游?拉里格香?拿大?教主天?机手?构机!织组??标商?歌谷?浦利飞?港香!.&人個?司公?府政?絡網?織組?育教???湾台?灣&台?臺??物购?界世?益公?看点?科盈訊電?站网?籍書?线在?络网?网文中?聘招?販通?逊马亚?通联?里嘉?锡马淡?門澳?门澳?闻新?電家?국한?넷닷?성삼?컴닷??");
+ "a&0&0trk9--nx?27qjf--nx?e9ebgn--nx?nbb0c7abgm--nx??1&2oa08--nx?apg6qpcbgm--nx?hbbgm--nx?rdceqa08--nx??2&8ugbgm--nx?eyh3la2ckx--nx?qbd9--nx??3&2wqq1--nx?60a0y8--nx??4x1d77xrck--nx?6&1f4a3abgm--nx?2yqyn--nx?5b06t--nx?axq--nx?ec7q--nx?lbgw--nx??883xnn--nx?9d2c24--nx?a&a?it??b!.&gro?lim?moc?sr,t&en?opsgolb,?ude?vog??abila?c?ihsot?m?n??c!.&b&a?m?n??c&b?g?q??ep?fn?k&s?y??ln?no?oc,p&i-on,ohsdaerpsym,?sn?t&n?opsgolb,?un?ysrab,?i&ma?r&emarp?fa??sroc??naiva?s??d&ats?n&eit?oh??om?sa?tl??eg?f&c?ob??g!emo?naripi?oy??hskihs?i&dem!.remarf,?hs?k!on??sa!.snduolc,??jnin?k&aso?dov?ede?usto??l!.&c,gro?moc?ofni?r&ep?nb,?t&en?ni??ude?vog??irgnahs?le&nisiuc?rbmuder???m!.&ca?gro?oc?sserp?ten?vog??ahokoy?e00sf7vqn--nx?m??n!.&ac?cc?eman?gro?ibom?loohcs?moc?ni?o&c?fni?rp??r&d?o??s&u?w??vt?xm??av?is?olecrab?tea??p!.&bog?ca?d&em?ls??g&ni?ro??mo&c?n??oba?ten?ude??c?g7hyabgm--nx?ra!.&461e?6pi?iru?nru?rdda-ni?siri???s??q!.&eman?gro?hcs?lim?moc?t&en?opsgolb,?ude?vog???r&az?emac?f4a3abgm--nx?n!d5uhf8le58r4w--nx??u&kas?tan???s!.&bup?dem?gro?hcs?moc?ten?ude?vog??ac!.uban.iu,?iv??t&ad?elhta?led?oyot??u!.&a&cinniv?emirc?i&hzhziropaz?stynniv?ttaprakaz??s&edo?sedo??tlay?vatlop??bs?cc,d&argovorik?o!ro&ghzu?hhzu???tl,?e&hzhziropaz?i,nvir?t??f&i?ni,?g&l?ro??hk?i&stvinrehc?ykstyn&lemhk?vypork???k&c?m?s&na&gul?hul??t&enod?ul??v&iknarf-onavi?orteporp&end?ind?????l&iponret?opotsa&bes?ves??p??m&k?oc?s?yrk??n&c?d?i?osrehk?v?ylov??o&c,nvor??p&d?p,z??r&c?imotihz?k?ymotyhz??sk?t&en?l?z??ude?v:c?e&alokin?ik??i&alokym?hinrehc?krahk?vl?yk??k?l?o&g!inrehc??krahk??r?,xc,y&ikstinlemhk?mus?s&akrehc?sakrehc?tvonrehc???z&ib,u????v!aj?bb?et?iv??waniko?x&a?iacal??yogan?z&.&bew?c&a?i&n?rga???gro?l&im?oohcs??m&on?t??o&c!.topsgolb,?gn??radnorg?sin?t&en?la??ude?vog?wal??zip!.korgn,???b&00ave5a9iabgm--nx?1&25qhx--nx?68quv--nx?e2kc1--nx??2xtbgm--nx?3&b2kcc--nx?jca1d--nx??4&6&1rfz--nx?qif--nx??96rzc--nx??88uvor--nx?a&0dc4xbgm--nx?c?her?n?ra?t??b!.&erots?gro?moc?o&c?fni??ten?ude?v&og?t??zib??a??c&j?s??d&hesa08--nx?mi??g?l!.&gro?moc?ten?ude?vog??m??s!.&gro?moc?ten?ude?vog???tc-retarebsnegmrev--nx?u&lc!.&elej,snduolc,ysrab,?smas??p!.ysrab,??wp-gnutarebsnegmrev--nx??c&1&1q54--nx?hbgw--nx??2e9c2czf--nx?4&4ub1km--nx?a1e--nx?byj9q--nx?erd5a9b1kcb--nx??8&4xx2g--nx?c9jrb2h--nx??9jr&b&2h--nx?54--nx?9s--nx??c&eg--nx?h3--nx?s2--nx???a!.&gro?lim?moc?rrd,ten?ude?vog??3a09--nx!.&ca1o--nx?gva1c--nx?h&ca1o--nx?za09--nx??ta1d--nx?ua08--nx????b&a?b?ci?f76a0c7ylqbgm--nx?sh??c!.&eugaelysatnaf,gnipparcs,liamwt,nwaps.secnatsni,revres-emag,s&nduolc,otohpym,seccaptf,?xsc,?0atf7b45--nx?a1l--nx??e!.&21k?bog?dem?esab,gro?l&aiciffo,im??moc?nif?o&fni?rp??ten?ude?vog??beuq?n?smoc??fdh?i&l&buperananab?ohtac??n&agro?ilc?osanap??sum?tic??l!.&gro?moc?oc?ten?ude?vog?yo,?l??m!.&mt?ossa??p1akcq--nx??n!.&mon?ossa??i?p??relcel?s!.&gro?moc?ten?ude?vog???t!.&e&m,w,?hc,?s?w??v!.&e0,gro?lim?moc?ten?ude?v&g:.d,,og????wp?yn??d&2urzc--nx?3&1wrpk--nx?c&4b11--nx?9jrcpf--nx???5xq55--nx?697uto--nx?75yrpk--nx?9ctdvkce--nx?a!.mon?d?er?olnwod??b2babgm--nx?c!.vog?g9a2g2b0ae0chclc--nx??e&m!bulc??r!k??sopxe?timil?w??fc?g!.&ude?vog???h&d3tbgm--nx?p?t??i!.&ased?bew?ca?etrof,hcs?lim?o&c!.topsgolb,?g??palf,ro?sepnop?ten?ym?zib??b?ordna?p?rdam??l&iub?og?row??m!.&ed,ot,pj,t&a,opsgolb,???n&a&b?l!.citats:.&setis,ved,?,raas???ob?uf??o&of?rp??r&a&c&tiderc?yalcrab??ugnav??ef506w4b--nx?k!.&oc,ude,?jh3a1habgm--nx??of??s!.&dem?gro?moc?ofni?ten?ude?v&og?t???m!kcrem???t!.topsgolb,excwkcc--nx?l??uolc!.&a&bura-vnej.&1ti,abura.rue.1ti,?tcepsrep,xo:.&ku,nt,?,?b&dnevar,ewilek:.sc,,?citsalej.piv,drayknil,elej,gnitsohdnert.&ed,hc,?letemirp:.ku,,m&edaid,ialcer.&ac,ku,su,??n&evueluk,woru,?r&epolroov,o&pav,tnemele,??tenraxa.1-se,ululetoj,wcs.&gnilebaltrams,koobelacs,latemerab.&1-&rap-rf,sma-ln,?2-rap-rf,?rap-rf.&3s,cnf:.snoitcnuf,,etisbew-3s,mhw,s8k:.sedon,,?s&8k,ecnatsni.&bup,virp,?ma-ln.&3s,etisbew-3s,mhw,s8k:.sedon,,??waw-lp.&3s,etisbew-3s,s8k:.sedon,,??xelpciffart,yawocne.ue,??za5cbgn--nx??e&1&53wlf--nx?7a1hbbgm--nx?ta3kg--nx??2a6a1b6b1i--nx?3ma0e1cvr--nx?418txh--nx?707b0e3--nx?a!.&ca?gro?hcs?lim?oc?t&en?opsgolb,?vog??09--nx??b!.&ca?etisbew321,gnitsohbew,nevueluk.yxorpze,pohsdaerpsym,snoitulostsohretni.duolc,topsgolb,?ortal?ut!uoy???c&0krbd4--nx!.&a2qbd8--nx?b8adbeh--nx?c6ytdgbd4--nx?d8lhbd5--nx???a&lp!.oc,?ps!.&lla4sx,rebu,tsafym,?artxe??sla??i!ffo??n&a&d?iler?nif?rusni!efil?srelevart???eics!.oby,??rofria??d!.&1sndnyd,42pi-nyd,7erauqs,amil4,b&ow-nrefeilgitsng--nx,rb-ni,vz-nelletsebgitsng--nx,?decalpb,e&daregtmueart,luhcsvresi,mohsnd,nihcamyek,tiesbew321,?hcierebsnoissuksid,keegnietsi,lsd-ni,m&oc,rofttalpluhcs,?n&-i-g-o-l,aw-ym,e&lletsebgitsnüg,sgnutiel,?i&emtsi,lreb-n&i,yd,??norblieh-sh.ti.segap,oitatsksid-ygolonys,pv&-n&i,yd,?nyd,?refeilgitsnüg,?orp-ytinummoc,p&h21,iog:ol,,ohsdaerpsym,?r&e&ntrapdeeps.remotsuc,su&-lautriv,lautriv,?t&adpusnd,tub-ni,uor-ym,?vres&-e&bucl,mohym,?bew-emoh:.nyd,,luhcs,??ogiv-&niem,ym,??s&d-&onys,ygolonys,?nd&-&dd,nufiat,sehcsimanyd,tenretni,yard,?isoc.nyd,ps,yard,?oper-&nvs,tig,?sndd:.&nyd,sndnyd,?,?topsgolb,vresi-&niem,tset,?xi2,y&awetag-&llawerif,ym,?srab,tic-amil,?zten&mitbel,sadtretteuf,??art!.oby,?i&sdoow?ug??on--nx??e!.&bil?dem?eif?gro?irp?kiir?moc!.topsgolb,?pia?ude?vog??ei?ffoc?gg?r&f?ged???f&a&c?s??il??g!.&gro?lim?moc?t&en?vp??ude?vog??a&f?gtrom?p!.&3xlh,detalsnart,grebedoc,kselp,sndp,tengam,xlh,y&cvrp,kcor,???rots?yov??elloc?na&hcxe?ro!.hcet,??roeg?ug??i!.&pohsdaerpsym,topsgolb,vog??tilop?v&bba?om???j!.&fo,gro?oc?ten???k!.&c&a?s??e&m?n??ibom?o&c!.topsgolb,?fni?g??ro??i&b?l?n???l&a&dmrif?s!rof???b&a?i&b?dua???c&aro?ric??dnik?g!oog??i&bom?ms??l&asal?erauqa??ppa?uhcs?yts!efil???m!.&4&32i,p&ct,v,??66c,ailisarb,b&dnevar,g-raegelif,?ca?duolcsd,e&d-raegelif,i&-raegelif,lpad:.tsohlacol,,?pcm,?g&ro?s-raegelif,?hctilg,kcatsegde,noitatsksid,o&bmoy,c?t&nigol,poh,??p&i&on,snart.etis,?j-raegelif,ohbew,?r&aegelif,idcm,ofsnd,?s&dym,ndd,ti?umhol,?t&en?s&acdnuos,ohon,??u&a-raegelif,de??v&irp?og??y&golonys,olpedew,srab,??a&g?n!.&reh.togrof,sih.togrof,???em?irp?orhc?w??n!goloc?i&lno!.&egats-oree,oree,ysrab,??w??o!.&derno:.gnigats,,ecivres,knilemoh,?hp?latipac?ts&der?e&gdirb?rif???z!.&66duolc,amil,sh,???ruoblem??om?p!.&bog?gro?lim?mo&c?n??t&en?opsgolb,?ude??irg?yks??r!.&mo&c?n??ossa?topsgolb,?a&c!htlaeh??pmoc?wtfos??bc?eh?if?ots!.&e&rawpohs,saberots,?yflles,??taeht?u&ces?sni?t&inruf?necca??za???s!.&a!bap.us,disnim321,?b!ibnal?rofmok??c!a??d!b?n&arb?ubroflanummok???e?f!noc,?g!ro??h!f??i!trap??k!shf??l?m!oc,t??n!mygskurbrutan??o?p!ohsdaerpsym,p??r!owebdluocti,?s!serp?yspoi,?t!opsgolb,?u?vhf?w?x!uvmok??y?z??a&c?el?hc??i&er?urc??nesemoh?roh?uoh??t&a&d?ts&e!laer??lla???is!.&e&lej,nilnigol,r&etnim,ocevon,?winmo,?k&rowtenoilof,wnf,?laicosnepo,n&eyb,oyc,?spvtsaf,thrs,xulel,ysrab,?bew!.remarf,??ov?ra?t&ioled?ol??utitsni??u&lb?qi&nilc?tuob???v!.&21e?b&ew?ib?og??ce&r?t??erots?gro?lim?m&o&c?n??rif??o&c?fni??rar?stra?t&en?ni??ude?vog??as?e3gerb2h--nx?i&l!.xlh,?rd?ssergorp??ol??w&kct--nx?r??xul?y!.&gro?lim?moc?ten?ude?vog????f&0f3rkcg--nx?198xim--nx?280xim--nx?7vqn--nx?a!.&gro?moc?ten?ude?vog???b!.vog?wa9bgm--nx??c!.topsgolb,a1p--nx!.&a14--nx,b8lea1j--nx,c&avc0aaa08--nx,ma09--nx,?f&a1a09--nx,ea1j--nx,?gva1c--nx,nha1h--nx,pda1j--nx,zila1h--nx,??ns??ea1j--nx?g?iam?l&a1d--nx?og??n!.&bew?cer?erots?m&oc?rif??ofni?re&hto?p??stra?ten???orp?p!.&gro?moc?ude???rus?t!.hcs,w??vd7ckaabgm--nx?w!.&hcs,zib,???g&2&4wq55--nx?8zrf6--nx??3&44sd3--nx?91w6j--nx!.&a5wqmg--nx?d&22svcw--nx?5xq55--nx??gla0do--nx?m1qtxm--nx?vta0cu--nx????455ses--nx?5mzt5--nx?69vqhr--nx?7&8a4d5a4prebgm--nx?rb2c--nx??a!.&gro?mo&c?n??oc?ten??vd??b!.&0?1?2?3?4?5?6?7?8?9?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t!opsgolb,?u?v?w?x?y!srab,?z???c!b?za9a0cbgm--nx??e!.&eman?gro?ics?lim?moc!.topsgolb,?nue?ten?ude?vog??a??g!.&ayc,gro?lenap:.nomead,,oc?saak,ten???i&a?v??k!.&g&olb,ro??ku,lim?moc?oi,pj,su,ten?ude?v&og?t,???m!.&drp?gro?lim?m&o&c?n??t??oc?ude?vog??pk??n!.&dtl,eman?gro?hcs?i!bom??l&im?oc,?m&oc!.topsgolb,?rif,?neg,ogn,ten?ude?vog??aw?i!b!mulp??car?d&art?dew??h&sif?tolc??k&iv?oo&b?c???ls?n&aelc?iart??p!pohs??re&enigne?tac??t&ad?ekram?hgil?lusnoc?neg?ov?soh!.tfarcnepo,??vi&g?l???o!s??u&rehcisrev?smas?tarebsnegömrev???o&d?lb?og!.&duolc,etalsnart,???r&2n084qlj--nx?ebmoolb?o!.&77ndc.c:sr,,a&remacytirucesym,t&neimip,sivretla,?z,?bew-llams,d&ab-yrev-si,e&sufnocsim,vas-si,?nuof-si,oog-yrev-si,uolc&arfniarodef,mw,??e&a,cin-yrev-si,grof&loot,peh,?l&as-4-ffuts,poeparodef,?m&-morf,agevres,ohruoyslles,?n&ozdop,uma.elet,?r&ehwongniogyldlob,iwym,uces-77ndc.nigiro.lss,?t&adidnac-a-si,is&-ybboh,golb,???fehc-a-si,golbymdaer,k&eeg-a&-si,si,?h,nut,?l&i&amwt,ve-yrev-si,?lawerif&-ym,ym,?sd-ni,?m&acssecca,edom-elbac,?n&af&blm,cfu,egelloc,lfn,s&citlec-a-si,niurb-a-si,tap-a-si,?xos-a-si,?ibptth,o&itatsksid,rviop,?p&j,v-ni,??o&jodsnd,tp&az,oh,??p&i&-on,fles,?o&hbew,tksedeerf,?tf&e&moh,vres,?ym,??r&e&gatop,ppepteews,su-xunil-a-si,?gmtrec,vdmac,?s&a&ila&nyd,snd,?nymsd,?b&alfmw,bevres,?d&ikcet.3s,ylimaf,?eirfotatophcuoc,j,koob-daer,ltbup,nd&-won,deerf,emoh,golb,kcud,mood,nyd:.&emoh,og,?,ps,rvd,tog,uolc,?s&a-skcik,ndd,?tnemhcattaomb,u,?t&ce&jorparodef.&duolc,gts.so.ppa,so.ppa,?riderbew,?e&ews-yrev-si,nretni&ehtfodne,fodne,??hgink-a-si,oi-allizom,s&ixetn&od,seod,?o&h-emag,l-si,?rifyam,??ue:.&a&-q,c,?cm,dc,e&b,d,e,i,m,s,?g&b,n,?hc,i&f,s,?k&d,m,s,u,?l&a,i,n,p,?n&c,i,?o&n,r,ssa,?pj,r&f,g,h,k,t,?s&e,i:rap,,u,?t&a,en,i,l,m,ni,p,?u&a,de,h,l,r,?vl,y&c,m,?z&c,n,??,vresnyd,x&inuemoh,unilemoh,?y&limafxut,srab,???ub&mah?oj???s!.&delacsne,gro?moc?rep?t&en?opsgolb,?ude?vog??gb639j43us5--nx??t?u!.&c&a?s??en?gro?moc?o&c?g??ro?topsgolb,??v!.ta,a1c--nx??wsa08--nx??h&0ee5a3ld2ckx--nx?4wc3o--nx!.&a&2xyc3o--nx?3j0hc3m--nx?ve4b3c0oc21--nx??id1kzuc3h--nx?l8bxi8ifc21--nx?rb0ef1c21--nx???8&8yvfe--nx?a7maabgm--nx??b!.&gro?moc?ten?ude?vog??mg??c!.&7erauqs,amil4,duolc-drayknil,etisbew321,gniksnd,p&h21,ohsdaerpsym,?sndtog,topsgolb,wolf.e&a.1pla,nigneppa,?xi2,ytic-amil,?aoc?et?ir!euz??r&aes?uhc??sob?taw!s???d0sbgp--nx?f&2lpbgm--nx?k??g!.&gro?lim?moc?ude?vog???m!a1j--nx??ocir?p!.&gro?i?lim?moc?ogn?ten?ude?vog???s!.&g&nabhsah,ro??l&im?xv,?m&oc?roftalp.&cb,su,t",
+ "ne,ue,??pib,ten?vog?won,yolpedew,?a&c?nom??i&d?f?ri???t!.&ca?enilno,im?ni?o&c?g??pohs,ro?ten??iaf!.oby,?laeh!.arh,?orxer?rae??vo!.lopdren,?zb??i&3tupk--nx?7a0oi--nx?a!.&ffo?gro?moc?ten?uwu,?1p--nx?bud?dnuyh?tnihc??b!.&gro?moc?oc?ro?ude??ahduba?o!m!.&duolcsd,ysrab,???s??c!.&ayb-tropora--nx?ca?d&e?m??esserp?gro?ln,moc?nif,o&c?g?ssa??ro?t&en?ni?roporéa??ude?vuog??cug?t??d&dk?ua??e&bhf--nx?piat??f!.&aw5-nenikkh--nx,dnala?i&ki,spak,?mroftalpduolc.if,nenikkäh,pohsdaerpsym,retnecatad.&omed,saap,?topsgolb,uvisitok321,yd,?onas??g!.&d&om?tl??gro?moc?ude?vog???h&c&atih?ra??s&abodoy?ibustim???juohs?k!.&gro?moc?ofni?ten?ude?vog?zib??b4gc--nx?iw!.remarf,?nisleh?s?uzus??l!.&aac,topsgolb,?drahcir?iamsi??maim?n!.&b&ew?og??ca?gro?lim?mo&c?n??ni?o&c?fni??pp?t&en?ni??ude?zib??airpic?i&hgrobmal?m??re??om?rarref?s!.&egaptig,ppatig,topsgolb,?ed??t&i&c?nifni??rahb??ut?v!.&21k?gro?moc?oc?ten???wik?xa&rp?t??yf??j&6pqgza9iabgm--nx?8da1tabbgl--nx?b!.&acirfa?eto?gro?m&oc?siruot??o&c!e??fni?noce?rga?tser??russa?s&etcetihcra?risiol?tacova??t&en?naruatser?opsgolb,?ude?vinu?yenom???d?f!.&ca?eman?gro?lim?moc?o&fni?rp??ten?vog?zib???nj?s?t!.&bew?c&a?in??eman?gro?lim?moc?o&c?g??t&en?ni?set??ude?vog?zib???yqx94qit--nx??k&8uxp3--nx?924tcf--nx?arfel?c&a&bdeef?lb??ebdnul?ilc?reme??d!.&e&disemmejh321,rots,?ger,mrif,oc,pohsdaerpsym,topsgolb,zib,?t??e&es?samet??h!.&a&4ya0cu--nx?5wqmg--nx??b3qa0do--nx?cni,d&2&2svcw--nx?3rvcl--nx??5xq55--nx?tl,?g&a0nt--nx?la0do--nx?ro??i&050qmg--nx?7a0oi--nx?xa0km--nx??m&1qtxm--nx?oc??npqic--nx?saaces,t&en?opsgolb,?ude?v&di?og?ta0cu--nx??xva0fz--nx?人&个?個?箇??司公?府政?絡&網?网??織&組?组??织&組?组??络&網?网??育&敎?教???n??i&tsob?vdnas??l!.&bew?c&a?os??dtl?gro?hcs?letoh?moc?nssa?ogn?prg?t&en?ni??ude?vog??at?cd?is??m!.&eman?fni?gro?moc?t&en?opsgolb,?ude?vog???n&ab!cfdh?etats?mmoc?t&en?fos??u??i!l!.&noyc,pepym,??p???oob?p!.&b&ew?og??gro?kog?m&af?oc??nog?ofni?pog?sog?ten?ude?vog?zib???row!ten!.&htumiza,nolt,o&c,vra,????s!.topsgolb,?t?u!.&c&a?lp??dtl?e&cilop?m??gro!.&gul:g,,sgul,yr&ettoly&lkeew,tiniffa,?tneelffar,???lenap-tnednepedni,n&noc,oissimmoc-&layor,tnednepedni,??o&c!.&bunsorter.tsuc,en&ilnoysrab,ozgniebllew,?krametyb.&hd,mv,?omida,p&i-on,ohsdaerpsym,?t&fihsreyal.j,opsgolb,?vres-hn,ysrab,??rpoc,?psoh,shn?t&en?nmyp,seuqni-tnednepedni,?vog!.&eci&ffoemoh,vres,?ipa,ngiapmac,??weiver-tnednepedni,y&riuqni-&cilbup,tnednepedni,?srab,????l&04sr4w--nx?a!.&gro?lim?moc?t&en?opsgolb,?ude?vog??bolg?c?ed?g!el??i&c&nanif!.oc,lpl??os??romem?tnedurp??n&if?oitanretni??t&i&gid!.sppaduolc:.nodnol,,?p&ac?soh???ned?ot???c!.&bog?lim?oc?topsgolb,vog???dil?e&datic?n&ahc?nahc!rehtaew???t!ria?tam??vart??f&8f&pbgo--nx?tbgm--nx??a?n??g!.&gro?moc?oc?ten?ude?xx,zib,??h&d?op??i!.&21k?ca?fdi?gro?inum?oc!.&egapvar,redrotibat,t&ibatym,opsgolb,???ten?vog??a&f?m&e?g?toh???m?r??l&a&b&esab?t&eksab!.&sua,zn,??oof???c?mt??e&d?hs??ihmailliw?j??m!.&esserp?gro?moc?ten?ude?v&og?uog????n!.&etisbew321,no&med,rtsic,?oc,pohsdaerpsym,retsulc-gnitsoh,topsgolb,vog,yalphk,?o??o&a?btuf?l!.gmo,?o&c!.&ed,rotnemele,??hcs??rit?u??p!.&a&cin&diws?gel??d&g,ortso?urawon??i&dem?mraw?nydg,?k&elo&guld?rtso??slopolam?tsu?ytsyrut??l&ip?o&kzs?w&-awolats?oksnok????n&erapohs,img?zcel,?rog&-ai&bab?nelej??j?z??syn?tsaim?w&a&l&eib?i?o??zsraw??o&namil?tainop,??z&eiwolaib?mol???c&e&iw&alselob?o&nsos?rtso???le&im?zrogz???orw,p??d&em,ia?ragrats?uolc&inu,sds,??e&c&i&lrog?w&ilg,o&hc&arats?orp??klop?tak????yzreibok??i&csjuoniws?ksromop?saldop??l&ahdop?opo??napokaz,t&atselaer?iselpmis,?z&romop?swozam???g&alble?ezrbo&lok?nrat??ro??hcyzrblaw?i&csomohcurein?grat?klawus??k&e&rut?walcolw??in&byr?diws,sark,?le?o&nas?tsylaib??rob&el?lam??s&als?jazel?nadg,puls?rowezrp???l&colw?e&r?vart??i&am?m???m&o&c?dar?n?tyb??s&g?iruot??t!a???n&a&gaz?nzop,?i&bul?cezczs?lbul,molow?nok?zd&eb?obeiws???u&leiw?rot,?y&tzslo?z&rtek?seic????o&c,fni?k&celo?zdolk??lkan?n&leim?pek?t&uk?yzczs??z&copo?eing?rowaj???rga?tua?w&ejarg?ogarm???p&e&eb,lks!emoh,??klwwortso?ohs!-ecremmoce,daerpsym,??romophcaz?sos?t&aiwop?en?opos,ra,sezc??ude?v&irp?og!.&a&io?p?s!w???bni&p?w??ci?dtiw?e&ko?ss&p?w???fiw?g&imu?u??hiiw?m&igu?rio?u!o???nds!ipz??o&ks?p!pu??s?wtsorats??p&a?sp!mk?pk?wk??u&m?p??wk?z??r&hcso?ksw?p?s??s&i?oiw?u?zu??talusnok?w&gzr?i&p?rg?w??m?o&o?pu??u!imzw???z&kw?ouw?????w&a&l&corw?sizdow??w??o&golg?k&ark,ul?zsurp??r&az?gew??t&rabul,sugua??z&coks?sezr????xes?y&buzsak?d&azczseib?ikseb??hcyt?n&jes?lod-zreimizak??pal?r&ogt?uzam??walup?zutrak??z&am-awar?c&aprak?iwol?zsogdyb??dalezc?ib?s&i&lak?p??uklo????l??r&as?f?s??s!.&gro?moc?ten?ude?vog???t!.vog??ubnatsi?x3b689qq6--nx?yc5rb54--nx??m&00tsb3--nx?1qtxm--nx?981rvj--nx?a!.&aayn,enummoc?gro?moc?o&c?idar,ken,?t&en?opsgolb,??c!bew??dretsma?e&rts?t!.&citsalej,esruocsid,???fma?xq--nx??b!.&gro?moc?ten?ude?vog??i??c!.&moc?oc?ten?vog???d!.&gro?moc?ten?ude?vog???f!.&gro?moc?oidar,ten?ude??i??g!vu96d8syzf--nx??h?i!.&ca?gro?moc?o&c!.&clp?dtl???r,?t&en?t??vt??k?rbg4--nx??k!.&drp?e&rianiretev?sserp??gro?lim?m&o&c?n??t??nicedem?ossa?pooc?s&eriaton?neicamrahp?sa??ude?v&og?uog????l&if?ohkcots??o!.&dem?gro?m&oc?uesum??o&c?rp??ten?ude?vog??b?c!.&0x,2aq,3pmevres,5sndd,a&c&-morf,ir&bafno,fa,??g&-morf,oy-sehcaet,?i-morf,m&-morf,all&-a-si,amai,??p&-morf,c-a-si,?remacytirucesym,s,tadtsudgniht,v-morf,w-morf,z,?b&ew&-sndnyd,arukas,draiw.segap,ottad,?ildts.ipa,?c&amytirucesemoh,d-morf,esyrcs,itsalej.omed,n&-morf,vym,?p&kroweht,ytirucesemoh,?q,rievres,s-morf,?d&aerotffuts,e&calpb,ifitrec-&si,ton-si,?llortnocduolc,rewopenignepw:.sj,,tsohecapsppa,?i&-morf,rgevissam.saap,?m-morf,n&-morf,abeht-htiw-si,?s-morf,uolc&-noitatsyalp,hr,iafaw.&d&ej,yr,?nol,?meaeboda,nevia,panqym:-&ahpla,ved,?,smetsystuo,ved&j,pw,??vreser,wetomer,?e&butuoyhtiw,ciffo-sndnyd,d:-morf,o&celgoog,n&il.srebmem,neve.&1-&su,ue,?2-&su,ue,?3-&su,ue,?4-&su,ue,????,erf&-sndnyd,sndd,?filflahevres,g&de-yltsaf,nahcxeevres,?i&hcet-a-si,p-sekil,?k&auqevres,irtsretnuocevres,?l&bitpa-no,googhtiw,?m&agevres,ina-otni-si,oh-&sndnyd,ta-sndnyd,??n&-morf,ilno&-evreser,ysrab,?og-si,?r&alfduolcyrt,ehwynanohtyp:.ue,,ihcec,?srun-a-si,t&i&nuarepo,s&-ybboh,aloy,elpmis,tipohs,xiw,??omer-sndnyd,upmocsma,ysgolb,?v&als-elcibuc-a-si,i&lsndd,tavresnoc-a-si,??z&amkcar,eelg,iig,??fehc-a-si,g&ni&gats-&raeghtua,swennwot,?ksndd,robsikrow,tsoh-bt.etis,?o&fgp,lb&-sndnyd,sihtsetirw,???h&n-morf,o-morf,?i&fiwehtno,h-morf,kiw-sndnyd,m-morf,p&aerocne,detsoh,?r-morf,w-morf,z&ihcppa,nilppa,??jn-morf,k&a&-morf,erfocsic,?cils-si,eeg&-a&-si,si,?sndd,?h,latsnaebcitsale:.&1-&ht&ron-ue,uos-&em,fa,pa,ue,??lartnec-&ac,li,ue,?ts&ae&-&as,pa,su,vog-su,?ht&ron-pa,uos-pa,??ew-&su,ue,vog-su,???2-ts&ae&-su,ht&ron-pa,uos-pa,??ew-&su,ue,??3-ts&aeht&ron-pa,uos-pa,?ew-ue,??,o-morf,r&adhtiwtliub,ow&-&sndnyd,ta-sndnyd,?ten-orehkcats,??sedal,u,?l&a&-morf,colottad,rebil-a-si,?f-morf,i&-morf,am&-sndnyd,detsohpw,??l&ecelffaw,uf-ytnuob:.a&hpla,teb,?,?ppmswa,ru-&elpmis,taen,?ssukoreh,xegap,?m&n-morf,pml.ppa,rofe&pyt.orp,rerac-htlaeh,?sacrasevres,uirarret-yltsaf,?n&a&cilbuper-a-si,f&-sllub-a-si,racsan-a-si,?i&cisum-a-si,ratrebil-a-si,?tarukas,?c,dc&hsums,umpw,xirtrepmi,?eerg-a-si,i&-morf,jod,?m-morf,o&ehtnaptog,isam-al-a-tse,r&italik,tap-el-tse,?s&iam-al-a-tse,replausunu,??pj,t-morf,?o&bordym,c,hce-namtsop,jodsnd,m&-morf,ed-baltlow,?n:iloxip,,t&ingocnozama.&1-&ht&ron-ue.htua,uos-&em.htua,fa.htua,pa.htua,ue.htua,??lartnec-&ac.htua,li.htua,ue.htua,?ts&ae&-&as.htua,su.&htua,spif-htua,??ht&ron-pa.htua,uos-pa.htua,??ew-&su.&htua,spif-htua,?ue.htua,vog-su.spif-htua,???2-ts&ae&-su.&htua,spif-htua,?ht&ron-pa.htua,uos-pa.htua,??ew-&su.&htua,spif-htua,?ue.htua,??3-ts&aeht&ron-pa.htua,uos-pa.htua,?ew-ue.htua,??tadym,??p&2pevres,aelutym,i&-sndnyd,fles,ogol,ruoy&esol,hctid,?ym&eerf,teg,??ohsdaerpsym,pa&-rettalp,anis:piv,,esaberif,k1,lortnocduolc,oifilauq,r&aegyks,oetem:.ue,,?t&ilmaerts,norfegap,?ukoreh,?t&fevres,thevres,??r&081,a:-morf,tskcor-a-si,,b,e&d&iv&erp-yb-detsoh.saap,orpnwo,?ner&.ppa,no,??e&bevres,nigne-na-si,?ggolb-a-si,h&caet-a-si,pargotohp-a-si,?krow-drah-a-si,n&gised-a-si,ia&rtlanosrep-a-si,tretne-na-si,??p&acsdnal-a-si,eekkoob-a-si,?retac-a-si,subq,tn&ecysrab,iap-a-si,uh-a-si,?vres&-&ki.&cpj-rev-duolcj,duolcj,?s&ndnyd,pvtsaf,??inim,nmad,sak,?y&alp-a-si,wal-a-si,?zilibomdeepsegap,?g,ituob,k,mgrp.nex,o&-morf,sivdalaicnanif-a-si,t&areleccalabolgswa,c&a-na-si,od-a-si,?susaym,??p-morf,u&as-o-nyd,e&tsoh.&duolc-gar,hc-duolc-gar,?ugolb-nom-tse,?omuhevres,??s&a&apod,ila&nyd,snd,?nymsd,vnacremarf,?bbevres,ci&p&-sndnyd,evres,?tcatytiruces,?dylimaf,e&cived-anelab,itilitu3,lahw-eht-sevas,mag-otni-si,t&i&iis,sro,?yskciuq,??fpi-&eralfduolc,fc,?i&ht2tniop,pa&elgoog,tneltneg,??jfac,k&-morf,aerf-ten,colb&egrof,pohsym,??m&-morf,cxolb,?n&d&-pmet,dyard,golb,htiwssem,mood,tog,?kselp,nyd,ootrac-otni-si,?o&-xobeerf,xobeerf,?ppa&-avnac,raeghtua,t&ikria,neg,??r&ac-otni-si,e&ntrap-paelut,tsohmaerd,??s&e&l-rof-slles,rtca-na-si,?ibodym,?tsaeb-cihtym.&a&llicno,zno,?ilay,lacarac,re&gitnef,motsuc,?sv,toleco,x:n&ihps,yl,?,?u,wanozama.&1-&3s,ht&ron-ue&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,??uos-&em&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,??fa.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,?pa&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,??ue.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,???la&nretxe-3s,rtnec-&ac&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3",
+ "s,etisbew-3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,??em.&3s,adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,?li.&3s,adbmal-tcejbo-3s,etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,?ue&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,????ts&ae&-&as&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,??pa&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,??su:-etisbew-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,d&etacerped-3s,orp-&iupparme,oidutsrme,skoobetonrme,??etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,?,vog-su&-&3s,spif-3s,?.&3s,adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,???ht&ron-pa&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,??uos-pa&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,????ew-&su&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,??ue&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,d&etacerped-3s,orp-&iupparme,oidutsrme,skoobetonrme,??etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,??vog-su&-&3s,etisbew-3s,spif-3s,?.&3s,adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,?????2-&htuos-&pa.&3s,adbmal-tcejbo-3s,etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,?ue.&3s,adbmal-tcejbo-3s,etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,??lartnec-ue.&3s,adbmal-tcejbo-3s,etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,?ts&ae&-su&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,d&etacerped-3s,orp-&iupparme,oidutsrme,skoobetonrme,??etisbew-3s,ipa-etucexe,kcatslaud.&3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,??ht&ron-pa&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,??uos-pa&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,????ew-&su&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,d&etacerped-3s,orp-&iupparme,oidutsrme,skoobetonrme,??etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,??ue&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,?????3&-ts&aeht&ron-pa&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,??uos-pa.&3s,adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,??ew-ue&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,???s,?4-tsaehtuos-pa.&3s,adbmal-tcejbo-3s,etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,?labolg-3s.tniopssecca.parm,?yasdrocsid,?t&arcomed-a-si,c&-morf,etedatad.&ecnatsni,omed,??eel&-si,rebu-si,?hgilfhtiwletoh,i:batym,,m-morf,n&atnuocca-na-si,e&duts-a-si,r-ot-ecaps,tnocresu&buhtig,e&capsppa,donil.pi,lbavresbo.citats,?pl,???ops&edoc,golb,ppa,?s&i&hcrana-&a-si,na-si,?laicos-a-si,pareht-a-si,tra-na-si,xetn&od,seod,??oh&piym,sfn,??u&-morf,nyekcoh-asi,?v-morf,?u&-rof-slles,4,a-sppatikria,e,h,oynahtretramssi,r:ug-a-si,,?v&n-morf,rdlf,w-morf,?w&o&lpwons-yrt,zok,?ww100,?x&bsbf.sppa,em,i&nuemoh,rtrepmi,?obaniateb,t-morf,unilemoh,?y&a&bnx:.&2u,lacol-2u,?,l&erottad,pezam,?wetag-llawerif,?dnacsekil,fipohsym,k&-morf,niksisnd,?rot&ceridevitcaym,sitk,?u:goo,,w-morf,x&alagkeeg,orp&hsilbup,mapson.duolc,???zesdrocsid,?inu??m?or?tsla??p!.&eman,nwo,??raf!.jrots,etats??s?t!.&gro?lim?mo&c?n??oc?ten?ude?vog???u&esum?rof??z!.&ca?gro?hcs?lim?moc?o&c?fni??ten?ude?vog?zib????n&315rmi--nx?a&brud?cilbuper?f?grompj?hkaga?idraug?m?ol?ssin?u&hix?qna??varac?yalo??b!.&gro?moc?oc,ten?ude?vog??c??c!.&ah?bh?c&a?s??d&5xq55--nx?g?s?uolctnatsni,?eh?g&la0do--nx?ro??h&a?q?s??i&7a0oi--nx?h??j&b?f?t?x?z??kh?l&h?im?j??m&n?oc!.&rekamegas.1-&htron-nc.&koobeton,oiduts,?tsewhtron-nc.&koobeton,oiduts,??swanozama.&1-&htron-nc.&3s,adbmal-tcejbo-3s,d&etacerped-3s,orp-&iupparme,oidutsrme,skoobetonrme,??etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,?tsewhtron-nc.&3s,adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,??be.1-&htron-nc,tsewhtron-nc,?????n&h?l?s?y??om?qc?s&g?j?ppa-avnac,?t&cennockciuq.tcerid,en??ude?vog?wt?x&g?j?n?s??z&g?x??司公?絡網?络网??b??d&g!.ypnc,?ka??e&drag?erg?fuak?gawsklov?hctik?i&libommi?w??m?po?r!ednaalv??sier?ves??g!.&ca?gro?moc?ten?ude?vog??is&ed!.ssb,?irev???h!.&bog?cc,gro?lim?moc?ten?ude???i!.&ac?bew,c&a?in??dni?e&m?sabapus,?g&5?6?p?ro??i&a?hled??ku?l&evart?im??m&a?oc?rif??n&c?eg??o&c?fni?i?rp??p&ooc?u??r&ahib?d?e??s&c?er?nduolc,senisub?u??t&arajug?en!retni??ni?opsgolb,sop??ude?v&og?t??ysrab,zib??elknivlac?griv?ks?lreb?p?v?w?x??k!.&gro?ten?ude?vog???l&eok?ocnil??m!.&cyn,gro?ude?vog???o&dnol?i&hsaf?n&o?utiderc??siv!orue??t&a&cude!.oc,?dnuof?tsyalp??c&etorp?u&a?rtsnoc?????kin?las?mrom?nac?p&q?uoc??s&iam?pe?scire??t&ron?sob??zama??p!.&gro?oc?ten?ude?vog??k??r&e&c?yab??op!.eidni,??s!.&gro?moc?osrep?t&opsgolb,ra??ude?v&inu?uog????t!.&d&ni?uolcegnaro,?gro?ltni?m&oc!nim??siruot??nif?o&fni?srep??sne?t&an?en??vog??m??u&f?r!.&bdnevar,lper,retropno,s&h,revres,?tnempoleved,xiw,??stad?xamay?y??v!.&a&lnos?ohhnah&k?t???c&a?ouhphnib?uhphniv??di?e&man?rtneb?uhneihtauht??g&n&a&boac?ig&ah?cab?n&a?ei&k?t???uah??nad?rtcos?uqneyut??o&dmal?hpiah?lhniv?nkad?ud&hnib?iah????ro??h&ni&b&aoh?gnauq?hnin?iaht??d&hnib?man??mihcohohphnaht?n&cab?gnauq?yat??tah?vart??tlaeh??i&a!bney?coal?gngnauq?laig?ngnod??onah?rtgnauq??kalkad?m&an&ah?gnauq??oc?utnok??n&a&ehgn?gnol?kcab?uhthni&b?n???e&ibneid?y&gnuh?u&gniaht?hp????osgnal??o&fni?ht&nac?uhp??i?rp??pahtgnod?t&en?ni?opsgolb,?u&a&hcial?mac?tgnuv-airab??de?eilcab??vog?zib???wo&rc?t!epac????o&76i4orfy--nx?a!.&bp?de?go?oc?ti?vg??boat??b!.&a&ci&sum?tilop??i&c&arcomed?neic??golo&ce?ncet??m&edaca?onoce??rt&ap?sudni??vilob??n&egidni?icidem??serpme?tsiver?vitarepooc??b&ew?og??dulas?e&rbmon?tr&a?op&ed?snart????g&olb?ro??ikiw?l&a&noi&canirulp?seforp??rutan??im??moc?o&fni?lbeup?rga?tneimivom??saiciton?t&askt?en?ni??ude?vt??h?iew?olg??c!.&bew?cer?dr&c,rac,?esabapus,gro?ipym,l&im?per:.di,,?m&o&c!.topsgolb,?n??rif??ofni?s&egap&dael,l,?tra??t&4n,en?ilperdellawerif:.di,,ni??ude?vog??a?e?in?mara?s&edarb?ic???d!.&b&ew?og??dls?gro?lim?moc?t&en?ra??ude?vog??agoba?if?zd7acbgm--nx??e&c?d&iv?or???f!ni!.&e&g&delwonk-fo-l&errab,lerrab,?ellocevoli,?ht-skorg,rom-rof-ereh,tadpusn:d,,?llatiswonk,macrvd,ofni-v,p&i&-on,fles,?ohbew,?ruo-rof,s&iht-skorg,nd&-cimanyd,nyd,uolc,??tsrifyam,ysrab,zmurof,???g&el?n!am?ib???hwsohw?i!.&35nyd,8302,a&minifed,tad-b,?b&altig,uhtig,?czh,d&in,raobelgaeb,u&olc&iaznab.ppa,ropav,?rd,??e&c&apsinu.1rf-duolc,ivedniser,?donppad.sndnyd,egipa,lej,nilnigol,sufxob,t&i&beulb,snoehtnap,?newtu,ybeeb.saap,??gni&gatsniser.secived,tsohytsoh,?ilpu,k&coregrof.di,orgn:.&as,ni,p&a,j,?su,u&a,e,??,ramytefasresworb,?moc?n&aicisum,mtsp:.kcom,,yded,?o&idutsxiw,t&oq,pyrctfihs,??p&opilol,pa&-arusah,e&nalpkcab,tybeeb.1dkes,???r&e&tsneum-hf,vres&cisab,lautriv,??ial.sppa,?s&codehtdaer,gnihtbew,nemeis-om,pparevelc,t&acdnas,ekcit,??t&e&kcubtib,notorp,?i&belet,detfihs,gude,kecaps,?raedon.egats,s&ohg,udgniht.&cersid.&dvreser,tsuc,?dorp.tsuc,gnitset.&dvreser,tsuc,?ved.&dvreser,tsuc,????vgib.0ku,whs,x&bslprbv.g,cq,rotide,?y&olpedew,srab,??b?d&ar?u&a?ts???j?r?syhp??j!.&eman?gro?hcs?lim?moc?ten?ude?vog???ll&ag?o??m!.&gro?moc?ten?ude?vog??g?il?mi?orp??n!.&a&0&b-ekhgnark--nx?c-iehsrgev--nx?g-lksedlig--nx?k-negnanvk--nx??1&p-nedragy--nx?q-&asierrs--nx?grebsnt--nx?lado-rs--nx?n&egnidl--nx?orf-rs--nx??regnayh--nx?ssofenh--nx??r-datsgrt--nx?s-ladrjts--nx?v-y&senner--nx?vrejks--nx???3g-datsobegh--nx?4&5-&dnaleprj--nx?goksnerl--nx?tednalyh--nx??6-neladnjm--nx?s-&antouvachb--nx?impouvtalm--nx??y-&agrjnevvad--nx?ikhvlaraeb--nx???7k-antouvacchb--nx?8&k-rekie-erv--nx?l-ladrua-rs--nx?m-darehsdrk--nx??a!.sg??bct-eimeuvejsemn--nx?d&do?iisevvad?l",
+ "ov?narts?uas??f&1-&l--nx?s--nx??2-h--nx??g&10aq0-ineve--nx?av?ev?lot?r&ajn&evvad?u??ájn&evvad?u????h?iz-lf--nx?j&ddadab?sel??k&el?hoj&sarak?šárák??iiv&ag&na&el?g??ŋ&ael?ág???ran???l&f?lahrevo?o&ms?s??sennev?t-&ilm--nx?tom--nx??u&-edr--nx?s??øms??muar?n&0-tsr--nx?2-dob--nx?5-&asir--nx?tals--nx??a&r!-i-om?f?t??t??douvsatvid?kiv?m&os?øs??n&od?ød??ra?sen?t&aouvatheig?ouv&a&c&ch&ab?áb??h&ab?áb???n??i&ag?ág??sa&mo?ttvid??án???z-rey--nx?ær&f?t???o&p-&ladr--nx?sens--nx??q-nagv--nx?r-asns--nx?s-kjks--nx?v-murb--nx?w-&anr&f--nx?t--nx??ublk--nx???ppol?q&0-t&baol--nx?soum--nx?veib--nx??x-&ipphl--nx?r&embh--nx?imph--nx???y-tinks--nx??r&f-atsr--nx?g-&an&ms--nx?nd--nx??e&drf--nx?ngs--nx??murs--nx?netl--nx?olmb--nx?sorr--nx??h-&a&lms--nx?yrf--nx??emjt--nx??i&-&lboh--nx?rsir--nx?y&d&ar--nx?na--nx??ksa--nx?lem--nx?r&ul--nx?yd--nx????stu??j-&drav--nx?rolf--nx?sdav--nx??kua?l-&drojf--nx?lares--nx??m-tlohr--nx?n-esans--nx?olf?p-sdnil--nx?s-ladrl--nx?tih?v-rvsyt--nx??s&a&ns?ons??i&ar?er&dron?r&os?øs???ár??la&g?h??mor!t??sir?uf?åns??t&koulo&nka?ŋká??la?p-raddjb--nx?r-agrjnu--nx?s&aefr&ammah?ámmáh??orf?r&o?ø???u-vreiks--nx??u&h-dnusel--nx?i-&drojfk--nx?vleslm--nx??j-ekerom--nx?k-rekrem--nx?u-&dnalr--nx?goksr--nx?sensk--nx??v-nekyr--nx?w-&k&abrd--nx?ivjg--nx??oryso--nx??y-y&dnas--nx?mrak--nx?n&art--nx?nif--nx??reva--nx??z-smort--nx??v!.sg?ledatskork?reiks??wh-antouvn--nx?x&9-dlofts--nx.aoq-relv--nx?d-nmaherk--nx?f-dnalnks--nx?h-neltloh--nx?i-drgeppo--nx?j-gve&gnal--nx?lreb--nx??m-negnilr--nx?n-drojfvk--nx??y&7-ujdaehal--nx?8-antouvig--nx?b-&dlofrs--nx?goksmr--nx?kivryr--nx?retslj--nx??e-nejsom--nx?f-y&krajb--nx?re&dni--nx?tso--nx??stivk--nx??g-regark--nx?orf?ørf??z9-drojfstb--nx??b&25-akiivagael--nx?53ay7-olousech--nx?a&iy-gv--nx?le-tl&b--nx?s--nx??n0-ydr--nx??c&0-dnal-erdns--nx?z-netot-erts--nx??g&g-regnarav-rs--nx?o-nejssendnas--nx??ju-erdils-ertsy--nx?nj-dnalh-goksrua--nx?q&q-ladsmor-go-erm--nx.&ari-yreh--nx?ednas??s-neslahsladrjts--nx???ca&4s-atsaefrmmh--nx?8m-dnusynnrb--nx?il-tl--nx?le-slg--nx?n5-rdib--nx?op-drgl--nx?uw-ynnrb--nx??d&a&qx-tggrv--nx?reh!nnivk?sd&ork?ørk??uas??ts&e&bi?kkar?llyh?nnan??g&ort?ørt??k&alf?irderf??levev?mirg?obeg&ah?æh??r&ah?ejg????barm-jdddb--nx?ie!rah?s&etivk?ladman???lof&r&os?øs??ts&ev.ednas?o.relav?ø.relåv???n&a&l&-erd&n&os?øs??ron??adroh.so?dron.&a&g5-b--nx?ri-yreh--nx??ob?y&oreh?øreh??øb??e&m!lejh??pr&oj?øj??vi??gyb?n&aks?åks??o&h-goksrua?rf??r&o?ua?ø??tros?øh-goksrua??rts!e&devt?lab?mloh???s&ellil?naitsirk?rof???u&l!os??s!d&im?lejt??e&guah?l&a?å???kkoh?lavk?naitsirk?r&af?eg&e?ie???tef?y&onnorb?ønnørb?????r&a&blavs!.sg??g&eppo?la???o&j&f&a!dniv?k?vk??die?e&dnas?kkelf??llins?r&iel?ots??s&lab?t&ab?åb??yt??å!k??ævk??les??ts??åg&eppo?lå???ureksub.sen??e&ayb-yrettn--nx?d&ar?isemmejh321,lom?r&of?øf??år??g&gyr?nats??i&meuv&ejsem&aan?åån??sekaal??rjea??j&d&ef?oks??les??k&er&aom?åom??hgna&ark?årk??iregnir?kot!s??s&ig?uaf???l&bmab?kyb?l&av?ehtats??oh??m&it?ojt?øjt??n&arg?g&os?øs??meh?reil?te?ummok?yrb??r&dils-erts&ev?y&o?ø???ua?vod??sa&ans?åns??t&robraa?spaav??urg??f&62ats-ugsrop--nx?a&10-ujvrekkhr--nx?7k-tajjrv-attm--nx??o!.sg?h??s!.sg??v!.sg???g&5aly-yr&n--nx?v--nx??a&llor?ve&gnal?lreb???n&av!snellu??org??oks&die?m&or?ør??ner&ol?øl??r&o?ø???r&eb!adnar?edyps?s&die?elf?gnok?n&ot?øt????obspras??uahatsla?åve&gnal?lreb???h&0alu-ysm--nx?7&4ay8-akiivagg--nx?5ay7-atkoulok--nx??a!.sg???i&e&hsr&agev?ågev??rf??k&h&avlaraeb?ávlaraeb??s??lm&a?å??mpouvtal&am?ám??pph&al?ál??rrounaddleid?ssaneve?ššáneve??j&0aoq-ysgv--nx?94bawh-akhojrk--nx??k&a&b&ord?ørd??jks?lleis??iv!aklejps?l&am?evs?u??mag?nel?ojg?r&a&l?n??epok?iel?y&or?ør???s&ah?kel?om??øjg??kabene?ojsarak?ram&deh.&aoq-relv--nx?rel&av?åv??so??e&let.&ag5-b--nx?ob?øb??ra???åjks??l&a!d&anrus?d&numurb?ron??e&gnard?nte?s&meh?sin??ttin??g&is?nyl??kro?l&em?l&ejfttah?of??u&ag-ertdim?s???n&am?era?gos?i&b?nroh?r??kos?nus?oj??o-&dron?r&os?øs???ppo?r&a!l?nram??e&gne?l?v??is?o&jts?ts??u&a-&dron?r&os?øs???h??å?æl?øjts??s&e&jg?nivk?ryf??kav?mor-go-er&om.&ednas?yoreh??øm.&ednas?yøreh???uag??t&las?rajh?suan??v&l&a?e-rots??u-go-eron??yt??ksedlig?res&a?å???bib&eklof?seklyf??es!dah??h!.sg??i&m?syrt??l&ejf?ov&etsua?gnit?ksa?sdie???n!.sg??o!.sg?boh?g?h??r!.sg??å!ksedlig??øboh??m&a&rah?vk??f!.sg??h!.sg??i&e&h&dnort?rtsua?ssej??rkrejb??ksa??ol?t!.sg??u&dom?esum?r&ab?drejg?evle?os?uh?æb?øs??ttals???n&a&g&av?okssman?åv??jlis?or?r&g?rev???e&d&do&sen?ton??lah?r&agy&o?ø??ojfsam???g&iets?n&a&l&as?lab??n&avk?ævk??t&arg?ddosen??v&al?essov???i&d&ol?øl??l&ar?ær???yl??reb??iks?k&srot?y&or?ør???l&a&d&gnos?n&er?ojm?øjm??om??tloh??ug?åtloh??mmard?ojs&om?sendnas??ppolg?s&lahsladr&ojts?øjts??o??t&o&l?t-erts&ev?o?ø???roh?øl??vly&kkys?nav??yam-naj!.sg??øjs&om?sendnas???g&orf?ujb??i&dnaort?vnarg??kob?ladendua?maherk&a?å??n&it?urgsrop??orf-&dron?r&os?øs???r&aieb?evats??sfev?uaks?yrts??o&6axi-ygvtsev--nx?c,d&ob?rav??ievs?kssouf?l&m&ob?øb??ous&adna?ech&ac?áč???so!.sg???msdeks?niekotuak?r&egark?olf?y&oso?øso???s&dav?mort???p&ed?ohsdaerpsym,p&akdron?elk???r&a&d&dj&ab?áb??iab??jtif?luag?mah?vsyt??e&gn&a&k&iel?ro??merb?n&at?mas??rav-r&os?øs??srop?talf?v&ats?el??y&oh?øh???ivsgnok??il?jkniets?k&a&nvej?rem?s&gnir?nellu???ie-er&den?v&o?ø???ram?sa?årem??la&jf?vh??m&b&ah?áh??mahellil??nnul?ts&l&oj?øj??ul??y&o?ø???imp&ah?áh??m!.sg??osir?t!.sg??ádiáb?ævsyt?øsir??s&adnil?en&dnas?e&dga?k&ri&b?k??som??ve??me&h?jg??nroh-go-ejve?s&a?ednil?k&o?ø??of?yt?å??tsev??gv?hf?igaval?o&r&or?ør??sman??so&fen&oh?øh??m?v??uh&lem?sreka.sen??å!dnil???t&a&baol?g&aov?grav??jjr&av-attam?áv-attám??l&a&b?s??ás??soum?ts?v&eib?our???e&dnaly&oh?øh??f?s&nyt?rokomsdeks?sen??vtpiks??in&aks?áks??loh&ar?år??n!.sg??o&m&a?å??psgolb,?s!.sg?efremmah?or?ør??terdi?á&baol?ggráv?lá&b?s??soum?veib???u&b!.sg?alk?e&dna?gnir?nner??les?ælk??dra&b?eb??g&nasrop?vi?ŋásrop??j&daehal&a?á??jedub?v&arekkhar?árekkhár???ksiouf?n&diaegadvoug?taed???v&irp?lesl&am?åm???y&b&essen?nart?sebel?tsev??o&d&ar?na!s??or??gavtsev?k&rajb?sa??lem?mrak?n&art?n&if?orb???r&a&mah?n?v??e&dni?t&so?ton??va??ul?yd??s&am?enner?gav?lrak?tivk??vrejks??ø&d&ar?na!s??ør??gåvtsev?k&rajb?sa??lem?mrak?n&art?n&if?ørb???r&e&dni?t&so?tøn??va??ul?yd?æ&n?v???s&enner?gåv?tivk?åm??vrejks???á&slág?tlá?vreiks??å&gåv?h?jddådåb?lf??ø&d&ob?rav??r&egark?olf??s&dav?mort????aki?i&sac?tal??u??o&b?f?g?hay?o?ttat??r!.&cer?erots?gro?m&o&c?n??rif?t??o&c,fni??pohs,stra?t&n?opsgolb,?www?ysrab,?e&a!.&a&ac?cgd?idem??bulc!orea??ci&ffartria?taborea??e&cn&a&l&lievrus-ria?ubma??netniam?rusni??erefnoc??gnahcxe?mordorea?ni&gne?lria?zagam??rawtfos??gni&d&art?ilg!arap?gnah???l&dnahdnuorg?ledom??noollab?retac?sael?t&lusnoc?uhcarap??vidyks??hcraeser?l&anruoj?euf?icnuoc?ortnoc!-ciffart-ria???n&gised?oi&nu?t&a&cifitrec?ercer?gi&tsevni-tnedicca?van??i&cossa!-regnessap??valivic??redef??cudorp?neverp-tnedicca????ograc?p&ihsnoipmahc?uorg!gnikrow???r&e&dart?enigne?korb?niart?trahc??o&htua?tacude???s&citsigol?e&civres?r??krow?serp!xe??tnega??t&farcr&ia?otor??hgil&f?orcim??liubemoh?n&atlusnoc?e&duts?m&esuma?n&iatretne?revog??piuqe????olip?ropria?si&lanruoj?tneics???w&erc?ohs??y&cnegreme?dobper?tefas????rref?z??p!.&a&aa?ca?pc??dem?ecartsnd.icb,gne?r&ab?uj??snduolc,t&acova?cca?hcer??wal?ysrab,???s!.&em?gro?hcs,moc?ten?ude?vog???t!.&0x,116,ayo,gro?lim?moc?nayn,sulpnpv,t&cennockciuq.tcerid,en??ude?v&dr,og???o&hp?m?v?yk??tol?ua??v&iv?lov??xas?ykot??p&a&ehc?g?m?s??eej?g!.&gro?ibom?moc?ossa?ppa,ten?ude???i&r!.nalc,?v?z??j!.&0o0o,a&3&5xq6f--nx?xqi0ostn--nx??5wtb6--nx?85uwuu--nx?9xtlk--nx?ad,b&ats,ihc!.&a&bihciakoy?don?ma&him?ye&ragan?tat???r&a&bom?gan?hihci??u&agedos?kas?ustak???s&os?ufomihs??t&amihcay?iran??w&a&g&im&anah?o??omak??kihci?zustum??ihsak??y&agamak?imonihci???e&akas?nagot??i&azni?esohc?h&asa?s&abanuf?ohc???ka&to?zok??musi?orihs?r&akihabihsokoy?o&dim?tak??ukujuk??usihs??nano&hc?yk??o&d&iakustoy?ustam??hsonhot?k&a&rihs?t??iba??nihsaran?sobimanim?tas&arihsimao?imot??uhc?yihcay??u&kujno?s&ayaru?t&imik?tuf???zarasik?????c&cah,ed,?g&as!.&a&gas?m&a&tamah?yik??ihsak??rat?t&a&gatik?hatik??ira!ihsin????e&kaira?nimimak??i&akneg?g&aruyk?o??h&c&amo?uo??siorihs??kaznak?modukuf?ra&gonihsoy?mi???nezih?u&k&at?ohuok??s&ot?tarak?????ihs!.&a&kok?m&a&hagan?yirom??ihsakat??rabiam?wagoton??e&miharot?nokih??houyr?i&azaihsin?esok?kustakat?moihsagih??na&mihcahimo?nok??o&hsia?mag?t&asoyot?ok?tir???us&ay?t&asuk?o??????k&aso!.&a&d&awihsik?eki??k&a&noyot?s&akaayahihc?oihsagih???oadat?uziak??m&ayas!akaso??odak??r&a&bustam?wihsak??ediijuf??t&akarih?i&k?us???wag&ayen?odoyihsagih???e&son?tawanojihs??honim?i&akas?h&cugirom?s&ayabadnot?i&a&kat?t??n??oyimusihsagih???k&a&rabi?sim??ustakat??muzi?r&ijat?otamuk???nan&ak?n&ah?es???o&ay?n&a&ganihcawak?simuzi?tak??eba?ikibah?oyot??t&anim?iad?omamihs??uhc??ust&oimuzi?tes????ou&kuf!.&a&d&amay?eos??g&no?ok?usak??hiku?k&awayim?uzii??ma&kan?y&asih?im???rawak?t&a&gon?ka&h?num?t???umo??wa&g&a&kan?nay?t??ias??ko!rih???y&ihsa?usak???e&m&ay?uruk??taruk?us??i&a&nohs?raihcat??goruk?h&cukuf?s&a&gih?hukuy??in???k&a&gako?muzim??iust?o?ustani??m&anim?otihsoynihs?u??r&ogo?ugasas??usu??ne&siek?zu&b?kihc???o&gukihc?h&ak?ot?ukihc??j&ono?ukihc??kayim?nihsukihc?to?uhc??u&fiazad?gnihs?stoyot????zihs!.&a&bmetog?d&amihs?eijuf?ihsoy?omihs??kouzihs?mihsim?ra&biah?honikam??tawi?wa&g&ekak?ukik??kijuf??yimonijuf??i&a&ra?sok??hcamirom?juf?kaz&eamo?ustam??ma&nnak?ta??nukonuzi?orukuf??nohenawak?o&nosus?ti??u&stamamah?z&a&mun?wak??i!ay?i&hs&agih?in??manim??mihs????????m&a&tias!.&a&d&ihsoy?ot?usah??k&a&dih?sa??o&arihs?s???m&a&tias?y&as?o&rom?tah??ustamihsagih???i&hsagurust?jawak??uri??ni?wa&g&e&ko?man??ikot?o??k&ara?i&hsoy?mak???ru?zorokot??y&a&g&amuk?ihsok?otah??kuf??imo??ziin??e&bakusak?ogawak?sogo?ttas?zokoy??i&baraw?h&cugawak?s&oyim?ubustam???iroy?k&ato?ihs?u&k?stawi???m&akoyr?i&hsoy?juf??uziimak???naznar?o&dakas?ihsay?jnoh?n&a&go?nim??imijuf?nah?oy??r&ihsayim?otagan??t&asim!ak??igus?omatik??zak??u&bihcihc!ihsagih??sonuok?ynah????y&ak&aw!.&a&d&ira?notimak??kadih?ma&h&arihs?im??y&a&kaw?tik??oduk???ru&ustakihcan?y??sauy?wa&g&a&dira?zok??orih??konik??yok?zok??e&banat?dawi??i&garustak?jiat?mani??naniak?o&bog?nimik?t&asim?omihs&ah?uk????ugnihs???o!.&a&jos?koasak?m&ay&ako?ust??ih",
+ "sayah??r&abi?ukawaihsin??wi&aka?nam???e&gakay?kaw??i&gan?h&cu&kasa?otes??sahakat??k&asim?ihsaruk??miin??n&anemuk?ezib??o&hsotas?jnihs?n&amat?imagak??ohs?uhcibik?????ot!.&a&damay?got?koakat?may&etat?ot??nahoj?riat?waki&inakan?reman???eb&ayo?oruk??i&h&asa?ciimak?sahanuf??kuzanu?m&an&i?ot??ih???nezuyn?otnan?u&hcuf?stimukuf?z&imi?ou???????ihs&o&gak!.&a&m&ayuok?ihsogak??si?yonak??e&banawak?n&at&akan?imanim??uka??tomoonihsin??i&adnesamustas?k&azarukam?oih??m&ama?uzi??usuy??nesi?o&knik?os?tomustam??uzimurat???rih!.&a&ka&n?s??m&ayukuf?i&hsorihihsagih?j&ate?imakikaso????r&a&bohs?h&ekat?im???es??tiak?wiad??e&kato?ruk??i&h&ci&akustah?mono?nihs??s&inares?oyim???manimasa?uk??negokikesnij?o&gnoh?namuk??uhcuf????uk&ot!.&a&bihci?mi&hsu&kot?stamok??m??wagakan??egihsustam?i&gum?h&coganas?soyim??kijaw?m&anim?uzia??ukihsihs??nan&a?iak??o&nati?turan????uf!.&a&batuf?m&a&to?y&enak?irok???ihs&im?ukuf??os?uko??r&aboihsatik?uganat??ta&katik?mawak?rih??w&a&g&akus?emas?uy??k&a&mat?rihs?sa??ihsi??nah??ohs???e&gnabuzia?iman?ta&d?tii???i&adnab?enet?hs&agih?iimagak??k&a&wi?zimuzi??ubay??minuk?r&ook?ustamay???nihsiat?o&g&etomo?ihsin?nan?omihs??no!duruf?rih??rihsawani?ta&may?simuzia???u&rahim?stamakawuzia?zia&ihsin?nay???????nug!.&a&bawak?doyihc?k&anna?oi&hsoy?juf?mot???m&ayakat?ustagaihsagih??n&ihsatak?nak??r&ahonagan?nak?o?u&kati?mamat???t&amun?inomihs?o??w&akubihs?iem?ohs???i&hsa&beam?yabetat??kas&akat?esi??m&akanim?uzio??ogamust?rodim??o&jonakan?n&eu?oyikust??tnihs??u&komnan?stasuk?yrik????rep,?n&ibmab,nog,ob,?ppacihc,ra&n!.&a&bihsak?d&akatotamay?u!o???guraki?m&ay&atik&imak?omihs??irokotamay??oki??ra&hihsak?n??wa&geson?knet???e&kayim?ozamay?sog?ustim??i&a&rukas?wak??garustak?h&ciomihs?sinawak??jo?ka&mnak?toruk??makawak?nos?r&net?otakat?ugeh???o&d&na?oyo??gnas?jnihs?nihsoy!ihsagih??tomarawat?yrok????rikik,?t&ag&amay!.&a&dihsio?k&atarihs?ourust??may&a&kan?rum??enak?onimak??rukho?ta&ga&may?nuf??hakat?kas??wa&g&ekas?orumam??ki&hsin?m??z&anabo?enoy?ot???zuy??e&agas?bonamay?dii?nihsagih?o??i&a&gan?nohs??h&asa?sinawak??nugo??o&dnet?jnihs?ynan??ukohak???iin!.&a&ga?k&ium?oagan??munou!imanim??t&a&bihs?giin??ioy??w&a&gioti?kikes?zuy??irak??yijo??e&kustim?mabust??i&aniat?hcamakot?kaz&awihsak?omuzi??m&a&gat?karum??o???n&anust?esog??o&das?ihcot?jnas?k&ihay?oym??mak?naga?ries??u&ories?steoj?????i&k&a!.&a&go?k&asok?oimak??t&ago!rihcah??ika!atik???w&aki?oyk???e&mojog?natim?suranihsagih?t&ado?okoy???i&hsoyirom?magatak?naokimak??nesiad?o&hakin?jnoh!iruy??nuzak?rihson?tasi&juf?m??yjnoh??u&kobmes?oppah????in,?o!.&a&dakatognub?m&asah?ihsemih??su?t&ekat?i&h?o????e&onokok?ustimak??i&jih?k&asinuk?ias?usu??mukust??onoognub?u&fuy?juk?ppeb?suk?????nayn,?wa&ga&k!.&a&mihsoan?rihotok?waga&kihsagih?ya???emaguram?i&j&nonak?ustnez??kunas?monihcu??o&hsonot?nnam?yotim??u&st&amakat?odat??zatu????nak!.&a&dustam?kus&okoy?tarih??maz?nibe?r&a&gihsaimanim?h&esi?imagas??wa&do?guy???u&im?kamak???tikamay?wa&k&ia?oyik?umas??sijuf??yimonin??e&nokah?saya??i&akan?esiak?gusta?hsuz?kasagihc?o?ukust??o&nadah?sio?tamay?????kihsi!.&a&danihcu?gak?kihs?mijaw?t&abust?ikawak??wazanak??i&gurust?hcionon?mon?ukah??nasukah?o&anan?ton!akan???u&kohak?stamok?z&imana?us?????niko!.&a&han?m&arat?ijemuk?uru??n&e&dak?zi??no??ra&hihsin?rih??wa&kihsi?niko??yehi?zonig??e&osaru?seay??i&hsagih?jomihs?k&a&gihsi?not??ihsakot??m&a&ginuk?kihsug?maz??igo?otekat??nuga!noy???n&a&moti?timoy?wonig??i&jikan?k???o&gan?jnan?tiad&atik?imanim???u&botom?kusug&akan!atik??imot??rab&anoy?eah??????yp,zomim,?bus,c&204ugv--nx?462a0t7--nx?678z7vq5d--nx?94ptr5--nx?a?mpopilol,?d&-2,17sql1--nx?3thr--nx?5&20xbz--nx?40sj5--nx??7&87tlk--nx?ptlk--nx??861ti4--nx?a?e!tfarcdnah,?n&eirf&lrig,yob,?om,?ooftac,?e&16thr--nx?5&1a4m2--nx?9ny7k--nx??damydaer,eweep,garotsarukas.&10ksi.3s,20ksi.3s,?i&bmoz,m!.&a&bot?k&asustam?uzus??m&a&him?y&emak?im???ihs??nawuk?wi&em?k???e&bani?ogawak?si!imanim???i&arataw?gusim?h&asa?ciakkoy??k&a&mat?sosik?t??iat??raban??o&dat?hik?n&amuk?ihseru?o&du?mok????ust????kilbew,lasrepus,mihe!.&a&m&a&h&ataway?iin??yustam??ij&awu?imak???taki!man???ebot?i&anoh?kasam?rabami??n&ania?egokamuk?oot??o&jias?kihcu?nustam?uhcukokihs?yi!es???u&kohik?zo????n!.&arukas,lapo,n&erukom,riheg,?omomus,stnim,teniesa.resu,xob-liam,yrovi,zapot,?amihs!.&a&d&amah?ho?usam??kustay?m&a?ihsoni&hsin?ko???wakih??e&namihs?ustam??i&g&aka?usay??konikak?mikih??nannu?o&mu&kay?zi!ihsagih?uko???nawust?tasim??u&stog?yamat????nep,?rotsnoihsaf,srev,t&awi!.&a&bahay?d&amay?on??koirom?t&a&honat?katnezukir??imus??w&as&ijuf?uzim??ihs???e&hon&i&hci?n??uk??tawi??i&a&duf?murak?wak??h&custo?si&amak?ukuzihs???j&oboj?uk??k&a&m&anah?uzuk??sagenak??esonihci??m&akatik?uzia&rih?wi????o&kayim?no&rih?t??tanufo??uhso???isarap,saman,tococ,?ulbybab,?g&3zsiu--nx?71qstn--nx?l?olblooc,?h&03pv23--nx?13ynr--nx?22tsiu--nx?61qqle--nx?o-hu,sulb,?i&54urkm--nx?azosbew,ced,g&ayim!.&a&dukak?m&a&goihs?kihs??ihsustam!ihsagih??unawi??r&awago?iho??ta&bihs?rum??w&a&gano?kuruf??iat??y&imot?ukaw???e&mot?nimes??i&hsiorihs?ka&monihsi?s&awak?o???mak?r&ataw?o&muram?tan????o&az?jagat?t&asim?omamay???u&fir?k&irnasimanim?uhsakihcihs?????ihcot!.&a&g&a&h?kihsa??ust??kom?m&ay&o?usarak??unak??r&a&boihsusan?watho??iho?ukas??t&akihsin?iay??wa&konimak?zenakat??y&imonustu?oihs???e&iiju?kustomihs?nufawi??i&akihci?g&etom?ihcot?on???o&k&ihsam?kin??nas?sioruk?tab??u&bim?san?????h&c&ia!.&a&dnah?m&a!h&akat?im??yuni??ihs&ibot?ust???r&a&hat?tihs??ik?u&ihsagih?kawi???t&ihc?o&k?yot???wa&koyot?zani??yi&monihci?rak???e&inak?k&aoyot?usa??manokot?noyot??i&a&gusak?kot?sia??eot?h&asairawo?cugo?s&ahoyot?oyim???k&a&mok?zako??ihssi??motay?rogamag??n&an&ikeh?ok??ihssin??o&got?ihsin?jna?rihsnihs?suf?tes??u&bo?raho?s&oyik?takihs??yrihc?zah????ok!.&a&dusay?kadih?mayotom?r&ah&im?usuy??umakan??sot!ihsin??wa&g&atik?odoyin??k&as?o????i&esieg?hco!k??jamu?k&a!sus??usto??ma&gak?k??rahan??o&mukus?n&i?ust!ihsagih???torum?yot!o???u&koknan?zimihsasot????ugamay!.&a&m&ayukot?ihso??toyot??e&bu?subat??i&gah?kesonomihs?nukawi?rakih??nanuhs?otagan?u&ba?foh?otim?stamaduk?uy?????s&anamay!.&a&dihsoyijuf?mayabat?r&ahoneu?ustakihsin??w&a&k&ayah?ijuf??suran??ohs???egusok?i&ak?h&cimakan?s&anamay?od???k&asarin?u&feuf?sto????o&k&akanamay?ihcugawakijuf??nihso?t&asimawakihci?ukoh??uhc??spla-imanim?u&b&nan?onim??fok?hsok?rust????ubon,??ix,ka&rabi!.&a&bukust?gok?kan!ihcatih??m&a&sak?timo?wi??ihsak?ustomihs??ni?r&a&hihcu?way??u&agimusak?ihcust???t&ag&amay?eman??oihcatih??w&ag&arukas?o??os??yi&moihcatih?rom???e&bomot?dirot?not?tadomihs??i&a&k&as?ot??rao??esukihc?gahakat?h&asa?catih??k&a&rabi?saguyr??ihsani?uy??ma?rukustamat??o&dnab?giad?him?kati?rihsijuf?soj?t&asorihs?im??yihcay??u&fius?kihsu?simak????sagan!.&a&m&abo?ihsust??natawak?r&abamihs?u&mo?ustam???wijihc?yahasi??i&akias?hies?k&asagan?i??masah??neznu?o&besas?darih?t&eso?og!imaknihs????ust&igot?onihcuk?uf????zayim!.&a&biihs?guyh?k&oebon?ustorom??mihsuk?r&emihsin?uatik??ta&katik?mim??wag&atik?odak??ya??e&banakat?sakog??i&hsayabok?kaza&kat?yim??m&animawak?ot&inuk?nihs????nanihcin?o&j&ik?onokayim??n&ibe?ust??tias??urahakat????ro&cep,moa!.&a&dawot?turust?wasim??e&hon&ihc&ah?ihs??nas?og?ukor??sario??i&anarih?ganayati?hsioruk?jehon?kasorih?makihsah?nawo?r&amodakan?omoa???o&gnihs?kkat??u&ragust?stum????ttot!.&a&r&ahawak?uotok??sa&kaw?sim???egok?irottot?nanihcin?o&ganoy?nih?tanimiakas??u&bnan?z&ay?ihc??????ukuf!.&a&deki?gurust?ma&bo?h&akat?im??yustak??sakaw??eabas?i&akas?ho?jiehie?ukuf??nezihce!imanim??ono????k&26rtl8--nx?4&3qtr5--nx?ytjd--nx??522tin--nx?797ti4--nx?ci&gid,ht,sevol,?ee,limybab,n&at,upatilol,??l&33ussp--nx?e&ccabew.&resu,sr,?llarap,?lik,oof,rigetuc,?m&11tqqq--nx?41s3c--nx?ef,sioge,?n&30sql1--nx?65zqhe--nx?a&ebyllej,i&lognom,viv,??iam,n7p7qrt0--nx?o&o&las,mflah,?ruk,staw,??o&131rot--nx?7qrbk--nx?aic,c?d&iakkoh!.&a&deki?gakihset?hcebihs?k&adih?u&fib?narihs???m&ayiruk?hot?ihs&orihatik?ukuf??oras?usta??r&ib&a!ka??o?uruf??ozo?u&gakihsagih?oyot???sakim?ta&gikust?mun??w&a&ga&k&an?uf??nus!imak???k&aru?i&h&asa?sagih??kat?mak??omihs?um??zimawi??ine?oyk??yot??e&a&mustam?nan??b&a&kihs?yak??o&noroh?to???ian?k&ihsam?ufoto??nakami?ppoko!ihsin??sotihc?tad!okah??uonikat??i&a&bib?mokamot?n&a&k&kaw?oroh??wi??eomak?ihsatu?okik?usta&moruk?sakan????eib?h&c&ioy?u&bmek?irihs???s&ase?ekka?oknar?uesom???jufirihsir?k&amamihs?i&at?n???m&atik?otoyot??oa&kihs?rihs??r&a&hs?kihsi?mot??ihs&aba?ir??otarib???n&a&hctuk?rorum?se?tokahs??uber??o&kayot?m&ire?ukay??naruf!ima&k?nim???orih?r&ih&ibo?suk??o&bah?h&i&b?hsimak??sa??pnan?yan??umen??t&asoyik?eko?ukoh???u&bassa?kotnihs?m&assaw?uo??pp&akiin?en&ioto?nuk??ip??rato?s&akat?t&eb&e?i&a?hs!a??robon??m&e?o&m?takan???no&h?tamah??o&mik?s?t??u&kir?ppihc?st???onihsnihs?ufuras??uaru??yru!koh??zimihs!ok?????nu,?g!iti,oyh!.&a&bmat?dnas?gusak?k&at?o&oyot?y??uzarakat??m&ayasas?irah??wa&g&ani?okak??k&i&hci?mak??oy???yi&hsa?monihsin???i&asak?hs&aka?i&at?nawak???j&awa!imanim??emih??k&a&goa?s&agama?ukuf??wihsin??i&hsog?m???mati?oia?rogimak??n&annas?esnonihs??o&gasa!kat??ka?n&ikat?o?ustat??rihsay?sihs?tomus?yas??u&bay?gnihs?????hih,konip,l&bs,ik,?mol,nagan!.&a&bukah?d&a&w?yim??e&ki?u??ii??k&a&s&ay?uki??zus??ihsoo?ousay??m&ay&akat?ii??i&hsukufosik?jii??ukihc??n&i!hsetat??uzii??r&ah?ugot??saim?t&agamay?oyim??w&a&g&a&kan?n??o??kustam?ziurak??onim!imanim??u&koo?s!omihs????ya&ko?rih???e&akas?nagamok?subo??i&gakat?h&asa?c&a!mo!nanihs???uonamay??sukagot??k&a&kas?mimanim?to??ia&atik?imanim??oa?uzihcom??m&akawak?ijuf?o!t???r&ato?ijoihs?omakat???n&ana?esnoawazon??o&hukas?n&a&gan?kan??i&hc?muza??ustat??romok?si&gan?k??tomustam??u&k&as?ohukihc??stamega????o&b,m,pac,?to&mamuk!.&a&gamay?rahihsin?sukama!imak??tamanim??enufim?i&hcukik?k&ihsam?u??nugo!imanim??romakat??o&ara?rihsustay?sa?t&amay?om&amuk?us??u!koyg???yohc??u&sagan?zo????yk!.&a&bmatoyk?k&ies?oemak?uzaw??mayi&h&cukuf?sagih??muk??nihsamay?rawatiju?t&away?ik???e&ba&nat!oyk??ya??di?ni??i&ju?kazamayo?manim??natnan?o&gnatoyk?kum?mak?rihsamayimanim?y&gakan?ka&koagan?s??oj???u&ruziam?z&ayim?ik??????wtc1--nx?ykot!.&a&d&i&hcam?mus??oyihc??k&atim?ihsustak??m&a&t!uko??yarumihsa&gih?sum???i&hs&agoa?ika?o!t??uzuok??ren???r&a&honih?wasago??iadok?umah??ssuf?t&ik?o??wa&g&anihs?ode??k&ara",
+ "?ihcat???y&agates?ubihs???e&amok?donih?m&o?urukihsagih??soyik??i&enagok?gani?h&ca&da?tinuk??sabati??j&nubukok?oihcah??manigus??o&huzim?jihcah?n&akan?ih!sasum??urika??rugem?t&a&mayihsagih?nim??iat?ok??uhc?yknub??u&fohc?hcuf?kujnihs?????p&a&ehc,rc,?o&hs&eht,iiawak,yub,?lf,p&evol,ydnac,?rd&kcab,niar,???r&2xro6--nx?atselttil,e&d&nu,wohc,?h,ilf,pp&ep,irts,u,?t&aerg,tib,??g!r,?ks,o!on,?ufekaf,?s&9nvfe--nx?dom,p&ihc,oo,?remagten,sikhcnerf,u&bloohcs,ruci,srev,?xvp4--nx??t&a&cyssup,obgip,?e&rces,vlev,?hginyad,netnocresu,opsgolb,sidas,u&b,ollihc,??u&4rvp8--nx?fig!.&a&d&eki?ih??kimot?m&ayakat?ihsah??ne?raha&gi&kes?makak??sak??taga&may?tik??wa&g&ibi?ustakan??karihs!ihsagih????e&katim?uawak??i&gohakas?hc&apna?uonaw??k&ago?es?ot??m&anuzim?ijat??nak?urat??nanig?o&dog?jug?makonim?nim?roy?sihcih??u&fig?s&otom?t&amasak?oay??????hc,pup,stoknot,ynup,?wonsetihw,x&5ytlk--nx?irtam,?y&adynnus,dr,knarc,l&oh,rig,?moolg,ob,pp&ih,olf,?rgn&a,uh,?u6d27srjd--nx?vaeh,?z&72thr--nx?e&ej,lur,??井福?京東?分大?取鳥?口山?城&宮?茨??媛愛?山&富?岡?歌和??岡&福?静??島&児鹿?広?徳?福??崎&宮?長??川&奈神?石?香??庫兵?形山?手岩?木栃?本熊?根島?梨山?森青?潟新?玉埼?田秋?知&愛?高??縄沖?良奈?葉千?賀&佐?滋??道海北?都京?重三?野長?阜岐?阪大?馬群???k!.&art?gro?moc?per?ude?vog???l&eh?l??m!.uj,ac?j??nd?o&g?h&pih?s!.&esab,xilpoh,ysrab,???lnud?oc?t!.&lldtn,snd-won,???pa!.&0mroftalp,a&rusah,ted,?bew:erif,,e&erf-korgn,gatskrelc,kalfwons:.kniletavirp,,niln&igol,okoob,?tupmocegde,virdhsalfno,?ilressem,k&orgn,relc,?le&crev,napysae,?maerdepyt,n&aecolatigidno,ur:.a,,?poon,r&cne,emarf,?sserpirots,t&i&belet,lmaerts,?xenw,?yfilten,??ra&a?hs??u&ekam?llag?org!.esruocsid,cts?kouk?nayalo???vsr?xece4ibgm--nx??q&a!3a9y--nx??g?i!.&gro?lim?moc?ten?ude?vog???m?se??r&a!.&a&cisum?sanes??bog?gro?l&autum?im??moc!.topsgolb,?pooc?rut?t&e&b?n??ni??ude?vog??4d5a4prebgm--nx?b?c?eydoog?los?t&at?s!uen???ugaj??b!.&21g?a&b&a&coros?iuc??itiruc??cnogoas?dicerapa?gniram?i&naiog?ramatnas??n&erom?irdnol??op?p&acam?irolf?ma&j?s???rief?tsivaob??b!aj?ib?mi?sb??c&ba?e&r?t??js?sp?t!e???d&em?mb?n&f?i??rt??e&dnarganipmac?ficer?ht?llivnioj?rdnaotnas??f&dj?ed?gg?n&e?i???g&e&l!.&a&b,m,p,?bp,c&a,s,?e&c,p,s,?fd,gm,ip,jr,la,ma,nr,o&g,r,t,?p&a,s,?r&p,r,?s&e,m,r,?tm,??s??l&s?z??n&c?e?o??ol!b?f?v??pp?ro??hvp?i&du?kiw?nana?oretin?r&c?eurab??sp?te?xat??l&at&an?rof??el?im?sq??m&a?da?e&gatnoc?leb??f?ic?oc!.&etiselpmis,topsgolb,???nce?o&ariebir?c&e?narboir?saso??d&o?ranreboas??e&g?t??i&b?dar?ecam?r??rp?t&a?erpoir???p&er?m!e?t??ooc?pa?se??qra?r&af?ga?o&davlas?j??tn?ut??s&a&ixac?mlap?nipmac??ed?u&anam?j?m???t&am?e&d?n?v??nc?o&f?n??ra?sf??u&caug9?de?ja?rg??v&da?ed?og!.&a&b?m?p??bp?c&a?s??e&c?p?s??fd?gm?ip?jr?la?ma?nr?o&g?r?t??p&a?s??r&p?r??s&e?m?r??tm???rs?t??xiv?z&hb?ls?o&c?f?????c!.&as?ca?de?if?o&c?g??ro???e&bew?ccos?e&b?n&igne?oip??rac??gni&arg?rheob??h&sok?t&aew?orb???itnorf?k&col?o&p?rb???l&aed?ffeahcs??mal?nes?pinuj?t&a&eht?rebsnegömrev??law?nec?s&acnal?nom?ubkcolb??upmoc??v&o&csid?rdnal??resbo??wulksretlow?ywal?zifp??f!.&aterg?bew&-no,etis321,?drp?e&c&itsuj-reissiuh?narf-ne-setsitned-sneigrurihc,?lipuog,rianiretev,?hny,i&cc?rgabmahc,?m&o&c?n??t??n&eicamrahp,icedem,?ossa?pohsdaerpsym,s&e&lbatpmoc-strepxe,riaton,tsitned-sneigrurihc,uova??o&-x&bf,obeerf,?x&bf,obeerf,???t&acova,o&or-ne,psgolb,?rop:orea,,?vuog?xobided,?avc7ylqbgm--nx?s??g!.&etiselpmis,gro?moc?t&en?opsgolb,?ude?vog???h!.&e&erf,man??mo&c?rf??topsgolb,zi??ur??i!.&a&61f4a3abgm--nx?rf4a3abgm--nx??ca?di?gro?hcs?oc?ten?vog?نار&يا?یا???a&h?per??ew?lf??k!.&c&a?s??e&n?p?r??gk?iggnoeyg?kub&gn&oeyg?uhc??noej??l&im?uoes??man&gn&oeyg?uhc??noej??n&as&lu?ub??o&e&hcni?jead??wgnag???o&c?g??ro?s&e?h?m??topsgolb,u&gead?j&ej?gnawg????cilf??l!.&gro?moc?ten?ude?vog???m!.&topsgolb,vog???n!.&gro?moc?ofni?ten?ude?vog?zib???o&htua?t&c&a?od??laer???p!.&alsi?ca?eman?forp?gro?moc?o&fni?rp??t&en?se??ude?vog?zib???s?t!.&21k?bew?cn!.vog??eman?gro?kst?l&e&b?t??im?op??moc!.topsgolb,?neg?ofni?pek?rd?sbb?ten?ude?v&a?og?t??zib??f?m??ubad?vd??s&8sqif--nx?9zqif--nx?a!.vog?birappnb?gev?lliv?mtsirhc?s??b!.&ew,gro?moc?ten?ude?vog??oj?s?u??c&i&hparg?p?t&sigolyrrek?ylana???od??d&a?d?ik?l?n&iwriaf?omaid??oogemoh?rac??e!.&b&ewim321,og??gro?mo&c!.topsgolb,?n??pohsdaerpsym,ude??civres!.enilnigol,?d&d2bgm--nx?oc??h&ctaw?guh??i&lppus?rtsudni?treporp!yrrek???jaiv?l&aw?cycrotom?gnis?pats??m&ag?oh?reh??nut?ohs?picer?r&it?ut&cip!.7331,?nev???s&i&rpretne?urc??ruoc??taicossa?vig??g!nidloh??h5c822qif--nx?i!.&ekacpuc,gro?moc?t&en?ni?opsgolb,?ude?vog??a09--nx?nnet?rap?targ??k&c&or!.&ecapsbew,snddym,ytic-amil,??us??hxda08--nx?row??l!.&c&a?s??ed,gro?o&c?fni??ten?ude?vog?zib??a&ed?tner??e&ssurb?toh!yrrek???lahsram?m?oot??m!.&bal,etisinim,gro?moc?ten?ude?vog??b?etsys!.tniopthgink,?ialc??n&a&f?gorf?ol??i&a&grab?mod??giro??o&it&acav?cudorp?ulos??puoc???o&dnoc?geuj?ppaz?t&ohp!.remarf,?ua???p!.&ces?gro?moc?olp?ten?ude?vog??i&hsralohcs?lihp?t??u??r!.&au,ca?gro?ni?oc?topsgolb,ude?vog?xo,yldnerb.pohs,?a&c?p?tiug??c?e&dliub!.etisduolc,?erac?gor?levart?mraf?n&niw?trap??wolf??ot&cartnoc?omatat??pj?uot??s!.&em?gro?hcs?moc?ten?ude?vog?zib??alg?e&n&isub!.oc,?tif??rp!xe!nacirema???xnal??iws??t&a&eb?ob??ek&cit?ram??fig?h&cay?gilf??n&atnuocca?e&mt&rapa?sevni??ve!.&nibook,oc,????rap??u!.&a&c!.&21k?bil?cc???g!.&21k?bil?cc???i!.&21k?bil?cc???l!.&21k?bil?cc???m!.&21k!.&hcorap?rthc?tvp???bil?cc???p!.&21k?bil?cc???si?v!.&21k?bil?cc???w!.&21k?bil?cc????c&d!.&21k?bil?cc???n!.&21k?bil?cc???s!.&21k?bil?cc????d&e&f?lacsne.xhp,?i!.&21k?bil?cc???m!.&21k?bil?cc???n!.&bil?cc???s!.&bil?cc???u&olcrim,rd,??e&d!.&bil,cc???las-4-&dnal,ffuts,?m!.&21k?bil?cc???n!.&21k?bil?cc????h&n!.&21k?bil?cc???o!.&21k?bil?cc????i&h!.&bil?cc???m!.&21k?bil?c&c?et??goc?n&eg?otae??robra-nna?sum?tsd?wanethsaw???nd?r!.&bil?cc???v!.&21k?bil?cc???w!.&21k?bil?cc????jn!.&21k?bil?cc???k&a!.&21k?bil?cc???o!.&21k?bil?cc????l&a!.&21k?bil?cc???f!.&21k?bil?cc???i!.&21k?bil?cc????mn!.&21k?bil?cc???n&afflog,i!.&21k?bil?cc???m!.&21k?bil?cc???sn?t!.&21k?bil?cc????o&c!.&21k?bil?cc???m!.&21k?bil?cc???ttniop,?p&ion,rettalp,?r&a!.&21k?bil?cc???o!.&21k?bil?cc???p!.&21k?bil?cc????s&a!.&21k?bil?cc???dik?k!.&21k?bil?cc???m!.&21k?bil?cc???nd&deerf,uolc,??t&c!.&21k?bil?cc???m!.&21k?bil?cc???u!.&21k?bil?cc???v!.&21k?bil?cc????ug!.&21k?bil?cc???v&n!.&21k?bil?cc???w!.cc???x&ohparg,t!.&21k?bil?cc????y&b-si,k!.&21k?bil?cc???n!.&21k?bil?cc???w!.&21k?bil?cc????za!.&21k?bil?cc????ah!uab??bria?col?e!.ytrap.resu,?ineserf?lp?xe&l?n???vt?w!.&66duolc,gro?moc?s&ndnyd,tepym,?ten?ude?vog??a!.rekamegas.&1-&ht&ron-ue.&koobeton,oiduts,?uos-&em.&koobeton,oiduts,?fa.&koobeton,oiduts,?pa.&koobeton,oiduts,?ue.&koobeton,oiduts,???lartnec-&ac.&koobeton,oiduts,?em.&koobeton,oiduts,?li.&koobeton,oiduts,?ue.&koobeton,oiduts,??ts&ae&-&as.&koobeton,oiduts,?pa.&koobeton,oiduts,?su.&koobeton,oiduts,spif-koobeton,?vog-su.&koobeton,oiduts,spif-&koobeton,oiduts,???ht&ron-pa.&koobeton,oiduts,?uos-pa.&koobeton,oiduts,???ew-&su.&koobeton,oiduts,?ue.&koobeton,oiduts,?vog-su.&koobeton,oiduts,spif-&koobeton,oiduts,?????2-&htuos-&pa.koobeton,ue.koobeton,?lartnec-ue.koobeton,ts&ae&-su.&koobeton,oiduts,spif-koobeton,?ht&ron-pa.&koobeton,oiduts,?uos-pa.&koobeton,oiduts,???ew-&su.&koobeton,oiduts,spif-koobeton,?ue.&koobeton,oiduts,????3-ts&aeht&ron-pa.&koobeton,oiduts,?uos-pa.&koobeton,oiduts,??ew-ue.&koobeton,oiduts,??4-tsaehtuos-pa.koobeton,??e&iver?n!.elbaeciton,??odniw??y&alcrab?ot???t&0srzc--nx?a!.&amil4,ca!.hts??etiesbew321,gni&liamerutuf,tsoherutuf,?o&c!.topsgolb,?fni,?p&h21,ohsdaerpsym,?r&euefknuf.neiw,o??v&g?irp,?xi2,ytic-amil,zib,?c?e!s??hc?l!asite??mami?rcomed??b!.&gro?moc?ten?ude?vog??b?gl??c&atnoc?e&les?rid!txen????dimhcs?e!.&eman?gro?moc?ofni?ten?ude?vog?zib??b?em?grat?id?k&circ?ram??n!.&0rab,1rab,2rab,5inu,6vnyd,7&7ndc.r,erauqs,?a&l&-morf,moob,?minifed,remacytirucesym,tadsyawla,z,?b&boi,g,lyltsaf:.pam,,?c&i&nagro-gnitae,tats-oieboda,?paidemym,?d&e&calpb,ziamaka,?hiamaka,irgevissam.saap.&1-&gs,nol,rf,yn,?2-&nol,yn,??nab-eht-ni,uolc&meaeboda,nievas.c&di-etsedron,itsalej,?xednay:.e&garots,tisbew,?,??e&c&narusnihtlaehezitavirp,rofelacs.j,?gd&eiamaka,irbtib,?ht-no-eciffo,l&acs&liat.ateb,noom,?ibom-eruza,?m&ecnuob,itnuroieboda,ohtanyd,tcerider,?n&ilno-evreser,ozdop,?rehurht,s:abapus,,ti&s-repparcs,usegde,?zam&aym,kcar,??f&aeletis,crs.&cos,resu,?ehc-a-si,?g&ni&gats-&d&eziamaka,hiamaka,?e&gdeiamaka,tiusegde,?iamaka,nigiroiamaka,yekegde,?reesnes,sirkcilc,tsohnnylf,?olbevres,?iamaka,k&catsvano,eeg-a&-si,si,?u,?l&acolottad,iamwt,meteh,s&d-ni,s-77ndc,??m&ac&asac,ih,?urofniem,?n&a&f&agp,lhn,?i&bed,llerk,??dcduabkcalb,i:giroiamaka,,pv-ni,?o&c-morf,duppa,jodsnd,rp-ytinummoc,ttadym,?p&i&-&etsef,on,?emoh,fles,nwo,?j,mac-dnab-ta,o&-oidar-mah,h&bew,sdaerpsym,??pa&duolc,egde,?tfe&moh,vres,?usnd,?r&e&tsulcyduolc,vres-xnk,?vdslennahc:.u,,?s&a&ila&nyd,snd,?nymsd,?bbevres,dylimaf,e&gde-ndc,rauqs,suohsyub,t&isbeweruza,ys,??k&catstsaf,ekokohcs,?n&d&-won,aka,d,golb,npv,?oitcnufduolc,?ppacitatseruza:.&1,2:suts&ae,ew,?,3,4,5,6,7,aisatsae,eporuetsew,sulartnec,?,s&a-skcik,ecca&-citats,duolc,??t,?t&adies,ce&ffeym,jorprot:.segap,,lespohs,?e&nretnifodne,smem,?farcenimevres,i-&ekorb,s&eod,lles,teg,??n&essidym,orfduolc,?r0p3l3t,s&ixetnod,oh&-spv:.citsalej.&cir,lta,sjn,?,gnik,???u&h,nyd,r:eakust.citsalej,,?ved-naissalta.dorp.ndc,x&inuemoh,spym,tsale.&1ots-slj,2ots-slj,3ots-slj,?unilemoh,?y&awetag-llawerif,ekegde,ffijduolc:.&ed-1arf,su-1tsew,?,ltsaf.&dorp.&a,labolg,?lss.&a,b,labolg,?pam,slteerf,?n&-morf,ofipi,?srab,?z&a-morf,tirfym,???p?tcip?v??f&ig?osorcim??g!.&bog?dni?ed,g&olb,ro??lim?moc?ot,ten?ude???h!.&dem?gro?l&er?op??m&oc?rif??o&fni?rp?s&rep?sa???po&hs?oc??t&en?luda?ra??ude?vuog???i!.&a&2n-loritds--nx?7e-etsoaellav--nx?8&c-aneseclrof--nx?i-lrofanesec--nx??at?b?c!cul??dv?i&blo&-oipmet?oipmet??cserb?drabmol?g&gof?urep??l&gup?i&cis?me&-oigger?oigger???uig&-&aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf???aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf????n&a&brev?cul?pmac?tac??idras?obrac&-saiselgi?saiselgi??resi??otsip?r&b&alac!-oigger?oigger??mu??dna&-&attelrab-inart?inart-attelrab??attelrabinart?inartattelrab?ssela??epmi?ugil??tnelav&-obiv?obiv??vap?z&e&nev?ps&-al?al???irog???l&iuqa!l??leib??m&or?rap??n!acsot?e&dom?is?sec&-",
+ "&ilrof?ìlrof??ilrof?ìlrof???g&amor&-ailime?ailime??edras?olob??i&ssem?tal??ne!var??o&cna?merc?rev?vas???oneg?p?r!a&csep?rr&ac&-assam?assam??ef??von??etam?tsailgo!-lled?lled???s!ip?sam&-ararrac?ararrac??u&caris?gar???t!a&cilisab?recam??resac?soa!-&d&-&ellav?lav??ellav?lav??ellav??d&-&ellav?lav??ellav?lav??ellav??te&lrab&-&airdna-inart?inart-airdna??airdnainart?inartairdna??ssinatlac???udap?v!o&dap?neg?tnam???zn&airb&-a&lled-e-aznom?znom??a&lledeaznom?znom??eaznom??e&c&aip?iv??soc?top??om???b&-&23,46,61,?3c-lorit-ds-onitnert--nx?be-etsoa&-ellav--nx?dellav--nx??c!f-anesec-lrof--nx?m-lrof-anesec--nx??he-etsoa-d-ellav--nx?m!u??o2-loritds-nezob--nx?sn-loritds&-nasl&ab--nx?ub--nx??nitnert--nx??v!6-lorit-dsnitnert--nx?7-loritds&-nitnert--nx?onitnert--nx???z&r-lorit-ds&-nitnert--nx?onitnert--nx??s-loritds-onitnert--nx???c&f?is?l?m?p?r?v??d&p?u!olcnys,??e&c!cel?inev?nerolf??f?g!apemoh321,ida&-&a&-onitnert?onitnert??otla!-onitnert?onitnert???a&-onitnert?onitnert??otla!-on&azlob?itnert??onitnert????hcram?l?m!or??n&idu?o&n&edrop?isorf??torc???p?r?s&erav?ilom??t!nomeip?s&eirt?oa!-&d-e&ellav?éllav??e&ellav?éllav???de&ellav?éllav??e&ellav?éllav?????v?znerif??g&a?b?f?il?o?p?r?up?vf??hc?i&b?c?dol?f?l!lecrev?opan?rof&-anesec?anesec???m?n&a&part?rt&-attelrab-airdna?attelrabairdna???imir?ret??p?r!a&b?ilgac?ssas???s!idnirb??t&ei&hc?r??sa??v??l&a!c??b?c?o&m?rit&-&d&eus&-&nitnert?onitnert??nitnert?onitnert??us&-&nitnert?onitnert??nitnert?onitnert??üs&-&nitnert?onitnert??nitnert?onitnert???s&-onitnert?onitnert???d&eus!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??us&-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??üs!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert???s&-onitnert?onitnert?????m&ac?f?i!t.nepo.citsalej.duolc,?ol?r??n&a!lim?sl&ab?ub???b?c?e!en.cj,v?zob??irut?m!p??p?r?t??o&a!v??b!retiv??c!cel??enuc?g!ivor??i&dem&-onadipmac?onadipmac??pmet&-aiblo?aiblo??rdnos?zal??l?m!a&greb?ret??oc?re&f?lap???n!a&dipmac&-oidem?oidem??lim?tsiro?zlob??ecip&-ilocsa?ilocsa??i&bru&-orasep?orasep??lleva?rot?tnert??r&elas?ovil??ulleb??p?r!a&sep&-onibru?onibru??znatac??oun??s!ivert?sabopmac??t!arp?e&nev?ssorg??n&arat?e&girga?rt?veneb????zz&era?urba???p&a?ohsdaerpsym,s?t??qa?r&a!m?s??b!a??c?f?g?k?me?o?p?s?t?v??s&a&b?iselgi&-ainobrac?ainobrac???b?c?elpan?i?m?o&t?x&bi,obdaili,??s?t?v??t&a?b?c?l?m?nomdeip?o!psgolb,?p?v??u&de?l?n?p??v&a?og?p?s?t?v??y&drabmol?ellav&-atsoa?atsoa??licis?nacsut??z&al?b?c?p??ìlrof&-anesec?anesec???derc?er?f?m?utni??je3a3abgm--nx?kh?l!.&topsgolb,vog??uda??m!.&gro?moc!.topsgolb,?ten?ude???n&a&morockivdnas?ruatser?tnuocca??e&g?m&eganam!.retuor,?piuqe??r??i!.ue?m?opdlog??opud?uocsid??o&b?cs!.&ude,vog:.ecivres,,??d?g?h?j?oferab?p&edemoh?s???p!.&bewanigap321,emon?gro?lbup?moc?t&en?ni?opsgolb,?ude?vog???r&a!m&law?s???epxe?op&er?pus!.ysrab,?s???s!.&a&daxiabme?rarik,?e&motoas?picnirp?rots??gro?lim?moc?o&c?dalusnoc?hon,?ten?ude??a&cmoc?f??e&b?r?uq??i!rolf?tned??o&h!.&duolc&p,rim,?e&lej,tiseerf,?flah,l&enapysae,rupmet,?s&pvtsaf,seccaduolc,?tsafym,vedumpw,??p!sua???urt??t!.&eman?gro?ibom?levart?m&oc?uesum??o&c?fni?r&ea?p???pooc?sboj?t&en?ni??ude?vog?zib??ayh?n?o!bba?irram???uognah?xen?y!.gro,?ztej??u&2&5te9--nx?yssp--nx??a!.&a&s?w??civ?d&i?lq??fnoc?gro?moc!.&pohsdaerpsym,stelduolc.lem,topsgolb,??nsa?ofni?sat?t&ca?en?n??ude!.&a&s?w??ci&lohtac?v??dlq?sat?t&ca?n??wsn!.sloohcs????vog!.&a&s?w??civ?dlq?sat???wsn?zo??ti??c!.&fni?gro?moc?ten?ude?vog??i??d&e!.tir.segap-tig,?iab??e!.&dcym,enozgniebllew,noitatsksid,odagod.citsalej,s&nd&ps,uolc,?ppatikria,?ysrab,??g!.&bew?gro?m&aug?oc??ofni?ten?ude?vog???h!.&0002?a&citore?idem?kitore??edszot?gro?ilus?letoh?m&alker?lif?t?urof??naltagni?o&c?ediv?fni?levynok?nisac??pohs?rarga?s&a&kal?zatu??emag?wen??t&lob?opsgolb,rops??virp?xe&s?zs??ytic?zsagoj??os?sut??l!.&etisbew321,topsgolb,??m!.&ca?gro?moc?oc?ro?ten?vog???n!.&duolcesirpretne,eni&esrem,m,?tenkcahs,?em!.ysrab,??o&ggnaw?y!c???r!.&3kl,a&i&kymlak,rikhsab,vodrom,?yegyda,?bps,ca,duolcrim,e&niram,rpcm,?g&bc,nitsohurger.citsalej,ro,?ianatsuk,k&ihclan,s&m,rogitayp,??li&amdlc.bh,m,?moc,natsegad,onijym,pp,ri&b,d&cm:.spv,,orue,?midalv,?s&ar,itym,?t&en,ias321,ni,opsgolb,set,?u&4an,de,?vo&g,n,?ynzorg,zakvakidalv,?myc?p?ug??s!.&a&d&golov,nagarak,?gulak,i&groeg,kymlak,lerak,nemra,rikhsab,ssakahk,vodrom,zahkba,?lut,rahkub,vut,yegyda,znep,?bps,da&baghsa,rgonilest,?gunel,i&anatsuk,hcos,ovan,ttailgot,?k&alhsygnam,ihclan,s&legnahkra,m,n&a&mrum,yrb,?i&buytka,nbo,??tiort,vorkop,??l&ocarak,ybmaj,?na&gruk,jiabreza,ts&egad,hkazak-&htron,tsae,???ovonavi,r&adonsark,imidalv,?t&enxe,nek&hsat,mihc,??vo&hsalab,n,?ynzorg,z&akvakidalv,emret,??t&amok?i&juf?masih????v!.&em,g&olb,ro??moc?nc,ten?ude?ved,??ykuyr??v&b?c!.&emon?gro?moc?t&ni?opsgolb,?ude???ed!.&2r,ated,e&docotua,erf-korgn,nilnigol,?gnigats-oned,hcetaidem,korgn,lecrev,o&ned,tpyrctfihs,?ppa-rettalp,s&egap,rekrow,?vr&esi,uc,?weiverpbuhtig,ylf,??ih?l!.&di?fnoc?gro?lim?moc?nsa?ten?ude?vog???m!.&eman?gro?lim?m&oc?uesum??o&fni?r&ea?p???pooc?t&en?ni??ude?vog?zib???o&g?m??rt?s!.&bog?der?gro?moc?ude???t!.&arukas,bew-eht-no,morf,naht-&esrow,retteb,?sndnyd,?d?i?won??uqhv--nx??w&a!.moc?hs?l??b!.&gro?oc???c!.&gro?moc?ten?ude??cp??e&iver!.oby,?n?s??g?k!.&bme?dni?gro?moc?ten?ude?vog???m!.&ca?gro?m&oc?uesum??oc?pooc?t&en?ni??ude?vog?zib??b??o&csom?h!s??n?w??p!.&344x,de?en?o&c?g??ro?snduolc,ualeb???r!.&ca?gro?lim?oc?pooc?ten?vog??n??t!.&a46oa0fz--nx?b&82wrzc--nx?ulc??emag?gro?l&im?ru,?moc!.reliamym,?t&en?opsgolb,?ude?v&di?og?ta0cu--nx??zibe?業商?織組?路網???z!.&ca?gro?lim?oc?vog????x&a!.&cm,eb,gg,s&e,u,?tac,ue,yx,?t??c!.&hta,ofni,vog???e&d&ef?nay??ma!nab??rof?s??ilften?jt?m!.&bog?gro?moc?t&en?opsgolb,?ude??g?ma2ibgy--nx??o&b!x??f?rex??rbgn--nx?s!.vog??x&am&jt?kt??x???y&4punu--nx?7rr03--nx?a&d!i&loh?rfkcalb??ot!.emyfilauqerp,??g?lp?p!ila??rot?ssin?wdaorb??b!.&duolcym,fo?hcetaidem,lim?moc!.topsgolb,?vog??ab?gur??c!.&ca?dtl?gro?lim?m&oc!.&ecrofelacs.j,topsgolb,??t??orp?s&egolke?serp??ten?vog?zib??amrahp?nega??d&dadog?uts??e&kcoh?ltneb?n&dys?om?rotta??snikcm??g!.&eb,gro?moc?oc?ten?ude?vog??olonhcet!.oc,?rene??hpargotohp?id?k!.&gro?moc?ten?ude??s??l!.&clp?d&em?i??gro?hcs?moc?ten?ude?vog??f?imaf!nacirema??l&a?il??ppus??m!.&eman?gro?lim?moc?t&en?opsgolb,?ude?vog?zib??edaca!.laiciffo,?ra??n&apmoc?os??o&j?s??p!.&gro?lim?moc?pooc?ten?ude?vog???r&e&corg?grus?llag?viled??lewej?otcerid?tnuoc?uxul??s!.&gro?lim?moc?ten?ude?vog??pil??t&efas?i&c?ledif?n&ifx?ummoc!.&bdnevar,gon,murofym,???r&ahc?uces??srevinu??laer?r&ap!.oby,?eporp??uaeb??u!.&bug?gro?lim?moc!.topsgolb,?ten?ude??b!tseb???van!dlo??xes??z&a!.&eman?gro?lim?moc?o&fni?rp??pp?t&en?ni??ude?vog?zib???b!.&az,gro?jsg,moc?ten?ude?vog???c!.&4e,inum.duolc.&rsu,tlf,?m&laer,urtnecatem.motsuc,?oc,topsgolb,??d!.&cos?gro?lop?m&oc?t??ossa?t&en?ra??ude?vog???ib!.&duolcsd,e&ht-rof,mos-rof,rom-rof,?izoj,liartevitca,nafamm,p&i&-on,fles,?ohbew,tfym,?retteb-rof,snd&nyd,uolc,?xro,?g??k!.&duolcj,gro?lim?moc?t&en?ropeletzak.saapu,?ude?vog???m!.&ca?gro?lim?oc?ten?ude?v&da?og????n!.&asq-irom--nx?ca?gro?htlaeh?i&r&c?o&am?ām???wi!k???keeg?l&im?oohcs??neg?oc!.topsgolb,?t&en?nemailrap?vog???a!niflla???rawhcs?s!.&ca?gro?oc???t!.&c&a?s??e&m?n??ibom?l&etoh?im??o&c?fni?g??ro?vt???u!.&gro?moc?oc?ten??rwon??yx!.&e&nozlacol,tisgolb,?gnitfarc,otpaz,??zub??λε?υε?авксом?брс!.&гро?до?ка?р&бо?п!у?????г&б?ро??дкм?зақ?итед?килотак?леб?мок?н&йално?ом??рку?сур!.&арамас,бпс,гро,зиб,ичос,ксм,м&ок,ырк,?рим,я,??тйас?фр?юе?յահ?לארשי!.&בושי?הימדקא?ל&הצ?שממ????םוק?اي&روس?سيلم?ناتيروم??بر&ع?غملا??ة&كبش?ي&دوعسلا?روس??یدوعسلا??ت&ا&راما?لاصتا??را&ب?ڀ?ھب???ر&ئازجلا?ازاب?صم?طق??سنوت?عقوم?قارع?ك&تيب?يلوثاك??موك?ن&ا&تس&كاپ?کاپ??دوس?ر&يا?یا??مع?يلعلا??درالا?ميلا?ي&رحبلا?طسلف???ه&ارمه?يدوعسلا??وكمارا?يبظوبا?ۃیدوعسلا?टेन?त&राभ?ोराभ??नठगंस?मॉक?्मतराभ?ত&রাভ?ৰাভ??ালংাব?ਤਰਾਭ?તરાભ?ତରାଭ?ாயித்நஇ?ைக்ஙலஇ?்ரூப்பக்ஙிச?్తరాభ?ತರಾಭ?ംതരാഭ?ාකංල?มอค?ยทไ!.&จิกรุธ?ต็นเ?ร&ก์คงอ?าหท??ลาบฐัร?าษกึศ???ວາລ?ეგ?なんみ?アトス?トンイポ?ドウラク?ムコ?ル&グーグ?ーセ??ン&ゾマア?ョシッァフ??业企?东广?乐娱?你爱我?信中?务政?动移?博微?卦八?厅餐?司公?品食?善慈?团集?国中?國中?址网?坡加新?城商?尚时?山佛?店&商?网?酒大里嘉??府政?康健?息信?戏游?拉里格香?拿大?教主天?机手?构机!织组??标商?歌谷?浦利飞?港香!.&人個?司公?府政?絡網?織組?育教???湾台?灣&台?臺??物购?界世?益公?看点?科盈訊電?站网?籍書?线在?络网?网文中?聘招?販通?逊马亚?通联?里嘉?锡马淡?門澳?门澳?闻新?電家?국한?넷닷?성삼?컴닷??");
/**
* If a hostname is not a key in the EXCLUDE map, and if removing its leftmost component results
@@ -56,7 +56,7 @@ public final class PublicSuffixPatterns {
*/
public static final ImmutableMap<String, PublicSuffixType> UNDER =
TrieParser.parseTrie(
- "ac.vedwa,d&b?i.ym.ssr,uolc.&etiso&isnes,tnegam,?iaznab,rehcnar-no,scitats,??e&b.lrusnart,d.&ecapsrebu,yksurf,?noz.notirt,t&atse.etupmoc,is.&areduolc,hsmroftalp,tst,???g&oog.tnetnocresu,p??h&c.tenerif:.cvs,,k?trae.sppad:.zzb,,?k&c?f?nil.bewd,rowten.secla,u.hcs??ln.lrusnart,m&f.resu,j?m?oc.&duolcmeaeboda.ved,edo&c.redliub:-&gts,ved,?,nil.recnalabedon,?ico-remotsuc:.&ico,pco,sco,?,lrihwyap,mme0,osseccandcved,s&ecapsnaecolatigid,t&cejbo&edonil,rtluv,?nemelepiuq,?wanozama.&1-etupmoc,ble,etupmoc,??t&neyoj.snc,opsppa.r,???n&c.moc.swanozama.&ble,etupmoc,?ur.&dliub,e&doc,sabatad,?noitargim,??o&c.pato,i.&duolciaznab.sdraykcab,elacsnoom,nroca-no,oir-no,reniatnoceruza,s&3k-no,olots,?xcq.sys,y5s,??p&j.&a&mahokoy?yogan??ebok?i&adnes?kasawak??oroppas?uhsuykatik??n?pa.&knalfhtron,repoleved,tegeb,??r&b.mon?e??s&edoc.owo,noitulos.rehid,w.rosivda,?t&a.&ofnistro.&nednuk,xe,?smcerutuf:.&ni,xe,?,?en.&cimonotpyrc,hvo.&gnitsoh,saapbew,???u&e.lrusnart,r.onijym.&gni&dnal,tsoh,?murtceps,spv,??ved.&e&gats&gts,lcl,?rahbew,?gts,lcl,treclacol.resu,yawetag,?z&c.murtnecatem.duolc,yx.tibelet,??");
+ "ac.vedwa,d&b?i.ym.ssr,uolc.&etiso&isnes,tnegam,?iaznab,rehcnar-no,scitats,??e&b.lrusnart,d.&ecapsrebu,yksurf,?noz.notirt,t&atse.etupmoc,is.&areduolc,hsmroftalp,tst,???g&oog.tnetnocresu,p??h&c.tenerif:.cvs,,k?trae.sppad:.zzb,,?k&c?f?nil.bewd,rowten.secla,u.hcs??ln.lrusnart,m&f.resu,j?m?oc.&duolcmeaeboda.ved,edo&c.redliub:-&gts,ved,?,nil.recnalabedon,?ico-remotsuc:.&ico,pco,sco,?,lrihwyap,mme0,osseccandcved,ppayfilpma,rennurppaswa,s&ecapsnaecolatigid,t&cejbo&edonil,rtluv,?nemelepiuq,?wanozama.&1-etupmoc,ble,etupmoc,wolfria.&1-&ht&ron-ue,uos-pa,?lartnec-&ac,ue,?ts&ae&-&as,su,?ht&ron-pa,uos-pa,??ew-ue,??2-ts&ae&-su,ht&ron-pa,uos-pa,??ew-&su,ue,??3-tsew-ue,???t&neyoj.snc,opsppa.r,???n&c.moc.swanozama.&ble,etupmoc,wolfria.1-&htron-nc,tsewhtron-nc,??ur.&dliub,e&doc,sabatad,?noitargim,??o&c.pato,i.&duolciaznab.sdraykcab,elacsnoom,nroca-no,oir-no,reniatnoceruza,s&3k-no,olots,?xcq.sys,y5s,??p&j.&a&mahokoy?yogan??ebok?i&adnes?kasawak??oroppas?uhsuykatik??n?pa.&knalfhtron,repoleved,tegeb,??r&b.mon?e??s&edoc.owo,noitulos.rehid,w.rosivda,?t&a.&ofnistro.&nednuk,xe,?smcerutuf:.&ni,xe,?,?en.&cimonotpyrc,hvo.&gnitsoh,saapbew,???u&e.lrusnart,r.onijym.&gni&dnal,tsoh,?murtceps,spv,??ved.&e&gats&gts,lcl,?rahbew,?gts,lcl,treclacol.resu,yawetag,?z&c.murtnecatem.duolc,yx.tibelet,??");
/**
* The elements in this map would pass the UNDER test, but are known not to be public suffixes and
diff --git a/android/pom.xml b/android/pom.xml
index d99f05992..8f752da30 100644
--- a/android/pom.xml
+++ b/android/pom.xml
@@ -15,12 +15,14 @@
<!-- Override this with -Dtest.include="**/SomeTest.java" on the CLI -->
<test.include>%regex[.*.class]</test.include>
<truth.version>1.1.3</truth.version>
- <maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version>
+ <jsr305.version>3.0.2</jsr305.version>
+ <checker.version>3.41.0</checker.version>
+ <errorprone.version>2.23.0</errorprone.version>
+ <j2objc.version>2.8</j2objc.version>
<javac.version>9+181-r4173-1</javac.version>
<!-- Empty for all JDKs but 9-12 -->
<maven-javadoc-plugin.additionalJOptions></maven-javadoc-plugin.additionalJOptions>
- <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
- <project.build.outputTimestamp>2023-07-31T21:00:57Z</project.build.outputTimestamp>
+ <project.build.outputTimestamp>2023-02-01T00:00:00Z</project.build.outputTimestamp>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<test.add.opens></test.add.opens>
<module.status>release</module.status>
@@ -94,7 +96,6 @@
</testResources>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
@@ -115,13 +116,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>${maven-javadoc-plugin.version}</version>
- <configuration>
- <source>${java.specification.version}</source>
- </configuration>
- </plugin>
</plugins>
<pluginManagement>
<plugins>
@@ -150,7 +144,7 @@
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
- <version>2.16</version>
+ <version>2.23.0</version>
</path>
</annotationProcessorPaths>
<!-- Fork:
@@ -168,12 +162,13 @@
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
- <version>${maven-source-plugin.version}</version>
+ <version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
- <phase>post-integration-test</phase>
- <goals><goal>jar</goal></goals>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
</execution>
</executions>
</plugin>
@@ -185,15 +180,14 @@
<annotations>com.google.common.collect.IgnoreJRERequirement,com.google.common.hash.IgnoreJRERequirement,com.google.common.io.IgnoreJRERequirement,com.google.common.reflect.IgnoreJRERequirement,com.google.common.testing.IgnoreJRERequirement</annotations>
<checkTestClasses>true</checkTestClasses>
<signature>
- <groupId>org.codehaus.mojo.signature</groupId>
- <artifactId>java16-sun</artifactId>
- <version>1.10</version>
+ <groupId>com.toasttab.android</groupId>
+ <artifactId>gummy-bears-api-19</artifactId>
+ <version>0.6.1</version>
+ <!-- TODO(cpovirk): In principle, it would make sense to *also* test compatibility with JDK 1.8, since guava-android also has JRE users. -->
</signature>
<ignores>
- <!-- Allow requireNonNull: Android desugaring rewrites it (so it's safe for us to use), and it's useful for null checks. Note that this line allows *all* methods from java.util.Objects. That's the best that we can do with the configuration options that Animal Sniffer offers. -->
- <ignore>java.util.Objects</ignore>
- <!-- Unsafe isn't part of the documented Java 6 API, but it is available.
- And in cases where it's not, we have fallbacks. -->
+ <!-- Unsafe isn't part of the documented Android API, but it is available.
+ And in cases where it's not, we have fallbacks (except maybe Striped64 (b/307807965)?). -->
<ignore>sun.misc.Unsafe</ignore>
</ignores>
</configuration>
@@ -209,7 +203,7 @@
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>${maven-javadoc-plugin.version}</version>
+ <version>3.5.0</version>
<configuration>
<quiet>true</quiet>
<notimestamp>true</notimestamp>
@@ -221,13 +215,12 @@
<additionalOption>-Xdoclint:-html</additionalOption>
</additionalOptions>
<linksource>true</linksource>
- <source>8</source>
+ <source>${java.specification.version}</source>
<additionalJOption>${maven-javadoc-plugin.additionalJOptions}</additionalJOption>
</configuration>
<executions>
<execution>
<id>attach-docs</id>
- <phase>post-integration-test</phase>
<goals><goal>jar</goal></goals>
</execution>
</executions>
@@ -264,7 +257,6 @@
</configuration>
</plugin>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
@@ -302,24 +294,28 @@
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
- <version>3.0.2</version>
+ <version>${jsr305.version}</version>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
- <version>3.33.0</version>
+ <version>${checker.version}</version>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
- <version>2.18.0</version>
+ <version>${errorprone.version}</version>
</dependency>
<dependency>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
- <version>2.8</version>
+ <version>${j2objc.version}</version>
</dependency>
- <!-- We avoid using dependencyManagement for test-only deps because of https://github.com/google/guava/issues/6654 -->
+ <!--
+ We moved away from using dependencyManagement for test-only deps because of https://github.com/google/guava/issues/6654.
+ We could probably have resumed it after https://github.com/google/guava/pull/6664.
+ But it's always weird that published poms reference test-only libraries at all, so I'm not in any rush to do so.
+ -->
</dependencies>
</dependencyManagement>
<profiles>
@@ -328,33 +324,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>${maven-source-plugin.version}</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>${maven-javadoc-plugin.version}</version>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<executions>
@@ -417,7 +386,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- Under JDK8, we continue to use errorprone's javac9 (even
@@ -460,7 +428,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs combine.children="append">
diff --git a/futures/failureaccess/pom.xml b/futures/failureaccess/pom.xml
index 47fe296de..8886a4b2f 100644
--- a/futures/failureaccess/pom.xml
+++ b/futures/failureaccess/pom.xml
@@ -8,7 +8,7 @@
<version>26.0-android</version>
</parent>
<artifactId>failureaccess</artifactId>
- <version>1.0.1</version>
+ <version>1.0.2</version>
<packaging>bundle</packaging>
<name>Guava InternalFutureFailureAccess and InternalFutures</name>
<description>
@@ -23,6 +23,16 @@
<build>
<plugins>
<plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Automatic-Module-Name>com.google.common.util.concurrent.internal</Automatic-Module-Name>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
@@ -65,4 +75,26 @@
</plugin>
</plugins>
</build>
+ <profiles>
+ <profile>
+ <id>sonatype-oss-release</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <version>3.0.1</version>
+ <executions>
+ <execution>
+ <id>sign-artifacts</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>sign</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git a/guava-gwt/pom.xml b/guava-gwt/pom.xml
index 8eddd48e7..1c3dc1ad3 100644
--- a/guava-gwt/pom.xml
+++ b/guava-gwt/pom.xml
@@ -45,7 +45,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>failureaccess</artifactId>
- <version>1.0.1</version>
+ <version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
@@ -249,7 +249,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>failureaccess</artifactId>
- <version>1.0.1</version>
+ <version>1.0.2</version>
<classifier>sources</classifier>
</dependency>
<dependency>
diff --git a/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/ExtraObjectsMethodsForWeb.java b/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/ExtraObjectsMethodsForWeb.java
index 9e3c89e2b..5cb5febc3 100644
--- a/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/ExtraObjectsMethodsForWeb.java
+++ b/guava-gwt/src-super/com/google/common/base/super/com/google/common/base/ExtraObjectsMethodsForWeb.java
@@ -17,7 +17,7 @@ package com.google.common.base;
import org.checkerframework.checker.nullness.qual.Nullable;
/** Holder for extra methods of {@code Objects} only in web. */
-abstract class ExtraObjectsMethodsForWeb {
+public abstract class ExtraObjectsMethodsForWeb {
public static boolean equal(@Nullable String a, @Nullable String b) {
return a == b;
}
diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableCollection.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableCollection.java
index ee93d9b1f..93fc4bd24 100644
--- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableCollection.java
+++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableCollection.java
@@ -22,9 +22,9 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.Spliterator;
+import java.util.function.Predicate;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -37,9 +37,6 @@ public abstract class ImmutableCollection<E> extends AbstractCollection<E> imple
static final int SPLITERATOR_CHARACTERISTICS =
Spliterator.IMMUTABLE | Spliterator.NONNULL | Spliterator.ORDERED;
- static final ImmutableCollection<Object> EMPTY_IMMUTABLE_COLLECTION =
- new ForwardingImmutableCollection<Object>(Collections.emptyList());
-
ImmutableCollection() {}
public abstract UnmodifiableIterator<E> iterator();
@@ -64,6 +61,10 @@ public abstract class ImmutableCollection<E> extends AbstractCollection<E> imple
throw new UnsupportedOperationException();
}
+ public final boolean removeIf(Predicate<? super E> predicate) {
+ throw new UnsupportedOperationException();
+ }
+
public final boolean retainAll(Collection<?> elementsToKeep) {
throw new UnsupportedOperationException();
}
diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableList.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableList.java
index 6fddbedc9..e9d8705ff 100644
--- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableList.java
+++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableList.java
@@ -40,8 +40,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
@SuppressWarnings("serial") // we're overriding default serialization
public abstract class ImmutableList<E> extends ImmutableCollection<E>
implements List<E>, RandomAccess {
- static final ImmutableList<Object> EMPTY =
- new RegularImmutableList<Object>(Collections.emptyList());
ImmutableList() {}
@@ -52,7 +50,7 @@ public abstract class ImmutableList<E> extends ImmutableCollection<E>
// Casting to any type is safe because the list will never hold any elements.
@SuppressWarnings("unchecked")
public static <E> ImmutableList<E> of() {
- return (ImmutableList<E>) EMPTY;
+ return (ImmutableList<E>) RegularImmutableList.EMPTY;
}
public static <E> ImmutableList<E> of(E element) {
diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableMap.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableMap.java
index 24063ac87..685e8ae17 100644
--- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableMap.java
+++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableMap.java
@@ -50,7 +50,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @author Hayward Chan
*/
public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
- static final ImmutableMap<Object, Object> EMPTY = new RegularImmutableMap<Object, Object>();
abstract static class IteratorBasedImmutableMap<K, V> extends ImmutableMap<K, V> {
abstract UnmodifiableIterator<Entry<K, V>> entryIterator();
@@ -92,7 +91,7 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
}
public static <K, V> ImmutableMap<K, V> of() {
- return (ImmutableMap<K, V>) EMPTY;
+ return (ImmutableMap<K, V>) RegularImmutableMap.EMPTY;
}
public static <K, V> ImmutableMap<K, V> of(K k1, V v1) {
diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/RegularImmutableList.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/RegularImmutableList.java
index cf00b78bb..f547d469b 100644
--- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/RegularImmutableList.java
+++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/RegularImmutableList.java
@@ -16,6 +16,7 @@
package com.google.common.collect;
+import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableList;
import java.util.List;
@@ -26,6 +27,9 @@ import java.util.List;
* @author Hayward Chan
*/
class RegularImmutableList<E> extends ForwardingImmutableList<E> {
+
+ static final ImmutableList<Object> EMPTY = new RegularImmutableList<Object>(emptyList());
+
private final List<E> delegate;
E forSerialization;
diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/RegularImmutableMap.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/RegularImmutableMap.java
index 988537114..e00ee4133 100644
--- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/RegularImmutableMap.java
+++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/RegularImmutableMap.java
@@ -25,6 +25,8 @@ import java.util.Map;
*/
final class RegularImmutableMap<K, V> extends ForwardingImmutableMap<K, V> {
+ static final ImmutableMap<Object, Object> EMPTY = new RegularImmutableMap<Object, Object>();
+
RegularImmutableMap(Map<? extends K, ? extends V> delegate) {
super(delegate);
}
diff --git a/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/DoublesMethodsForWeb.java b/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/DoublesMethodsForWeb.java
index 2fdd4c175..36720f8f3 100644
--- a/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/DoublesMethodsForWeb.java
+++ b/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/DoublesMethodsForWeb.java
@@ -18,7 +18,7 @@ import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsPackage;
/** Web specializations for {@link Doubles} methods. */
-abstract class DoublesMethodsForWeb {
+public abstract class DoublesMethodsForWeb {
@JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
public static native double min(double... array);
diff --git a/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/FloatsMethodsForWeb.java b/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/FloatsMethodsForWeb.java
index 61d57ccb4..fe713e385 100644
--- a/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/FloatsMethodsForWeb.java
+++ b/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/FloatsMethodsForWeb.java
@@ -18,7 +18,7 @@ import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsPackage;
/** Web specializations for {@link Floats} methods. */
-abstract class FloatsMethodsForWeb {
+public abstract class FloatsMethodsForWeb {
@JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
public static native float min(float... array);
diff --git a/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/IntsMethodsForWeb.java b/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/IntsMethodsForWeb.java
index 540b2173f..dfe10fe49 100644
--- a/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/IntsMethodsForWeb.java
+++ b/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/IntsMethodsForWeb.java
@@ -18,7 +18,7 @@ import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsPackage;
/** Web specializations for {@link Ints} methods. */
-abstract class IntsMethodsForWeb {
+public abstract class IntsMethodsForWeb {
@JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
public static native int min(int... array);
diff --git a/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/ShortsMethodsForWeb.java b/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/ShortsMethodsForWeb.java
index 8036e6cb3..2cd3d0c18 100644
--- a/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/ShortsMethodsForWeb.java
+++ b/guava-gwt/src-super/com/google/common/primitives/super/com/google/common/primitives/ShortsMethodsForWeb.java
@@ -18,7 +18,7 @@ import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsPackage;
/** Web specializations for {@link Shorts} methods. */
-abstract class ShortsMethodsForWeb {
+public abstract class ShortsMethodsForWeb {
@JsMethod(name = "Math.min", namespace = JsPackage.GLOBAL)
public static native short min(short... array);
diff --git a/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/ListenableFuture.java b/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/ListenableFuture.java
index 345fb94c2..5a6307a61 100644
--- a/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/ListenableFuture.java
+++ b/guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/ListenableFuture.java
@@ -35,8 +35,8 @@ public interface ListenableFuture<V extends @Nullable Object> extends Future<V>,
@JsMethod
@Override
default <R extends @Nullable Object> IThenable<R> then(
- @JsOptional IThenOnFulfilledCallbackFn<? super V, ? extends R> onFulfilled,
- @JsOptional IThenOnRejectedCallbackFn<? extends R> onRejected) {
+ @JsOptional @Nullable IThenOnFulfilledCallbackFn<? super V, ? extends R> onFulfilled,
+ @JsOptional @Nullable IThenOnRejectedCallbackFn<? extends R> onRejected) {
return new Promise<V>(
(resolve, reject) -> {
Futures.addCallback(
@@ -65,8 +65,8 @@ public interface ListenableFuture<V extends @Nullable Object> extends Future<V>,
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "IThenable")
interface IThenable<T extends @Nullable Object> {
<V extends @Nullable Object> IThenable<V> then(
- @JsOptional IThenOnFulfilledCallbackFn<? super T, ? extends V> onFulfilled,
- @JsOptional IThenOnRejectedCallbackFn<? extends V> onRejected);
+ @JsOptional @Nullable IThenOnFulfilledCallbackFn<? super T, ? extends V> onFulfilled,
+ @JsOptional @Nullable IThenOnRejectedCallbackFn<? extends V> onRejected);
@JsFunction
interface IThenOnFulfilledCallbackFn<T extends @Nullable Object, V extends @Nullable Object> {
@@ -102,6 +102,6 @@ class Promise<T extends @Nullable Object> implements IThenable<T> {
@Override
public native <V extends @Nullable Object> Promise<V> then(
- @JsOptional IThenOnFulfilledCallbackFn<? super T, ? extends V> onFulfilled,
- @JsOptional IThenOnRejectedCallbackFn<? extends V> onRejected);
+ @JsOptional @Nullable IThenOnFulfilledCallbackFn<? super T, ? extends V> onFulfilled,
+ @JsOptional @Nullable IThenOnRejectedCallbackFn<? extends V> onRejected);
}
diff --git a/guava-gwt/test-super/com/google/common/collect/testing/super/com/google/common/collect/testing/testers/Platform.java b/guava-gwt/test-super/com/google/common/collect/testing/super/com/google/common/collect/testing/testers/Platform.java
index 479b80f20..13f623148 100644
--- a/guava-gwt/test-super/com/google/common/collect/testing/super/com/google/common/collect/testing/testers/Platform.java
+++ b/guava-gwt/test-super/com/google/common/collect/testing/super/com/google/common/collect/testing/testers/Platform.java
@@ -17,7 +17,6 @@
package com.google.common.collect.testing.testers;
import com.google.common.annotations.GwtCompatible;
-import com.google.gwt.core.client.GWT;
/**
* The emulation source used in GWT.
@@ -31,13 +30,13 @@ final class Platform {
// mode.
static int listListIteratorTesterNumIterations() {
// TODO(hhchan): It's 4 in java. Figure out why even 3 is too slow in prod mode.
- return GWT.isProdMode() ? 2 : 4;
+ return 2;
}
// Use fewer steps in the IteratorTester in CollectionIteratorTester because it's slow in prod
- // mode..
+ // mode.
static int collectionIteratorTesterNumIterations() {
- return GWT.isProdMode() ? 3 : 5;
+ return 3;
}
// TODO: Consolidate different copies in one single place.
diff --git a/guava-testlib/README.md b/guava-testlib/README.md
index 141ad989c..636c5be59 100644
--- a/guava-testlib/README.md
+++ b/guava-testlib/README.md
@@ -13,7 +13,7 @@ To add a dependency on Guava testlib using Maven, use the following:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
- <version>32.1.2-jre</version>
+ <version>33.0.0-jre</version>
<scope>test</scope>
</dependency>
```
@@ -22,16 +22,16 @@ To add a dependency using Gradle:
```gradle
dependencies {
- test 'com.google.guava:guava-testlib:32.1.2-jre'
+ test 'com.google.guava:guava-testlib:33.0.0-jre'
}
```
## Links
-- [GitHub project](https://github.com/google/guava)
-- [Issue tracker: Report a defect or feature request](https://github.com/google/guava/issues/new)
-- [StackOverflow: Ask "how-to" and "why-didn't-it-work" questions](https://stackoverflow.com/questions/ask?tags=guava+java)
-- [guava-discuss: For open-ended questions and discussion](http://groups.google.com/group/guava-discuss)
+- [GitHub project](https://github.com/google/guava)
+- [Issue tracker: Report a defect or feature request](https://github.com/google/guava/issues/new)
+- [StackOverflow: Ask "how-to" and "why-didn't-it-work" questions](https://stackoverflow.com/questions/ask?tags=guava+java)
+- [guava-discuss: For open-ended questions and discussion](https://groups.google.com/group/guava-discuss)
## IMPORTANT WARNINGS
diff --git a/guava-testlib/src/com/google/common/collect/testing/AbstractIteratorTester.java b/guava-testlib/src/com/google/common/collect/testing/AbstractIteratorTester.java
index e9242a794..43a3d066d 100644
--- a/guava-testlib/src/com/google/common/collect/testing/AbstractIteratorTester.java
+++ b/guava-testlib/src/com/google/common/collect/testing/AbstractIteratorTester.java
@@ -58,7 +58,7 @@ abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
static final PermittedMetaException UOE_OR_ISE =
new PermittedMetaException("UnsupportedOperationException or IllegalStateException") {
@Override
- boolean isPermitted(RuntimeException exception) {
+ boolean isPermitted(Exception exception) {
return exception instanceof UnsupportedOperationException
|| exception instanceof IllegalStateException;
}
@@ -66,21 +66,21 @@ abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
static final PermittedMetaException UOE =
new PermittedMetaException("UnsupportedOperationException") {
@Override
- boolean isPermitted(RuntimeException exception) {
+ boolean isPermitted(Exception exception) {
return exception instanceof UnsupportedOperationException;
}
};
static final PermittedMetaException ISE =
new PermittedMetaException("IllegalStateException") {
@Override
- boolean isPermitted(RuntimeException exception) {
+ boolean isPermitted(Exception exception) {
return exception instanceof IllegalStateException;
}
};
static final PermittedMetaException NSEE =
new PermittedMetaException("NoSuchElementException") {
@Override
- boolean isPermitted(RuntimeException exception) {
+ boolean isPermitted(Exception exception) {
return exception instanceof NoSuchElementException;
}
};
@@ -89,9 +89,9 @@ abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
super(message);
}
- abstract boolean isPermitted(RuntimeException exception);
+ abstract boolean isPermitted(Exception exception);
- void assertPermitted(RuntimeException exception) {
+ void assertPermitted(Exception exception) {
if (!isPermitted(exception)) {
String message =
"Exception "
@@ -313,10 +313,11 @@ abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
protected void verify(List<E> elements) {}
/** Executes the test. */
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public final void test() {
try {
recurse(0);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
throw new RuntimeException(Arrays.toString(stimuli), e);
}
}
@@ -388,16 +389,17 @@ abstract class AbstractIteratorTester<E, I extends Iterator<E>> {
*
* @see Stimulus#executeAndCompare(ListIterator, Iterator)
*/
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private <T extends Iterator<E>> void internalExecuteAndCompare(
T reference, T target, IteratorOperation method) {
Object referenceReturnValue = null;
PermittedMetaException referenceException = null;
Object targetReturnValue = null;
- RuntimeException targetException = null;
+ Exception targetException = null;
try {
targetReturnValue = method.execute(target);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
targetException = e;
}
diff --git a/guava-testlib/src/com/google/common/collect/testing/AbstractTester.java b/guava-testlib/src/com/google/common/collect/testing/AbstractTester.java
index adbc8dcc6..cd9cbfdea 100644
--- a/guava-testlib/src/com/google/common/collect/testing/AbstractTester.java
+++ b/guava-testlib/src/com/google/common/collect/testing/AbstractTester.java
@@ -17,6 +17,7 @@
package com.google.common.collect.testing;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import junit.framework.TestCase;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -31,7 +32,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* parameterize the test.
* @author George van den Driessche
*/
-@GwtCompatible
+@GwtCompatible(emulated = true)
public class AbstractTester<G> extends TestCase {
private G subjectGenerator;
private String suiteName;
@@ -73,10 +74,12 @@ public class AbstractTester<G> extends TestCase {
}
/** Returns the name of the test method invoked by this test instance. */
+ @GwtIncompatible // not used under GWT, and super.getName() is not available under J2CL
public final String getTestMethodName() {
return super.getName();
}
+ @GwtIncompatible // not used under GWT, and super.getName() is not available under J2CL
@Override
public String getName() {
return Platform.format("%s[%s]", super.getName(), suiteName);
diff --git a/guava-testlib/src/com/google/common/collect/testing/IteratorFeature.java b/guava-testlib/src/com/google/common/collect/testing/IteratorFeature.java
index c447e2922..c1e502272 100644
--- a/guava-testlib/src/com/google/common/collect/testing/IteratorFeature.java
+++ b/guava-testlib/src/com/google/common/collect/testing/IteratorFeature.java
@@ -16,10 +16,13 @@
package com.google.common.collect.testing;
+import static java.util.Arrays.asList;
+import static java.util.Collections.emptySet;
+import static java.util.Collections.unmodifiableSet;
+
import com.google.common.annotations.GwtCompatible;
-import java.util.Collections;
-import java.util.EnumSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.ListIterator;
import java.util.Set;
@@ -49,12 +52,12 @@ public enum IteratorFeature {
* A set containing none of the optional features of the {@link Iterator} or {@link ListIterator}
* interfaces.
*/
- public static final Set<IteratorFeature> UNMODIFIABLE = Collections.emptySet();
+ public static final Set<IteratorFeature> UNMODIFIABLE = emptySet();
/**
* A set containing all of the optional features of the {@link Iterator} and {@link ListIterator}
* interfaces.
*/
public static final Set<IteratorFeature> MODIFIABLE =
- Collections.unmodifiableSet(EnumSet.allOf(IteratorFeature.class));
+ unmodifiableSet(new LinkedHashSet<>(asList(values())));
}
diff --git a/guava-testlib/src/com/google/common/collect/testing/MapInterfaceTest.java b/guava-testlib/src/com/google/common/collect/testing/MapInterfaceTest.java
index 484913878..067973c2a 100644
--- a/guava-testlib/src/com/google/common/collect/testing/MapInterfaceTest.java
+++ b/guava-testlib/src/com/google/common/collect/testing/MapInterfaceTest.java
@@ -477,8 +477,8 @@ public abstract class MapInterfaceTest<K, V> extends TestCase {
} catch (IllegalStateException expected) {
}
} else {
+ iterator.next();
try {
- iterator.next();
iterator.remove();
fail("Expected UnsupportedOperationException.");
} catch (UnsupportedOperationException expected) {
@@ -729,7 +729,7 @@ public abstract class MapInterfaceTest<K, V> extends TestCase {
try {
entrySet.retainAll(null);
// Returning successfully is not ideal, but tolerated.
- } catch (NullPointerException expected) {
+ } catch (NullPointerException tolerated) {
}
} else {
try {
@@ -1365,7 +1365,7 @@ public abstract class MapInterfaceTest<K, V> extends TestCase {
try {
keySet.retainAll(null);
// Returning successfully is not ideal, but tolerated.
- } catch (NullPointerException expected) {
+ } catch (NullPointerException tolerated) {
}
} else {
try {
@@ -1425,8 +1425,8 @@ public abstract class MapInterfaceTest<K, V> extends TestCase {
} catch (IllegalStateException expected) {
}
} else {
+ iterator.next();
try {
- iterator.next();
iterator.remove();
fail("Expected UnsupportedOperationException.");
} catch (UnsupportedOperationException expected) {
@@ -1527,7 +1527,7 @@ public abstract class MapInterfaceTest<K, V> extends TestCase {
try {
values.removeAll(null);
// Returning successfully is not ideal, but tolerated.
- } catch (NullPointerException expected) {
+ } catch (NullPointerException tolerated) {
}
} else {
try {
@@ -1581,7 +1581,7 @@ public abstract class MapInterfaceTest<K, V> extends TestCase {
try {
values.retainAll(null);
// Returning successfully is not ideal, but tolerated.
- } catch (NullPointerException expected) {
+ } catch (NullPointerException tolerated) {
}
} else {
try {
diff --git a/guava-testlib/src/com/google/common/collect/testing/SpliteratorTester.java b/guava-testlib/src/com/google/common/collect/testing/SpliteratorTester.java
index e0c2ebfea..6197e86a6 100644
--- a/guava-testlib/src/com/google/common/collect/testing/SpliteratorTester.java
+++ b/guava-testlib/src/com/google/common/collect/testing/SpliteratorTester.java
@@ -20,6 +20,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.testing.Helpers.assertEqualIgnoringOrder;
import static com.google.common.collect.testing.Helpers.assertEqualInOrder;
import static com.google.common.collect.testing.Platform.format;
+import static java.util.Arrays.asList;
+import static java.util.Collections.unmodifiableSet;
import static java.util.Comparator.naturalOrder;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
@@ -34,8 +36,9 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
-import java.util.EnumSet;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Set;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -199,6 +202,9 @@ public final class SpliteratorTester<E> {
};
abstract <E> void forEach(GeneralSpliterator<E> spliterator, Consumer<? super E> consumer);
+
+ static final Set<SpliteratorDecompositionStrategy> ALL_STRATEGIES =
+ unmodifiableSet(new LinkedHashSet<>(asList(values())));
}
private static <E> @Nullable GeneralSpliterator<E> trySplitTestingSize(
@@ -289,7 +295,7 @@ public final class SpliteratorTester<E> {
int characteristics = spliterator.characteristics();
long estimatedSize = spliterator.estimateSize();
for (SpliteratorDecompositionStrategy strategy :
- EnumSet.allOf(SpliteratorDecompositionStrategy.class)) {
+ SpliteratorDecompositionStrategy.ALL_STRATEGIES) {
List<E> resultsForStrategy = new ArrayList<>();
strategy.forEach(spliteratorSupplier.get(), resultsForStrategy::add);
diff --git a/guava-testlib/src/com/google/common/collect/testing/google/AbstractMultisetSetCountTester.java b/guava-testlib/src/com/google/common/collect/testing/google/AbstractMultisetSetCountTester.java
index a72fd9fba..cd28cdc28 100644
--- a/guava-testlib/src/com/google/common/collect/testing/google/AbstractMultisetSetCountTester.java
+++ b/guava-testlib/src/com/google/common/collect/testing/google/AbstractMultisetSetCountTester.java
@@ -188,9 +188,9 @@ public abstract class AbstractMultisetSetCountTester<E> extends AbstractMultiset
@CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
public void testSetCountZeroToOneConcurrentWithIteration() {
+ Iterator<E> iterator = collection.iterator();
+ assertSetCount(e3(), 1);
try {
- Iterator<E> iterator = collection.iterator();
- assertSetCount(e3(), 1);
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
@@ -200,9 +200,9 @@ public abstract class AbstractMultisetSetCountTester<E> extends AbstractMultiset
@CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
public void testSetCountZeroToOneConcurrentWithEntrySetIteration() {
+ Iterator<Entry<E>> iterator = getMultiset().entrySet().iterator();
+ assertSetCount(e3(), 1);
try {
- Iterator<Entry<E>> iterator = getMultiset().entrySet().iterator();
- assertSetCount(e3(), 1);
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
@@ -248,9 +248,9 @@ public abstract class AbstractMultisetSetCountTester<E> extends AbstractMultiset
@CollectionFeature.Require({SUPPORTS_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
@CollectionSize.Require(absent = ZERO)
public void testSetCountOneToZeroConcurrentWithIteration() {
+ Iterator<E> iterator = collection.iterator();
+ assertSetCount(e0(), 0);
try {
- Iterator<E> iterator = collection.iterator();
- assertSetCount(e0(), 0);
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
@@ -261,9 +261,9 @@ public abstract class AbstractMultisetSetCountTester<E> extends AbstractMultiset
@CollectionFeature.Require({SUPPORTS_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION})
@CollectionSize.Require(absent = ZERO)
public void testSetCountOneToZeroConcurrentWithEntrySetIteration() {
+ Iterator<Entry<E>> iterator = getMultiset().entrySet().iterator();
+ assertSetCount(e0(), 0);
try {
- Iterator<Entry<E>> iterator = getMultiset().entrySet().iterator();
- assertSetCount(e0(), 0);
iterator.next();
fail("Expected ConcurrentModificationException");
} catch (ConcurrentModificationException expected) {
diff --git a/guava-testlib/src/com/google/common/collect/testing/google/UnmodifiableCollectionTests.java b/guava-testlib/src/com/google/common/collect/testing/google/UnmodifiableCollectionTests.java
index 40b2c859d..8cbd7ea9a 100644
--- a/guava-testlib/src/com/google/common/collect/testing/google/UnmodifiableCollectionTests.java
+++ b/guava-testlib/src/com/google/common/collect/testing/google/UnmodifiableCollectionTests.java
@@ -224,6 +224,11 @@ public class UnmodifiableCollectionTests {
}
assertCollectionsAreEquivalent(multiset, copy);
+ try {
+ multiset.removeIf(x -> false);
+ fail("removeIf(Predicate) succeeded on unmodifiable collection");
+ } catch (UnsupportedOperationException expected) {
+ }
assertCollectionsAreEquivalent(multiset, copy);
assertSetIsUnmodifiable(multiset.elementSet(), sampleElement);
diff --git a/guava-testlib/src/com/google/common/collect/testing/testers/NavigableMapNavigationTester.java b/guava-testlib/src/com/google/common/collect/testing/testers/NavigableMapNavigationTester.java
index ebb86b615..936783e77 100644
--- a/guava-testlib/src/com/google/common/collect/testing/testers/NavigableMapNavigationTester.java
+++ b/guava-testlib/src/com/google/common/collect/testing/testers/NavigableMapNavigationTester.java
@@ -20,6 +20,7 @@ import static com.google.common.collect.testing.features.CollectionSize.ONE;
import static com.google.common.collect.testing.features.CollectionSize.SEVERAL;
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.testing.AbstractMapTester;
@@ -162,11 +163,7 @@ public class NavigableMapNavigationTester<K, V> extends AbstractMapTester<K, V>
@MapFeature.Require(absent = SUPPORTS_REMOVE)
public void testPollFirstUnsupported() {
- try {
- navigableMap.pollFirstEntry();
- fail();
- } catch (UnsupportedOperationException e) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> navigableMap.pollFirstEntry());
}
@CollectionSize.Require(SEVERAL)
@@ -229,11 +226,7 @@ public class NavigableMapNavigationTester<K, V> extends AbstractMapTester<K, V>
@MapFeature.Require(absent = SUPPORTS_REMOVE)
@CollectionSize.Require(SEVERAL)
public void testPollLastUnsupported() {
- try {
- navigableMap.pollLastEntry();
- fail();
- } catch (UnsupportedOperationException e) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> navigableMap.pollLastEntry());
}
@CollectionSize.Require(SEVERAL)
diff --git a/guava-testlib/src/com/google/common/collect/testing/testers/NavigableSetNavigationTester.java b/guava-testlib/src/com/google/common/collect/testing/testers/NavigableSetNavigationTester.java
index 8b056b4cb..354dd608d 100644
--- a/guava-testlib/src/com/google/common/collect/testing/testers/NavigableSetNavigationTester.java
+++ b/guava-testlib/src/com/google/common/collect/testing/testers/NavigableSetNavigationTester.java
@@ -20,6 +20,7 @@ import static com.google.common.collect.testing.features.CollectionFeature.SUPPO
import static com.google.common.collect.testing.features.CollectionSize.ONE;
import static com.google.common.collect.testing.features.CollectionSize.SEVERAL;
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.testing.Helpers;
@@ -128,11 +129,7 @@ public class NavigableSetNavigationTester<E> extends AbstractSetTester<E> {
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testPollFirstUnsupported() {
- try {
- navigableSet.pollFirst();
- fail();
- } catch (UnsupportedOperationException e) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> navigableSet.pollFirst());
}
@CollectionSize.Require(SEVERAL)
@@ -209,11 +206,7 @@ public class NavigableSetNavigationTester<E> extends AbstractSetTester<E> {
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testPollLastUnsupported() {
- try {
- navigableSet.pollLast();
- fail();
- } catch (UnsupportedOperationException e) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> navigableSet.pollLast());
}
@CollectionSize.Require(SEVERAL)
diff --git a/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java b/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java
index 0071feacf..9e4ab85fe 100644
--- a/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java
+++ b/guava-testlib/src/com/google/common/testing/ArbitraryInstances.java
@@ -17,6 +17,7 @@
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
@@ -422,7 +423,8 @@ public final class ArbitraryInstances {
}
private static <T> T createEmptyArray(Class<T> arrayType) {
- return arrayType.cast(Array.newInstance(arrayType.getComponentType(), 0));
+ // getComponentType() is non-null because we call createEmptyArray only with an array type.
+ return arrayType.cast(Array.newInstance(requireNonNull(arrayType.getComponentType()), 0));
}
// Internal implementations of some classes, with public default constructor that get() needs.
diff --git a/guava-testlib/src/com/google/common/testing/ClassSanityTester.java b/guava-testlib/src/com/google/common/testing/ClassSanityTester.java
index d327666fe..e0998f0af 100644
--- a/guava-testlib/src/com/google/common/testing/ClassSanityTester.java
+++ b/guava-testlib/src/com/google/common/testing/ClassSanityTester.java
@@ -496,13 +496,14 @@ public final class ClassSanityTester {
* @return this tester
*/
@CanIgnoreReturnValue
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public FactoryMethodReturnValueTester testSerializable() throws Exception {
for (Invokable<?, ?> factory : getFactoriesToTest()) {
Object instance = instantiate(factory);
if (instance != null) {
try {
SerializableTester.reserialize(instance);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
AssertionError error =
new AssertionFailedError("Serialization failed on return value of " + factory);
error.initCause(e.getCause());
@@ -522,6 +523,7 @@ public final class ClassSanityTester {
* @return this tester
*/
@CanIgnoreReturnValue
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public FactoryMethodReturnValueTester testEqualsAndSerializable() throws Exception {
for (Invokable<?, ?> factory : getFactoriesToTest()) {
try {
@@ -533,7 +535,7 @@ public final class ClassSanityTester {
if (instance != null) {
try {
SerializableTester.reserializeAndAssert(instance);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
AssertionError error =
new AssertionFailedError("Serialization failed on return value of " + factory);
error.initCause(e.getCause());
diff --git a/guava-testlib/src/com/google/common/testing/CollectorTester.java b/guava-testlib/src/com/google/common/testing/CollectorTester.java
index 656edbd41..2e154c175 100644
--- a/guava-testlib/src/com/google/common/testing/CollectorTester.java
+++ b/guava-testlib/src/com/google/common/testing/CollectorTester.java
@@ -147,6 +147,7 @@ public final class CollectorTester<
*/
@SafeVarargs
@CanIgnoreReturnValue
+ @SuppressWarnings("nullness") // TODO(cpovirk): Remove after we fix whatever the bug is.
public final CollectorTester<T, A, R> expectCollects(R expectedResult, T... inputs) {
List<T> list = Arrays.asList(inputs);
doExpectCollects(expectedResult, list);
diff --git a/guava-testlib/src/com/google/common/testing/EqualsTester.java b/guava-testlib/src/com/google/common/testing/EqualsTester.java
index d4484702a..5f02dba84 100644
--- a/guava-testlib/src/com/google/common/testing/EqualsTester.java
+++ b/guava-testlib/src/com/google/common/testing/EqualsTester.java
@@ -95,6 +95,16 @@ public final class EqualsTester {
/**
* Adds {@code equalityGroup} with objects that are supposed to be equal to each other and not
* equal to any other equality groups added to this tester.
+ *
+ * <p>The {@code @Nullable} annotations on the {@code equalityGroup} parameter imply that the
+ * objects, and the array itself, can be null. That is for programmer convenience, when the
+ * objects come from factory methods that are themselves {@code @Nullable}. In reality neither the
+ * array nor its contents can be null, but it is not useful to force the use of {@code
+ * requireNonNull} or the like just to assert that.
+ *
+ * <p>{@code EqualsTester} will always check that every object it is given returns false from
+ * {@code equals(null)}, so it is neither useful nor allowed to include a null value in any
+ * equality group.
*/
@CanIgnoreReturnValue
public EqualsTester addEqualityGroup(@Nullable Object @Nullable ... equalityGroup) {
diff --git a/guava-testlib/src/com/google/common/testing/NullPointerTester.java b/guava-testlib/src/com/google/common/testing/NullPointerTester.java
index 5b14fa5eb..32e29d43e 100644
--- a/guava-testlib/src/com/google/common/testing/NullPointerTester.java
+++ b/guava-testlib/src/com/google/common/testing/NullPointerTester.java
@@ -352,13 +352,6 @@ public final class NullPointerTester {
*/
private void testParameter(
@Nullable Object instance, Invokable<?, ?> invokable, int paramIndex, Class<?> testedClass) {
- /*
- * com.google.common is starting to rely on type-use annotations, which aren't visible under
- * Android VMs. So we skip testing there.
- */
- if (isAndroid() && Reflection.getPackageName(testedClass).startsWith("com.google.common")) {
- return;
- }
if (isPrimitiveOrNullable(invokable.getParameters().get(paramIndex))) {
return; // there's nothing to test
}
@@ -605,19 +598,17 @@ public final class NullPointerTester {
* Looks for declaration nullness annotations and, if supported, type-use nullness annotations.
*
* <p>Under Android VMs, the methods for retrieving type-use annotations don't exist. This means
- * that {@link NullPointerException} may misbehave under Android when used on classes that rely on
+ * that {@link NullPointerTester} may misbehave under Android when used on classes that rely on
* type-use annotations.
*
* <p>Under j2objc, the necessary APIs exist, but some (perhaps all) return stub values, like
- * empty arrays. Presumably {@link NullPointerException} could likewise misbehave under j2objc,
- * but I don't know that anyone uses it there, anyway.
+ * empty arrays. Presumably {@link NullPointerTester} could likewise misbehave under j2objc, but I
+ * don't know that anyone uses it there, anyway.
*/
private enum NullnessAnnotationReader {
- // Usages (which are unsafe only for Android) are guarded by the annotatedTypeExists() check.
- @SuppressWarnings({"Java7ApiChecker", "AndroidApiChecker", "DoNotCall", "deprecation"})
+ @SuppressWarnings("Java7ApiChecker")
FROM_DECLARATION_AND_TYPE_USE_ANNOTATIONS {
@Override
- @IgnoreJRERequirement
boolean isNullable(Invokable<?, ?> invokable) {
return FROM_DECLARATION_ANNOTATIONS_ONLY.isNullable(invokable)
|| containsNullable(invokable.getAnnotatedReturnType().getAnnotations());
@@ -625,14 +616,12 @@ public final class NullPointerTester {
}
@Override
- @IgnoreJRERequirement
boolean isNullable(Parameter param) {
return FROM_DECLARATION_ANNOTATIONS_ONLY.isNullable(param)
|| containsNullable(param.getAnnotatedType().getAnnotations())
|| isNullableTypeVariable(param.getAnnotatedType().getType());
}
- @IgnoreJRERequirement
boolean isNullableTypeVariable(Type type) {
if (!(type instanceof TypeVariable)) {
return false;
@@ -664,9 +653,4 @@ public final class NullPointerTester {
abstract boolean isNullable(Parameter param);
}
-
- private static boolean isAndroid() {
- // Arguably it would make more sense to test "can we see type-use annotations" directly....
- return checkNotNull(System.getProperty("java.runtime.name", "")).contains("Android");
- }
}
diff --git a/guava-testlib/src/com/google/common/testing/Platform.java b/guava-testlib/src/com/google/common/testing/Platform.java
index bbad5598d..9726d2de0 100644
--- a/guava-testlib/src/com/google/common/testing/Platform.java
+++ b/guava-testlib/src/com/google/common/testing/Platform.java
@@ -17,6 +17,7 @@
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import java.io.ByteArrayInputStream;
@@ -42,7 +43,7 @@ final class Platform {
ObjectOutputStream out = new ObjectOutputStream(bytes);
out.writeObject(object);
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()));
- return (T) in.readObject();
+ return (T) requireNonNull(in.readObject());
} catch (IOException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
diff --git a/guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java b/guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java
index abe419e05..325388342 100644
--- a/guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java
+++ b/guava-testlib/src/com/google/common/util/concurrent/testing/AbstractListenableFutureTest.java
@@ -18,6 +18,7 @@ package com.google.common.util.concurrent.testing;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.util.concurrent.ListenableFuture;
@@ -70,29 +71,17 @@ public abstract class AbstractListenableFutureTest extends TestCase {
assertFalse(future.isDone());
assertFalse(future.isCancelled());
- CountDownLatch successLatch = new CountDownLatch(1);
- Throwable[] badness = new Throwable[1];
-
- // Wait on the future in a separate thread.
- new Thread(
- () -> {
- try {
- assertSame(Boolean.TRUE, future.get());
- successLatch.countDown();
- } catch (Throwable t) {
- t.printStackTrace();
- badness[0] = t;
- }
- })
- .start();
+ ExecutorService executor = Executors.newSingleThreadExecutor();
- // Release the future value.
- latch.countDown();
+ try {
+ Future<Boolean> getResult = executor.submit(() -> future.get());
- assertTrue(successLatch.await(10, SECONDS));
+ // Release the future value.
+ latch.countDown();
- if (badness[0] != null) {
- throw badness[0];
+ assertTrue(getResult.get(10, SECONDS));
+ } finally {
+ executor.shutdownNow();
}
assertTrue(future.isDone());
@@ -127,13 +116,8 @@ public abstract class AbstractListenableFutureTest extends TestCase {
// Run cancellation in a separate thread as an extra thread-safety test.
new Thread(
() -> {
- try {
- future.get();
- } catch (CancellationException expected) {
- successLatch.countDown();
- } catch (Exception ignored) {
- // All other errors are ignored, we expect a cancellation.
- }
+ assertThrows(CancellationException.class, future::get);
+ successLatch.countDown();
})
.start();
@@ -160,13 +144,8 @@ public abstract class AbstractListenableFutureTest extends TestCase {
new Thread(
() -> {
- try {
- future.get();
- } catch (CancellationException expected) {
- successLatch.countDown();
- } catch (Exception ignored) {
- // No success latch count down.
- }
+ assertThrows(CancellationException.class, future::get);
+ successLatch.countDown();
})
.start();
diff --git a/guava-testlib/test/com/google/common/collect/testing/features/FeatureUtilTest.java b/guava-testlib/test/com/google/common/collect/testing/features/FeatureUtilTest.java
index 37af90bda..130e86f87 100644
--- a/guava-testlib/test/com/google/common/collect/testing/features/FeatureUtilTest.java
+++ b/guava-testlib/test/com/google/common/collect/testing/features/FeatureUtilTest.java
@@ -17,6 +17,7 @@
package com.google.common.collect.testing.features;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
@@ -28,7 +29,9 @@ import java.util.Collections;
import java.util.Set;
import junit.framework.TestCase;
-/** @author George van den Driessche */
+/**
+ * @author George van den Driessche
+ */
// Enum values use constructors with generic varargs.
@SuppressWarnings("unchecked")
public class FeatureUtilTest extends TestCase {
@@ -232,27 +235,26 @@ public class FeatureUtilTest extends TestCase {
@AndroidIncompatible // Android runs ExampleDerivedInterfaceTester directly if it exists
public void testBuildTesterRequirements_classClassConflict() throws Exception {
- try {
- FeatureUtil.buildTesterRequirements(
- ConflictingRequirementsExampleDerivedInterfaceTester.class);
- fail("Expected ConflictingRequirementsException");
- } catch (ConflictingRequirementsException e) {
- assertThat(e.getConflicts()).contains(ExampleBaseFeature.BASE_FEATURE_1);
- assertEquals(ConflictingRequirementsExampleDerivedInterfaceTester.class, e.getSource());
- }
+ ConflictingRequirementsException e =
+ assertThrows(
+ ConflictingRequirementsException.class,
+ () ->
+ FeatureUtil.buildTesterRequirements(
+ ConflictingRequirementsExampleDerivedInterfaceTester.class));
+ assertThat(e.getConflicts()).contains(ExampleBaseFeature.BASE_FEATURE_1);
+ assertEquals(ConflictingRequirementsExampleDerivedInterfaceTester.class, e.getSource());
}
@AndroidIncompatible // Android runs ExampleDerivedInterfaceTester directly if it exists
public void testBuildTesterRequirements_methodClassConflict() throws Exception {
final Method method =
ExampleDerivedInterfaceTester.class.getMethod("testRequiringConflictingFeatures");
- try {
- FeatureUtil.buildTesterRequirements(method);
- fail("Expected ConflictingRequirementsException");
- } catch (ConflictingRequirementsException e) {
- assertThat(e.getConflicts()).contains(ExampleBaseFeature.BASE_FEATURE_1);
- assertEquals(method, e.getSource());
- }
+ ConflictingRequirementsException e =
+ assertThrows(
+ ConflictingRequirementsException.class,
+ () -> FeatureUtil.buildTesterRequirements(method));
+ assertThat(e.getConflicts()).contains(ExampleBaseFeature.BASE_FEATURE_1);
+ assertEquals(method, e.getSource());
}
@AndroidIncompatible // Android runs ExampleDerivedInterfaceTester directly if it exists
diff --git a/guava-testlib/test/com/google/common/testing/ArbitraryInstancesTest.java b/guava-testlib/test/com/google/common/testing/ArbitraryInstancesTest.java
index ecca9c873..c75790c5b 100644
--- a/guava-testlib/test/com/google/common/testing/ArbitraryInstancesTest.java
+++ b/guava-testlib/test/com/google/common/testing/ArbitraryInstancesTest.java
@@ -17,6 +17,7 @@
package com.google.common.testing;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.CharMatcher;
import com.google.common.base.Charsets;
@@ -286,11 +287,7 @@ public class ArbitraryInstancesTest extends TestCase {
Comparable<Object> comparable = ArbitraryInstances.get(Comparable.class);
assertEquals(0, comparable.compareTo(comparable));
assertTrue(comparable.compareTo("") > 0);
- try {
- comparable.compareTo(null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> comparable.compareTo(null));
}
public void testGet_array() {
diff --git a/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java b/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java
index ac4e05fba..a6378bea4 100644
--- a/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java
+++ b/guava-testlib/test/com/google/common/testing/ClassSanityTesterTest.java
@@ -18,6 +18,7 @@ package com.google.common.testing;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Functions;
import com.google.common.base.Optional;
@@ -45,7 +46,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*
* @author Ben Yu
*/
-@AndroidIncompatible // NullPointerTester refuses to run for c.g.c under Android
public class ClassSanityTesterTest extends TestCase {
private final ClassSanityTester tester = new ClassSanityTester();
@@ -64,18 +64,22 @@ public class ClassSanityTesterTest extends TestCase {
@SuppressWarnings("unused") @Nullable NoConstantEnum noConstant) {
return new GoodEquals(a, b);
}
+
// instance method ignored
public Object badIgnored() {
return new BadEquals();
}
+
// primitive ignored
public int returnsInt() {
throw new UnsupportedOperationException();
}
+
// void ignored
public void voidMethod() {
throw new UnsupportedOperationException();
}
+
// non-public method ignored
static Object badButNotPublic() {
return new BadEquals();
@@ -332,11 +336,9 @@ public class ClassSanityTesterTest extends TestCase {
}
public void testBadEquals_withSingleParameterValue() throws Exception {
- try {
- tester.doTestEquals(ConstructorParameterWithOptionalNotInstantiable.class);
- fail();
- } catch (ParameterHasNoDistinctValueException expected) {
- }
+ assertThrows(
+ ParameterHasNoDistinctValueException.class,
+ () -> tester.doTestEquals(ConstructorParameterWithOptionalNotInstantiable.class));
}
public void testGoodReferentialEqualityComparison() throws Exception {
@@ -375,35 +377,26 @@ public class ClassSanityTesterTest extends TestCase {
}
public void testParameterNotInstantiableForEqualsTest() throws Exception {
- try {
- tester.doTestEquals(ConstructorParameterNotInstantiable.class);
- fail("should have failed");
- } catch (ParameterNotInstantiableException expected) {
- }
+ assertThrows(
+ ParameterNotInstantiableException.class,
+ () -> tester.doTestEquals(ConstructorParameterNotInstantiable.class));
}
public void testNoDistinctValueForEqualsTest() throws Exception {
- try {
- tester.doTestEquals(ConstructorParameterSingleValue.class);
- fail("should have failed");
- } catch (ParameterHasNoDistinctValueException expected) {
- }
+ assertThrows(
+ ParameterHasNoDistinctValueException.class,
+ () -> tester.doTestEquals(ConstructorParameterSingleValue.class));
}
public void testConstructorThrowsForEqualsTest() throws Exception {
- try {
- tester.doTestEquals(ConstructorThrows.class);
- fail("should have failed");
- } catch (InvocationTargetException expected) {
- }
+ assertThrows(
+ InvocationTargetException.class, () -> tester.doTestEquals(ConstructorThrows.class));
}
public void testFactoryMethodReturnsNullForEqualsTest() throws Exception {
- try {
- tester.doTestEquals(FactoryMethodReturnsNullAndAnnotated.class);
- fail("should have failed");
- } catch (FactoryMethodReturnsNullException expected) {
- }
+ assertThrows(
+ FactoryMethodReturnsNullException.class,
+ () -> tester.doTestEquals(FactoryMethodReturnsNullAndAnnotated.class));
}
public void testFactoryMethodReturnsNullButNotAnnotatedInEqualsTest() throws Exception {
@@ -493,11 +486,9 @@ public class ClassSanityTesterTest extends TestCase {
}
public void testInstantiate_factoryMethodReturnsNullAndAnnotated() throws Exception {
- try {
- tester.instantiate(FactoryMethodReturnsNullAndAnnotated.class);
- fail("should have failed");
- } catch (FactoryMethodReturnsNullException expected) {
- }
+ assertThrows(
+ FactoryMethodReturnsNullException.class,
+ () -> tester.instantiate(FactoryMethodReturnsNullAndAnnotated.class));
}
public void testInstantiate_factoryMethodAcceptsNull() throws Exception {
@@ -547,11 +538,8 @@ public class ClassSanityTesterTest extends TestCase {
}
public void testSetDistinctValues_equalInstances() {
- try {
- tester.setDistinctValues(String.class, "", "");
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> tester.setDistinctValues(String.class, "", ""));
}
public void testInstantiate_setDistinctValues() throws Exception {
@@ -563,35 +551,25 @@ public class ClassSanityTesterTest extends TestCase {
}
public void testInstantiate_constructorThrows() throws Exception {
- try {
- tester.instantiate(ConstructorThrows.class);
- fail();
- } catch (InvocationTargetException expected) {
- }
+ assertThrows(
+ InvocationTargetException.class, () -> tester.instantiate(ConstructorThrows.class));
}
public void testInstantiate_factoryMethodThrows() throws Exception {
- try {
- tester.instantiate(FactoryMethodThrows.class);
- fail();
- } catch (InvocationTargetException expected) {
- }
+ assertThrows(
+ InvocationTargetException.class, () -> tester.instantiate(FactoryMethodThrows.class));
}
public void testInstantiate_constructorParameterNotInstantiable() throws Exception {
- try {
- tester.instantiate(ConstructorParameterNotInstantiable.class);
- fail();
- } catch (ParameterNotInstantiableException expected) {
- }
+ assertThrows(
+ ParameterNotInstantiableException.class,
+ () -> tester.instantiate(ConstructorParameterNotInstantiable.class));
}
public void testInstantiate_factoryMethodParameterNotInstantiable() throws Exception {
- try {
- tester.instantiate(FactoryMethodParameterNotInstantiable.class);
- fail();
- } catch (ParameterNotInstantiableException expected) {
- }
+ assertThrows(
+ ParameterNotInstantiableException.class,
+ () -> tester.instantiate(FactoryMethodParameterNotInstantiable.class));
}
public void testInstantiate_instantiableFactoryMethodChosen() throws Exception {
@@ -665,11 +643,9 @@ public class ClassSanityTesterTest extends TestCase {
}
public void testEquals_setOfNonInstantiable() throws Exception {
- try {
- new ClassSanityTester().doTestEquals(SetWrapper.class);
- fail();
- } catch (ParameterNotInstantiableException expected) {
- }
+ assertThrows(
+ ParameterNotInstantiableException.class,
+ () -> new ClassSanityTester().doTestEquals(SetWrapper.class));
}
private abstract static class Wrapper {
diff --git a/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java b/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java
index 7fe3a6080..3bae972b3 100644
--- a/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java
+++ b/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java
@@ -17,6 +17,7 @@
package com.google.common.testing;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.testing.GcFinalization.FinalizationPredicate;
import com.google.common.util.concurrent.SettableFuture;
@@ -148,12 +149,9 @@ public class GcFinalizationTest extends TestCase {
Interruptenator interruptenator = new Interruptenator(Thread.currentThread());
try {
final CountDownLatch latch = new CountDownLatch(1);
- try {
- GcFinalization.await(latch);
- fail("should throw");
- } catch (RuntimeException expected) {
- assertWrapsInterruptedException(expected);
- }
+ RuntimeException expected =
+ assertThrows(RuntimeException.class, () -> GcFinalization.await(latch));
+ assertWrapsInterruptedException(expected);
} finally {
interruptenator.shutdown();
Thread.interrupted();
@@ -164,12 +162,9 @@ public class GcFinalizationTest extends TestCase {
Interruptenator interruptenator = new Interruptenator(Thread.currentThread());
try {
final SettableFuture<@Nullable Void> future = SettableFuture.create();
- try {
- GcFinalization.awaitDone(future);
- fail("should throw");
- } catch (RuntimeException expected) {
- assertWrapsInterruptedException(expected);
- }
+ RuntimeException expected =
+ assertThrows(RuntimeException.class, () -> GcFinalization.awaitDone(future));
+ assertWrapsInterruptedException(expected);
} finally {
interruptenator.shutdown();
Thread.interrupted();
@@ -180,12 +175,9 @@ public class GcFinalizationTest extends TestCase {
Interruptenator interruptenator = new Interruptenator(Thread.currentThread());
try {
final WeakReference<Object> ref = new WeakReference<Object>(Boolean.TRUE);
- try {
- GcFinalization.awaitClear(ref);
- fail("should throw");
- } catch (RuntimeException expected) {
- assertWrapsInterruptedException(expected);
- }
+ RuntimeException expected =
+ assertThrows(RuntimeException.class, () -> GcFinalization.awaitClear(ref));
+ assertWrapsInterruptedException(expected);
} finally {
interruptenator.shutdown();
Thread.interrupted();
@@ -195,18 +187,18 @@ public class GcFinalizationTest extends TestCase {
public void testAwaitDone_FinalizationPredicate_Interrupted() {
Interruptenator interruptenator = new Interruptenator(Thread.currentThread());
try {
- try {
- GcFinalization.awaitDone(
- new FinalizationPredicate() {
- @Override
- public boolean isDone() {
- return false;
- }
- });
- fail("should throw");
- } catch (RuntimeException expected) {
- assertWrapsInterruptedException(expected);
- }
+ RuntimeException expected =
+ assertThrows(
+ RuntimeException.class,
+ () ->
+ GcFinalization.awaitDone(
+ new FinalizationPredicate() {
+ @Override
+ public boolean isDone() {
+ return false;
+ }
+ }));
+ assertWrapsInterruptedException(expected);
} finally {
interruptenator.shutdown();
Thread.interrupted();
diff --git a/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java b/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
index 050f05f6d..c224d8a54 100644
--- a/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
+++ b/guava-testlib/test/com/google/common/testing/NullPointerTesterTest.java
@@ -19,6 +19,7 @@ package com.google.common.testing;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Converter;
import com.google.common.base.Function;
@@ -56,7 +57,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @author Mick Killianey
*/
@SuppressWarnings("CheckReturnValue")
-@AndroidIncompatible // NullPointerTester refuses to run for c.g.c under Android
public class NullPointerTesterTest extends TestCase {
/** Non-NPE RuntimeException. */
@@ -1432,12 +1432,11 @@ public class NullPointerTesterTest extends TestCase {
}
public void testNonStaticInnerClass() {
- try {
- new NullPointerTester().testAllPublicConstructors(Inner.class);
- fail();
- } catch (IllegalArgumentException expected) {
- assertThat(expected.getMessage()).contains("inner class");
- }
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new NullPointerTester().testAllPublicConstructors(Inner.class));
+ assertThat(expected.getMessage()).contains("inner class");
}
private static String rootLocaleFormat(String format, Object... args) {
diff --git a/guava-testlib/test/com/google/common/testing/anotherpackage/ForwardingWrapperTesterTest.java b/guava-testlib/test/com/google/common/testing/anotherpackage/ForwardingWrapperTesterTest.java
index bd823f8f6..17655f6ef 100644
--- a/guava-testlib/test/com/google/common/testing/anotherpackage/ForwardingWrapperTesterTest.java
+++ b/guava-testlib/test/com/google/common/testing/anotherpackage/ForwardingWrapperTesterTest.java
@@ -17,6 +17,7 @@
package com.google.common.testing.anotherpackage;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
@@ -265,11 +266,11 @@ public class ForwardingWrapperTesterTest extends TestCase {
}
public void testNotInterfaceType() {
- try {
- new ForwardingWrapperTester().testForwarding(String.class, Functions.<String>identity());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new ForwardingWrapperTester()
+ .testForwarding(String.class, Functions.<String>identity()));
}
public void testNulls() {
@@ -583,6 +584,7 @@ public class ForwardingWrapperTesterTest extends TestCase {
// A method that is defined to 'return this'
@CanIgnoreReturnValue
ChainingCalls chainingCall();
+
// A method that just happens to return a ChainingCalls object
ChainingCalls nonChainingCall();
}
diff --git a/guava-testlib/test/com/google/common/util/concurrent/testing/TestingExecutorsTest.java b/guava-testlib/test/com/google/common/util/concurrent/testing/TestingExecutorsTest.java
index 66ad78491..a82aa8710 100644
--- a/guava-testlib/test/com/google/common/util/concurrent/testing/TestingExecutorsTest.java
+++ b/guava-testlib/test/com/google/common/util/concurrent/testing/TestingExecutorsTest.java
@@ -16,6 +16,8 @@
package com.google.common.util.concurrent.testing;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListeningScheduledExecutorService;
import java.util.List;
@@ -76,12 +78,7 @@ public class TestingExecutorsTest extends TestCase {
Future<Boolean> future = futureList.get(0);
assertFalse(taskDone);
assertTrue(future.isDone());
- try {
- future.get();
- fail();
- } catch (CancellationException e) {
- // pass
- }
+ assertThrows(CancellationException.class, () -> future.get());
}
public void testSameThreadScheduledExecutor() throws ExecutionException, InterruptedException {
@@ -110,11 +107,6 @@ public class TestingExecutorsTest extends TestCase {
};
Future<?> future = TestingExecutors.sameThreadScheduledExecutor().submit(runnable);
- try {
- future.get();
- fail("Should have thrown exception");
- } catch (ExecutionException e) {
- // pass
- }
+ assertThrows(ExecutionException.class, () -> future.get());
}
}
diff --git a/guava-tests/pom.xml b/guava-tests/pom.xml
index d14fe5869..867a0070a 100644
--- a/guava-tests/pom.xml
+++ b/guava-tests/pom.xml
@@ -60,7 +60,7 @@
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
- <version>1.2</version>
+ <version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/guava-tests/test/com/google/common/base/ConverterTest.java b/guava-tests/test/com/google/common/base/ConverterTest.java
index c787ef004..87e93282b 100644
--- a/guava-tests/test/com/google/common/base/ConverterTest.java
+++ b/guava-tests/test/com/google/common/base/ConverterTest.java
@@ -19,6 +19,7 @@ package com.google.common.base;
import static com.google.common.base.Functions.toStringFunction;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.primitives.Longs;
@@ -29,7 +30,7 @@ import java.util.List;
import junit.framework.TestCase;
/** Unit tests for {@link Converter}. */
-@GwtCompatible
+@GwtCompatible(emulated = true)
public class ConverterTest extends TestCase {
private static final Converter<String, Long> STR_TO_LONG =
@@ -111,6 +112,7 @@ public class ConverterTest extends TestCase {
}
}
+ @GwtIncompatible // J2CL generics problem
public void testAndThen() {
Converter<StringWrapper, String> first =
new Converter<StringWrapper, String>() {
@@ -140,6 +142,7 @@ public class ConverterTest extends TestCase {
assertEquals(first.andThen(STR_TO_LONG), first.andThen(STR_TO_LONG));
}
+ @GwtIncompatible // J2CL generics problem
public void testIdentityConverter() {
Converter<String, String> stringIdentityConverter = Converter.identity();
@@ -213,6 +216,7 @@ public class ConverterTest extends TestCase {
SerializableTester.reserializeAndAssert(reverseConverter);
}
+ @GwtIncompatible // J2CL generics problem
public void testSerialization_andThen() {
Converter<String, Long> converterA = Longs.stringConverter();
Converter<Long, String> reverseConverter = Longs.stringConverter().reverse();
diff --git a/guava-tests/test/com/google/common/base/DefaultsTest.java b/guava-tests/test/com/google/common/base/DefaultsTest.java
index 7b990ba52..06b3c5da3 100644
--- a/guava-tests/test/com/google/common/base/DefaultsTest.java
+++ b/guava-tests/test/com/google/common/base/DefaultsTest.java
@@ -16,6 +16,7 @@
package com.google.common.base;
+import com.google.common.annotations.GwtIncompatible;
import junit.framework.TestCase;
/**
@@ -23,6 +24,7 @@ import junit.framework.TestCase;
*
* @author Jige Yu
*/
+@GwtIncompatible
public class DefaultsTest extends TestCase {
public void testGetDefaultValue() {
assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
diff --git a/guava-tests/test/com/google/common/base/EnumsTest.java b/guava-tests/test/com/google/common/base/EnumsTest.java
index 66dfe591a..df821d361 100644
--- a/guava-tests/test/com/google/common/base/EnumsTest.java
+++ b/guava-tests/test/com/google/common/base/EnumsTest.java
@@ -19,6 +19,7 @@ package com.google.common.base;
import static com.google.common.base.StandardSystemProperty.JAVA_CLASS_PATH;
import static com.google.common.base.StandardSystemProperty.PATH_SEPARATOR;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
@@ -129,11 +130,7 @@ public class EnumsTest extends TestCase {
@GwtIncompatible // stringConverter
public void testStringConverter_convertError() {
Converter<String, TestEnum> converter = Enums.stringConverter(TestEnum.class);
- try {
- converter.convert("xxx");
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> converter.convert("xxx"));
}
@GwtIncompatible // stringConverter
diff --git a/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java b/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java
index 08ead4365..8bddca227 100644
--- a/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java
+++ b/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java
@@ -16,6 +16,7 @@
package com.google.common.base;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.internal.Finalizer;
import com.google.common.testing.GcFinalization;
import java.lang.ref.ReferenceQueue;
@@ -36,6 +37,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
// - .class files aren't available
// - possibly no real concept of separate ClassLoaders?
@AndroidIncompatible
+@GwtIncompatible
public class FinalizableReferenceQueueTest extends TestCase {
private @Nullable FinalizableReferenceQueue frq;
diff --git a/guava-tests/test/com/google/common/base/PackageSanityTests.java b/guava-tests/test/com/google/common/base/PackageSanityTests.java
index f524fbb6c..c9eeed0de 100644
--- a/guava-tests/test/com/google/common/base/PackageSanityTests.java
+++ b/guava-tests/test/com/google/common/base/PackageSanityTests.java
@@ -16,10 +16,12 @@
package com.google.common.base;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.testing.AbstractPackageSanityTests;
/** Basic sanity tests for classes in {@code common.base}. */
+@GwtIncompatible
public class PackageSanityTests extends AbstractPackageSanityTests {
public PackageSanityTests() {
// package private classes like FunctionalEquivalence are tested through the public API.
diff --git a/guava-tests/test/com/google/common/base/PreconditionsTest.java b/guava-tests/test/com/google/common/base/PreconditionsTest.java
index 6209d3a06..acbd7cfd1 100644
--- a/guava-tests/test/com/google/common/base/PreconditionsTest.java
+++ b/guava-tests/test/com/google/common/base/PreconditionsTest.java
@@ -17,6 +17,7 @@
package com.google.common.base;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -397,12 +398,11 @@ public class PreconditionsTest extends TestCase {
checkArgumentMethod.invoke(null /* static method */, getParametersForSignature(true, sig));
Object[] failingParams = getParametersForSignature(false, sig);
- try {
- checkArgumentMethod.invoke(null /* static method */, failingParams);
- fail();
- } catch (InvocationTargetException ite) {
- assertFailureCause(ite.getCause(), IllegalArgumentException.class, failingParams);
- }
+ InvocationTargetException ite =
+ assertThrows(
+ InvocationTargetException.class,
+ () -> checkArgumentMethod.invoke(null /* static method */, failingParams));
+ assertFailureCause(ite.getCause(), IllegalArgumentException.class, failingParams);
}
}
@@ -415,12 +415,11 @@ public class PreconditionsTest extends TestCase {
checkArgumentMethod.invoke(null /* static method */, getParametersForSignature(true, sig));
Object[] failingParams = getParametersForSignature(false, sig);
- try {
- checkArgumentMethod.invoke(null /* static method */, failingParams);
- fail();
- } catch (InvocationTargetException ite) {
- assertFailureCause(ite.getCause(), IllegalStateException.class, failingParams);
- }
+ InvocationTargetException ite =
+ assertThrows(
+ InvocationTargetException.class,
+ () -> checkArgumentMethod.invoke(null /* static method */, failingParams));
+ assertFailureCause(ite.getCause(), IllegalStateException.class, failingParams);
}
}
@@ -434,12 +433,11 @@ public class PreconditionsTest extends TestCase {
null /* static method */, getParametersForSignature(new Object(), sig));
Object[] failingParams = getParametersForSignature(null, sig);
- try {
- checkArgumentMethod.invoke(null /* static method */, failingParams);
- fail();
- } catch (InvocationTargetException ite) {
- assertFailureCause(ite.getCause(), NullPointerException.class, failingParams);
- }
+ InvocationTargetException ite =
+ assertThrows(
+ InvocationTargetException.class,
+ () -> checkArgumentMethod.invoke(null /* static method */, failingParams));
+ assertFailureCause(ite.getCause(), NullPointerException.class, failingParams);
}
}
diff --git a/guava-tests/test/com/google/common/base/PredicatesTest.java b/guava-tests/test/com/google/common/base/PredicatesTest.java
index 24b4e108b..ed017d00f 100644
--- a/guava-tests/test/com/google/common/base/PredicatesTest.java
+++ b/guava-tests/test/com/google/common/base/PredicatesTest.java
@@ -18,6 +18,7 @@ package com.google.common.base;
import static com.google.common.base.CharMatcher.whitespace;
import static com.google.common.collect.Lists.newArrayList;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -623,11 +624,7 @@ public class PredicatesTest extends TestCase {
assertTrue(isInteger.apply(Integer.class));
assertFalse(isInteger.apply(Float.class));
- try {
- isInteger.apply(null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> isInteger.apply(null));
}
@J2ktIncompatible
diff --git a/guava-tests/test/com/google/common/base/SplitterTest.java b/guava-tests/test/com/google/common/base/SplitterTest.java
index ed14a8f6f..2f9ea2532 100644
--- a/guava-tests/test/com/google/common/base/SplitterTest.java
+++ b/guava-tests/test/com/google/common/base/SplitterTest.java
@@ -18,6 +18,7 @@ package com.google.common.base;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -471,11 +472,7 @@ public class SplitterTest extends TestCase {
@J2ktIncompatible
@GwtIncompatible // java.util.regex.Pattern
public void testPatternSplitInvalidPattern() {
- try {
- Splitter.on(Pattern.compile("a*"));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Splitter.on(Pattern.compile("a*")));
}
@J2ktIncompatible
diff --git a/guava-tests/test/com/google/common/base/StandardSystemPropertyTest.java b/guava-tests/test/com/google/common/base/StandardSystemPropertyTest.java
index 3a88366c0..f4907a337 100644
--- a/guava-tests/test/com/google/common/base/StandardSystemPropertyTest.java
+++ b/guava-tests/test/com/google/common/base/StandardSystemPropertyTest.java
@@ -20,6 +20,7 @@ import static com.google.common.base.StandardSystemProperty.JAVA_COMPILER;
import static com.google.common.base.StandardSystemProperty.JAVA_EXT_DIRS;
import static com.google.common.truth.Truth.assertWithMessage;
+import com.google.common.annotations.GwtIncompatible;
import junit.framework.TestCase;
/**
@@ -27,6 +28,7 @@ import junit.framework.TestCase;
*
* @author Kurt Alfred Kluever
*/
+@GwtIncompatible
public class StandardSystemPropertyTest extends TestCase {
public void testGetKeyMatchesString() {
diff --git a/guava-tests/test/com/google/common/base/SuppliersTest.java b/guava-tests/test/com/google/common/base/SuppliersTest.java
index 9befacc6f..fef3a2684 100644
--- a/guava-tests/test/com/google/common/base/SuppliersTest.java
+++ b/guava-tests/test/com/google/common/base/SuppliersTest.java
@@ -18,6 +18,7 @@ package com.google.common.base;
import static com.google.common.testing.SerializableTester.reserialize;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -141,12 +142,8 @@ public class SuppliersTest extends TestCase {
.isEqualTo("Suppliers.memoize(<supplier that returned 10>)");
// Should get an exception when we try to serialize.
- try {
- reserialize(memoizedSupplier);
- fail();
- } catch (RuntimeException ex) {
- assertThat(ex).hasCauseThat().isInstanceOf(java.io.NotSerializableException.class);
- }
+ RuntimeException ex = assertThrows(RuntimeException.class, () -> reserialize(memoizedSupplier));
+ assertThat(ex).hasCauseThat().isInstanceOf(java.io.NotSerializableException.class);
}
@J2ktIncompatible
diff --git a/guava-tests/test/com/google/common/base/ThrowablesTest.java b/guava-tests/test/com/google/common/base/ThrowablesTest.java
index 975765340..194b435a3 100644
--- a/guava-tests/test/com/google/common/base/ThrowablesTest.java
+++ b/guava-tests/test/com/google/common/base/ThrowablesTest.java
@@ -25,6 +25,7 @@ import static com.google.common.base.Throwables.throwIfUnchecked;
import static com.google.common.truth.Truth.assertThat;
import static java.util.Arrays.asList;
import static java.util.regex.Pattern.quote;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -100,11 +101,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the unchecked exception to propagate as-is
- try {
- sample.noneDeclared();
- fail();
- } catch (SomeUncheckedException expected) {
- }
+ assertThrows(SomeUncheckedException.class, () -> sample.noneDeclared());
}
@J2ktIncompatible
@@ -124,11 +121,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the undeclared exception to have been chained inside another
- try {
- sample.noneDeclared();
- fail();
- } catch (SomeChainingException expected) {
- }
+ assertThrows(SomeChainingException.class, () -> sample.noneDeclared());
}
@J2ktIncompatible
@@ -170,11 +163,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the unchecked exception to propagate as-is
- try {
- sample.oneDeclared();
- fail();
- } catch (SomeUncheckedException expected) {
- }
+ assertThrows(SomeUncheckedException.class, () -> sample.oneDeclared());
}
@J2ktIncompatible
@@ -194,11 +183,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the checked exception to propagate as-is
- try {
- sample.oneDeclared();
- fail();
- } catch (SomeCheckedException expected) {
- }
+ assertThrows(SomeCheckedException.class, () -> sample.oneDeclared());
}
@J2ktIncompatible
@@ -218,11 +203,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the undeclared exception to have been chained inside another
- try {
- sample.oneDeclared();
- fail();
- } catch (SomeChainingException expected) {
- }
+ assertThrows(SomeChainingException.class, () -> sample.oneDeclared());
}
@J2ktIncompatible
@@ -266,11 +247,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the unchecked exception to propagate as-is
- try {
- sample.twoDeclared();
- fail();
- } catch (SomeUncheckedException expected) {
- }
+ assertThrows(SomeUncheckedException.class, () -> sample.twoDeclared());
}
@J2ktIncompatible
@@ -291,11 +268,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the checked exception to propagate as-is
- try {
- sample.twoDeclared();
- fail();
- } catch (SomeCheckedException expected) {
- }
+ assertThrows(SomeCheckedException.class, () -> sample.twoDeclared());
}
@J2ktIncompatible
@@ -316,11 +289,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the checked exception to propagate as-is
- try {
- sample.twoDeclared();
- fail();
- } catch (SomeOtherCheckedException expected) {
- }
+ assertThrows(SomeOtherCheckedException.class, () -> sample.twoDeclared());
}
public void testThrowIfUnchecked_null() throws SomeCheckedException {
@@ -384,11 +353,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the unchecked exception to propagate as-is
- try {
- sample.noneDeclared();
- fail();
- } catch (SomeUncheckedException expected) {
- }
+ assertThrows(SomeUncheckedException.class, () -> sample.noneDeclared());
}
@J2ktIncompatible
@@ -407,11 +372,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect the error to propagate as-is
- try {
- sample.noneDeclared();
- fail();
- } catch (SomeError expected) {
- }
+ assertThrows(SomeError.class, () -> sample.noneDeclared());
}
@J2ktIncompatible
@@ -430,12 +391,8 @@ public class ThrowablesTest extends TestCase {
};
// Expect the undeclared exception to have been chained inside another
- try {
- sample.noneDeclared();
- fail();
- } catch (RuntimeException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(SomeCheckedException.class);
- }
+ RuntimeException expected = assertThrows(RuntimeException.class, () -> sample.noneDeclared());
+ assertThat(expected).hasCauseThat().isInstanceOf(SomeCheckedException.class);
}
@J2ktIncompatible
@@ -453,21 +410,17 @@ public class ThrowablesTest extends TestCase {
@J2ktIncompatible
@GwtIncompatible // throwIfInstanceOf
public void testThrowIfInstanceOf_CheckedSame() {
- try {
- throwIfInstanceOf(new SomeCheckedException(), SomeCheckedException.class);
- fail();
- } catch (SomeCheckedException expected) {
- }
+ assertThrows(
+ SomeCheckedException.class,
+ () -> throwIfInstanceOf(new SomeCheckedException(), SomeCheckedException.class));
}
@J2ktIncompatible
@GwtIncompatible // throwIfInstanceOf
public void testThrowIfInstanceOf_CheckedSubclass() {
- try {
- throwIfInstanceOf(new SomeCheckedException() {}, SomeCheckedException.class);
- fail();
- } catch (SomeCheckedException expected) {
- }
+ assertThrows(
+ SomeCheckedException.class,
+ () -> throwIfInstanceOf(new SomeCheckedException() {}, SomeCheckedException.class));
}
@J2ktIncompatible
@@ -507,11 +460,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect declared exception to be thrown as-is
- try {
- sample.oneDeclared();
- fail();
- } catch (SomeCheckedException expected) {
- }
+ assertThrows(SomeCheckedException.class, () -> sample.oneDeclared());
}
@J2ktIncompatible
@@ -531,11 +480,7 @@ public class ThrowablesTest extends TestCase {
};
// Expect unchecked exception to be thrown as-is
- try {
- sample.oneDeclared();
- fail();
- } catch (SomeUncheckedException expected) {
- }
+ assertThrows(SomeUncheckedException.class, () -> sample.oneDeclared());
}
@J2ktIncompatible
@@ -555,22 +500,15 @@ public class ThrowablesTest extends TestCase {
};
// Expect undeclared exception wrapped by RuntimeException to be thrown
- try {
- sample.oneDeclared();
- fail();
- } catch (RuntimeException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(SomeOtherCheckedException.class);
- }
+ RuntimeException expected = assertThrows(RuntimeException.class, () -> sample.oneDeclared());
+ assertThat(expected).hasCauseThat().isInstanceOf(SomeOtherCheckedException.class);
}
@J2ktIncompatible
@GwtIncompatible // throwIfInstanceOf
public void testThrowIfInstanceOf_null() throws SomeCheckedException {
- try {
- throwIfInstanceOf(null, SomeCheckedException.class);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(
+ NullPointerException.class, () -> throwIfInstanceOf(null, SomeCheckedException.class));
}
@J2ktIncompatible
@@ -720,12 +658,11 @@ public class ThrowablesTest extends TestCase {
assertThat(Throwables.getCauseAs(thrown, SomeCheckedException.class)).isSameInstanceAs(cause);
assertThat(Throwables.getCauseAs(thrown, Exception.class)).isSameInstanceAs(cause);
- try {
- Throwables.getCauseAs(thrown, IllegalStateException.class);
- fail("Should have thrown CCE");
- } catch (ClassCastException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(thrown);
- }
+ ClassCastException expected =
+ assertThrows(
+ ClassCastException.class,
+ () -> Throwables.getCauseAs(thrown, IllegalStateException.class));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(thrown);
}
@AndroidIncompatible // No getJavaLangAccess in Android (at least not in the version we use).
@@ -749,11 +686,7 @@ public class ThrowablesTest extends TestCase {
assertThat(lazyStackTrace(e)).containsExactly((Object[]) originalStackTrace).inOrder();
- try {
- lazyStackTrace(e).set(0, null);
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> lazyStackTrace(e).set(0, null));
// Now we test a property that holds only for the lazy implementation.
diff --git a/guava-tests/test/com/google/common/base/UnannotatedJavaClass.java b/guava-tests/test/com/google/common/base/UnannotatedJavaClass.java
new file mode 100644
index 000000000..521035c61
--- /dev/null
+++ b/guava-tests/test/com/google/common/base/UnannotatedJavaClass.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2023 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.base;
+
+/** Class containing an unannotated Java method for use from {@code OptionalExtensionsTest}. */
+final class UnannotatedJavaClass {
+ static Object getNull() {
+ return null;
+ }
+
+ private UnannotatedJavaClass() {}
+}
diff --git a/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java b/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java
index 84e004a8b..c029ff3d0 100644
--- a/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java
+++ b/guava-tests/test/com/google/common/cache/AbstractLoadingCacheTest.java
@@ -17,6 +17,7 @@
package com.google.common.cache;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.ExecutionError;
import com.google.common.util.concurrent.UncheckedExecutionException;
@@ -52,12 +53,9 @@ public class AbstractLoadingCacheTest extends TestCase {
}
};
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(cause);
- }
+ UncheckedExecutionException expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isEqualTo(cause);
Object newValue = new Object();
valueRef.set(newValue);
@@ -84,12 +82,9 @@ public class AbstractLoadingCacheTest extends TestCase {
}
};
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(cause);
- }
+ UncheckedExecutionException expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isEqualTo(cause);
Object newValue = new Object();
valueRef.set(newValue);
@@ -116,12 +111,9 @@ public class AbstractLoadingCacheTest extends TestCase {
}
};
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isEqualTo(cause);
- }
+ ExecutionError expected =
+ assertThrows(ExecutionError.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isEqualTo(cause);
Object newValue = new Object();
valueRef.set(newValue);
@@ -148,12 +140,9 @@ public class AbstractLoadingCacheTest extends TestCase {
}
};
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(cause);
- }
+ UncheckedExecutionException expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isEqualTo(cause);
Object newValue = new Object();
valueRef.set(newValue);
diff --git a/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java b/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
index 09f2eb6c2..8a60cd30d 100644
--- a/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
+++ b/guava-tests/test/com/google/common/cache/CacheBuilderSpecTest.java
@@ -18,6 +18,7 @@ package com.google.common.cache;
import static com.google.common.cache.CacheBuilderSpec.parse;
import static com.google.common.cache.TestingWeighers.constantWeigher;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Suppliers;
import com.google.common.cache.LocalCache.Strength;
@@ -60,11 +61,8 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_initialCapacityRepeated() {
- try {
- parse("initialCapacity=10, initialCapacity=20");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> parse("initialCapacity=10, initialCapacity=20"));
}
public void testParse_maximumSize() {
@@ -81,11 +79,7 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_maximumSizeRepeated() {
- try {
- parse("maximumSize=10, maximumSize=20");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("maximumSize=10, maximumSize=20"));
}
public void testParse_maximumWeight() {
@@ -102,19 +96,11 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_maximumWeightRepeated() {
- try {
- parse("maximumWeight=10, maximumWeight=20");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("maximumWeight=10, maximumWeight=20"));
}
public void testParse_maximumSizeAndMaximumWeight() {
- try {
- parse("maximumSize=10, maximumWeight=20");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("maximumSize=10, maximumWeight=20"));
}
public void testParse_concurrencyLevel() {
@@ -132,11 +118,8 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_concurrencyLevelRepeated() {
- try {
- parse("concurrencyLevel=10, concurrencyLevel=20");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> parse("concurrencyLevel=10, concurrencyLevel=20"));
}
public void testParse_weakKeys() {
@@ -153,19 +136,11 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_weakKeysCannotHaveValue() {
- try {
- parse("weakKeys=true");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("weakKeys=true"));
}
public void testParse_repeatedKeyStrength() {
- try {
- parse("weakKeys, weakKeys");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("weakKeys, weakKeys"));
}
public void testParse_softValues() {
@@ -182,11 +157,7 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_softValuesCannotHaveValue() {
- try {
- parse("softValues=true");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("softValues=true"));
}
public void testParse_weakValues() {
@@ -203,37 +174,17 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_weakValuesCannotHaveValue() {
- try {
- parse("weakValues=true");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("weakValues=true"));
}
public void testParse_repeatedValueStrength() {
- try {
- parse("softValues, softValues");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
-
- try {
- parse("softValues, weakValues");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
-
- try {
- parse("weakValues, softValues");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
-
- try {
- parse("weakValues, weakValues");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("softValues, softValues"));
+
+ assertThrows(IllegalArgumentException.class, () -> parse("softValues, weakValues"));
+
+ assertThrows(IllegalArgumentException.class, () -> parse("weakValues, softValues"));
+
+ assertThrows(IllegalArgumentException.class, () -> parse("weakValues, weakValues"));
}
public void testParse_writeExpirationDays() {
@@ -276,11 +227,8 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_writeExpirationRepeated() {
- try {
- parse("expireAfterWrite=10s,expireAfterWrite=10m");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> parse("expireAfterWrite=10s,expireAfterWrite=10m"));
}
public void testParse_accessExpirationDays() {
@@ -325,11 +273,8 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_accessExpirationRepeated() {
- try {
- parse("expireAfterAccess=10s,expireAfterAccess=10m");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> parse("expireAfterAccess=10s,expireAfterAccess=10m"));
}
public void testParse_recordStats() {
@@ -339,19 +284,11 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_recordStatsValueSpecified() {
- try {
- parse("recordStats=True");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("recordStats=True"));
}
public void testParse_recordStatsRepeated() {
- try {
- parse("recordStats,recordStats");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("recordStats,recordStats"));
}
public void testParse_accessExpirationAndWriteExpiration() {
@@ -419,31 +356,15 @@ public class CacheBuilderSpecTest extends TestCase {
}
public void testParse_unknownKey() {
- try {
- parse("foo=17");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("foo=17"));
}
public void testParse_extraCommaIsInvalid() {
- try {
- parse("weakKeys,");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("weakKeys,"));
- try {
- parse(",weakKeys");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse(",weakKeys"));
- try {
- parse("weakKeys,,softValues");
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> parse("weakKeys,,softValues"));
}
public void testEqualsAndHashCode() {
@@ -477,11 +398,9 @@ public class CacheBuilderSpecTest extends TestCase {
@SuppressWarnings("ReturnValueIgnored")
public void testMaximumWeight_withoutWeigher() {
CacheBuilder<Object, Object> builder = CacheBuilder.from(parse("maximumWeight=9000"));
- try {
- builder.build(CacheLoader.from(Suppliers.ofInstance(null)));
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> builder.build(CacheLoader.from(Suppliers.ofInstance(null))));
}
@SuppressWarnings("ReturnValueIgnored")
diff --git a/guava-tests/test/com/google/common/cache/CacheBuilderTest.java b/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
index dad5ff4fb..9e8a1a2db 100644
--- a/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
+++ b/guava-tests/test/com/google/common/cache/CacheBuilderTest.java
@@ -26,6 +26,7 @@ import static com.google.common.truth.Truth.assertThat;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -164,11 +165,7 @@ public class CacheBuilderTest extends TestCase {
@GwtIncompatible // maximumWeight
public void testMaximumSize_andWeight() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder().maximumSize(16);
- try {
- builder.maximumWeight(16);
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder.maximumWeight(16));
}
@GwtIncompatible // digs into internals of the non-GWT implementation
@@ -182,98 +179,53 @@ public class CacheBuilderTest extends TestCase {
@GwtIncompatible // maximumWeight
public void testMaximumWeight_negative() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
- try {
- builder.maximumWeight(-1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.maximumWeight(-1));
}
@GwtIncompatible // maximumWeight
public void testMaximumWeight_setTwice() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder().maximumWeight(16);
- try {
- // even to the same value is not allowed
- builder.maximumWeight(16);
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- builder.maximumSize(16);
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder.maximumWeight(16));
+ assertThrows(IllegalStateException.class, () -> builder.maximumSize(16));
}
@GwtIncompatible // maximumWeight
public void testMaximumWeight_withoutWeigher() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder().maximumWeight(1);
- try {
- builder.build(identityLoader());
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder.build(identityLoader()));
}
@GwtIncompatible // weigher
public void testWeigher_withoutMaximumWeight() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder().weigher(constantWeigher(42));
- try {
- builder.build(identityLoader());
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder.build(identityLoader()));
}
@GwtIncompatible // weigher
public void testWeigher_withMaximumSize() {
- try {
- CacheBuilder.newBuilder().weigher(constantWeigher(42)).maximumSize(1);
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- CacheBuilder.newBuilder().maximumSize(1).weigher(constantWeigher(42));
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> CacheBuilder.newBuilder().weigher(constantWeigher(42)).maximumSize(1));
+ assertThrows(
+ IllegalStateException.class,
+ () -> CacheBuilder.newBuilder().maximumSize(1).weigher(constantWeigher(42)));
}
@GwtIncompatible // weakKeys
public void testKeyStrengthSetTwice() {
CacheBuilder<Object, Object> builder1 = CacheBuilder.newBuilder().weakKeys();
- try {
- builder1.weakKeys();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder1.weakKeys());
}
@GwtIncompatible // weakValues
public void testValueStrengthSetTwice() {
CacheBuilder<Object, Object> builder1 = CacheBuilder.newBuilder().weakValues();
- try {
- builder1.weakValues();
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- builder1.softValues();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder1.weakValues());
+ assertThrows(IllegalStateException.class, () -> builder1.softValues());
CacheBuilder<Object, Object> builder2 = CacheBuilder.newBuilder().softValues();
- try {
- builder2.softValues();
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- builder2.weakValues();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder2.softValues());
+ assertThrows(IllegalStateException.class, () -> builder2.weakValues());
}
@GwtIncompatible // java.time.Duration
@@ -298,11 +250,9 @@ public class CacheBuilderTest extends TestCase {
@GwtIncompatible // java.time.Duration
public void testTimeToLive_negative_duration() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
- try {
- builder.expireAfterWrite(java.time.Duration.ofSeconds(-1));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> builder.expireAfterWrite(java.time.Duration.ofSeconds(-1)));
}
@SuppressWarnings("ReturnValueIgnored")
@@ -326,12 +276,9 @@ public class CacheBuilderTest extends TestCase {
public void testTimeToLive_setTwice_duration() {
CacheBuilder<Object, Object> builder =
CacheBuilder.newBuilder().expireAfterWrite(java.time.Duration.ofSeconds(3600));
- try {
- // even to the same value is not allowed
- builder.expireAfterWrite(java.time.Duration.ofSeconds(3600));
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> builder.expireAfterWrite(java.time.Duration.ofSeconds(3600)));
}
public void testTimeToIdle_negative() {
@@ -346,11 +293,9 @@ public class CacheBuilderTest extends TestCase {
@GwtIncompatible // java.time.Duration
public void testTimeToIdle_negative_duration() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
- try {
- builder.expireAfterAccess(java.time.Duration.ofSeconds(-1));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> builder.expireAfterAccess(java.time.Duration.ofSeconds(-1)));
}
@SuppressWarnings("ReturnValueIgnored")
@@ -374,12 +319,9 @@ public class CacheBuilderTest extends TestCase {
public void testTimeToIdle_setTwice_duration() {
CacheBuilder<Object, Object> builder =
CacheBuilder.newBuilder().expireAfterAccess(java.time.Duration.ofSeconds(3600));
- try {
- // even to the same value is not allowed
- builder.expireAfterAccess(java.time.Duration.ofSeconds(3600));
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> builder.expireAfterAccess(java.time.Duration.ofSeconds(3600)));
}
@SuppressWarnings("ReturnValueIgnored")
@@ -394,45 +336,30 @@ public class CacheBuilderTest extends TestCase {
@GwtIncompatible // refreshAfterWrite
public void testRefresh_zero() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
- try {
- builder.refreshAfterWrite(0, SECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.refreshAfterWrite(0, SECONDS));
}
@GwtIncompatible // java.time.Duration
public void testRefresh_zero_duration() {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
- try {
- builder.refreshAfterWrite(java.time.Duration.ZERO);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> builder.refreshAfterWrite(java.time.Duration.ZERO));
}
@GwtIncompatible // refreshAfterWrite
public void testRefresh_setTwice() {
CacheBuilder<Object, Object> builder =
CacheBuilder.newBuilder().refreshAfterWrite(3600, SECONDS);
- try {
- // even to the same value is not allowed
- builder.refreshAfterWrite(3600, SECONDS);
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> builder.refreshAfterWrite(3600, SECONDS));
}
@GwtIncompatible // java.time.Duration
public void testRefresh_setTwice_duration() {
CacheBuilder<Object, Object> builder =
CacheBuilder.newBuilder().refreshAfterWrite(java.time.Duration.ofSeconds(3600));
- try {
- // even to the same value is not allowed
- builder.refreshAfterWrite(java.time.Duration.ofSeconds(3600));
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> builder.refreshAfterWrite(java.time.Duration.ofSeconds(3600)));
}
public void testTicker_setTwice() {
diff --git a/guava-tests/test/com/google/common/cache/CacheLoadingTest.java b/guava-tests/test/com/google/common/cache/CacheLoadingTest.java
index 9b193ed7f..df36a81c7 100644
--- a/guava-tests/test/com/google/common/cache/CacheLoadingTest.java
+++ b/guava-tests/test/com/google/common/cache/CacheLoadingTest.java
@@ -24,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
import static java.lang.Thread.currentThread;
import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
import com.google.common.cache.TestingCacheLoaders.CountingLoader;
@@ -521,11 +522,7 @@ public class CacheLoadingTest extends TestCase {
assertSame(extraKey, cache.asMap().get(extraKey));
Object[] lookupKeys = new Object[] {new Object(), new Object(), new Object()};
- try {
- cache.getAll(asList(lookupKeys));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getAll(asList(lookupKeys)));
for (Object key : lookupKeys) {
assertTrue(cache.asMap().containsKey(key));
@@ -561,11 +558,7 @@ public class CacheLoadingTest extends TestCase {
assertSame(extraKey, cache.asMap().get(extraKey));
Object[] lookupKeys = new Object[] {new Object(), new Object(), new Object()};
- try {
- cache.getAll(asList(lookupKeys));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getAll(asList(lookupKeys)));
for (Object key : lookupKeys) {
assertTrue(cache.asMap().containsKey(key));
@@ -595,11 +588,7 @@ public class CacheLoadingTest extends TestCase {
LoadingCache<Object, Object> cache = CacheBuilder.newBuilder().build(loader);
Object[] lookupKeys = new Object[] {new Object(), new Object(), new Object()};
- try {
- cache.getAll(asList(lookupKeys));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getAll(asList(lookupKeys)));
assertSame(extraValue, cache.asMap().get(extraKey));
}
@@ -612,22 +601,14 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.get(new Object());
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.get(new Object()));
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(1, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getUnchecked(new Object()));
stats = cache.stats();
assertEquals(2, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -642,22 +623,15 @@ public class CacheLoadingTest extends TestCase {
assertEquals(3, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.get(new Object(), Callables.returning(null));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(
+ InvalidCacheLoadException.class, () -> cache.get(new Object(), Callables.returning(null)));
stats = cache.stats();
assertEquals(3, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(4, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getAll(asList(new Object())));
stats = cache.stats();
assertEquals(4, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -828,11 +802,7 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getAll(asList(new Object())));
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -863,11 +833,7 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (InvalidCacheLoadException expected) {
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getAll(asList(new Object())));
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -885,24 +851,16 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.get(new Object());
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ ExecutionError expected = assertThrows(ExecutionError.class, () -> cache.get(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(1, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected = assertThrows(ExecutionError.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(2, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -918,31 +876,27 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.hitCount());
final Error callableError = new Error();
- try {
- cache.get(
- new Object(),
- new Callable<Object>() {
- @Override
- public Object call() {
- throw callableError;
- }
- });
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(callableError);
- }
+ expected =
+ assertThrows(
+ ExecutionError.class,
+ () ->
+ cache.get(
+ new Object(),
+ new Callable<Object>() {
+ @Override
+ public Object call() {
+ throw callableError;
+ }
+ }));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(callableError);
stats = cache.stats();
assertEquals(3, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(4, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected = assertThrows(ExecutionError.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(4, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1118,12 +1072,9 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ ExecutionError expected =
+ assertThrows(ExecutionError.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1141,24 +1092,17 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.get(new Object());
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ Exception expected = assertThrows(ExecutionException.class, () -> cache.get(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(1, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(2, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1174,24 +1118,18 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.hitCount());
Exception callableException = new Exception();
- try {
- cache.get(new Object(), throwing(callableException));
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(callableException);
- }
+ expected =
+ assertThrows(
+ ExecutionException.class, () -> cache.get(new Object(), throwing(callableException)));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(callableException);
stats = cache.stats();
assertEquals(3, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(4, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected = assertThrows(ExecutionException.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(4, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1212,12 +1150,8 @@ public class CacheLoadingTest extends TestCase {
// Sanity check:
assertFalse(currentThread().interrupted());
- try {
- cache.get(new Object());
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ Exception expected = assertThrows(ExecutionException.class, () -> cache.get(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
assertTrue(currentThread().interrupted());
stats = cache.stats();
assertEquals(1, stats.missCount());
@@ -1225,12 +1159,9 @@ public class CacheLoadingTest extends TestCase {
assertEquals(1, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
assertTrue(currentThread().interrupted());
stats = cache.stats();
assertEquals(2, stats.missCount());
@@ -1248,12 +1179,10 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.hitCount());
Exception callableException = new InterruptedException();
- try {
- cache.get(new Object(), throwing(callableException));
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(callableException);
- }
+ expected =
+ assertThrows(
+ ExecutionException.class, () -> cache.get(new Object(), throwing(callableException)));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(callableException);
assertTrue(currentThread().interrupted());
stats = cache.stats();
assertEquals(3, stats.missCount());
@@ -1261,12 +1190,8 @@ public class CacheLoadingTest extends TestCase {
assertEquals(4, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected = assertThrows(ExecutionException.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
assertTrue(currentThread().interrupted());
stats = cache.stats();
assertEquals(4, stats.missCount());
@@ -1443,12 +1368,9 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ ExecutionException expected =
+ assertThrows(ExecutionException.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1467,12 +1389,9 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ ExecutionException expected =
+ assertThrows(ExecutionException.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
assertTrue(currentThread().interrupted());
stats = cache.stats();
assertEquals(1, stats.missCount());
@@ -1491,24 +1410,18 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.get(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ UncheckedExecutionException expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.get(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(1, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(new Object()));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(2, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1524,24 +1437,20 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.hitCount());
Exception callableException = new RuntimeException();
- try {
- cache.get(new Object(), throwing(callableException));
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(callableException);
- }
+ expected =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () -> cache.get(new Object(), throwing(callableException)));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(callableException);
stats = cache.stats();
assertEquals(3, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
assertEquals(4, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(4, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1717,12 +1626,9 @@ public class CacheLoadingTest extends TestCase {
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.hitCount());
- try {
- cache.getAll(asList(new Object()));
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(e);
- }
+ UncheckedExecutionException expected =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getAll(asList(new Object())));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(e);
stats = cache.stats();
assertEquals(1, stats.missCount());
assertEquals(0, stats.loadSuccessCount());
@@ -1748,12 +1654,9 @@ public class CacheLoadingTest extends TestCase {
LoadingCache<Integer, String> cache =
CacheBuilder.newBuilder().removalListener(removalListener).build(failOnceFunction);
- try {
- cache.getUnchecked(1);
- fail();
- } catch (UncheckedExecutionException ue) {
- assertThat(ue).hasCauseThat().isSameInstanceAs(e);
- }
+ UncheckedExecutionException ue =
+ assertThrows(UncheckedExecutionException.class, () -> cache.getUnchecked(1));
+ assertThat(ue).hasCauseThat().isSameInstanceAs(e);
assertEquals("1", cache.getUnchecked(1));
assertEquals(0, removalListener.getCount());
@@ -1871,12 +1774,10 @@ public class CacheLoadingTest extends TestCase {
assertThat(caughtEe).hasCauseThat().isSameInstanceAs(uee);
}
- try {
- cacheUnchecked.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException caughtUee) {
- assertThat(caughtUee).hasCauseThat().isSameInstanceAs(uee);
- }
+ UncheckedExecutionException caughtUee =
+ assertThrows(
+ UncheckedExecutionException.class, () -> cacheUnchecked.getUnchecked(new Object()));
+ assertThat(caughtUee).hasCauseThat().isSameInstanceAs(uee);
cacheUnchecked.refresh(new Object());
checkLoggedCause(uee);
@@ -1890,29 +1791,21 @@ public class CacheLoadingTest extends TestCase {
assertThat(caughtEe).hasCauseThat().isSameInstanceAs(uee);
}
- try {
- cacheChecked.get(new Object());
- fail();
- } catch (ExecutionException caughtEe) {
- assertThat(caughtEe).hasCauseThat().isSameInstanceAs(ee);
- }
+ ExecutionException caughtEe =
+ assertThrows(ExecutionException.class, () -> cacheChecked.get(new Object()));
+ assertThat(caughtEe).hasCauseThat().isSameInstanceAs(ee);
- try {
- cacheChecked.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException caughtUee) {
- assertThat(caughtUee).hasCauseThat().isSameInstanceAs(ee);
- }
+ caughtUee =
+ assertThrows(
+ UncheckedExecutionException.class, () -> cacheChecked.getUnchecked(new Object()));
+ assertThat(caughtUee).hasCauseThat().isSameInstanceAs(ee);
cacheChecked.refresh(new Object());
checkLoggedCause(ee);
- try {
- cacheChecked.getAll(asList(new Object()));
- fail();
- } catch (ExecutionException caughtEe) {
- assertThat(caughtEe).hasCauseThat().isSameInstanceAs(ee);
- }
+ caughtEe =
+ assertThrows(ExecutionException.class, () -> cacheChecked.getAll(asList(new Object())));
+ assertThat(caughtEe).hasCauseThat().isSameInstanceAs(ee);
}
public void testBulkLoadingExceptionWithCause() {
@@ -1934,12 +1827,9 @@ public class CacheLoadingTest extends TestCase {
assertThat(caughtEe).hasCauseThat().isSameInstanceAs(uee);
}
- try {
- cacheChecked.getAll(asList(new Object()));
- fail();
- } catch (ExecutionException caughtEe) {
- assertThat(caughtEe).hasCauseThat().isSameInstanceAs(ee);
- }
+ ExecutionException caughtEe =
+ assertThrows(ExecutionException.class, () -> cacheChecked.getAll(asList(new Object())));
+ assertThat(caughtEe).hasCauseThat().isSameInstanceAs(ee);
}
@AndroidIncompatible // Bug? expected:<1> but was:<2>
diff --git a/guava-tests/test/com/google/common/cache/EmptyCachesTest.java b/guava-tests/test/com/google/common/cache/EmptyCachesTest.java
index a5e3a59a0..ccdcb955d 100644
--- a/guava-tests/test/com/google/common/cache/EmptyCachesTest.java
+++ b/guava-tests/test/com/google/common/cache/EmptyCachesTest.java
@@ -19,6 +19,7 @@ import static com.google.common.cache.TestingCacheLoaders.identityLoader;
import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Function;
import com.google.common.cache.CacheBuilderFactory.DurationSpec;
@@ -89,22 +90,14 @@ public class EmptyCachesTest extends TestCase {
public void testGet_null() throws ExecutionException {
for (LoadingCache<Object, Object> cache : caches()) {
- try {
- cache.get(null);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> cache.get(null));
checkEmpty(cache);
}
}
public void testGetUnchecked_null() {
for (LoadingCache<Object, Object> cache : caches()) {
- try {
- cache.getUnchecked(null);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> cache.getUnchecked(null));
checkEmpty(cache);
}
}
@@ -114,28 +107,17 @@ public class EmptyCachesTest extends TestCase {
public void testKeySet_nullToArray() {
for (LoadingCache<Object, Object> cache : caches()) {
Set<Object> keys = cache.asMap().keySet();
- try {
- keys.toArray((Object[]) null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> keys.toArray((Object[]) null));
checkEmpty(cache);
}
}
public void testKeySet_addNotSupported() {
for (LoadingCache<Object, Object> cache : caches()) {
- try {
- cache.asMap().keySet().add(1);
- fail();
- } catch (UnsupportedOperationException expected) {
- }
-
- try {
- cache.asMap().keySet().addAll(asList(1, 2));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> cache.asMap().keySet().add(1));
+
+ assertThrows(
+ UnsupportedOperationException.class, () -> cache.asMap().keySet().addAll(asList(1, 2)));
}
}
@@ -189,28 +171,17 @@ public class EmptyCachesTest extends TestCase {
public void testValues_nullToArray() {
for (LoadingCache<Object, Object> cache : caches()) {
Collection<Object> values = cache.asMap().values();
- try {
- values.toArray((Object[]) null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> values.toArray((Object[]) null));
checkEmpty(cache);
}
}
public void testValues_addNotSupported() {
for (LoadingCache<Object, Object> cache : caches()) {
- try {
- cache.asMap().values().add(1);
- fail();
- } catch (UnsupportedOperationException expected) {
- }
-
- try {
- cache.asMap().values().addAll(asList(1, 2));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> cache.asMap().values().add(1));
+
+ assertThrows(
+ UnsupportedOperationException.class, () -> cache.asMap().values().addAll(asList(1, 2)));
}
}
@@ -264,28 +235,20 @@ public class EmptyCachesTest extends TestCase {
public void testEntrySet_nullToArray() {
for (LoadingCache<Object, Object> cache : caches()) {
Set<Entry<Object, Object>> entries = cache.asMap().entrySet();
- try {
- entries.toArray((Entry<Object, Object>[]) null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(
+ NullPointerException.class, () -> entries.toArray((Entry<Object, Object>[]) null));
checkEmpty(cache);
}
}
public void testEntrySet_addNotSupported() {
for (LoadingCache<Object, Object> cache : caches()) {
- try {
- cache.asMap().entrySet().add(entryOf(1, 1));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
-
- try {
- cache.asMap().values().addAll(asList(entryOf(1, 1), entryOf(2, 2)));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(
+ UnsupportedOperationException.class, () -> cache.asMap().entrySet().add(entryOf(1, 1)));
+
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> cache.asMap().values().addAll(asList(entryOf(1, 1), entryOf(2, 2))));
}
}
diff --git a/guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java b/guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java
index 61f5fed2d..f418d105b 100644
--- a/guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java
+++ b/guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java
@@ -17,6 +17,7 @@
package com.google.common.cache;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.UncheckedExecutionException;
import java.util.ArrayList;
@@ -180,20 +181,19 @@ public class LocalCacheMapComputeTest extends TestCase {
}
public void testComputeExceptionally() {
- try {
- doParallelCacheOp(
- count,
- n -> {
- cache
- .asMap()
- .compute(
- key,
- (k, v) -> {
- throw new RuntimeException();
- });
- });
- fail("Should not get here");
- } catch (RuntimeException ex) {
- }
+ assertThrows(
+ RuntimeException.class,
+ () ->
+ doParallelCacheOp(
+ count,
+ n -> {
+ cache
+ .asMap()
+ .compute(
+ key,
+ (k, v) -> {
+ throw new RuntimeException();
+ });
+ }));
}
}
diff --git a/guava-tests/test/com/google/common/cache/LocalCacheTest.java b/guava-tests/test/com/google/common/cache/LocalCacheTest.java
index 7cc67e840..a16c0ab37 100644
--- a/guava-tests/test/com/google/common/cache/LocalCacheTest.java
+++ b/guava-tests/test/com/google/common/cache/LocalCacheTest.java
@@ -58,6 +58,7 @@ import com.google.common.testing.FakeTicker;
import com.google.common.testing.NullPointerTester;
import com.google.common.testing.SerializableTester;
import com.google.common.testing.TestLogHandler;
+import com.google.common.util.concurrent.UncheckedExecutionException;
import java.io.Serializable;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
@@ -2688,8 +2689,86 @@ public class LocalCacheTest extends TestCase {
assertEquals(localCacheTwo.ticker, localCacheThree.ticker);
}
+ public void testLoadDifferentKeyInLoader() throws ExecutionException, InterruptedException {
+ LocalCache<String, String> cache = makeLocalCache(createCacheBuilder());
+ String key1 = "key1";
+ String key2 = "key2";
+
+ assertEquals(
+ key2,
+ cache.get(
+ key1,
+ new CacheLoader<String, String>() {
+ @Override
+ public String load(String key) throws Exception {
+ return cache.get(key2, identityLoader()); // loads a different key, should work
+ }
+ }));
+ }
+
+ public void testRecursiveLoad() throws InterruptedException {
+ LocalCache<String, String> cache = makeLocalCache(createCacheBuilder());
+ String key = "key";
+ CacheLoader<String, String> loader =
+ new CacheLoader<String, String>() {
+ @Override
+ public String load(String key) throws Exception {
+ return cache.get(key, identityLoader()); // recursive load, this should fail
+ }
+ };
+ testLoadThrows(key, cache, loader);
+ }
+
+ public void testRecursiveLoadWithProxy() throws InterruptedException {
+ String key = "key";
+ String otherKey = "otherKey";
+ LocalCache<String, String> cache = makeLocalCache(createCacheBuilder());
+ CacheLoader<String, String> loader =
+ new CacheLoader<String, String>() {
+ @Override
+ public String load(String key) throws Exception {
+ return cache.get(
+ key,
+ identityLoader()); // recursive load (same as the initial one), this should fail
+ }
+ };
+ CacheLoader<String, String> proxyLoader =
+ new CacheLoader<String, String>() {
+ @Override
+ public String load(String key) throws Exception {
+ return cache.get(otherKey, loader); // loads another key, is ok
+ }
+ };
+ testLoadThrows(key, cache, proxyLoader);
+ }
+
// utility methods
+ private void testLoadThrows(
+ String key, LocalCache<String, String> cache, CacheLoader<String, String> loader)
+ throws InterruptedException {
+ CountDownLatch doneSignal = new CountDownLatch(1);
+ Thread thread =
+ new Thread(
+ () -> {
+ try {
+ cache.get(key, loader);
+ } catch (UncheckedExecutionException | ExecutionException e) {
+ doneSignal.countDown();
+ }
+ });
+ thread.start();
+
+ boolean done = doneSignal.await(1, TimeUnit.SECONDS);
+ if (!done) {
+ StringBuilder builder = new StringBuilder();
+ for (StackTraceElement trace : thread.getStackTrace()) {
+ builder.append("\tat ").append(trace).append('\n');
+ }
+ fail(builder.toString());
+ }
+ }
+
/**
* Returns an iterable containing all combinations of maximumSize, expireAfterAccess/Write,
* weakKeys and weak/softValues.
diff --git a/guava-tests/test/com/google/common/cache/NullCacheTest.java b/guava-tests/test/com/google/common/cache/NullCacheTest.java
index 89dc3fb14..6fa8f7b13 100644
--- a/guava-tests/test/com/google/common/cache/NullCacheTest.java
+++ b/guava-tests/test/com/google/common/cache/NullCacheTest.java
@@ -20,6 +20,7 @@ import static com.google.common.cache.TestingCacheLoaders.exceptionLoader;
import static com.google.common.cache.TestingRemovalListeners.queuingRemovalListener;
import static com.google.common.truth.Truth.assertThat;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
import com.google.common.cache.TestingRemovalListeners.QueuingRemovalListener;
@@ -100,12 +101,7 @@ public class NullCacheTest extends TestCase {
.removalListener(listener)
.build(constantLoader(null));
- try {
- cache.getUnchecked(new Object());
- fail();
- } catch (InvalidCacheLoadException e) {
- /* expected */
- }
+ assertThrows(InvalidCacheLoadException.class, () -> cache.getUnchecked(new Object()));
assertTrue(listener.isEmpty());
checkEmpty(cache);
@@ -119,12 +115,9 @@ public class NullCacheTest extends TestCase {
.removalListener(listener)
.build(exceptionLoader(e));
- try {
- map.getUnchecked(new Object());
- fail();
- } catch (UncheckedExecutionException uee) {
- assertThat(uee).hasCauseThat().isSameInstanceAs(e);
- }
+ UncheckedExecutionException uee =
+ assertThrows(UncheckedExecutionException.class, () -> map.getUnchecked(new Object()));
+ assertThat(uee).hasCauseThat().isSameInstanceAs(e);
assertTrue(listener.isEmpty());
checkEmpty(map);
}
diff --git a/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java b/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java
index b02b8ac61..5518190a5 100644
--- a/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java
+++ b/guava-tests/test/com/google/common/cache/PopulatedCachesTest.java
@@ -20,6 +20,7 @@ import static com.google.common.cache.TestingCacheLoaders.identityLoader;
import static com.google.common.truth.Truth.assertThat;
import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Function;
import com.google.common.cache.CacheBuilderFactory.DurationSpec;
@@ -279,11 +280,7 @@ public class PopulatedCachesTest extends TestCase {
assertEquals(3, cache.getIfPresent(1));
checkValidState(cache);
- try {
- entry.setValue(null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> entry.setValue(null));
checkValidState(cache);
}
}
diff --git a/guava-tests/test/com/google/common/collect/AbstractFilteredMapTest.java b/guava-tests/test/com/google/common/collect/AbstractFilteredMapTest.java
new file mode 100644
index 000000000..b415b2b1b
--- /dev/null
+++ b/guava-tests/test/com/google/common/collect/AbstractFilteredMapTest.java
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 2007 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.collect;
+
+import com.google.common.annotations.GwtCompatible;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import java.util.Map;
+import java.util.Map.Entry;
+import junit.framework.TestCase;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+@GwtCompatible
+abstract class AbstractFilteredMapTest extends TestCase {
+ private static final Predicate<@Nullable String> NOT_LENGTH_3 =
+ input -> input == null || input.length() != 3;
+ private static final Predicate<@Nullable Integer> EVEN = input -> input == null || input % 2 == 0;
+ static final Predicate<Entry<String, Integer>> CORRECT_LENGTH =
+ input -> input.getKey().length() == input.getValue();
+
+ abstract Map<String, Integer> createUnfiltered();
+
+ public void testFilteredKeysIllegalPut() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3);
+ filtered.put("a", 1);
+ filtered.put("b", 2);
+ assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered);
+
+ try {
+ filtered.put("yyy", 3);
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ }
+
+ public void testFilteredKeysIllegalPutAll() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3);
+ filtered.put("a", 1);
+ filtered.put("b", 2);
+ assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered);
+
+ try {
+ filtered.putAll(ImmutableMap.of("c", 3, "zzz", 4, "b", 5));
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+
+ assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered);
+ }
+
+ public void testFilteredKeysFilteredReflectsBackingChanges() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3);
+ unfiltered.put("two", 2);
+ unfiltered.put("three", 3);
+ unfiltered.put("four", 4);
+ assertEquals(ImmutableMap.of("two", 2, "three", 3, "four", 4), unfiltered);
+ assertEquals(ImmutableMap.of("three", 3, "four", 4), filtered);
+
+ unfiltered.remove("three");
+ assertEquals(ImmutableMap.of("two", 2, "four", 4), unfiltered);
+ assertEquals(ImmutableMap.of("four", 4), filtered);
+
+ unfiltered.clear();
+ assertEquals(ImmutableMap.of(), unfiltered);
+ assertEquals(ImmutableMap.of(), filtered);
+ }
+
+ public void testFilteredValuesIllegalPut() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
+ filtered.put("a", 2);
+ unfiltered.put("b", 4);
+ unfiltered.put("c", 5);
+ assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
+
+ try {
+ filtered.put("yyy", 3);
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
+ }
+
+ public void testFilteredValuesIllegalPutAll() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
+ filtered.put("a", 2);
+ unfiltered.put("b", 4);
+ unfiltered.put("c", 5);
+ assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
+
+ try {
+ filtered.putAll(ImmutableMap.of("c", 4, "zzz", 5, "b", 6));
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
+ }
+
+ public void testFilteredValuesIllegalSetValue() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
+ filtered.put("a", 2);
+ filtered.put("b", 4);
+ assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
+
+ Entry<String, Integer> entry = filtered.entrySet().iterator().next();
+ try {
+ entry.setValue(5);
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+
+ assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
+ }
+
+ public void testFilteredValuesClear() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ unfiltered.put("one", 1);
+ unfiltered.put("two", 2);
+ unfiltered.put("three", 3);
+ unfiltered.put("four", 4);
+ Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
+ assertEquals(ImmutableMap.of("one", 1, "two", 2, "three", 3, "four", 4), unfiltered);
+ assertEquals(ImmutableMap.of("two", 2, "four", 4), filtered);
+
+ filtered.clear();
+ assertEquals(ImmutableMap.of("one", 1, "three", 3), unfiltered);
+ assertTrue(filtered.isEmpty());
+ }
+
+ public void testFilteredEntriesIllegalPut() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ unfiltered.put("cat", 3);
+ unfiltered.put("dog", 2);
+ unfiltered.put("horse", 5);
+ Map<String, Integer> filtered = Maps.filterEntries(unfiltered, CORRECT_LENGTH);
+ assertEquals(ImmutableMap.of("cat", 3, "horse", 5), filtered);
+
+ filtered.put("chicken", 7);
+ assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
+
+ try {
+ filtered.put("cow", 7);
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
+ }
+
+ public void testFilteredEntriesIllegalPutAll() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ unfiltered.put("cat", 3);
+ unfiltered.put("dog", 2);
+ unfiltered.put("horse", 5);
+ Map<String, Integer> filtered = Maps.filterEntries(unfiltered, CORRECT_LENGTH);
+ assertEquals(ImmutableMap.of("cat", 3, "horse", 5), filtered);
+
+ filtered.put("chicken", 7);
+ assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
+
+ try {
+ filtered.putAll(ImmutableMap.of("sheep", 5, "cow", 7));
+ fail();
+ } catch (IllegalArgumentException expected) {
+ }
+ assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
+ }
+
+ public void testFilteredEntriesObjectPredicate() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ unfiltered.put("cat", 3);
+ unfiltered.put("dog", 2);
+ unfiltered.put("horse", 5);
+ Predicate<Object> predicate = Predicates.alwaysFalse();
+ Map<String, Integer> filtered = Maps.filterEntries(unfiltered, predicate);
+ assertTrue(filtered.isEmpty());
+ }
+
+ public void testFilteredEntriesWildCardEntryPredicate() {
+ Map<String, Integer> unfiltered = createUnfiltered();
+ unfiltered.put("cat", 3);
+ unfiltered.put("dog", 2);
+ unfiltered.put("horse", 5);
+ Predicate<Entry<?, ?>> predicate =
+ new Predicate<Entry<?, ?>>() {
+ @Override
+ public boolean apply(Entry<?, ?> input) {
+ return "cat".equals(input.getKey()) || Integer.valueOf(2) == input.getValue();
+ }
+ };
+ Map<String, Integer> filtered = Maps.filterEntries(unfiltered, predicate);
+ assertEquals(ImmutableMap.of("cat", 3, "dog", 2), filtered);
+ }
+}
diff --git a/guava-tests/test/com/google/common/collect/AbstractHashFloodingTest.java b/guava-tests/test/com/google/common/collect/AbstractHashFloodingTest.java
index 049da4cbc..5ba863c73 100644
--- a/guava-tests/test/com/google/common/collect/AbstractHashFloodingTest.java
+++ b/guava-tests/test/com/google/common/collect/AbstractHashFloodingTest.java
@@ -17,7 +17,6 @@ package com.google.common.collect;
import static com.google.common.truth.Truth.assertWithMessage;
-import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Arrays;
@@ -35,7 +34,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* Abstract superclass for tests that hash flooding a collection has controlled worst-case
* performance.
*/
-@GwtCompatible
+@GwtIncompatible
public abstract class AbstractHashFloodingTest<T> extends TestCase {
private final List<Construction<T>> constructions;
private final IntToDoubleFunction constructionAsymptotics;
@@ -188,7 +187,6 @@ public abstract class AbstractHashFloodingTest<T> extends TestCase {
return result;
}
- @GwtIncompatible
public void testResistsHashFloodingInConstruction() {
CallsCounter smallCounter = new CallsCounter();
List<CountsHashCodeAndEquals> haveSameHashesSmall = createAdversarialInput(10, smallCounter);
@@ -221,7 +219,6 @@ public abstract class AbstractHashFloodingTest<T> extends TestCase {
}
}
- @GwtIncompatible
public void testResistsHashFloodingOnQuery() {
CallsCounter smallCounter = new CallsCounter();
List<CountsHashCodeAndEquals> haveSameHashesSmall = createAdversarialInput(10, smallCounter);
diff --git a/guava-tests/test/com/google/common/collect/AbstractMapsTransformValuesTest.java b/guava-tests/test/com/google/common/collect/AbstractMapsTransformValuesTest.java
new file mode 100644
index 000000000..3b56fef5e
--- /dev/null
+++ b/guava-tests/test/com/google/common/collect/AbstractMapsTransformValuesTest.java
@@ -0,0 +1,275 @@
+/*
+ * Copyright (C) 2008 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.collect;
+
+import com.google.common.annotations.GwtCompatible;
+import com.google.common.base.Function;
+import com.google.common.base.Functions;
+import com.google.common.collect.testing.MapInterfaceTest;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/**
+ * Superclass for tests for {@link Maps#transformValues} overloads.
+ *
+ * @author Isaac Shum
+ */
+@GwtCompatible
+abstract class AbstractMapsTransformValuesTest extends MapInterfaceTest<String, String> {
+ public AbstractMapsTransformValuesTest() {
+ super(false, true, false, true, true);
+ }
+
+ @Override
+ protected String getKeyNotInPopulatedMap() throws UnsupportedOperationException {
+ return "z";
+ }
+
+ @Override
+ protected String getValueNotInPopulatedMap() throws UnsupportedOperationException {
+ return "26";
+ }
+
+ /** Helper assertion comparing two maps */
+ private void assertMapsEqual(Map<?, ?> expected, Map<?, ?> map) {
+ assertEquals(expected, map);
+ assertEquals(expected.hashCode(), map.hashCode());
+ assertEquals(expected.entrySet(), map.entrySet());
+
+ // Assert that expectedValues > mapValues and that
+ // mapValues > expectedValues; i.e. that expectedValues == mapValues.
+ Collection<?> expectedValues = expected.values();
+ Collection<?> mapValues = map.values();
+ assertEquals(expectedValues.size(), mapValues.size());
+ assertTrue(expectedValues.containsAll(mapValues));
+ assertTrue(mapValues.containsAll(expectedValues));
+ }
+
+ public void testTransformEmptyMapEquality() {
+ Map<String, String> map =
+ Maps.transformValues(ImmutableMap.<String, Integer>of(), Functions.toStringFunction());
+ assertMapsEqual(Maps.newHashMap(), map);
+ }
+
+ public void testTransformSingletonMapEquality() {
+ Map<String, String> map =
+ Maps.transformValues(ImmutableMap.of("a", 1), Functions.toStringFunction());
+ Map<String, String> expected = ImmutableMap.of("a", "1");
+ assertMapsEqual(expected, map);
+ assertEquals(expected.get("a"), map.get("a"));
+ }
+
+ public void testTransformIdentityFunctionEquality() {
+ Map<String, Integer> underlying = ImmutableMap.of("a", 1);
+ Map<String, Integer> map = Maps.transformValues(underlying, Functions.<Integer>identity());
+ assertMapsEqual(underlying, map);
+ }
+
+ public void testTransformPutEntryIsUnsupported() {
+ Map<String, String> map =
+ Maps.transformValues(ImmutableMap.of("a", 1), Functions.toStringFunction());
+ try {
+ map.put("b", "2");
+ fail();
+ } catch (UnsupportedOperationException expected) {
+ }
+
+ try {
+ map.putAll(ImmutableMap.of("b", "2"));
+ fail();
+ } catch (UnsupportedOperationException expected) {
+ }
+
+ try {
+ map.entrySet().iterator().next().setValue("one");
+ fail();
+ } catch (UnsupportedOperationException expected) {
+ }
+ }
+
+ public void testTransformRemoveEntry() {
+ Map<String, Integer> underlying = Maps.newHashMap();
+ underlying.put("a", 1);
+ Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction());
+ assertEquals("1", map.remove("a"));
+ assertNull(map.remove("b"));
+ }
+
+ public void testTransformEqualityOfMapsWithNullValues() {
+ Map<String, String> underlying = Maps.newHashMap();
+ underlying.put("a", null);
+ underlying.put("b", "");
+
+ Map<String, Boolean> map =
+ Maps.transformValues(
+ underlying,
+ new Function<String, Boolean>() {
+ @Override
+ public Boolean apply(@Nullable String from) {
+ return from == null;
+ }
+ });
+ Map<String, Boolean> expected = ImmutableMap.of("a", true, "b", false);
+ assertMapsEqual(expected, map);
+ assertEquals(expected.get("a"), map.get("a"));
+ assertEquals(expected.containsKey("a"), map.containsKey("a"));
+ assertEquals(expected.get("b"), map.get("b"));
+ assertEquals(expected.containsKey("b"), map.containsKey("b"));
+ assertEquals(expected.get("c"), map.get("c"));
+ assertEquals(expected.containsKey("c"), map.containsKey("c"));
+ }
+
+ public void testTransformReflectsUnderlyingMap() {
+ Map<String, Integer> underlying = Maps.newHashMap();
+ underlying.put("a", 1);
+ underlying.put("b", 2);
+ underlying.put("c", 3);
+ Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction());
+ assertEquals(underlying.size(), map.size());
+
+ underlying.put("d", 4);
+ assertEquals(underlying.size(), map.size());
+ assertEquals("4", map.get("d"));
+
+ underlying.remove("c");
+ assertEquals(underlying.size(), map.size());
+ assertFalse(map.containsKey("c"));
+
+ underlying.clear();
+ assertEquals(underlying.size(), map.size());
+ }
+
+ public void testTransformChangesAreReflectedInUnderlyingMap() {
+ Map<String, Integer> underlying = Maps.newLinkedHashMap();
+ underlying.put("a", 1);
+ underlying.put("b", 2);
+ underlying.put("c", 3);
+ underlying.put("d", 4);
+ underlying.put("e", 5);
+ underlying.put("f", 6);
+ underlying.put("g", 7);
+ Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction());
+
+ map.remove("a");
+ assertFalse(underlying.containsKey("a"));
+
+ Set<String> keys = map.keySet();
+ keys.remove("b");
+ assertFalse(underlying.containsKey("b"));
+
+ Iterator<String> keyIterator = keys.iterator();
+ keyIterator.next();
+ keyIterator.remove();
+ assertFalse(underlying.containsKey("c"));
+
+ Collection<String> values = map.values();
+ values.remove("4");
+ assertFalse(underlying.containsKey("d"));
+
+ Iterator<String> valueIterator = values.iterator();
+ valueIterator.next();
+ valueIterator.remove();
+ assertFalse(underlying.containsKey("e"));
+
+ Set<Entry<String, String>> entries = map.entrySet();
+ Entry<String, String> firstEntry = entries.iterator().next();
+ entries.remove(firstEntry);
+ assertFalse(underlying.containsKey("f"));
+
+ Iterator<Entry<String, String>> entryIterator = entries.iterator();
+ entryIterator.next();
+ entryIterator.remove();
+ assertFalse(underlying.containsKey("g"));
+
+ assertTrue(underlying.isEmpty());
+ assertTrue(map.isEmpty());
+ assertTrue(keys.isEmpty());
+ assertTrue(values.isEmpty());
+ assertTrue(entries.isEmpty());
+ }
+
+ public void testTransformEquals() {
+ Map<String, Integer> underlying = ImmutableMap.of("a", 0, "b", 1, "c", 2);
+ Map<String, Integer> expected = Maps.transformValues(underlying, Functions.<Integer>identity());
+
+ assertMapsEqual(expected, expected);
+
+ Map<String, Integer> equalToUnderlying = Maps.newTreeMap();
+ equalToUnderlying.putAll(underlying);
+ Map<String, Integer> map =
+ Maps.transformValues(equalToUnderlying, Functions.<Integer>identity());
+ assertMapsEqual(expected, map);
+
+ map =
+ Maps.transformValues(
+ ImmutableMap.of("a", 1, "b", 2, "c", 3),
+ new Function<Integer, Integer>() {
+ @Override
+ public Integer apply(Integer from) {
+ return from - 1;
+ }
+ });
+ assertMapsEqual(expected, map);
+ }
+
+ public void testTransformEntrySetContains() {
+ Map<@Nullable String, @Nullable Boolean> underlying = Maps.newHashMap();
+ underlying.put("a", null);
+ underlying.put("b", true);
+ underlying.put(null, true);
+
+ Map<@Nullable String, @Nullable Boolean> map =
+ Maps.transformValues(
+ underlying,
+ new Function<@Nullable Boolean, @Nullable Boolean>() {
+ @Override
+ public @Nullable Boolean apply(@Nullable Boolean from) {
+ return (from == null) ? true : null;
+ }
+ });
+
+ Set<Entry<@Nullable String, @Nullable Boolean>> entries = map.entrySet();
+ assertTrue(entries.contains(Maps.immutableEntry("a", true)));
+ assertTrue(entries.contains(Maps.immutableEntry("b", (Boolean) null)));
+ assertTrue(entries.contains(Maps.immutableEntry((String) null, (Boolean) null)));
+
+ assertFalse(entries.contains(Maps.immutableEntry("c", (Boolean) null)));
+ assertFalse(entries.contains(Maps.immutableEntry((String) null, true)));
+ }
+
+ @Override
+ public void testKeySetRemoveAllNullFromEmpty() {
+ try {
+ super.testKeySetRemoveAllNullFromEmpty();
+ } catch (RuntimeException tolerated) {
+ // GWT's HashMap.keySet().removeAll(null) doesn't throws NPE.
+ }
+ }
+
+ @Override
+ public void testEntrySetRemoveAllNullFromEmpty() {
+ try {
+ super.testEntrySetRemoveAllNullFromEmpty();
+ } catch (RuntimeException tolerated) {
+ // GWT's HashMap.entrySet().removeAll(null) doesn't throws NPE.
+ }
+ }
+}
diff --git a/guava-tests/test/com/google/common/collect/Base.java b/guava-tests/test/com/google/common/collect/Base.java
new file mode 100644
index 000000000..b68bd7f65
--- /dev/null
+++ b/guava-tests/test/com/google/common/collect/Base.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2007 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.collect;
+
+import com.google.common.annotations.GwtCompatible;
+import java.io.Serializable;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/** Simple base class to verify that we handle generics correctly. */
+@GwtCompatible
+class Base implements Comparable<Base>, Serializable {
+ private final String s;
+
+ public Base(String s) {
+ this.s = s;
+ }
+
+ @Override
+ public int hashCode() { // delegate to 's'
+ return s.hashCode();
+ }
+
+ @Override
+ public boolean equals(@Nullable Object other) {
+ if (other == null) {
+ return false;
+ } else if (other instanceof Base) {
+ return s.equals(((Base) other).s);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int compareTo(Base o) {
+ return s.compareTo(o.s);
+ }
+
+ private static final long serialVersionUID = 0;
+}
diff --git a/guava-tests/test/com/google/common/collect/CompactHashMapFloodingTest.java b/guava-tests/test/com/google/common/collect/CompactHashMapFloodingTest.java
index 1a03163d2..ad8801852 100644
--- a/guava-tests/test/com/google/common/collect/CompactHashMapFloodingTest.java
+++ b/guava-tests/test/com/google/common/collect/CompactHashMapFloodingTest.java
@@ -16,8 +16,10 @@
package com.google.common.collect;
+import com.google.common.annotations.GwtIncompatible;
import java.util.Map;
+@GwtIncompatible
public class CompactHashMapFloodingTest extends AbstractHashFloodingTest<Map<Object, Object>> {
public CompactHashMapFloodingTest() {
super(
diff --git a/guava-tests/test/com/google/common/collect/CompactHashSetFloodingTest.java b/guava-tests/test/com/google/common/collect/CompactHashSetFloodingTest.java
index 53e9a6195..a481871b5 100644
--- a/guava-tests/test/com/google/common/collect/CompactHashSetFloodingTest.java
+++ b/guava-tests/test/com/google/common/collect/CompactHashSetFloodingTest.java
@@ -16,8 +16,10 @@
package com.google.common.collect;
+import com.google.common.annotations.GwtIncompatible;
import java.util.Set;
+@GwtIncompatible
public class CompactHashSetFloodingTest extends AbstractHashFloodingTest<Set<Object>> {
public CompactHashSetFloodingTest() {
super(
diff --git a/guava-tests/test/com/google/common/collect/CompactLinkedHashMapFloodingTest.java b/guava-tests/test/com/google/common/collect/CompactLinkedHashMapFloodingTest.java
index 826fc82b7..0ca15beda 100644
--- a/guava-tests/test/com/google/common/collect/CompactLinkedHashMapFloodingTest.java
+++ b/guava-tests/test/com/google/common/collect/CompactLinkedHashMapFloodingTest.java
@@ -14,8 +14,10 @@
package com.google.common.collect;
+import com.google.common.annotations.GwtIncompatible;
import java.util.Map;
+@GwtIncompatible
public class CompactLinkedHashMapFloodingTest
extends AbstractHashFloodingTest<Map<Object, Object>> {
public CompactLinkedHashMapFloodingTest() {
diff --git a/guava-tests/test/com/google/common/collect/CompactLinkedHashSetFloodingTest.java b/guava-tests/test/com/google/common/collect/CompactLinkedHashSetFloodingTest.java
index b8a5d9797..5ca76bfc0 100644
--- a/guava-tests/test/com/google/common/collect/CompactLinkedHashSetFloodingTest.java
+++ b/guava-tests/test/com/google/common/collect/CompactLinkedHashSetFloodingTest.java
@@ -16,8 +16,10 @@
package com.google.common.collect;
+import com.google.common.annotations.GwtIncompatible;
import java.util.Set;
+@GwtIncompatible
public class CompactLinkedHashSetFloodingTest extends AbstractHashFloodingTest<Set<Object>> {
public CompactLinkedHashSetFloodingTest() {
super(
diff --git a/guava-tests/test/com/google/common/collect/ComparatorsTest.java b/guava-tests/test/com/google/common/collect/ComparatorsTest.java
index 473f1d753..3e1136516 100644
--- a/guava-tests/test/com/google/common/collect/ComparatorsTest.java
+++ b/guava-tests/test/com/google/common/collect/ComparatorsTest.java
@@ -23,9 +23,7 @@ import static java.util.Comparator.naturalOrder;
import com.google.common.annotations.GwtCompatible;
import com.google.common.collect.testing.Helpers;
-import com.google.common.testing.CollectorTester;
import com.google.common.testing.EqualsTester;
-import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Optional;
@@ -79,20 +77,6 @@ public class ComparatorsTest extends TestCase {
assertTrue(Comparators.isInStrictOrder(Collections.<Integer>emptyList(), Ordering.natural()));
}
- public void testLeastCollector() {
- CollectorTester.of(Comparators.<Integer>least(2, Comparator.naturalOrder()))
- .expectCollects(Arrays.asList(1, 2), 1, 2, 3, 4, 5, 6)
- .expectCollects(Arrays.asList(1), 1)
- .expectCollects(Collections.emptyList());
- }
-
- public void testGreatestCollector() {
- CollectorTester.of(Comparators.<Integer>greatest(2, Comparator.naturalOrder()))
- .expectCollects(Arrays.asList(6, 5), 1, 2, 3, 4, 5, 6)
- .expectCollects(Arrays.asList(1), 1)
- .expectCollects(Collections.emptyList());
- }
-
public void testEmptiesFirst() {
Optional<String> empty = Optional.empty();
Optional<String> abc = Optional.of("abc");
diff --git a/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java b/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java
index 1d38c8600..f7ffbc92f 100644
--- a/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java
+++ b/guava-tests/test/com/google/common/collect/ConcurrentHashMultisetTest.java
@@ -20,6 +20,7 @@ import static com.google.common.collect.MapMakerInternalMap.Strength.STRONG;
import static com.google.common.collect.MapMakerInternalMap.Strength.WEAK;
import static com.google.common.testing.SerializableTester.reserializeAndAssert;
import static java.util.Arrays.asList;
+import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
@@ -159,11 +160,7 @@ public class ConcurrentHashMultisetTest extends TestCase {
when(backingMap.get(KEY)).thenReturn(new AtomicInteger(INITIAL_COUNT));
- try {
- multiset.add(KEY, COUNT_TO_ADD);
- fail("Must reject arguments that would cause counter overflow.");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> multiset.add(KEY, COUNT_TO_ADD));
}
/**
@@ -246,11 +243,7 @@ public class ConcurrentHashMultisetTest extends TestCase {
cms.add("a", 2);
cms.add("b", 3);
- try {
- cms.removeExactly("a", -2);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> cms.removeExactly("a", -2));
assertTrue(cms.removeExactly("a", 0));
assertEquals(2, cms.count("a"));
diff --git a/guava-tests/test/com/google/common/collect/ContiguousSetTest.java b/guava-tests/test/com/google/common/collect/ContiguousSetTest.java
index 6b19b1edc..f3c5fe864 100644
--- a/guava-tests/test/com/google/common/collect/ContiguousSetTest.java
+++ b/guava-tests/test/com/google/common/collect/ContiguousSetTest.java
@@ -44,7 +44,9 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-/** @author Gregory Kick */
+/**
+ * @author Gregory Kick
+ */
@GwtCompatible(emulated = true)
public class ContiguousSetTest extends TestCase {
private static final DiscreteDomain<Integer> NOT_EQUAL_TO_INTEGERS =
@@ -155,10 +157,28 @@ public class ContiguousSetTest extends TestCase {
assertEquals(enormous, enormousReserialized);
}
+ private static final DiscreteDomain<Integer> UNBOUNDED_THROWING_DOMAIN =
+ new DiscreteDomain<Integer>() {
+ @Override
+ public Integer next(Integer value) {
+ throw new AssertionError();
+ }
+
+ @Override
+ public Integer previous(Integer value) {
+ throw new AssertionError();
+ }
+
+ @Override
+ public long distance(Integer start, Integer end) {
+ throw new AssertionError();
+ }
+ };
+
public void testCreate_noMin() {
Range<Integer> range = Range.lessThan(0);
try {
- ContiguousSet.create(range, RangeTest.UNBOUNDED_DOMAIN);
+ ContiguousSet.create(range, UNBOUNDED_THROWING_DOMAIN);
fail();
} catch (IllegalArgumentException expected) {
}
@@ -167,7 +187,7 @@ public class ContiguousSetTest extends TestCase {
public void testCreate_noMax() {
Range<Integer> range = Range.greaterThan(0);
try {
- ContiguousSet.create(range, RangeTest.UNBOUNDED_DOMAIN);
+ ContiguousSet.create(range, UNBOUNDED_THROWING_DOMAIN);
fail();
} catch (IllegalArgumentException expected) {
}
diff --git a/guava-tests/test/com/google/common/collect/Derived.java b/guava-tests/test/com/google/common/collect/Derived.java
new file mode 100644
index 000000000..995c42be8
--- /dev/null
+++ b/guava-tests/test/com/google/common/collect/Derived.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.collect;
+
+import com.google.common.annotations.GwtCompatible;
+
+/** Simple derived class to verify that we handle generics correctly. */
+@GwtCompatible
+class Derived extends Base {
+ public Derived(String s) {
+ super(s);
+ }
+
+ private static final long serialVersionUID = 0;
+}
diff --git a/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java b/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java
index b9e15fd9c..bd7fa8b64 100644
--- a/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java
+++ b/guava-tests/test/com/google/common/collect/DiscreteDomainTest.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import static com.google.common.testing.SerializableTester.reserializeAndAssert;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import java.math.BigInteger;
@@ -43,16 +44,10 @@ public class DiscreteDomainTest extends TestCase {
}
public void testIntegersOffsetExceptions() {
- try {
- DiscreteDomain.integers().offset(0, -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- DiscreteDomain.integers().offset(Integer.MAX_VALUE, 1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> DiscreteDomain.integers().offset(0, -1));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> DiscreteDomain.integers().offset(Integer.MAX_VALUE, 1));
}
public void testLongsOffset() {
@@ -61,16 +56,9 @@ public class DiscreteDomainTest extends TestCase {
}
public void testLongsOffsetExceptions() {
- try {
- DiscreteDomain.longs().offset(0L, -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- DiscreteDomain.longs().offset(Long.MAX_VALUE, 1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> DiscreteDomain.longs().offset(0L, -1));
+ assertThrows(
+ IllegalArgumentException.class, () -> DiscreteDomain.longs().offset(Long.MAX_VALUE, 1));
}
public void testBigIntegersOffset() {
@@ -81,24 +69,15 @@ public class DiscreteDomainTest extends TestCase {
}
public void testBigIntegersOffsetExceptions() {
- try {
- DiscreteDomain.bigIntegers().offset(BigInteger.ZERO, -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> DiscreteDomain.bigIntegers().offset(BigInteger.ZERO, -1));
}
public void testCustomOffsetExceptions() {
- try {
- new MyIntegerDomain().offset(0, -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- new MyIntegerDomain().offset(Integer.MAX_VALUE, 1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> new MyIntegerDomain().offset(0, -1));
+ assertThrows(
+ IllegalArgumentException.class, () -> new MyIntegerDomain().offset(Integer.MAX_VALUE, 1));
}
private static final class MyIntegerDomain extends DiscreteDomain<Integer> {
diff --git a/guava-tests/test/com/google/common/collect/FauxveridesTest.java b/guava-tests/test/com/google/common/collect/FauxveridesTest.java
index f7eda67d5..9dfac093f 100644
--- a/guava-tests/test/com/google/common/collect/FauxveridesTest.java
+++ b/guava-tests/test/com/google/common/collect/FauxveridesTest.java
@@ -21,6 +21,7 @@ import static com.google.common.collect.Sets.difference;
import static com.google.common.collect.Sets.newHashSet;
import static java.lang.reflect.Modifier.isPublic;
import static java.lang.reflect.Modifier.isStatic;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
@@ -44,26 +45,32 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* @author Chris Povirk
*/
public class FauxveridesTest extends TestCase {
+ @AndroidIncompatible // similar to ImmutableTableTest.testNullPointerInstance
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);
}
+ @AndroidIncompatible // similar to ImmutableTableTest.testNullPointerInstance
public void testImmutableSortedMap() {
doHasAllFauxveridesTest(ImmutableSortedMap.class, ImmutableMap.class);
}
+ @AndroidIncompatible // similar to ImmutableTableTest.testNullPointerInstance
public void testImmutableSortedSet() {
doHasAllFauxveridesTest(ImmutableSortedSet.class, ImmutableSet.class);
}
+ @AndroidIncompatible // similar to ImmutableTableTest.testNullPointerInstance
public void testImmutableSortedMultiset() {
doHasAllFauxveridesTest(ImmutableSortedMultiset.class, ImmutableMultiset.class);
}
@@ -78,31 +85,19 @@ public class FauxveridesTest extends TestCase {
Map<Object, Object> original =
ImmutableMap.of(new Object(), new Object(), new Object(), new Object());
- try {
- ImmutableSortedMap.copyOf(original);
- fail();
- } catch (ClassCastException expected) {
- }
+ assertThrows(ClassCastException.class, () -> ImmutableSortedMap.copyOf(original));
}
public void testImmutableSortedSetCopyOfIterable() {
Set<Object> original = ImmutableSet.of(new Object(), new Object());
- try {
- ImmutableSortedSet.copyOf(original);
- fail();
- } catch (ClassCastException expected) {
- }
+ assertThrows(ClassCastException.class, () -> ImmutableSortedSet.copyOf(original));
}
public void testImmutableSortedSetCopyOfIterator() {
Set<Object> original = ImmutableSet.of(new Object(), new Object());
- try {
- ImmutableSortedSet.copyOf(original.iterator());
- fail();
- } catch (ClassCastException expected) {
- }
+ assertThrows(ClassCastException.class, () -> ImmutableSortedSet.copyOf(original.iterator()));
}
private void doHasAllFauxveridesTest(Class<?> descendant, Class<?> ancestor) {
diff --git a/guava-tests/test/com/google/common/collect/FilteredBiMapTest.java b/guava-tests/test/com/google/common/collect/FilteredBiMapTest.java
index f575a73c4..8f5f4c6c3 100644
--- a/guava-tests/test/com/google/common/collect/FilteredBiMapTest.java
+++ b/guava-tests/test/com/google/common/collect/FilteredBiMapTest.java
@@ -19,7 +19,7 @@ package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
@GwtCompatible
-public class FilteredBiMapTest extends FilteredMapTest {
+public class FilteredBiMapTest extends AbstractFilteredMapTest {
@Override
BiMap<String, Integer> createUnfiltered() {
return HashBiMap.create();
diff --git a/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java b/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java
index 95bfac5bc..174176c45 100644
--- a/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java
+++ b/guava-tests/test/com/google/common/collect/FilteredCollectionsTestUtil.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
@@ -171,11 +172,7 @@ public final class FilteredCollectionsTestUtil {
C filtered = filter(createUnfiltered(contents), EVEN);
C filteredToModify = filter(createUnfiltered(contents), EVEN);
- try {
- filteredToModify.addAll(toAdd);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> filteredToModify.addAll(toAdd));
assertThat(filteredToModify).containsExactlyElementsIn(filtered);
}
@@ -187,17 +184,9 @@ public final class FilteredCollectionsTestUtil {
C filtered1 = filter(unfiltered, EVEN);
C filtered2 = filter(filtered1, PRIME_DIGIT);
- try {
- filtered2.add(4);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> filtered2.add(4));
- try {
- filtered2.add(3);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> filtered2.add(3));
filtered2.add(2);
}
diff --git a/guava-tests/test/com/google/common/collect/FilteredMapTest.java b/guava-tests/test/com/google/common/collect/FilteredMapTest.java
index 159fec9a9..da080fbe3 100644
--- a/guava-tests/test/com/google/common/collect/FilteredMapTest.java
+++ b/guava-tests/test/com/google/common/collect/FilteredMapTest.java
@@ -16,196 +16,14 @@
package com.google.common.collect;
-import static com.google.common.collect.MapsTest.CORRECT_LENGTH;
-import static com.google.common.collect.MapsTest.EVEN;
-import static com.google.common.collect.MapsTest.NOT_LENGTH_3;
import com.google.common.annotations.GwtCompatible;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
import java.util.Map;
-import java.util.Map.Entry;
-import junit.framework.TestCase;
@GwtCompatible
-public class FilteredMapTest extends TestCase {
+public class FilteredMapTest extends AbstractFilteredMapTest {
+ @Override
Map<String, Integer> createUnfiltered() {
return Maps.newHashMap();
}
-
- public void testFilteredKeysIllegalPut() {
- Map<String, Integer> unfiltered = createUnfiltered();
- Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3);
- filtered.put("a", 1);
- filtered.put("b", 2);
- assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered);
-
- try {
- filtered.put("yyy", 3);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- }
-
- public void testFilteredKeysIllegalPutAll() {
- Map<String, Integer> unfiltered = createUnfiltered();
- Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3);
- filtered.put("a", 1);
- filtered.put("b", 2);
- assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered);
-
- try {
- filtered.putAll(ImmutableMap.of("c", 3, "zzz", 4, "b", 5));
- fail();
- } catch (IllegalArgumentException expected) {
- }
-
- assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered);
- }
-
- public void testFilteredKeysFilteredReflectsBackingChanges() {
- Map<String, Integer> unfiltered = createUnfiltered();
- Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3);
- unfiltered.put("two", 2);
- unfiltered.put("three", 3);
- unfiltered.put("four", 4);
- assertEquals(ImmutableMap.of("two", 2, "three", 3, "four", 4), unfiltered);
- assertEquals(ImmutableMap.of("three", 3, "four", 4), filtered);
-
- unfiltered.remove("three");
- assertEquals(ImmutableMap.of("two", 2, "four", 4), unfiltered);
- assertEquals(ImmutableMap.of("four", 4), filtered);
-
- unfiltered.clear();
- assertEquals(ImmutableMap.of(), unfiltered);
- assertEquals(ImmutableMap.of(), filtered);
- }
-
- public void testFilteredValuesIllegalPut() {
- Map<String, Integer> unfiltered = createUnfiltered();
- Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
- filtered.put("a", 2);
- unfiltered.put("b", 4);
- unfiltered.put("c", 5);
- assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
-
- try {
- filtered.put("yyy", 3);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
- }
-
- public void testFilteredValuesIllegalPutAll() {
- Map<String, Integer> unfiltered = createUnfiltered();
- Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
- filtered.put("a", 2);
- unfiltered.put("b", 4);
- unfiltered.put("c", 5);
- assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
-
- try {
- filtered.putAll(ImmutableMap.of("c", 4, "zzz", 5, "b", 6));
- fail();
- } catch (IllegalArgumentException expected) {
- }
- assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
- }
-
- public void testFilteredValuesIllegalSetValue() {
- Map<String, Integer> unfiltered = createUnfiltered();
- Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
- filtered.put("a", 2);
- filtered.put("b", 4);
- assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
-
- Entry<String, Integer> entry = filtered.entrySet().iterator().next();
- try {
- entry.setValue(5);
- fail();
- } catch (IllegalArgumentException expected) {
- }
-
- assertEquals(ImmutableMap.of("a", 2, "b", 4), filtered);
- }
-
- public void testFilteredValuesClear() {
- Map<String, Integer> unfiltered = createUnfiltered();
- unfiltered.put("one", 1);
- unfiltered.put("two", 2);
- unfiltered.put("three", 3);
- unfiltered.put("four", 4);
- Map<String, Integer> filtered = Maps.filterValues(unfiltered, EVEN);
- assertEquals(ImmutableMap.of("one", 1, "two", 2, "three", 3, "four", 4), unfiltered);
- assertEquals(ImmutableMap.of("two", 2, "four", 4), filtered);
-
- filtered.clear();
- assertEquals(ImmutableMap.of("one", 1, "three", 3), unfiltered);
- assertTrue(filtered.isEmpty());
- }
-
- public void testFilteredEntriesIllegalPut() {
- Map<String, Integer> unfiltered = createUnfiltered();
- unfiltered.put("cat", 3);
- unfiltered.put("dog", 2);
- unfiltered.put("horse", 5);
- Map<String, Integer> filtered = Maps.filterEntries(unfiltered, CORRECT_LENGTH);
- assertEquals(ImmutableMap.of("cat", 3, "horse", 5), filtered);
-
- filtered.put("chicken", 7);
- assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
-
- try {
- filtered.put("cow", 7);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
- }
-
- public void testFilteredEntriesIllegalPutAll() {
- Map<String, Integer> unfiltered = createUnfiltered();
- unfiltered.put("cat", 3);
- unfiltered.put("dog", 2);
- unfiltered.put("horse", 5);
- Map<String, Integer> filtered = Maps.filterEntries(unfiltered, CORRECT_LENGTH);
- assertEquals(ImmutableMap.of("cat", 3, "horse", 5), filtered);
-
- filtered.put("chicken", 7);
- assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
-
- try {
- filtered.putAll(ImmutableMap.of("sheep", 5, "cow", 7));
- fail();
- } catch (IllegalArgumentException expected) {
- }
- assertEquals(ImmutableMap.of("cat", 3, "horse", 5, "chicken", 7), filtered);
- }
-
- public void testFilteredEntriesObjectPredicate() {
- Map<String, Integer> unfiltered = createUnfiltered();
- unfiltered.put("cat", 3);
- unfiltered.put("dog", 2);
- unfiltered.put("horse", 5);
- Predicate<Object> predicate = Predicates.alwaysFalse();
- Map<String, Integer> filtered = Maps.filterEntries(unfiltered, predicate);
- assertTrue(filtered.isEmpty());
- }
-
- public void testFilteredEntriesWildCardEntryPredicate() {
- Map<String, Integer> unfiltered = createUnfiltered();
- unfiltered.put("cat", 3);
- unfiltered.put("dog", 2);
- unfiltered.put("horse", 5);
- Predicate<Entry<?, ?>> predicate =
- new Predicate<Entry<?, ?>>() {
- @Override
- public boolean apply(Entry<?, ?> input) {
- return "cat".equals(input.getKey()) || Integer.valueOf(2) == input.getValue();
- }
- };
- Map<String, Integer> filtered = Maps.filterEntries(unfiltered, predicate);
- assertEquals(ImmutableMap.of("cat", 3, "dog", 2), filtered);
- }
}
diff --git a/guava-tests/test/com/google/common/collect/FilteredSortedMapTest.java b/guava-tests/test/com/google/common/collect/FilteredSortedMapTest.java
index 23b3f2a99..0a08da3d8 100644
--- a/guava-tests/test/com/google/common/collect/FilteredSortedMapTest.java
+++ b/guava-tests/test/com/google/common/collect/FilteredSortedMapTest.java
@@ -16,13 +16,11 @@
package com.google.common.collect;
-import static com.google.common.collect.MapsTest.CORRECT_LENGTH;
-
import com.google.common.annotations.GwtCompatible;
import java.util.SortedMap;
@GwtCompatible
-public class FilteredSortedMapTest extends FilteredMapTest {
+public class FilteredSortedMapTest extends AbstractFilteredMapTest {
@Override
SortedMap<String, Integer> createUnfiltered() {
return Maps.newTreeMap();
diff --git a/guava-tests/test/com/google/common/collect/ImmutableBiMapFloodingTest.java b/guava-tests/test/com/google/common/collect/ImmutableBiMapFloodingTest.java
index 722e3189a..53ecdd47f 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableBiMapFloodingTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableBiMapFloodingTest.java
@@ -16,7 +16,7 @@
package com.google.common.collect;
-import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.EnumSet;
import java.util.LinkedHashMap;
@@ -25,7 +25,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Stream;
-@GwtCompatible
+@GwtIncompatible
public class ImmutableBiMapFloodingTest extends AbstractHashFloodingTest<BiMap<Object, Object>> {
public ImmutableBiMapFloodingTest() {
super(
diff --git a/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java
index b9696301f..3ea288d6e 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableClassToInstanceMapTest.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import static com.google.common.collect.Maps.immutableEntry;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.testing.MapTestSuiteBuilder;
import com.google.common.collect.testing.SampleElements;
@@ -116,19 +117,11 @@ public class ImmutableClassToInstanceMapTest extends TestCase {
public void testCopyOf_map_nulls() {
Map<Class<? extends Number>, Number> nullKey = Collections.singletonMap(null, (Number) 1.0);
- try {
- ImmutableClassToInstanceMap.copyOf(nullKey);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ImmutableClassToInstanceMap.copyOf(nullKey));
Map<? extends Class<? extends Number>, Number> nullValue =
Collections.singletonMap(Number.class, null);
- try {
- ImmutableClassToInstanceMap.copyOf(nullValue);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ImmutableClassToInstanceMap.copyOf(nullValue));
}
public void testCopyOf_imap_empty() {
diff --git a/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java b/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java
index 4e0bdda13..1b1252c22 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableListMultimapTest.java
@@ -30,6 +30,7 @@ import com.google.common.collect.testing.features.CollectionSize;
import com.google.common.collect.testing.google.ListMultimapTestSuiteBuilder;
import com.google.common.collect.testing.google.TestStringListMultimapGenerator;
import com.google.common.collect.testing.google.UnmodifiableCollectionTests;
+import com.google.common.primitives.Chars;
import com.google.common.testing.CollectorTester;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
@@ -413,7 +414,7 @@ public class ImmutableListMultimapTest extends TestCase {
public void testFlatteningToImmutableListMultimap() {
Collector<String, ?, ImmutableListMultimap<Character, Character>> collector =
ImmutableListMultimap.flatteningToImmutableListMultimap(
- str -> str.charAt(0), str -> str.substring(1).chars().mapToObj(c -> (char) c));
+ str -> str.charAt(0), str -> Chars.asList(str.substring(1).toCharArray()).stream());
BiPredicate<Multimap<?, ?>, Multimap<?, ?>> equivalence =
Equivalence.equals()
.onResultOf((Multimap<?, ?> mm) -> ImmutableList.copyOf(mm.asMap().entrySet()))
@@ -604,6 +605,7 @@ public class ImmutableListMultimapTest extends TestCase {
}
@GwtIncompatible // reflection
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableListMultimap.class);
diff --git a/guava-tests/test/com/google/common/collect/ImmutableListTest.java b/guava-tests/test/com/google/common/collect/ImmutableListTest.java
index 99b31d694..c881e0bf4 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableListTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableListTest.java
@@ -460,6 +460,7 @@ public class ImmutableListTest extends TestCase {
// Basic tests
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableList.class);
diff --git a/guava-tests/test/com/google/common/collect/ImmutableMapFloodingTest.java b/guava-tests/test/com/google/common/collect/ImmutableMapFloodingTest.java
index cdf85e3af..4d6d7b6f7 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableMapFloodingTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableMapFloodingTest.java
@@ -16,13 +16,13 @@
package com.google.common.collect;
-import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-@GwtCompatible
+@GwtIncompatible
public class ImmutableMapFloodingTest extends AbstractHashFloodingTest<Map<Object, Object>> {
public ImmutableMapFloodingTest() {
super(
diff --git a/guava-tests/test/com/google/common/collect/ImmutableMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableMapTest.java
index 3e4390bd4..ce462ec82 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableMapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableMapTest.java
@@ -904,6 +904,7 @@ public class ImmutableMapTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableMap.class);
diff --git a/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java b/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
index ac09593ba..bf32922e1 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableMultimapTest.java
@@ -128,6 +128,7 @@ public class ImmutableMultimapTest extends TestCase {
}
@GwtIncompatible // reflection
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableMultimap.class);
diff --git a/guava-tests/test/com/google/common/collect/ImmutableMultisetFloodingTest.java b/guava-tests/test/com/google/common/collect/ImmutableMultisetFloodingTest.java
index 551637987..0076fdfe1 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableMultisetFloodingTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableMultisetFloodingTest.java
@@ -16,12 +16,12 @@
package com.google.common.collect;
-import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Arrays;
import java.util.List;
-@GwtCompatible
+@GwtIncompatible
public class ImmutableMultisetFloodingTest extends AbstractHashFloodingTest<Multiset<Object>> {
public ImmutableMultisetFloodingTest() {
super(
diff --git a/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java b/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java
index 719cfc8c1..2e0b1d23b 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableMultisetTest.java
@@ -578,6 +578,7 @@ public class ImmutableMultisetTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableMultiset.class);
diff --git a/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
index e5caa6245..fb47bce56 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
@@ -15,6 +15,7 @@
package com.google.common.collect;
import static com.google.common.collect.BoundType.OPEN;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.testing.CollectorTester;
@@ -65,18 +66,10 @@ public class ImmutableRangeMapTest extends TestCase {
public void testBuilderRejectsEmptyRanges() {
for (int i = MIN_BOUND; i <= MAX_BOUND; i++) {
+ final int ii = i;
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
- try {
- builder.put(Range.closedOpen(i, i), 1);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- // success
- }
- try {
- builder.put(Range.openClosed(i, i), 1);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.put(Range.closedOpen(ii, ii), 1));
+ assertThrows(IllegalArgumentException.class, () -> builder.put(Range.openClosed(ii, ii), 1));
}
}
@@ -120,11 +113,7 @@ public class ImmutableRangeMapTest extends TestCase {
}
public void testSpanEmpty() {
- try {
- ImmutableRangeMap.of().span();
- fail("Expected NoSuchElementException");
- } catch (NoSuchElementException expected) {
- }
+ assertThrows(NoSuchElementException.class, () -> ImmutableRangeMap.of().span());
}
public void testSpanSingleRange() {
diff --git a/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java b/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
index 1fe56c7cc..378841cbd 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableRangeSetTest.java
@@ -15,6 +15,7 @@
package com.google.common.collect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.testing.NavigableSetTestSuiteBuilder;
@@ -321,12 +322,7 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
.add(Range.closedOpen(1, 3))
.build();
- try {
- rangeSet.add(Range.open(3, 4));
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(UnsupportedOperationException.class, () -> rangeSet.add(Range.open(3, 4)));
}
@SuppressWarnings("DoNotCall")
@@ -337,12 +333,9 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
.add(Range.closedOpen(1, 3))
.build();
- try {
- rangeSet.addAll(ImmutableRangeSet.<Integer>of());
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> rangeSet.addAll(ImmutableRangeSet.<Integer>of()));
}
@SuppressWarnings("DoNotCall")
@@ -353,12 +346,7 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
.add(Range.closedOpen(1, 3))
.build();
- try {
- rangeSet.remove(Range.closed(6, 7));
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(UnsupportedOperationException.class, () -> rangeSet.remove(Range.closed(6, 7)));
}
@SuppressWarnings("DoNotCall")
@@ -369,19 +357,13 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
.add(Range.closedOpen(1, 3))
.build();
- try {
- rangeSet.removeAll(ImmutableRangeSet.<Integer>of());
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> rangeSet.removeAll(ImmutableRangeSet.<Integer>of()));
- try {
- rangeSet.removeAll(ImmutableRangeSet.of(Range.closed(6, 8)));
- fail();
- } catch (UnsupportedOperationException expected) {
- // success
- }
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> rangeSet.removeAll(ImmutableRangeSet.of(Range.closed(6, 8))));
}
@AndroidIncompatible // slow
@@ -429,11 +411,11 @@ public class ImmutableRangeSetTest extends AbstractRangeSetTest {
}
if (anyOverlaps) {
- try {
- RangeSet<Integer> copy = ImmutableRangeSet.copyOf(subset);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ RangeSet<Integer> copy = ImmutableRangeSet.copyOf(subset);
+ });
} else {
RangeSet<Integer> copy = ImmutableRangeSet.copyOf(subset);
assertEquals(mutable, copy);
diff --git a/guava-tests/test/com/google/common/collect/ImmutableSetFloodingTest.java b/guava-tests/test/com/google/common/collect/ImmutableSetFloodingTest.java
index c32a160c5..85fa4d0fb 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableSetFloodingTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableSetFloodingTest.java
@@ -16,12 +16,12 @@
package com.google.common.collect;
-import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
-@GwtCompatible
+@GwtIncompatible
public class ImmutableSetFloodingTest extends AbstractHashFloodingTest<Set<Object>> {
public ImmutableSetFloodingTest() {
super(
diff --git a/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java b/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java
index 842ba9286..b5eeb58bc 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableSetMultimapTest.java
@@ -30,6 +30,7 @@ import com.google.common.collect.testing.features.CollectionSize;
import com.google.common.collect.testing.google.SetMultimapTestSuiteBuilder;
import com.google.common.collect.testing.google.TestStringSetMultimapGenerator;
import com.google.common.collect.testing.google.UnmodifiableCollectionTests;
+import com.google.common.primitives.Chars;
import com.google.common.testing.CollectorTester;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
@@ -428,7 +429,7 @@ public class ImmutableSetMultimapTest extends TestCase {
public void testFlatteningToImmutableSetMultimap() {
Collector<String, ?, ImmutableSetMultimap<Character, Character>> collector =
ImmutableSetMultimap.flatteningToImmutableSetMultimap(
- str -> str.charAt(0), str -> str.substring(1).chars().mapToObj(c -> (char) c));
+ str -> str.charAt(0), str -> Chars.asList(str.substring(1).toCharArray()).stream());
BiPredicate<Multimap<?, ?>, Multimap<?, ?>> equivalence =
Equivalence.equals()
.onResultOf((Multimap<?, ?> mm) -> ImmutableList.copyOf(mm.asMap().entrySet()))
@@ -627,6 +628,7 @@ public class ImmutableSetMultimapTest extends TestCase {
}
@GwtIncompatible // reflection
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNulls() throws Exception {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableSetMultimap.class);
diff --git a/guava-tests/test/com/google/common/collect/ImmutableSetTest.java b/guava-tests/test/com/google/common/collect/ImmutableSetTest.java
index 4f76cc888..e5fb0ecb2 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableSetTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableSetTest.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -261,11 +262,7 @@ public class ImmutableSetTest extends AbstractImmutableSetTest {
assertEquals(1 << 30, ImmutableSet.chooseTableSize((1 << 30) - 1));
// Now we've gone too far
- try {
- ImmutableSet.chooseTableSize(1 << 30);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> ImmutableSet.chooseTableSize(1 << 30));
}
@GwtIncompatible // RegularImmutableSet.table not in emulation
diff --git a/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java
index 9eb466cd4..bc6c014d4 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableSortedMapTest.java
@@ -685,6 +685,7 @@ public class ImmutableSortedMapTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicStaticMethods(ImmutableSortedMap.class);
diff --git a/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java b/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java
index 0fee1cda3..95bfc5ce8 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableSortedMultisetTest.java
@@ -17,6 +17,7 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.truth.Truth.assertThat;
import static java.util.Arrays.asList;
+import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -199,11 +200,7 @@ public class ImmutableSortedMultisetTest extends TestCase {
public void testCreation_arrayContainingOnlyNull() {
String[] array = new String[] {null};
- try {
- ImmutableSortedMultiset.copyOf(array);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ImmutableSortedMultiset.copyOf(array));
}
public void testCopyOf_collection_empty() {
@@ -227,11 +224,7 @@ public class ImmutableSortedMultisetTest extends TestCase {
public void testCopyOf_collectionContainingNull() {
Collection<String> c = MinimalCollection.of("a", null, "b");
- try {
- ImmutableSortedMultiset.copyOf(c);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ImmutableSortedMultiset.copyOf(c));
}
public void testCopyOf_multiset_empty() {
@@ -254,11 +247,7 @@ public class ImmutableSortedMultisetTest extends TestCase {
public void testCopyOf_multisetContainingNull() {
Multiset<String> c = HashMultiset.create(asList("a", null, "b"));
- try {
- ImmutableSortedMultiset.copyOf(c);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ImmutableSortedMultiset.copyOf(c));
}
public void testCopyOf_iterator_empty() {
@@ -281,11 +270,7 @@ public class ImmutableSortedMultisetTest extends TestCase {
public void testCopyOf_iteratorContainingNull() {
Iterator<String> iterator = asList("a", null, "b").iterator();
- try {
- ImmutableSortedMultiset.copyOf(iterator);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ImmutableSortedMultiset.copyOf(iterator));
}
private static class CountingIterable implements Iterable<String> {
@@ -384,73 +369,47 @@ public class ImmutableSortedMultisetTest extends TestCase {
public void testBuilderAddHandlesNullsCorrectly() {
ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
- try {
- builder.add((String) null);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> builder.add((String) null));
}
public void testBuilderAddAllHandlesNullsCorrectly() {
- ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
- try {
- builder.addAll((Collection<String>) null);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
+ {
+ ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
+ assertThrows(NullPointerException.class, () -> builder.addAll((Collection<String>) null));
}
- builder = ImmutableSortedMultiset.naturalOrder();
- List<String> listWithNulls = asList("a", null, "b");
- try {
- builder.addAll(listWithNulls);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
+ {
+ ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
+ List<String> listWithNulls = asList("a", null, "b");
+ assertThrows(NullPointerException.class, () -> builder.addAll(listWithNulls));
}
- builder = ImmutableSortedMultiset.naturalOrder();
- Multiset<String> multisetWithNull = LinkedHashMultiset.create(asList("a", null, "b"));
- try {
- builder.addAll(multisetWithNull);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
+ {
+ ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
+ Multiset<String> multisetWithNull = LinkedHashMultiset.create(asList("a", null, "b"));
+ assertThrows(NullPointerException.class, () -> builder.addAll(multisetWithNull));
}
}
public void testBuilderAddCopiesHandlesNullsCorrectly() {
ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
- try {
- builder.addCopies(null, 2);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> builder.addCopies(null, 2));
}
public void testBuilderAddCopiesIllegal() {
ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
- try {
- builder.addCopies("a", -2);
- fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.addCopies("a", -2));
}
public void testBuilderSetCountHandlesNullsCorrectly() {
ImmutableSortedMultiset.Builder<String> builder =
new ImmutableSortedMultiset.Builder<>(Ordering.natural().nullsFirst());
- try {
- builder.setCount(null, 2);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> builder.setCount(null, 2));
}
public void testBuilderSetCountIllegal() {
ImmutableSortedMultiset.Builder<String> builder = ImmutableSortedMultiset.naturalOrder();
- try {
- builder.setCount("a", -2);
- fail("expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.setCount("a", -2));
}
public void testToImmutableSortedMultiset() {
@@ -503,6 +462,7 @@ public class ImmutableSortedMultisetTest extends TestCase {
"C");
}
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
new NullPointerTester().testAllPublicStaticMethods(ImmutableSortedMultiset.class);
}
diff --git a/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java b/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java
index 9ab3bb867..3b66aa90d 100644
--- a/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java
+++ b/guava-tests/test/com/google/common/collect/ImmutableSortedSetTest.java
@@ -235,6 +235,7 @@ public class ImmutableSortedSetTest extends AbstractImmutableSetTest {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
new NullPointerTester().testAllPublicStaticMethods(ImmutableSortedSet.class);
}
diff --git a/guava-tests/test/com/google/common/collect/InternersTest.java b/guava-tests/test/com/google/common/collect/InternersTest.java
index cfa14b892..51cf835ea 100644
--- a/guava-tests/test/com/google/common/collect/InternersTest.java
+++ b/guava-tests/test/com/google/common/collect/InternersTest.java
@@ -16,6 +16,8 @@
package com.google.common.collect;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.base.Function;
import com.google.common.collect.Interners.InternerImpl;
import com.google.common.collect.MapMakerInternalMap.Strength;
@@ -42,11 +44,7 @@ public class InternersTest extends TestCase {
public void testStrong_null() {
Interner<String> pool = Interners.newStrongInterner();
- try {
- pool.intern(null);
- fail();
- } catch (NullPointerException ok) {
- }
+ assertThrows(NullPointerException.class, () -> pool.intern(null));
}
public void testStrong_builder() {
@@ -68,11 +66,7 @@ public class InternersTest extends TestCase {
public void testWeak_null() {
Interner<String> pool = Interners.newWeakInterner();
- try {
- pool.intern(null);
- fail();
- } catch (NullPointerException ok) {
- }
+ assertThrows(NullPointerException.class, () -> pool.intern(null));
}
public void testWeak_builder() {
@@ -116,19 +110,11 @@ public class InternersTest extends TestCase {
public void testConcurrencyLevel_Zero() {
Interners.InternerBuilder builder = Interners.newBuilder();
- try {
- builder.concurrencyLevel(0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.concurrencyLevel(0));
}
public void testConcurrencyLevel_Negative() {
Interners.InternerBuilder builder = Interners.newBuilder();
- try {
- builder.concurrencyLevel(-42);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> builder.concurrencyLevel(-42));
}
}
diff --git a/guava-tests/test/com/google/common/collect/IterablesTest.java b/guava-tests/test/com/google/common/collect/IterablesTest.java
index 036cdaf09..24f3d5da7 100644
--- a/guava-tests/test/com/google/common/collect/IterablesTest.java
+++ b/guava-tests/test/com/google/common/collect/IterablesTest.java
@@ -1433,6 +1433,7 @@ public class IterablesTest extends TestCase {
}
@GwtIncompatible // reflection
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testIterables_nullCheck() throws Exception {
new ClassSanityTester()
.forAllPublicStaticMethods(Iterables.class)
diff --git a/guava-tests/test/com/google/common/collect/IteratorsTest.java b/guava-tests/test/com/google/common/collect/IteratorsTest.java
index e71c8bd51..96ae2417e 100644
--- a/guava-tests/test/com/google/common/collect/IteratorsTest.java
+++ b/guava-tests/test/com/google/common/collect/IteratorsTest.java
@@ -1119,6 +1119,11 @@ public class IteratorsTest extends TestCase {
fail();
} catch (NoSuchElementException expected) {
}
+ try {
+ Iterators.forArrayWithPosition(array, 1);
+ fail();
+ } catch (IndexOutOfBoundsException expected) {
+ }
}
@SuppressWarnings("DoNotCall")
@@ -1142,33 +1147,26 @@ public class IteratorsTest extends TestCase {
}
}
- public void testForArrayOffset() {
- String[] array = {"foo", "bar", "cat", "dog"};
- Iterator<String> iterator = Iterators.forArray(array, 1, 2, 0);
+ public void testForArrayWithPosition() {
+ String[] array = {"foo", "bar", "cat"};
+ Iterator<String> iterator = Iterators.forArrayWithPosition(array, 1);
assertTrue(iterator.hasNext());
assertEquals("bar", iterator.next());
assertTrue(iterator.hasNext());
assertEquals("cat", iterator.next());
assertFalse(iterator.hasNext());
- try {
- Iterators.forArray(array, 2, 3, 0);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
}
- public void testForArrayLength0() {
+ public void testForArrayLengthWithPositionBoundaryCases() {
String[] array = {"foo", "bar"};
- assertFalse(Iterators.forArray(array, 0, 0, 0).hasNext());
- assertFalse(Iterators.forArray(array, 1, 0, 0).hasNext());
- assertFalse(Iterators.forArray(array, 2, 0, 0).hasNext());
+ assertFalse(Iterators.forArrayWithPosition(array, 2).hasNext());
try {
- Iterators.forArray(array, -1, 0, 0);
+ Iterators.forArrayWithPosition(array, -1);
fail();
} catch (IndexOutOfBoundsException expected) {
}
try {
- Iterators.forArray(array, 3, 0, 0);
+ Iterators.forArrayWithPosition(array, 3);
fail();
} catch (IndexOutOfBoundsException expected) {
}
@@ -1185,16 +1183,10 @@ public class IteratorsTest extends TestCase {
}.test();
}
- @GwtIncompatible // unreasonably slow
- public void testForArrayWithOffsetUsingTester() {
- new IteratorTester<Integer>(
- 6, UNMODIFIABLE, asList(1, 2, 3), IteratorTester.KnownOrder.KNOWN_ORDER) {
- @Override
- protected Iterator<Integer> newTargetIterator() {
- return Iterators.forArray(new Integer[] {0, 1, 2, 3, 4}, 1, 3, 0);
- }
- }.test();
- }
+ /*
+ * TODO(cpovirk): Test forArray with ListIteratorTester (not just IteratorTester), including with
+ * a start position other than 0.
+ */
public void testForEnumerationEmpty() {
Enumeration<Integer> enumer = enumerate();
diff --git a/guava-tests/test/com/google/common/collect/ListsImplTest.java b/guava-tests/test/com/google/common/collect/ListsImplTest.java
index 237bcc2c9..73071de12 100644
--- a/guava-tests/test/com/google/common/collect/ListsImplTest.java
+++ b/guava-tests/test/com/google/common/collect/ListsImplTest.java
@@ -99,11 +99,13 @@ public class ListsImplTest extends TestCase {
return example == null ? new ImmutableListExample("test") : example;
}
+ @GwtIncompatible // not used under GWT, and super.getName() is not available under J2CL
@Override
public String getName() {
return example == null ? super.getName() : buildTestName();
}
+ @GwtIncompatible // not used under GWT, and super.getName() is not available under J2CL
private String buildTestName() {
return super.getName() + ":" + example.getName();
}
diff --git a/guava-tests/test/com/google/common/collect/MapsSortedTransformValuesTest.java b/guava-tests/test/com/google/common/collect/MapsSortedTransformValuesTest.java
index 98bbde501..6bf066f51 100644
--- a/guava-tests/test/com/google/common/collect/MapsSortedTransformValuesTest.java
+++ b/guava-tests/test/com/google/common/collect/MapsSortedTransformValuesTest.java
@@ -27,8 +27,7 @@ import java.util.SortedMap;
* @author Louis Wasserman
*/
@GwtCompatible
-public class MapsSortedTransformValuesTest extends MapsTransformValuesTest {
-
+public class MapsSortedTransformValuesTest extends AbstractMapsTransformValuesTest {
@Override
protected SortedMap<String, String> makeEmptyMap() {
return Maps.transformValues(Maps.<String, String>newTreeMap(), Functions.<String>identity());
diff --git a/guava-tests/test/com/google/common/collect/MapsTest.java b/guava-tests/test/com/google/common/collect/MapsTest.java
index 6c4800550..f29151e4b 100644
--- a/guava-tests/test/com/google/common/collect/MapsTest.java
+++ b/guava-tests/test/com/google/common/collect/MapsTest.java
@@ -30,10 +30,8 @@ import com.google.common.base.Converter;
import com.google.common.base.Equivalence;
import com.google.common.base.Function;
import com.google.common.base.Functions;
-import com.google.common.base.Predicate;
import com.google.common.collect.Maps.EntryTransformer;
import com.google.common.collect.Maps.ValueDifferenceImpl;
-import com.google.common.collect.SetsTest.Derived;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
import com.google.common.testing.SerializableTester;
@@ -62,7 +60,6 @@ import java.util.SortedSet;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentMap;
import junit.framework.TestCase;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Unit test for {@code Maps}.
@@ -385,6 +382,7 @@ public class MapsTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointerExceptions() {
new NullPointerTester().testAllPublicStaticMethods(Maps.class);
}
@@ -1371,37 +1369,7 @@ public class MapsTest extends TestCase {
assertEquals(ImmutableSet.of(1, 2, 3), sync.inverse().keySet());
}
- static final Predicate<@Nullable String> NOT_LENGTH_3 =
- new Predicate<@Nullable String>() {
- @Override
- public boolean apply(@Nullable String input) {
- return input == null || input.length() != 3;
- }
- };
-
- static final Predicate<@Nullable Integer> EVEN =
- new Predicate<@Nullable Integer>() {
- @Override
- public boolean apply(@Nullable Integer input) {
- return input == null || input % 2 == 0;
- }
- };
-
- static final Predicate<Entry<String, Integer>> CORRECT_LENGTH =
- new Predicate<Entry<String, Integer>>() {
- @Override
- public boolean apply(Entry<String, Integer> input) {
- return input.getKey().length() == input.getValue();
- }
- };
-
- static final Function<Integer, Double> SQRT_FUNCTION =
- new Function<Integer, Double>() {
- @Override
- public Double apply(Integer in) {
- return Math.sqrt(in);
- }
- };
+ private static final Function<Integer, Double> SQRT_FUNCTION = in -> Math.sqrt(in);
public void testTransformValues() {
Map<String, Integer> map = ImmutableMap.of("a", 4, "b", 9);
diff --git a/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java b/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java
index e35aa3647..6c6bca3dd 100644
--- a/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java
+++ b/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java
@@ -19,45 +19,15 @@ package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.base.Function;
import com.google.common.base.Functions;
-import com.google.common.collect.testing.MapInterfaceTest;
-import java.util.Collection;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import org.checkerframework.checker.nullness.qual.Nullable;
/**
- * Tests for {@link Maps#transformValues}.
+ * Tests for {@link Maps#transformValues(Map, Function)}.
*
* @author Isaac Shum
*/
@GwtCompatible
-public class MapsTransformValuesTest extends MapInterfaceTest<String, String> {
-
- /**
- * Constructor that assigns {@code supportsIteratorRemove} the same value as {@code
- * supportsRemove}.
- */
- protected MapsTransformValuesTest(
- boolean allowsNullKeys,
- boolean allowsNullValues,
- boolean supportsPut,
- boolean supportsRemove,
- boolean supportsClear) {
- super(
- allowsNullKeys,
- allowsNullValues,
- supportsPut,
- supportsRemove,
- supportsClear,
- supportsRemove);
- }
-
- public MapsTransformValuesTest() {
- super(false, true, false, true, true);
- }
-
+public class MapsTransformValuesTest extends AbstractMapsTransformValuesTest {
@Override
protected Map<String, String> makeEmptyMap() {
return Maps.transformValues(Maps.<String, String>newHashMap(), Functions.<String>identity());
@@ -71,239 +41,4 @@ public class MapsTransformValuesTest extends MapInterfaceTest<String, String> {
underlying.put("c", 3);
return Maps.transformValues(underlying, Functions.toStringFunction());
}
-
- @Override
- protected String getKeyNotInPopulatedMap() throws UnsupportedOperationException {
- return "z";
- }
-
- @Override
- protected String getValueNotInPopulatedMap() throws UnsupportedOperationException {
- return "26";
- }
-
- /** Helper assertion comparing two maps */
- private void assertMapsEqual(Map<?, ?> expected, Map<?, ?> map) {
- assertEquals(expected, map);
- assertEquals(expected.hashCode(), map.hashCode());
- assertEquals(expected.entrySet(), map.entrySet());
-
- // Assert that expectedValues > mapValues and that
- // mapValues > expectedValues; i.e. that expectedValues == mapValues.
- Collection<?> expectedValues = expected.values();
- Collection<?> mapValues = map.values();
- assertEquals(expectedValues.size(), mapValues.size());
- assertTrue(expectedValues.containsAll(mapValues));
- assertTrue(mapValues.containsAll(expectedValues));
- }
-
- public void testTransformEmptyMapEquality() {
- Map<String, String> map =
- Maps.transformValues(ImmutableMap.<String, Integer>of(), Functions.toStringFunction());
- assertMapsEqual(Maps.newHashMap(), map);
- }
-
- public void testTransformSingletonMapEquality() {
- Map<String, String> map =
- Maps.transformValues(ImmutableMap.of("a", 1), Functions.toStringFunction());
- Map<String, String> expected = ImmutableMap.of("a", "1");
- assertMapsEqual(expected, map);
- assertEquals(expected.get("a"), map.get("a"));
- }
-
- public void testTransformIdentityFunctionEquality() {
- Map<String, Integer> underlying = ImmutableMap.of("a", 1);
- Map<String, Integer> map = Maps.transformValues(underlying, Functions.<Integer>identity());
- assertMapsEqual(underlying, map);
- }
-
- public void testTransformPutEntryIsUnsupported() {
- Map<String, String> map =
- Maps.transformValues(ImmutableMap.of("a", 1), Functions.toStringFunction());
- try {
- map.put("b", "2");
- fail();
- } catch (UnsupportedOperationException expected) {
- }
-
- try {
- map.putAll(ImmutableMap.of("b", "2"));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
-
- try {
- map.entrySet().iterator().next().setValue("one");
- fail();
- } catch (UnsupportedOperationException expected) {
- }
- }
-
- public void testTransformRemoveEntry() {
- Map<String, Integer> underlying = Maps.newHashMap();
- underlying.put("a", 1);
- Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction());
- assertEquals("1", map.remove("a"));
- assertNull(map.remove("b"));
- }
-
- public void testTransformEqualityOfMapsWithNullValues() {
- Map<String, String> underlying = Maps.newHashMap();
- underlying.put("a", null);
- underlying.put("b", "");
-
- Map<String, Boolean> map =
- Maps.transformValues(
- underlying,
- new Function<String, Boolean>() {
- @Override
- public Boolean apply(@Nullable String from) {
- return from == null;
- }
- });
- Map<String, Boolean> expected = ImmutableMap.of("a", true, "b", false);
- assertMapsEqual(expected, map);
- assertEquals(expected.get("a"), map.get("a"));
- assertEquals(expected.containsKey("a"), map.containsKey("a"));
- assertEquals(expected.get("b"), map.get("b"));
- assertEquals(expected.containsKey("b"), map.containsKey("b"));
- assertEquals(expected.get("c"), map.get("c"));
- assertEquals(expected.containsKey("c"), map.containsKey("c"));
- }
-
- public void testTransformReflectsUnderlyingMap() {
- Map<String, Integer> underlying = Maps.newHashMap();
- underlying.put("a", 1);
- underlying.put("b", 2);
- underlying.put("c", 3);
- Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction());
- assertEquals(underlying.size(), map.size());
-
- underlying.put("d", 4);
- assertEquals(underlying.size(), map.size());
- assertEquals("4", map.get("d"));
-
- underlying.remove("c");
- assertEquals(underlying.size(), map.size());
- assertFalse(map.containsKey("c"));
-
- underlying.clear();
- assertEquals(underlying.size(), map.size());
- }
-
- public void testTransformChangesAreReflectedInUnderlyingMap() {
- Map<String, Integer> underlying = Maps.newLinkedHashMap();
- underlying.put("a", 1);
- underlying.put("b", 2);
- underlying.put("c", 3);
- underlying.put("d", 4);
- underlying.put("e", 5);
- underlying.put("f", 6);
- underlying.put("g", 7);
- Map<String, String> map = Maps.transformValues(underlying, Functions.toStringFunction());
-
- map.remove("a");
- assertFalse(underlying.containsKey("a"));
-
- Set<String> keys = map.keySet();
- keys.remove("b");
- assertFalse(underlying.containsKey("b"));
-
- Iterator<String> keyIterator = keys.iterator();
- keyIterator.next();
- keyIterator.remove();
- assertFalse(underlying.containsKey("c"));
-
- Collection<String> values = map.values();
- values.remove("4");
- assertFalse(underlying.containsKey("d"));
-
- Iterator<String> valueIterator = values.iterator();
- valueIterator.next();
- valueIterator.remove();
- assertFalse(underlying.containsKey("e"));
-
- Set<Entry<String, String>> entries = map.entrySet();
- Entry<String, String> firstEntry = entries.iterator().next();
- entries.remove(firstEntry);
- assertFalse(underlying.containsKey("f"));
-
- Iterator<Entry<String, String>> entryIterator = entries.iterator();
- entryIterator.next();
- entryIterator.remove();
- assertFalse(underlying.containsKey("g"));
-
- assertTrue(underlying.isEmpty());
- assertTrue(map.isEmpty());
- assertTrue(keys.isEmpty());
- assertTrue(values.isEmpty());
- assertTrue(entries.isEmpty());
- }
-
- public void testTransformEquals() {
- Map<String, Integer> underlying = ImmutableMap.of("a", 0, "b", 1, "c", 2);
- Map<String, Integer> expected = Maps.transformValues(underlying, Functions.<Integer>identity());
-
- assertMapsEqual(expected, expected);
-
- Map<String, Integer> equalToUnderlying = Maps.newTreeMap();
- equalToUnderlying.putAll(underlying);
- Map<String, Integer> map =
- Maps.transformValues(equalToUnderlying, Functions.<Integer>identity());
- assertMapsEqual(expected, map);
-
- map =
- Maps.transformValues(
- ImmutableMap.of("a", 1, "b", 2, "c", 3),
- new Function<Integer, Integer>() {
- @Override
- public Integer apply(Integer from) {
- return from - 1;
- }
- });
- assertMapsEqual(expected, map);
- }
-
- public void testTransformEntrySetContains() {
- Map<@Nullable String, @Nullable Boolean> underlying = Maps.newHashMap();
- underlying.put("a", null);
- underlying.put("b", true);
- underlying.put(null, true);
-
- Map<@Nullable String, @Nullable Boolean> map =
- Maps.transformValues(
- underlying,
- new Function<@Nullable Boolean, @Nullable Boolean>() {
- @Override
- public @Nullable Boolean apply(@Nullable Boolean from) {
- return (from == null) ? true : null;
- }
- });
-
- Set<Entry<@Nullable String, @Nullable Boolean>> entries = map.entrySet();
- assertTrue(entries.contains(Maps.immutableEntry("a", true)));
- assertTrue(entries.contains(Maps.immutableEntry("b", (Boolean) null)));
- assertTrue(entries.contains(Maps.immutableEntry((String) null, (Boolean) null)));
-
- assertFalse(entries.contains(Maps.immutableEntry("c", (Boolean) null)));
- assertFalse(entries.contains(Maps.immutableEntry((String) null, true)));
- }
-
- @Override
- public void testKeySetRemoveAllNullFromEmpty() {
- try {
- super.testKeySetRemoveAllNullFromEmpty();
- } catch (RuntimeException tolerated) {
- // GWT's HashMap.keySet().removeAll(null) doesn't throws NPE.
- }
- }
-
- @Override
- public void testEntrySetRemoveAllNullFromEmpty() {
- try {
- super.testEntrySetRemoveAllNullFromEmpty();
- } catch (RuntimeException tolerated) {
- // GWT's HashMap.entrySet().removeAll(null) doesn't throws NPE.
- }
- }
}
diff --git a/guava-tests/test/com/google/common/collect/MultimapsTest.java b/guava-tests/test/com/google/common/collect/MultimapsTest.java
index 738ba10dd..eecc158fb 100644
--- a/guava-tests/test/com/google/common/collect/MultimapsTest.java
+++ b/guava-tests/test/com/google/common/collect/MultimapsTest.java
@@ -35,6 +35,7 @@ import com.google.common.base.Supplier;
import com.google.common.collect.Maps.EntryTransformer;
import com.google.common.collect.testing.IteratorTester;
import com.google.common.collect.testing.google.UnmodifiableCollectionTests;
+import com.google.common.primitives.Chars;
import com.google.common.testing.CollectorTester;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
@@ -106,7 +107,7 @@ public class MultimapsTest extends TestCase {
Collector<String, ?, ListMultimap<Character, Character>> collector =
Multimaps.flatteningToMultimap(
str -> str.charAt(0),
- str -> str.substring(1).chars().mapToObj(c -> (char) c),
+ str -> Chars.asList(str.substring(1).toCharArray()).stream(),
MultimapBuilder.linkedHashKeys().arrayListValues()::build);
BiPredicate<Multimap<?, ?>, Multimap<?, ?>> equivalence =
Equivalence.equals()
@@ -1057,6 +1058,7 @@ public class MultimapsTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
new NullPointerTester().testAllPublicStaticMethods(Multimaps.class);
}
diff --git a/guava-tests/test/com/google/common/collect/MultisetsTest.java b/guava-tests/test/com/google/common/collect/MultisetsTest.java
index 6ba5182db..b6b67aa80 100644
--- a/guava-tests/test/com/google/common/collect/MultisetsTest.java
+++ b/guava-tests/test/com/google/common/collect/MultisetsTest.java
@@ -294,6 +294,7 @@ public class MultisetsTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
new NullPointerTester().testAllPublicStaticMethods(Multisets.class);
}
diff --git a/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java b/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java
index 156b62d98..8384f03f9 100644
--- a/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java
+++ b/guava-tests/test/com/google/common/collect/MutableClassToInstanceMapTest.java
@@ -16,6 +16,8 @@
package com.google.common.collect;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.collect.ImmutableClassToInstanceMapTest.Impl;
import com.google.common.collect.ImmutableClassToInstanceMapTest.TestClassToInstanceMapGenerator;
import com.google.common.collect.testing.MapTestSuiteBuilder;
@@ -83,11 +85,7 @@ public class MutableClassToInstanceMapTest extends TestCase {
* well-tested. A purist would object to this, but what can I say, we're dirty cheaters.
*/
map.put(Integer.class, new Integer(5));
- try {
- map.put(Double.class, new Long(42));
- fail();
- } catch (ClassCastException expected) {
- }
+ assertThrows(ClassCastException.class, () -> map.put(Double.class, new Long(42)));
// Won't compile: map.put(String.class, "x");
}
@@ -104,11 +102,7 @@ public class MutableClassToInstanceMapTest extends TestCase {
}
public void testNull() {
- try {
- map.put(null, new Integer(1));
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> map.put(null, new Integer(1)));
map.putInstance(Integer.class, null);
assertNull(map.get(Integer.class));
assertNull(map.getInstance(Integer.class));
diff --git a/guava-tests/test/com/google/common/collect/OrderingTest.java b/guava-tests/test/com/google/common/collect/OrderingTest.java
index a98379986..8a8854097 100644
--- a/guava-tests/test/com/google/common/collect/OrderingTest.java
+++ b/guava-tests/test/com/google/common/collect/OrderingTest.java
@@ -161,6 +161,19 @@ public class OrderingTest extends TestCase {
assertEquals("Ordering.explicit([0])", c.toString());
}
+ public void testExplicitMax_b297601553() {
+ Ordering<Integer> c = Ordering.explicit(1, 2, 3);
+
+ // TODO(b/297601553): this should probably throw an CCE since 0 isn't explicitly listed
+ assertEquals(0, (int) c.max(asList(0)));
+ try {
+ c.max(asList(0, 1));
+ fail();
+ } catch (IncomparableValueException expected) {
+ assertEquals(0, expected.value);
+ }
+ }
+
public void testExplicit_two() {
Comparator<Integer> c = Ordering.explicit(42, 5);
assertEquals(0, c.compare(5, 5));
diff --git a/guava-tests/test/com/google/common/collect/QueuesTest.java b/guava-tests/test/com/google/common/collect/QueuesTest.java
index e2c3485f9..e0878d7ed 100644
--- a/guava-tests/test/com/google/common/collect/QueuesTest.java
+++ b/guava-tests/test/com/google/common/collect/QueuesTest.java
@@ -24,6 +24,7 @@ import static java.util.concurrent.Executors.newCachedThreadPool;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Stopwatch;
import java.util.Collection;
@@ -239,23 +240,13 @@ public class QueuesTest extends TestCase {
}
public void testNewLinkedBlockingDequeCapacity() {
- try {
- Queues.newLinkedBlockingDeque(0);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- // any capacity less than 1 should throw IllegalArgumentException
- }
+ assertThrows(IllegalArgumentException.class, () -> Queues.newLinkedBlockingDeque(0));
assertEquals(1, Queues.newLinkedBlockingDeque(1).remainingCapacity());
assertEquals(11, Queues.newLinkedBlockingDeque(11).remainingCapacity());
}
public void testNewLinkedBlockingQueueCapacity() {
- try {
- Queues.newLinkedBlockingQueue(0);
- fail("Should have thrown IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- // any capacity less than 1 should throw IllegalArgumentException
- }
+ assertThrows(IllegalArgumentException.class, () -> Queues.newLinkedBlockingQueue(0));
assertEquals(1, Queues.newLinkedBlockingQueue(1).remainingCapacity());
assertEquals(11, Queues.newLinkedBlockingQueue(11).remainingCapacity());
}
diff --git a/guava-tests/test/com/google/common/collect/RangeTest.java b/guava-tests/test/com/google/common/collect/RangeTest.java
index e8578bfd1..16764a699 100644
--- a/guava-tests/test/com/google/common/collect/RangeTest.java
+++ b/guava-tests/test/com/google/common/collect/RangeTest.java
@@ -614,7 +614,7 @@ public class RangeTest extends TestCase {
Range<LegacyComparable> range = Range.closed(LegacyComparable.X, LegacyComparable.Y);
}
- static final DiscreteDomain<Integer> UNBOUNDED_DOMAIN =
+ private static final DiscreteDomain<Integer> UNBOUNDED_DOMAIN =
new DiscreteDomain<Integer>() {
@Override
public Integer next(Integer value) {
diff --git a/guava-tests/test/com/google/common/collect/SetsTest.java b/guava-tests/test/com/google/common/collect/SetsTest.java
index 50fb456e5..c8cb0e0bb 100644
--- a/guava-tests/test/com/google/common/collect/SetsTest.java
+++ b/guava-tests/test/com/google/common/collect/SetsTest.java
@@ -52,7 +52,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.Serializable;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
@@ -669,6 +668,7 @@ public class SetsTest extends TestCase {
}
@GwtIncompatible // NullPointerTester
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointerExceptions() {
new NullPointerTester()
.setDefault(Enum.class, SomeEnum.A)
@@ -783,6 +783,21 @@ public class SetsTest extends TestCase {
assertFalse(actual.contains(list(3, 1)));
}
+ public void testCartesianProduct_equals() {
+ Set<List<Integer>> cartesian = Sets.cartesianProduct(set(1, 2), set(3, 4));
+ ImmutableSet<List<Integer>> equivalent =
+ ImmutableSet.of(ImmutableList.of(1, 3), ImmutableList.of(1, 4), list(2, 3), list(2, 4));
+ ImmutableSet<List<Integer>> different1 =
+ ImmutableSet.of(ImmutableList.of(0, 3), ImmutableList.of(1, 4), list(2, 3), list(2, 4));
+ ImmutableSet<List<Integer>> different2 =
+ ImmutableSet.of(ImmutableList.of(1, 3), ImmutableList.of(1, 4), list(2, 3));
+ new EqualsTester()
+ .addEqualityGroup(cartesian, equivalent)
+ .addEqualityGroup(different1)
+ .addEqualityGroup(different2)
+ .testEquals();
+ }
+
@SuppressWarnings("unchecked") // varargs!
public void testCartesianProduct_unrelatedTypes() {
Set<Integer> x = set(1, 2);
@@ -1138,47 +1153,6 @@ public class SetsTest extends TestCase {
assertEquals(expected, set);
}
- /** Simple base class to verify that we handle generics correctly. */
- static class Base implements Comparable<Base>, Serializable {
- private final String s;
-
- public Base(String s) {
- this.s = s;
- }
-
- @Override
- public int hashCode() { // delegate to 's'
- return s.hashCode();
- }
-
- @Override
- public boolean equals(@Nullable Object other) {
- if (other == null) {
- return false;
- } else if (other instanceof Base) {
- return s.equals(((Base) other).s);
- } else {
- return false;
- }
- }
-
- @Override
- public int compareTo(Base o) {
- return s.compareTo(o.s);
- }
-
- private static final long serialVersionUID = 0;
- }
-
- /** Simple derived class to verify that we handle generics correctly. */
- static class Derived extends Base {
- public Derived(String s) {
- super(s);
- }
-
- private static final long serialVersionUID = 0;
- }
-
@GwtIncompatible // NavigableSet
public void testUnmodifiableNavigableSet() {
TreeSet<Integer> mod = Sets.newTreeSet();
diff --git a/guava-tests/test/com/google/common/collect/StreamsTest.java b/guava-tests/test/com/google/common/collect/StreamsTest.java
index 9d3dab65a..2da73a974 100644
--- a/guava-tests/test/com/google/common/collect/StreamsTest.java
+++ b/guava-tests/test/com/google/common/collect/StreamsTest.java
@@ -14,6 +14,7 @@
package com.google.common.collect;
+import static com.google.common.collect.Streams.findLast;
import static com.google.common.collect.Streams.stream;
import com.google.common.annotations.GwtCompatible;
@@ -22,16 +23,19 @@ import com.google.common.collect.testing.SpliteratorTester;
import com.google.common.primitives.Doubles;
import com.google.common.truth.IterableSubject;
import com.google.common.truth.Truth;
+import com.google.common.truth.Truth8;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.OptionalDouble;
import java.util.OptionalInt;
import java.util.OptionalLong;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
+import java.util.stream.Collectors;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
@@ -75,6 +79,62 @@ public class StreamsTest extends TestCase {
assertThat(stream(java.util.Optional.of("a"))).containsExactly("a");
}
+ public void testFindLast_refStream() {
+ Truth8.assertThat(findLast(Stream.of())).isEmpty();
+ Truth8.assertThat(findLast(Stream.of("a", "b", "c", "d"))).hasValue("d");
+
+ // test with a large, not-subsized Spliterator
+ List<Integer> list =
+ IntStream.rangeClosed(0, 10000).boxed().collect(Collectors.toCollection(LinkedList::new));
+ Truth8.assertThat(findLast(list.stream())).hasValue(10000);
+
+ // no way to find out the stream is empty without walking its spliterator
+ Truth8.assertThat(findLast(list.stream().filter(i -> i < 0))).isEmpty();
+ }
+
+ public void testFindLast_intStream() {
+ Truth.assertThat(findLast(IntStream.of())).isEqualTo(OptionalInt.empty());
+ Truth.assertThat(findLast(IntStream.of(1, 2, 3, 4, 5))).isEqualTo(OptionalInt.of(5));
+
+ // test with a large, not-subsized Spliterator
+ List<Integer> list =
+ IntStream.rangeClosed(0, 10000).boxed().collect(Collectors.toCollection(LinkedList::new));
+ Truth.assertThat(findLast(list.stream().mapToInt(i -> i))).isEqualTo(OptionalInt.of(10000));
+
+ // no way to find out the stream is empty without walking its spliterator
+ Truth.assertThat(findLast(list.stream().mapToInt(i -> i).filter(i -> i < 0)))
+ .isEqualTo(OptionalInt.empty());
+ }
+
+ public void testFindLast_longStream() {
+ Truth.assertThat(findLast(LongStream.of())).isEqualTo(OptionalLong.empty());
+ Truth.assertThat(findLast(LongStream.of(1, 2, 3, 4, 5))).isEqualTo(OptionalLong.of(5));
+
+ // test with a large, not-subsized Spliterator
+ List<Long> list =
+ LongStream.rangeClosed(0, 10000).boxed().collect(Collectors.toCollection(LinkedList::new));
+ Truth.assertThat(findLast(list.stream().mapToLong(i -> i))).isEqualTo(OptionalLong.of(10000));
+
+ // no way to find out the stream is empty without walking its spliterator
+ Truth.assertThat(findLast(list.stream().mapToLong(i -> i).filter(i -> i < 0)))
+ .isEqualTo(OptionalLong.empty());
+ }
+
+ public void testFindLast_doubleStream() {
+ Truth.assertThat(findLast(DoubleStream.of())).isEqualTo(OptionalDouble.empty());
+ Truth.assertThat(findLast(DoubleStream.of(1, 2, 3, 4, 5))).isEqualTo(OptionalDouble.of(5));
+
+ // test with a large, not-subsized Spliterator
+ List<Long> list =
+ LongStream.rangeClosed(0, 10000).boxed().collect(Collectors.toCollection(LinkedList::new));
+ Truth.assertThat(findLast(list.stream().mapToDouble(i -> i)))
+ .isEqualTo(OptionalDouble.of(10000));
+
+ // no way to find out the stream is empty without walking its spliterator
+ Truth.assertThat(findLast(list.stream().mapToDouble(i -> i).filter(i -> i < 0)))
+ .isEqualTo(OptionalDouble.empty());
+ }
+
public void testConcat_refStream() {
assertThat(Streams.concat(Stream.of("a"), Stream.of("b"), Stream.empty(), Stream.of("c", "d")))
.containsExactly("a", "b", "c", "d")
@@ -121,6 +181,31 @@ public class StreamsTest extends TestCase {
Truth.assertThat(closeCountB.get()).isEqualTo(1);
}
+ public void testConcat_refStream_closeIsPropagated_exceptionsChained() {
+ RuntimeException exception1 = new IllegalArgumentException("exception from stream 1");
+ RuntimeException exception2 = new IllegalStateException("exception from stream 2");
+ RuntimeException exception3 = new ArithmeticException("exception from stream 3");
+ Stream<String> stream1 = Stream.of("foo", "bar").onClose(doThrow(exception1));
+ Stream<String> stream2 = Stream.of("baz", "buh").onClose(doThrow(exception2));
+ Stream<String> stream3 = Stream.of("quux").onClose(doThrow(exception3));
+ RuntimeException exception = null;
+ try (Stream<String> concatenated = Streams.concat(stream1, stream2, stream3)) {
+ } catch (RuntimeException e) {
+ exception = e;
+ }
+ Truth.assertThat(exception).isEqualTo(exception1);
+ Truth.assertThat(exception.getSuppressed())
+ .asList()
+ .containsExactly(exception2, exception3)
+ .inOrder();
+ }
+
+ private static Runnable doThrow(RuntimeException exception) {
+ return () -> {
+ throw exception;
+ };
+ }
+
public void testConcat_refStream_parallel() {
Truth.assertThat(
Streams.concat(Stream.of("a"), Stream.of("b"), Stream.empty(), Stream.of("c", "d"))
diff --git a/guava-tests/test/com/google/common/collect/TablesTest.java b/guava-tests/test/com/google/common/collect/TablesTest.java
index dd56614f9..6fe3e99be 100644
--- a/guava-tests/test/com/google/common/collect/TablesTest.java
+++ b/guava-tests/test/com/google/common/collect/TablesTest.java
@@ -19,10 +19,8 @@ package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.Table.Cell;
-import com.google.common.testing.CollectorTester;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.SerializableTester;
-import java.util.stream.Collector;
import junit.framework.TestCase;
/**
@@ -32,35 +30,6 @@ import junit.framework.TestCase;
*/
@GwtCompatible(emulated = true)
public class TablesTest extends TestCase {
-
- // The bulk of the toTable tests can be found in TableCollectorsTest.
- // This gives minimal coverage to the forwarding functions
- public void testToTableSanityTest() {
- Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
- Tables.toTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue, HashBasedTable::create);
- HashBasedTable<String, String, Integer> expected = HashBasedTable.create();
- expected.put("one", "uno", 1);
- CollectorTester.of(collector)
- .expectCollects(HashBasedTable.create())
- .expectCollects(expected, Tables.immutableCell("one", "uno", 1));
- }
-
- public void testToTableMergingSanityTest() {
- Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
- Tables.toTable(
- Cell::getRowKey,
- Cell::getColumnKey,
- Cell::getValue,
- Integer::sum,
- HashBasedTable::create);
- HashBasedTable<String, String, Integer> expected = HashBasedTable.create();
- expected.put("one", "uno", 3);
- CollectorTester.of(collector)
- .expectCollects(HashBasedTable.create())
- .expectCollects(
- expected, Tables.immutableCell("one", "uno", 1), Tables.immutableCell("one", "uno", 2));
- }
-
@GwtIncompatible // SerializableTester
public void testImmutableEntrySerialization() {
Cell<String, Integer, Character> entry = Tables.immutableCell("foo", 1, 'a');
diff --git a/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java b/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
index 9e57bba62..816a08cba 100644
--- a/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
+++ b/guava-tests/test/com/google/common/collect/TreeRangeMapTest.java
@@ -16,6 +16,7 @@ package com.google.common.collect;
import static com.google.common.collect.BoundType.OPEN;
import static com.google.common.collect.testing.Helpers.mapEntry;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.testing.MapTestSuiteBuilder;
@@ -768,14 +769,10 @@ public class TreeRangeMapTest extends TestCase {
3),
rangeMap.asMapOfRanges());
- try {
- sub.put(Range.open(9, 12), 5);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> sub.put(Range.open(9, 12), 5));
- sub = sub.subRangeMap(Range.closedOpen(5, 5));
- sub.put(Range.closedOpen(5, 5), 6); // should be a no-op
+ RangeMap<Integer, Integer> subSub = sub.subRangeMap(Range.closedOpen(5, 5));
+ subSub.put(Range.closedOpen(5, 5), 6); // should be a no-op
assertEquals(
ImmutableMap.of(
Range.open(3, 7),
@@ -819,11 +816,7 @@ public class TreeRangeMapTest extends TestCase {
3),
rangeMap.asMapOfRanges());
- try {
- sub.putCoalescing(Range.open(9, 12), 5);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> sub.putCoalescing(Range.open(9, 12), 5));
}
public void testSubRangeMapRemove() {
diff --git a/guava-tests/test/com/google/common/collect/WriteReplaceOverridesTest.java b/guava-tests/test/com/google/common/collect/WriteReplaceOverridesTest.java
new file mode 100644
index 000000000..bf10f5f75
--- /dev/null
+++ b/guava-tests/test/com/google/common/collect/WriteReplaceOverridesTest.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2023 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.collect;
+
+import static com.google.common.truth.Truth.assertWithMessage;
+import static java.lang.reflect.Modifier.PRIVATE;
+import static java.lang.reflect.Modifier.PROTECTED;
+import static java.lang.reflect.Modifier.PUBLIC;
+import static java.util.Arrays.asList;
+
+import com.google.common.base.Optional;
+import com.google.common.reflect.ClassPath;
+import com.google.common.reflect.ClassPath.ClassInfo;
+import com.google.common.reflect.TypeToken;
+import java.lang.reflect.Method;
+import junit.framework.TestCase;
+
+/**
+ * Tests that all package-private {@code writeReplace} methods are overridden in any existing
+ * subclasses. Without such overrides, optimizers might put a {@code writeReplace}-containing class
+ * and its subclass in different packages, causing the serialization system to fail to invoke {@code
+ * writeReplace} when serializing an instance of the subclass. For an example of this problem, see
+ * b/310253115.
+ */
+public class WriteReplaceOverridesTest extends TestCase {
+ private static final ImmutableSet<String> GUAVA_PACKAGES =
+ FluentIterable.of(
+ "base",
+ "cache",
+ "collect",
+ "escape",
+ "eventbus",
+ "graph",
+ "hash",
+ "html",
+ "io",
+ "math",
+ "net",
+ "primitives",
+ "reflect",
+ "util.concurrent",
+ "xml")
+ .transform("com.google.common."::concat)
+ .toSet();
+
+ public void testClassesHaveOverrides() throws Exception {
+ for (ClassInfo info : ClassPath.from(getClass().getClassLoader()).getAllClasses()) {
+ if (!GUAVA_PACKAGES.contains(info.getPackageName())) {
+ continue;
+ }
+ if (info.getName().endsWith("GwtSerializationDependencies")) {
+ continue; // These classes exist only for the GWT compiler, not to be used.
+ }
+ if (
+ /*
+ * At least one of the classes nested inside TypeResolverTest triggers a bug under older JDKs:
+ * https://bugs.openjdk.org/browse/JDK-8215328 -> https://bugs.openjdk.org/browse/JDK-8215470
+ * https://github.com/google/guava/blob/4f12c5891a7adedbaa1d99fc9f77d8cc4e9da206/guava-tests/test/com/google/common/reflect/TypeResolverTest.java#L201
+ */
+ info.getName().contains("TypeResolverTest")
+ /*
+ * And at least one of the classes inside TypeTokenTest ends up with a null value in
+ * TypeMappingIntrospector.mappings. That happens only under older JDKs, too, so it may
+ * well be a JDK bug.
+ */
+ || info.getName().contains("TypeTokenTest")
+ /*
+ * Luckily, we don't care about analyzing tests at all. We'd skip them all if we could do so
+ * trivially, but it's enough to skip these ones.
+ */
+ ) {
+ continue;
+ }
+ Class<?> clazz = info.load();
+ try {
+ Method unused = clazz.getDeclaredMethod("writeReplace");
+ continue; // It overrides writeReplace, so it's safe.
+ } catch (NoSuchMethodException e) {
+ // This is a class whose supertypes we want to examine. We'll do that below.
+ }
+ Optional<Class<?>> supersWithPackagePrivateWriteReplace =
+ FluentIterable.from(TypeToken.of(clazz).getTypes())
+ .transform(TypeToken::getRawType)
+ .transformAndConcat(c -> asList(c.getDeclaredMethods()))
+ .firstMatch(
+ m ->
+ m.getName().equals("writeReplace")
+ && m.getParameterTypes().length == 0
+ // Only package-private methods are a problem.
+ && (m.getModifiers() & (PUBLIC | PROTECTED | PRIVATE)) == 0)
+ .transform(Method::getDeclaringClass);
+ if (!supersWithPackagePrivateWriteReplace.isPresent()) {
+ continue;
+ }
+ assertWithMessage(
+ "To help optimizers, any class that inherits a package-private writeReplace() method"
+ + " should override that method.\n"
+ + "(An override that delegates to the supermethod is fine.)\n"
+ + "%s has no such override despite inheriting writeReplace() from %s",
+ clazz.getName(), supersWithPackagePrivateWriteReplace.get().getName())
+ .fail();
+ }
+ }
+}
diff --git a/guava-tests/test/com/google/common/eventbus/EventBusTest.java b/guava-tests/test/com/google/common/eventbus/EventBusTest.java
index d314f7ee7..8161c271b 100644
--- a/guava-tests/test/com/google/common/eventbus/EventBusTest.java
+++ b/guava-tests/test/com/google/common/eventbus/EventBusTest.java
@@ -16,6 +16,8 @@
package com.google.common.eventbus;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.util.List;
@@ -194,12 +196,7 @@ public class EventBusTest extends TestCase {
public void testUnregister() {
StringCatcher catcher1 = new StringCatcher();
StringCatcher catcher2 = new StringCatcher();
- try {
- bus.unregister(catcher1);
- fail("Attempting to unregister an unregistered object succeeded");
- } catch (IllegalArgumentException expected) {
- // OK.
- }
+ assertThrows(IllegalArgumentException.class, () -> bus.unregister(catcher1));
bus.register(catcher1);
bus.post(EVENT);
@@ -222,12 +219,7 @@ public class EventBusTest extends TestCase {
"Shouldn't catch any more events when unregistered.", expectedEvents, catcher1.getEvents());
assertEquals("Two correct events should be delivered.", expectedEvents, catcher2.getEvents());
- try {
- bus.unregister(catcher1);
- fail("Attempting to unregister an unregistered object succeeded");
- } catch (IllegalArgumentException expected) {
- // OK.
- }
+ assertThrows(IllegalArgumentException.class, () -> bus.unregister(catcher1));
bus.unregister(catcher2);
bus.post(EVENT);
@@ -293,11 +285,7 @@ public class EventBusTest extends TestCase {
@Subscribe
public void toInt(int i) {}
}
- try {
- bus.register(new SubscribesToPrimitive());
- fail("should have thrown");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> bus.register(new SubscribesToPrimitive()));
}
/** Records thrown exception information. */
diff --git a/guava-tests/test/com/google/common/eventbus/SubscriberRegistryTest.java b/guava-tests/test/com/google/common/eventbus/SubscriberRegistryTest.java
index c9e5c9a5b..901bb2b51 100644
--- a/guava-tests/test/com/google/common/eventbus/SubscriberRegistryTest.java
+++ b/guava-tests/test/com/google/common/eventbus/SubscriberRegistryTest.java
@@ -16,6 +16,8 @@
package com.google.common.eventbus;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterators;
import java.util.Iterator;
@@ -59,28 +61,15 @@ public class SubscriberRegistryTest extends TestCase {
}
public void testUnregister_notRegistered() {
- try {
- registry.unregister(new StringSubscriber());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> registry.unregister(new StringSubscriber()));
StringSubscriber s1 = new StringSubscriber();
registry.register(s1);
- try {
- registry.unregister(new StringSubscriber());
- fail();
- } catch (IllegalArgumentException expected) {
- // a StringSubscriber was registered, but not the same one we tried to unregister
- }
+ assertThrows(IllegalArgumentException.class, () -> registry.unregister(new StringSubscriber()));
registry.unregister(s1);
- try {
- registry.unregister(s1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> registry.unregister(s1));
}
public void testGetSubscribers() {
diff --git a/guava-tests/test/com/google/common/eventbus/SubscriberTest.java b/guava-tests/test/com/google/common/eventbus/SubscriberTest.java
index 14210ac14..6e02627fe 100644
--- a/guava-tests/test/com/google/common/eventbus/SubscriberTest.java
+++ b/guava-tests/test/com/google/common/eventbus/SubscriberTest.java
@@ -17,6 +17,7 @@
package com.google.common.eventbus;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.testing.EqualsTester;
import java.lang.reflect.InvocationTargetException;
@@ -70,23 +71,18 @@ public class SubscriberTest extends TestCase {
Method method = getTestSubscriberMethod("exceptionThrowingMethod");
Subscriber subscriber = Subscriber.create(bus, this, method);
- try {
- subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT);
- fail("Subscribers whose methods throw must throw InvocationTargetException");
- } catch (InvocationTargetException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(IntentionalException.class);
- }
+ InvocationTargetException expected =
+ assertThrows(
+ InvocationTargetException.class,
+ () -> subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT));
+ assertThat(expected).hasCauseThat().isInstanceOf(IntentionalException.class);
}
public void testInvokeSubscriberMethod_errorPassthrough() throws Throwable {
Method method = getTestSubscriberMethod("errorThrowingMethod");
Subscriber subscriber = Subscriber.create(bus, this, method);
- try {
- subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT);
- fail("Subscribers whose methods throw Errors must rethrow them");
- } catch (JudgmentError expected) {
- }
+ assertThrows(JudgmentError.class, () -> subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT));
}
public void testEquals() throws Exception {
diff --git a/guava-tests/test/com/google/common/graph/AbstractGraphTest.java b/guava-tests/test/com/google/common/graph/AbstractGraphTest.java
index 3a489a11c..a8209244c 100644
--- a/guava-tests/test/com/google/common/graph/AbstractGraphTest.java
+++ b/guava-tests/test/com/google/common/graph/AbstractGraphTest.java
@@ -16,13 +16,12 @@
package com.google.common.graph;
-import static com.google.common.graph.TestUtil.ERROR_NODE_NOT_IN_GRAPH;
import static com.google.common.graph.TestUtil.assertNodeNotInGraphErrorMessage;
import static com.google.common.graph.TestUtil.assertStronglyEquivalent;
import static com.google.common.graph.TestUtil.sanityCheckSet;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableSet;
import java.util.HashSet;
@@ -235,12 +234,9 @@ public abstract class AbstractGraphTest {
@Test
public void adjacentNodes_nodeNotInGraph() {
- try {
- graph.adjacentNodes(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.adjacentNodes(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -251,12 +247,9 @@ public abstract class AbstractGraphTest {
@Test
public void predecessors_nodeNotInGraph() {
- try {
- graph.predecessors(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.predecessors(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -267,12 +260,9 @@ public abstract class AbstractGraphTest {
@Test
public void successors_nodeNotInGraph() {
- try {
- graph.successors(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.successors(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -283,12 +273,9 @@ public abstract class AbstractGraphTest {
@Test
public void incidentEdges_nodeNotInGraph() {
- try {
- graph.incidentEdges(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.incidentEdges(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -306,12 +293,9 @@ public abstract class AbstractGraphTest {
@Test
public void degree_nodeNotInGraph() {
- try {
- graph.degree(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.degree(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -322,12 +306,9 @@ public abstract class AbstractGraphTest {
@Test
public void inDegree_nodeNotInGraph() {
- try {
- graph.inDegree(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.inDegree(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -338,12 +319,9 @@ public abstract class AbstractGraphTest {
@Test
public void outDegree_nodeNotInGraph() {
- try {
- graph.outDegree(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.outDegree(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -407,16 +385,16 @@ public abstract class AbstractGraphTest {
public void removeNode_queryAfterRemoval() {
assume().that(graphIsMutable()).isTrue();
- addNode(N1);
- @SuppressWarnings("unused")
- Set<Integer> unused = graph.adjacentNodes(N1); // ensure cache (if any) is populated
+ putEdge(N1, N2);
+ putEdge(N2, N1);
+ Set<Integer> n1AdjacentNodes = graph.adjacentNodes(N1);
+ Set<Integer> n2AdjacentNodes = graph.adjacentNodes(N2);
assertThat(graphAsMutableGraph.removeNode(N1)).isTrue();
- try {
- graph.adjacentNodes(N1);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ assertThat(n1AdjacentNodes).isEmpty();
+ assertThat(n2AdjacentNodes).isEmpty();
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graph.adjacentNodes(N1));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
diff --git a/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java b/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java
index be551ce34..a29ffc5ae 100644
--- a/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java
+++ b/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java
@@ -16,7 +16,6 @@
package com.google.common.graph;
-import static com.google.common.graph.TestUtil.ERROR_NODE_NOT_IN_GRAPH;
import static com.google.common.graph.TestUtil.assertEdgeNotInGraphErrorMessage;
import static com.google.common.graph.TestUtil.assertNodeNotInGraphErrorMessage;
import static com.google.common.graph.TestUtil.assertStronglyEquivalent;
@@ -25,6 +24,7 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
import static java.util.concurrent.Executors.newFixedThreadPool;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -423,12 +423,10 @@ public abstract class AbstractNetworkTest {
@Test
public void incidentEdges_nodeNotInGraph() {
- try {
- network.incidentEdges(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> network.incidentEdges(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -439,12 +437,10 @@ public abstract class AbstractNetworkTest {
@Test
public void incidentNodes_edgeNotInGraph() {
- try {
- network.incidentNodes(EDGE_NOT_IN_GRAPH);
- fail(ERROR_EDGE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertEdgeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> network.incidentNodes(EDGE_NOT_IN_GRAPH));
+ assertEdgeNotInGraphErrorMessage(e);
}
@Test
@@ -462,12 +458,10 @@ public abstract class AbstractNetworkTest {
@Test
public void adjacentNodes_nodeNotInGraph() {
- try {
- network.adjacentNodes(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> network.adjacentNodes(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -488,12 +482,10 @@ public abstract class AbstractNetworkTest {
@Test
public void adjacentEdges_edgeNotInGraph() {
- try {
- network.adjacentEdges(EDGE_NOT_IN_GRAPH);
- fail(ERROR_EDGE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertEdgeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> network.adjacentEdges(EDGE_NOT_IN_GRAPH));
+ assertEdgeNotInGraphErrorMessage(e);
}
@Test
@@ -519,24 +511,19 @@ public abstract class AbstractNetworkTest {
public void edgesConnecting_nodesNotInGraph() {
addNode(N1);
addNode(N2);
- try {
- network.edgesConnecting(N1, NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
- try {
- network.edgesConnecting(NODE_NOT_IN_GRAPH, N2);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
- try {
- network.edgesConnecting(NODE_NOT_IN_GRAPH, NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> network.edgesConnecting(N1, NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> network.edgesConnecting(NODE_NOT_IN_GRAPH, N2));
+ assertNodeNotInGraphErrorMessage(e);
+ e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> network.edgesConnecting(NODE_NOT_IN_GRAPH, NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -601,12 +588,9 @@ public abstract class AbstractNetworkTest {
@Test
public void inEdges_nodeNotInGraph() {
- try {
- network.inEdges(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> network.inEdges(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -617,12 +601,9 @@ public abstract class AbstractNetworkTest {
@Test
public void outEdges_nodeNotInGraph() {
- try {
- network.outEdges(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> network.outEdges(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -633,12 +614,9 @@ public abstract class AbstractNetworkTest {
@Test
public void predecessors_nodeNotInGraph() {
- try {
- network.predecessors(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> network.predecessors(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -649,12 +627,9 @@ public abstract class AbstractNetworkTest {
@Test
public void successors_nodeNotInGraph() {
- try {
- network.successors(NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> network.successors(NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -702,17 +677,16 @@ public abstract class AbstractNetworkTest {
public void removeNode_queryAfterRemoval() {
assume().that(graphIsMutable()).isTrue();
- addNode(N1);
- @SuppressWarnings("unused")
- Set<Integer> unused =
- networkAsMutableNetwork.adjacentNodes(N1); // ensure cache (if any) is populated
+ addEdge(N1, N2, E12);
+ Set<Integer> n1AdjacentNodes = networkAsMutableNetwork.adjacentNodes(N1);
+ Set<Integer> n2AdjacentNodes = networkAsMutableNetwork.adjacentNodes(N2);
assertTrue(networkAsMutableNetwork.removeNode(N1));
- try {
- networkAsMutableNetwork.adjacentNodes(N1);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ assertThat(n1AdjacentNodes).isEmpty();
+ assertThat(n2AdjacentNodes).isEmpty();
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.adjacentNodes(N1));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -757,12 +731,10 @@ public abstract class AbstractNetworkTest {
EndpointPair<Integer> unused =
networkAsMutableNetwork.incidentNodes(E12); // ensure cache (if any) is populated
assertTrue(networkAsMutableNetwork.removeEdge(E12));
- try {
- networkAsMutableNetwork.incidentNodes(E12);
- fail(ERROR_EDGE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertEdgeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.incidentNodes(E12));
+ assertEdgeNotInGraphErrorMessage(e);
}
@Test
diff --git a/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java b/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java
index c50a7da67..b1a69de2f 100644
--- a/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java
+++ b/guava-tests/test/com/google/common/graph/AbstractStandardDirectedGraphTest.java
@@ -19,8 +19,8 @@ package com.google.common.graph;
import static com.google.common.graph.GraphConstants.ENDPOINTS_MISMATCH;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.util.Set;
import org.junit.Test;
@@ -36,13 +36,10 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
assume().that(graphIsMutable()).isTrue();
Set<Integer> nodes = graph.nodes();
- try {
- nodes.add(N2);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- addNode(N1);
- assertThat(graph.nodes()).containsExactlyElementsIn(nodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2));
+ addNode(N1);
+ assertThat(graph.nodes()).containsExactlyElementsIn(nodes);
}
@Override
@@ -52,13 +49,10 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
addNode(N1);
Set<Integer> adjacentNodes = graph.adjacentNodes(N1);
- try {
- adjacentNodes.add(N2);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2));
+ putEdge(N1, N2);
+ assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
}
@Override
@@ -68,13 +62,10 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
addNode(N2);
Set<Integer> predecessors = graph.predecessors(N2);
- try {
- predecessors.add(N1);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(graph.predecessors(N2)).containsExactlyElementsIn(predecessors);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1));
+ putEdge(N1, N2);
+ assertThat(graph.predecessors(N2)).containsExactlyElementsIn(predecessors);
}
@Override
@@ -84,13 +75,10 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
addNode(N1);
Set<Integer> successors = graph.successors(N1);
- try {
- successors.add(N2);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(successors).containsExactlyElementsIn(graph.successors(N1));
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> successors.add(N2));
+ putEdge(N1, N2);
+ assertThat(successors).containsExactlyElementsIn(graph.successors(N1));
}
@Override
@@ -100,13 +88,12 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
addNode(N1);
Set<EndpointPair<Integer>> incidentEdges = graph.incidentEdges(N1);
- try {
- incidentEdges.add(EndpointPair.ordered(N1, N2));
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(incidentEdges).containsExactlyElementsIn(graph.incidentEdges(N1));
- }
+ UnsupportedOperationException e =
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> incidentEdges.add(EndpointPair.ordered(N1, N2)));
+ putEdge(N1, N2);
+ assertThat(incidentEdges).containsExactlyElementsIn(graph.incidentEdges(N1));
}
@Test
@@ -364,12 +351,9 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
assume().that(graphIsMutable()).isTrue();
EndpointPair<Integer> endpoints = EndpointPair.unordered(N1, N2);
- try {
- graphAsMutableGraph.putEdge(endpoints);
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graphAsMutableGraph.putEdge(endpoints));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
/**
@@ -398,12 +382,9 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
assume().that(graphIsMutable()).isTrue();
assume().that(graph.allowsSelfLoops()).isFalse();
- try {
- graphAsMutableGraph.putEdge(N1, N1);
- fail(ERROR_ADDED_SELF_LOOP);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> graphAsMutableGraph.putEdge(N1, N1));
+ assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
}
@Test
@@ -449,12 +430,10 @@ public abstract class AbstractStandardDirectedGraphTest extends AbstractGraphTes
putEdge(N1, N2);
EndpointPair<Integer> endpoints = EndpointPair.unordered(N1, N2);
- try {
- graphAsMutableGraph.removeEdge(endpoints);
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graphAsMutableGraph.removeEdge(endpoints));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
diff --git a/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java b/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java
index 39d82ee87..bb90a6813 100644
--- a/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java
+++ b/guava-tests/test/com/google/common/graph/AbstractStandardDirectedNetworkTest.java
@@ -20,6 +20,7 @@ import static com.google.common.graph.GraphConstants.ENDPOINTS_MISMATCH;
import static com.google.common.graph.TestUtil.assertEdgeNotInGraphErrorMessage;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -65,13 +66,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(graphIsMutable()).isTrue();
Set<Integer> nodes = network.nodes();
- try {
- nodes.add(N2);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addNode(N1);
- assertThat(network.nodes()).containsExactlyElementsIn(nodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2));
+ addNode(N1);
+ assertThat(network.nodes()).containsExactlyElementsIn(nodes);
}
@Override
@@ -80,13 +78,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(graphIsMutable()).isTrue();
Set<String> edges = network.edges();
- try {
- edges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.edges()).containsExactlyElementsIn(edges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> edges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.edges()).containsExactlyElementsIn(edges);
}
@Override
@@ -96,13 +91,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N1);
Set<String> incidentEdges = network.incidentEdges(N1);
- try {
- incidentEdges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> incidentEdges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges);
}
@Override
@@ -112,13 +104,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N1);
Set<Integer> adjacentNodes = network.adjacentNodes(N1);
- try {
- adjacentNodes.add(N2);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2));
+ addEdge(N1, N2, E12);
+ assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
}
@Override
@@ -144,13 +133,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N1);
addNode(N2);
Set<String> edgesConnecting = network.edgesConnecting(N1, N2);
- try {
- edgesConnecting.add(E23);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23));
+ addEdge(N1, N2, E12);
+ assertThat(network.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
}
@Override
@@ -160,13 +146,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N2);
Set<String> inEdges = network.inEdges(N2);
- try {
- inEdges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.inEdges(N2)).containsExactlyElementsIn(inEdges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> inEdges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.inEdges(N2)).containsExactlyElementsIn(inEdges);
}
@Override
@@ -176,13 +159,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N1);
Set<String> outEdges = network.outEdges(N1);
- try {
- outEdges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.outEdges(N1)).containsExactlyElementsIn(outEdges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> outEdges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.outEdges(N1)).containsExactlyElementsIn(outEdges);
}
@Override
@@ -192,13 +172,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N2);
Set<Integer> predecessors = network.predecessors(N2);
- try {
- predecessors.add(N1);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.predecessors(N2)).containsExactlyElementsIn(predecessors);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1));
+ addEdge(N1, N2, E12);
+ assertThat(network.predecessors(N2)).containsExactlyElementsIn(predecessors);
}
@Override
@@ -208,13 +185,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
addNode(N1);
Set<Integer> successors = network.successors(N1);
- try {
- successors.add(N2);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(successors).containsExactlyElementsIn(network.successors(N1));
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> successors.add(N2));
+ addEdge(N1, N2, E12);
+ assertThat(successors).containsExactlyElementsIn(network.successors(N1));
}
@Test
@@ -229,34 +203,37 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
@Test
public void edgesConnecting_orderMismatch() {
addEdge(N1, N2, E12);
- try {
- Set<String> unused = network.edgesConnecting(EndpointPair.unordered(N1, N2));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ Set<String> unused = network.edgesConnecting(EndpointPair.unordered(N1, N2));
+ });
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
public void edgeConnecting_orderMismatch() {
addEdge(N1, N2, E12);
- try {
- Optional<String> unused = network.edgeConnecting(EndpointPair.unordered(N1, N2));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ Optional<String> unused = network.edgeConnecting(EndpointPair.unordered(N1, N2));
+ });
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
public void edgeConnectingOrNull_orderMismatch() {
addEdge(N1, N2, E12);
- try {
- String unused = network.edgeConnectingOrNull(EndpointPair.unordered(N1, N2));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ String unused = network.edgeConnectingOrNull(EndpointPair.unordered(N1, N2));
+ });
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Override
@@ -316,12 +293,11 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
@Test
public void source_edgeNotInGraph() {
- try {
- network.incidentNodes(EDGE_NOT_IN_GRAPH).source();
- fail(ERROR_EDGE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertEdgeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> network.incidentNodes(EDGE_NOT_IN_GRAPH).source());
+ assertEdgeNotInGraphErrorMessage(e);
}
@Test
@@ -332,12 +308,11 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
@Test
public void target_edgeNotInGraph() {
- try {
- network.incidentNodes(EDGE_NOT_IN_GRAPH).target();
- fail(ERROR_EDGE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertEdgeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> network.incidentNodes(EDGE_NOT_IN_GRAPH).target());
+ assertEdgeNotInGraphErrorMessage(e);
}
@Test
@@ -528,20 +503,12 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(graphIsMutable()).isTrue();
addEdge(N1, N2, E12);
- try {
- // Edge between totally different nodes
- networkAsMutableNetwork.addEdge(N4, N5, E12);
- fail(ERROR_ADDED_EXISTING_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
- }
- try {
- // Edge between same nodes but in reverse direction
- addEdge(N2, N1, E12);
- fail(ERROR_ADDED_EXISTING_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N4, N5, E12));
+ assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
+ e = assertThrows(IllegalArgumentException.class, () -> addEdge(N2, N1, E12));
+ assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
}
@Test
@@ -550,12 +517,11 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(network.allowsParallelEdges()).isFalse();
addEdge(N1, N2, E12);
- try {
- networkAsMutableNetwork.addEdge(N1, N2, EDGE_NOT_IN_GRAPH);
- fail(ERROR_ADDED_PARALLEL_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkAsMutableNetwork.addEdge(N1, N2, EDGE_NOT_IN_GRAPH));
+ assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
}
@Test
@@ -573,12 +539,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(graphIsMutable()).isTrue();
EndpointPair<Integer> endpoints = EndpointPair.unordered(N1, N2);
- try {
- networkAsMutableNetwork.addEdge(endpoints, E12);
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(endpoints, E12));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -586,12 +550,10 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(graphIsMutable()).isTrue();
assume().that(network.allowsSelfLoops()).isFalse();
- try {
- networkAsMutableNetwork.addEdge(N1, N1, E11);
- fail(ERROR_ADDED_SELF_LOOP);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N1, E11));
+ assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
}
/**
@@ -644,25 +606,19 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(network.allowsSelfLoops()).isTrue();
addEdge(N1, N1, E11);
- try {
- networkAsMutableNetwork.addEdge(N1, N2, E11);
- fail("Reusing an existing self-loop edge to connect different nodes succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_REUSE_EDGE);
- }
- try {
- networkAsMutableNetwork.addEdge(N2, N2, E11);
- fail("Reusing an existing self-loop edge to make a different self-loop edge succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_REUSE_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N2, E11));
+ assertThat(e.getMessage()).contains(ERROR_REUSE_EDGE);
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N2, N2, E11));
+ assertThat(e.getMessage()).contains(ERROR_REUSE_EDGE);
addEdge(N1, N2, E12);
- try {
- networkAsMutableNetwork.addEdge(N1, N1, E12);
- fail("Reusing an existing edge to add a self-loop edge between different nodes succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_REUSE_EDGE);
- }
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N1, E12));
+ assertThat(e.getMessage()).contains(ERROR_REUSE_EDGE);
}
@Test
@@ -672,12 +628,11 @@ public abstract class AbstractStandardDirectedNetworkTest extends AbstractNetwor
assume().that(network.allowsParallelEdges()).isFalse();
addEdge(N1, N1, E11);
- try {
- networkAsMutableNetwork.addEdge(N1, N1, EDGE_NOT_IN_GRAPH);
- fail("Adding a parallel self-loop edge succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkAsMutableNetwork.addEdge(N1, N1, EDGE_NOT_IN_GRAPH));
+ assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
}
@Test
diff --git a/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java b/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java
index da9226c31..0acc786a4 100644
--- a/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java
+++ b/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedGraphTest.java
@@ -18,8 +18,8 @@ package com.google.common.graph;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import com.google.common.testing.EqualsTester;
import java.util.Set;
@@ -47,13 +47,10 @@ public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphT
assume().that(graphIsMutable()).isTrue();
Set<Integer> nodes = graph.nodes();
- try {
- nodes.add(N2);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- addNode(N1);
- assertThat(graph.nodes()).containsExactlyElementsIn(nodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2));
+ addNode(N1);
+ assertThat(graph.nodes()).containsExactlyElementsIn(nodes);
}
@Override
@@ -63,13 +60,10 @@ public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphT
addNode(N1);
Set<Integer> adjacentNodes = graph.adjacentNodes(N1);
- try {
- adjacentNodes.add(N2);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2));
+ putEdge(N1, N2);
+ assertThat(graph.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
}
@Override
@@ -79,13 +73,10 @@ public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphT
addNode(N2);
Set<Integer> predecessors = graph.predecessors(N2);
- try {
- predecessors.add(N1);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(graph.predecessors(N2)).containsExactlyElementsIn(predecessors);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1));
+ putEdge(N1, N2);
+ assertThat(graph.predecessors(N2)).containsExactlyElementsIn(predecessors);
}
@Override
@@ -95,13 +86,10 @@ public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphT
addNode(N1);
Set<Integer> successors = graph.successors(N1);
- try {
- successors.add(N2);
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(graph.successors(N1)).containsExactlyElementsIn(successors);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> successors.add(N2));
+ putEdge(N1, N2);
+ assertThat(graph.successors(N1)).containsExactlyElementsIn(successors);
}
@Override
@@ -111,13 +99,12 @@ public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphT
addNode(N1);
Set<EndpointPair<Integer>> incidentEdges = graph.incidentEdges(N1);
- try {
- incidentEdges.add(EndpointPair.unordered(N1, N2));
- fail(ERROR_MODIFIABLE_SET);
- } catch (UnsupportedOperationException e) {
- putEdge(N1, N2);
- assertThat(incidentEdges).containsExactlyElementsIn(graph.incidentEdges(N1));
- }
+ UnsupportedOperationException e =
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> incidentEdges.add(EndpointPair.unordered(N1, N2)));
+ putEdge(N1, N2);
+ assertThat(incidentEdges).containsExactlyElementsIn(graph.incidentEdges(N1));
}
@Test
@@ -380,12 +367,9 @@ public abstract class AbstractStandardUndirectedGraphTest extends AbstractGraphT
assume().that(graphIsMutable()).isTrue();
assume().that(graph.allowsSelfLoops()).isFalse();
- try {
- putEdge(N1, N1);
- fail(ERROR_ADDED_SELF_LOOP);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> putEdge(N1, N1));
+ assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
}
@Test
diff --git a/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java b/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java
index de6fee22e..6bc1d00b6 100644
--- a/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java
+++ b/guava-tests/test/com/google/common/graph/AbstractStandardUndirectedNetworkTest.java
@@ -19,6 +19,7 @@ package com.google.common.graph;
import static com.google.common.graph.GraphConstants.ENDPOINTS_MISMATCH;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -60,26 +61,20 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
@Test
public void nodes_checkReturnedSetMutability() {
Set<Integer> nodes = network.nodes();
- try {
- nodes.add(N2);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addNode(N1);
- assertThat(network.nodes()).containsExactlyElementsIn(nodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> nodes.add(N2));
+ addNode(N1);
+ assertThat(network.nodes()).containsExactlyElementsIn(nodes);
}
@Override
@Test
public void edges_checkReturnedSetMutability() {
Set<String> edges = network.edges();
- try {
- edges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.edges()).containsExactlyElementsIn(edges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> edges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.edges()).containsExactlyElementsIn(edges);
}
@Override
@@ -87,13 +82,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
public void incidentEdges_checkReturnedSetMutability() {
addNode(N1);
Set<String> incidentEdges = network.incidentEdges(N1);
- try {
- incidentEdges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> incidentEdges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.incidentEdges(N1)).containsExactlyElementsIn(incidentEdges);
}
@Override
@@ -101,13 +93,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
public void adjacentNodes_checkReturnedSetMutability() {
addNode(N1);
Set<Integer> adjacentNodes = network.adjacentNodes(N1);
- try {
- adjacentNodes.add(N2);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> adjacentNodes.add(N2));
+ addEdge(N1, N2, E12);
+ assertThat(network.adjacentNodes(N1)).containsExactlyElementsIn(adjacentNodes);
}
@Override
@@ -129,13 +118,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
addNode(N1);
addNode(N2);
Set<String> edgesConnecting = network.edgesConnecting(N1, N2);
- try {
- edgesConnecting.add(E23);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23));
+ addEdge(N1, N2, E12);
+ assertThat(network.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
}
@Override
@@ -143,13 +129,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
public void inEdges_checkReturnedSetMutability() {
addNode(N2);
Set<String> inEdges = network.inEdges(N2);
- try {
- inEdges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.inEdges(N2)).containsExactlyElementsIn(inEdges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> inEdges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.inEdges(N2)).containsExactlyElementsIn(inEdges);
}
@Override
@@ -157,13 +140,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
public void outEdges_checkReturnedSetMutability() {
addNode(N1);
Set<String> outEdges = network.outEdges(N1);
- try {
- outEdges.add(E12);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.outEdges(N1)).containsExactlyElementsIn(outEdges);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> outEdges.add(E12));
+ addEdge(N1, N2, E12);
+ assertThat(network.outEdges(N1)).containsExactlyElementsIn(outEdges);
}
@Override
@@ -171,13 +151,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
public void predecessors_checkReturnedSetMutability() {
addNode(N2);
Set<Integer> predecessors = network.predecessors(N2);
- try {
- predecessors.add(N1);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.predecessors(N2)).containsExactlyElementsIn(predecessors);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> predecessors.add(N1));
+ addEdge(N1, N2, E12);
+ assertThat(network.predecessors(N2)).containsExactlyElementsIn(predecessors);
}
@Override
@@ -185,13 +162,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
public void successors_checkReturnedSetMutability() {
addNode(N1);
Set<Integer> successors = network.successors(N1);
- try {
- successors.add(N2);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- addEdge(N1, N2, E12);
- assertThat(network.successors(N1)).containsExactlyElementsIn(successors);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> successors.add(N2));
+ addEdge(N1, N2, E12);
+ assertThat(network.successors(N1)).containsExactlyElementsIn(successors);
}
@Test
@@ -204,34 +178,37 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
@Test
public void edgesConnecting_orderMismatch() {
addEdge(N1, N2, E12);
- try {
- Set<String> unused = network.edgesConnecting(ENDPOINTS_N1N2);
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ Set<String> unused = network.edgesConnecting(ENDPOINTS_N1N2);
+ });
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
public void edgeConnecting_orderMismatch() {
addEdge(N1, N2, E12);
- try {
- Optional<String> unused = network.edgeConnecting(ENDPOINTS_N1N2);
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ Optional<String> unused = network.edgeConnecting(ENDPOINTS_N1N2);
+ });
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
public void edgeConnectingOrNull_orderMismatch() {
addEdge(N1, N2, E12);
- try {
- String unused = network.edgeConnectingOrNull(ENDPOINTS_N1N2);
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ String unused = network.edgeConnectingOrNull(ENDPOINTS_N1N2);
+ });
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -441,13 +418,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
assume().that(graphIsMutable()).isTrue();
addEdge(N1, N2, E12);
- try {
- // Edge between totally different nodes
- networkAsMutableNetwork.addEdge(N4, N5, E12);
- fail(ERROR_ADDED_EXISTING_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N4, N5, E12));
+ assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
}
@Test
@@ -456,18 +430,16 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
assume().that(network.allowsParallelEdges()).isFalse();
addEdge(N1, N2, E12);
- try {
- networkAsMutableNetwork.addEdge(N1, N2, EDGE_NOT_IN_GRAPH);
- fail(ERROR_ADDED_PARALLEL_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
- }
- try {
- networkAsMutableNetwork.addEdge(N2, N1, EDGE_NOT_IN_GRAPH);
- fail(ERROR_ADDED_PARALLEL_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkAsMutableNetwork.addEdge(N1, N2, EDGE_NOT_IN_GRAPH));
+ assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
+ e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkAsMutableNetwork.addEdge(N2, N1, EDGE_NOT_IN_GRAPH));
+ assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
}
@Test
@@ -486,12 +458,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
assume().that(graphIsMutable()).isTrue();
EndpointPair<Integer> endpoints = EndpointPair.ordered(N1, N2);
- try {
- networkAsMutableNetwork.addEdge(endpoints, E12);
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(endpoints, E12));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -499,12 +469,10 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
assume().that(graphIsMutable()).isTrue();
assume().that(network.allowsSelfLoops()).isFalse();
- try {
- networkAsMutableNetwork.addEdge(N1, N1, E11);
- fail(ERROR_ADDED_SELF_LOOP);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N1, E11));
+ assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
}
/**
@@ -556,25 +524,19 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
assume().that(network.allowsSelfLoops()).isTrue();
addEdge(N1, N1, E11);
- try {
- networkAsMutableNetwork.addEdge(N1, N2, E11);
- fail("Reusing an existing self-loop edge to connect different nodes succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
- }
- try {
- networkAsMutableNetwork.addEdge(N2, N2, E11);
- fail("Reusing an existing self-loop edge to make a different self-loop edge succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N2, E11));
+ assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N2, N2, E11));
+ assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
addEdge(N1, N2, E12);
- try {
- networkAsMutableNetwork.addEdge(N1, N1, E12);
- fail("Reusing an existing edge to add a self-loop edge between different nodes succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
- }
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> networkAsMutableNetwork.addEdge(N1, N1, E12));
+ assertThat(e).hasMessageThat().contains(ERROR_REUSE_EDGE);
}
@Test
@@ -584,12 +546,11 @@ public abstract class AbstractStandardUndirectedNetworkTest extends AbstractNetw
assume().that(network.allowsParallelEdges()).isFalse();
addEdge(N1, N1, E11);
- try {
- networkAsMutableNetwork.addEdge(N1, N1, EDGE_NOT_IN_GRAPH);
- fail("Adding a parallel self-loop edge succeeded");
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkAsMutableNetwork.addEdge(N1, N1, EDGE_NOT_IN_GRAPH));
+ assertThat(e).hasMessageThat().contains(ERROR_PARALLEL_EDGE);
}
@Test
diff --git a/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java b/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java
index eaddb949c..b773a36e6 100644
--- a/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java
+++ b/guava-tests/test/com/google/common/graph/DefaultNetworkImplementationsTest.java
@@ -16,13 +16,11 @@
package com.google.common.graph;
-import static com.google.common.graph.AbstractNetworkTest.ERROR_MODIFIABLE_COLLECTION;
-import static com.google.common.graph.TestUtil.ERROR_NODE_NOT_IN_GRAPH;
import static com.google.common.graph.TestUtil.EdgeType.DIRECTED;
import static com.google.common.graph.TestUtil.EdgeType.UNDIRECTED;
import static com.google.common.graph.TestUtil.assertNodeNotInGraphErrorMessage;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import com.google.common.graph.TestUtil.EdgeType;
import java.util.Arrays;
@@ -89,24 +87,21 @@ public final class DefaultNetworkImplementationsTest {
public void edgesConnecting_nodesNotInGraph() {
network.addNode(N1);
network.addNode(N2);
- try {
- networkForTest.edgesConnecting(N1, NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
- try {
- networkForTest.edgesConnecting(NODE_NOT_IN_GRAPH, N2);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
- try {
- networkForTest.edgesConnecting(NODE_NOT_IN_GRAPH, NODE_NOT_IN_GRAPH);
- fail(ERROR_NODE_NOT_IN_GRAPH);
- } catch (IllegalArgumentException e) {
- assertNodeNotInGraphErrorMessage(e);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkForTest.edgesConnecting(N1, NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
+ e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkForTest.edgesConnecting(NODE_NOT_IN_GRAPH, N2));
+ assertNodeNotInGraphErrorMessage(e);
+ e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> networkForTest.edgesConnecting(NODE_NOT_IN_GRAPH, NODE_NOT_IN_GRAPH));
+ assertNodeNotInGraphErrorMessage(e);
}
@Test
@@ -114,13 +109,10 @@ public final class DefaultNetworkImplementationsTest {
network.addNode(N1);
network.addNode(N2);
Set<String> edgesConnecting = network.edgesConnecting(N1, N2);
- try {
- edgesConnecting.add(E23);
- fail(ERROR_MODIFIABLE_COLLECTION);
- } catch (UnsupportedOperationException e) {
- network.addEdge(N1, N2, E12);
- assertThat(networkForTest.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
- }
+ UnsupportedOperationException e =
+ assertThrows(UnsupportedOperationException.class, () -> edgesConnecting.add(E23));
+ network.addEdge(N1, N2, E12);
+ assertThat(networkForTest.edgesConnecting(N1, N2)).containsExactlyElementsIn(edgesConnecting);
}
@Test
diff --git a/guava-tests/test/com/google/common/graph/EndpointPairTest.java b/guava-tests/test/com/google/common/graph/EndpointPairTest.java
index c67693a71..391f4c838 100644
--- a/guava-tests/test/com/google/common/graph/EndpointPairTest.java
+++ b/guava-tests/test/com/google/common/graph/EndpointPairTest.java
@@ -17,7 +17,7 @@
package com.google.common.graph;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -91,11 +91,7 @@ public final class EndpointPairTest {
for (MutableNetwork<Integer, String> network : testNetworks) {
network.addEdge(1, 2, "1-2");
EndpointPair<Integer> endpointPair = network.incidentNodes("1-2");
- try {
- endpointPair.adjacentNode(3);
- fail("Should have rejected adjacentNode() called with a node not incident to edge.");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> endpointPair.adjacentNode(3));
}
}
@@ -195,11 +191,8 @@ public final class EndpointPairTest {
directedGraph.removeEdge(N2, N1);
containsExactlySanityCheck(edges);
- try {
- edges.add(EndpointPair.ordered(N1, N2));
- fail("Set returned by edges() should be unmodifiable");
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(
+ UnsupportedOperationException.class, () -> edges.add(EndpointPair.ordered(N1, N2)));
}
@Test
diff --git a/guava-tests/test/com/google/common/graph/GraphsTest.java b/guava-tests/test/com/google/common/graph/GraphsTest.java
index 305df1746..6a41b1ad7 100644
--- a/guava-tests/test/com/google/common/graph/GraphsTest.java
+++ b/guava-tests/test/com/google/common/graph/GraphsTest.java
@@ -22,7 +22,7 @@ import static com.google.common.graph.Graphs.reachableNodes;
import static com.google.common.graph.Graphs.transitiveClosure;
import static com.google.common.graph.Graphs.transpose;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableSet;
import java.util.Set;
@@ -400,20 +400,14 @@ public class GraphsTest {
public void inducedSubgraph_nodeNotInGraph() {
MutableNetwork<Integer, String> undirectedGraph = NetworkBuilder.undirected().build();
- try {
- inducedSubgraph(undirectedGraph, ImmutableSet.of(N1));
- fail("Should have rejected getting induced subgraph with node not in original graph.");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> inducedSubgraph(undirectedGraph, ImmutableSet.of(N1)));
}
@Test
public void copyOf_nullArgument() {
- try {
- copyOf((Graph<?>) null);
- fail("Should have rejected a null graph.");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> copyOf((Graph<?>) null));
}
@Test
@@ -476,20 +470,13 @@ public class GraphsTest {
assertThat(directedGraph.edgesConnecting(N2, N1)).isEmpty();
// By default, parallel edges are not allowed.
- try {
- directedGraph.addEdge(N1, N2, E12_A);
- fail(ERROR_ADDED_PARALLEL_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> directedGraph.addEdge(N1, N2, E12_A));
+ assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
// By default, self-loop edges are not allowed.
- try {
- directedGraph.addEdge(N1, N1, E11);
- fail(ERROR_ADDED_SELF_LOOP);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
- }
+ e = assertThrows(IllegalArgumentException.class, () -> directedGraph.addEdge(N1, N1, E11));
+ assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
}
@Test
@@ -502,26 +489,15 @@ public class GraphsTest {
assertThat(undirectedGraph.edgesConnecting(N2, N1)).isEqualTo(ImmutableSet.of(E12));
// By default, parallel edges are not allowed.
- try {
- undirectedGraph.addEdge(N1, N2, E12_A);
- fail(ERROR_ADDED_PARALLEL_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
- }
- try {
- undirectedGraph.addEdge(N2, N1, E21);
- fail(ERROR_ADDED_PARALLEL_EDGE);
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
- }
+ IllegalArgumentException e =
+ assertThrows(IllegalArgumentException.class, () -> undirectedGraph.addEdge(N1, N2, E12_A));
+ assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
+ e = assertThrows(IllegalArgumentException.class, () -> undirectedGraph.addEdge(N2, N1, E21));
+ assertThat(e.getMessage()).contains(ERROR_PARALLEL_EDGE);
// By default, self-loop edges are not allowed.
- try {
- undirectedGraph.addEdge(N1, N1, E11);
- fail(ERROR_ADDED_SELF_LOOP);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
- }
+ e = assertThrows(IllegalArgumentException.class, () -> undirectedGraph.addEdge(N1, N1, E11));
+ assertThat(e).hasMessageThat().contains(ERROR_SELF_LOOP);
}
@Test
@@ -565,12 +541,10 @@ public class GraphsTest {
@Test
public void builder_expectedNodeCount_negative() {
- try {
- NetworkBuilder.directed().expectedNodeCount(-1);
- fail("Should have rejected negative expected node count.");
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_NEGATIVE_COUNT);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> NetworkBuilder.directed().expectedNodeCount(-1));
+ assertThat(e.getMessage()).contains(ERROR_NEGATIVE_COUNT);
}
@Test
@@ -593,12 +567,10 @@ public class GraphsTest {
@Test
public void builder_expectedEdgeCount_negative() {
- try {
- NetworkBuilder.directed().expectedEdgeCount(-1);
- fail("Should have rejected negative expected edge count.");
- } catch (IllegalArgumentException e) {
- assertThat(e.getMessage()).contains(ERROR_NEGATIVE_COUNT);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> NetworkBuilder.directed().expectedEdgeCount(-1));
+ assertThat(e.getMessage()).contains(ERROR_NEGATIVE_COUNT);
}
private static <N> void checkTransitiveClosure(Graph<N> originalGraph, Graph<N> expectedClosure) {
diff --git a/guava-tests/test/com/google/common/graph/PackageSanityTests.java b/guava-tests/test/com/google/common/graph/PackageSanityTests.java
index f1526c235..4c863020e 100644
--- a/guava-tests/test/com/google/common/graph/PackageSanityTests.java
+++ b/guava-tests/test/com/google/common/graph/PackageSanityTests.java
@@ -51,8 +51,14 @@ public class PackageSanityTests extends AbstractPackageSanityTests {
NetworkBuilder.directed().<String, String>immutable().addNode("B").build();
public PackageSanityTests() {
+ MutableNetwork<String, String> mutableNetworkA = NetworkBuilder.directed().build();
+ mutableNetworkA.addNode("a");
+ MutableNetwork<String, String> mutableNetworkB = NetworkBuilder.directed().build();
+ mutableNetworkB.addNode("b");
+
setDistinctValues(AbstractGraphBuilder.class, GRAPH_BUILDER_A, GRAPH_BUILDER_B);
setDistinctValues(Graph.class, IMMUTABLE_GRAPH_A, IMMUTABLE_GRAPH_B);
+ setDistinctValues(MutableNetwork.class, mutableNetworkA, mutableNetworkB);
setDistinctValues(NetworkBuilder.class, NETWORK_BUILDER_A, NETWORK_BUILDER_B);
setDistinctValues(Network.class, IMMUTABLE_NETWORK_A, IMMUTABLE_NETWORK_B);
setDefault(EndpointPair.class, EndpointPair.ordered("A", "B"));
diff --git a/guava-tests/test/com/google/common/graph/TraverserTest.java b/guava-tests/test/com/google/common/graph/TraverserTest.java
index d4c8cf752..a941b9529 100644
--- a/guava-tests/test/com/google/common/graph/TraverserTest.java
+++ b/guava-tests/test/com/google/common/graph/TraverserTest.java
@@ -21,7 +21,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Lists.charactersOf;
import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.ImmutableList;
@@ -311,11 +311,9 @@ public class TraverserTest {
@Test
public void forGraph_breadthFirst_emptyGraph() {
- try {
- Traverser.forGraph(createDirectedGraph()).breadthFirst('a');
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forGraph(createDirectedGraph()).breadthFirst('a'));
}
/**
@@ -326,11 +324,9 @@ public class TraverserTest {
public void forGraph_breadthFirstIterable_emptyGraph() {
assertEqualCharNodes(
Traverser.forGraph(createDirectedGraph()).breadthFirst(charactersOf("")), "");
- try {
- Traverser.forGraph(createDirectedGraph()).breadthFirst(charactersOf("a"));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forGraph(createDirectedGraph()).breadthFirst(charactersOf("a")));
}
/**
@@ -509,22 +505,18 @@ public class TraverserTest {
@Test
public void forGraph_depthFirstPreOrder_emptyGraph() {
- try {
- Traverser.forGraph(createDirectedGraph()).depthFirstPreOrder('a');
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forGraph(createDirectedGraph()).depthFirstPreOrder('a'));
}
@Test
public void forGraph_depthFirstPreOrderIterable_emptyGraph() {
assertEqualCharNodes(
Traverser.forGraph(createDirectedGraph()).depthFirstPreOrder(charactersOf("")), "");
- try {
- Traverser.forGraph(createDirectedGraph()).depthFirstPreOrder(charactersOf("a"));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forGraph(createDirectedGraph()).depthFirstPreOrder(charactersOf("a")));
}
@Test
@@ -691,22 +683,18 @@ public class TraverserTest {
@Test
public void forGraph_depthFirstPostOrder_emptyGraph() {
- try {
- Traverser.forGraph(createDirectedGraph()).depthFirstPostOrder('a');
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forGraph(createDirectedGraph()).depthFirstPostOrder('a'));
}
@Test
public void forGraph_depthFirstPostOrderIterable_emptyGraph() {
assertEqualCharNodes(
Traverser.forGraph(createDirectedGraph()).depthFirstPostOrder(charactersOf("")), "");
- try {
- Traverser.forGraph(createDirectedGraph()).depthFirstPostOrder(charactersOf("a"));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forGraph(createDirectedGraph()).depthFirstPostOrder(charactersOf("a")));
}
@Test
@@ -749,11 +737,7 @@ public class TraverserTest {
MutableGraph<String> graph = GraphBuilder.undirected().build();
graph.putEdge("a", "b");
- try {
- Traverser.forTree(graph);
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Traverser.forTree(graph));
}
@Test
@@ -770,11 +754,7 @@ public class TraverserTest {
MutableValueGraph<String, Integer> valueGraph = ValueGraphBuilder.undirected().build();
valueGraph.putEdgeValue("a", "b", 11);
- try {
- Traverser.forTree(valueGraph);
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Traverser.forTree(valueGraph));
}
@Test
@@ -791,11 +771,7 @@ public class TraverserTest {
MutableNetwork<String, Integer> network = NetworkBuilder.undirected().build();
network.addEdge("a", "b", 11);
- try {
- Traverser.forTree(network);
- fail("Expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Traverser.forTree(network));
}
@Test
@@ -889,22 +865,18 @@ public class TraverserTest {
@Test
public void forTree_breadthFirst_emptyGraph() {
- try {
- Traverser.forTree(createDirectedGraph()).breadthFirst('a');
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forTree(createDirectedGraph()).breadthFirst('a'));
}
@Test
public void forTree_breadthFirstIterable_emptyGraph() {
assertEqualCharNodes(
Traverser.forTree(createDirectedGraph()).breadthFirst(charactersOf("")), "");
- try {
- Traverser.forTree(createDirectedGraph()).breadthFirst(charactersOf("a"));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forTree(createDirectedGraph()).breadthFirst(charactersOf("a")));
}
@Test
@@ -1026,22 +998,18 @@ public class TraverserTest {
@Test
public void forTree_depthFirstPreOrder_emptyGraph() {
- try {
- Traverser.forTree(createDirectedGraph()).depthFirstPreOrder('a');
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forTree(createDirectedGraph()).depthFirstPreOrder('a'));
}
@Test
public void forTree_depthFirstPreOrderIterable_emptyGraph() {
assertEqualCharNodes(
Traverser.forTree(createDirectedGraph()).depthFirstPreOrder(charactersOf("")), "");
- try {
- Traverser.forTree(createDirectedGraph()).depthFirstPreOrder(charactersOf("a"));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forTree(createDirectedGraph()).depthFirstPreOrder(charactersOf("a")));
}
@Test
@@ -1156,22 +1124,18 @@ public class TraverserTest {
@Test
public void forTree_depthFirstPostOrder_emptyGraph() {
- try {
- Traverser.forTree(createDirectedGraph()).depthFirstPostOrder('a');
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forTree(createDirectedGraph()).depthFirstPostOrder('a'));
}
@Test
public void forTree_depthFirstPostOrderIterable_emptyGraph() {
assertEqualCharNodes(
Traverser.forTree(createDirectedGraph()).depthFirstPostOrder(charactersOf("")), "");
- try {
- Traverser.forTree(createDirectedGraph()).depthFirstPostOrder(charactersOf("a"));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Traverser.forTree(createDirectedGraph()).depthFirstPostOrder(charactersOf("a")));
}
@Test
@@ -1201,11 +1165,11 @@ public class TraverserTest {
}
private static SuccessorsFunction<Character> createDirectedGraph(String... edges) {
- return createGraph(/* directed = */ true, edges);
+ return createGraph(/* directed= */ true, edges);
}
private static SuccessorsFunction<Character> createUndirectedGraph(String... edges) {
- return createGraph(/* directed = */ false, edges);
+ return createGraph(/* directed= */ false, edges);
}
/**
diff --git a/guava-tests/test/com/google/common/graph/ValueGraphTest.java b/guava-tests/test/com/google/common/graph/ValueGraphTest.java
index c9be9818d..62e596546 100644
--- a/guava-tests/test/com/google/common/graph/ValueGraphTest.java
+++ b/guava-tests/test/com/google/common/graph/ValueGraphTest.java
@@ -21,10 +21,9 @@ import static com.google.common.graph.TestUtil.assertStronglyEquivalent;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static java.util.concurrent.Executors.newFixedThreadPool;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
-import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.CyclicBarrier;
@@ -198,13 +197,14 @@ public final class ValueGraphTest {
public void edgeValue_directed_mismatch() {
graph = ValueGraphBuilder.directed().build();
graph.putEdgeValue(1, 2, "A");
- try {
- Optional<String> unused = graph.edgeValue(EndpointPair.unordered(1, 2));
- unused = graph.edgeValue(EndpointPair.unordered(2, 1));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graph.edgeValue(EndpointPair.unordered(1, 2)));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graph.edgeValue(EndpointPair.unordered(2, 1)));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -226,18 +226,14 @@ public final class ValueGraphTest {
graph = ValueGraphBuilder.undirected().build();
graph.putEdgeValue(1, 2, "A");
// Check that edgeValue() throws on each possible ordering of an ordered EndpointPair
- try {
- Optional<String> unused = graph.edgeValue(EndpointPair.ordered(1, 2));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
- try {
- Optional<String> unused = graph.edgeValue(EndpointPair.ordered(2, 1));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graph.edgeValue(EndpointPair.ordered(1, 2)));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graph.edgeValue(EndpointPair.ordered(2, 1)));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -259,13 +255,16 @@ public final class ValueGraphTest {
public void edgeValueOrDefault_directed_mismatch() {
graph = ValueGraphBuilder.directed().build();
graph.putEdgeValue(1, 2, "A");
- try {
- String unused = graph.edgeValueOrDefault(EndpointPair.unordered(1, 2), "default");
- unused = graph.edgeValueOrDefault(EndpointPair.unordered(2, 1), "default");
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> graph.edgeValueOrDefault(EndpointPair.unordered(1, 2), "default"));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
+ e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> graph.edgeValueOrDefault(EndpointPair.unordered(2, 1), "default"));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -287,18 +286,16 @@ public final class ValueGraphTest {
graph = ValueGraphBuilder.undirected().build();
graph.putEdgeValue(1, 2, "A");
// Check that edgeValueOrDefault() throws on each possible ordering of an ordered EndpointPair
- try {
- String unused = graph.edgeValueOrDefault(EndpointPair.ordered(1, 2), "default");
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
- try {
- String unused = graph.edgeValueOrDefault(EndpointPair.ordered(2, 1), "default");
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> graph.edgeValueOrDefault(EndpointPair.ordered(1, 2), "default"));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
+ e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> graph.edgeValueOrDefault(EndpointPair.ordered(2, 1), "default"));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -314,23 +311,21 @@ public final class ValueGraphTest {
@Test
public void putEdgeValue_directed_orderMismatch() {
graph = ValueGraphBuilder.directed().build();
- try {
- graph.putEdgeValue(EndpointPair.unordered(1, 2), "irrelevant");
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> graph.putEdgeValue(EndpointPair.unordered(1, 2), "irrelevant"));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
public void putEdgeValue_undirected_orderMismatch() {
graph = ValueGraphBuilder.undirected().build();
- try {
- graph.putEdgeValue(EndpointPair.ordered(1, 2), "irrelevant");
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> graph.putEdgeValue(EndpointPair.ordered(1, 2), "irrelevant"));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -377,13 +372,14 @@ public final class ValueGraphTest {
graph = ValueGraphBuilder.directed().build();
graph.putEdgeValue(1, 2, "1->2");
graph.putEdgeValue(2, 1, "2->1");
- try {
- graph.removeEdge(EndpointPair.unordered(1, 2));
- graph.removeEdge(EndpointPair.unordered(2, 1));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graph.removeEdge(EndpointPair.unordered(1, 2)));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graph.removeEdge(EndpointPair.unordered(2, 1)));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
@@ -391,18 +387,14 @@ public final class ValueGraphTest {
graph = ValueGraphBuilder.undirected().build();
graph.putEdgeValue(1, 2, "1-2");
// Check that removeEdge() throws on each possible ordering of an ordered EndpointPair
- try {
- graph.removeEdge(EndpointPair.ordered(1, 2));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
- try {
- graph.removeEdge(EndpointPair.ordered(2, 1));
- fail("Expected IllegalArgumentException: " + ENDPOINTS_MISMATCH);
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graph.removeEdge(EndpointPair.ordered(1, 2)));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
+ e =
+ assertThrows(
+ IllegalArgumentException.class, () -> graph.removeEdge(EndpointPair.ordered(2, 1)));
+ assertThat(e).hasMessageThat().contains(ENDPOINTS_MISMATCH);
}
@Test
diff --git a/guava-tests/test/com/google/common/hash/AbstractByteHasherTest.java b/guava-tests/test/com/google/common/hash/AbstractByteHasherTest.java
index 7ceb25e0c..8b54d4959 100644
--- a/guava-tests/test/com/google/common/hash/AbstractByteHasherTest.java
+++ b/guava-tests/test/com/google/common/hash/AbstractByteHasherTest.java
@@ -16,6 +16,7 @@ package com.google.common.hash;
import static com.google.common.base.Charsets.UTF_16LE;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertThrows;
import java.io.ByteArrayOutputStream;
import java.util.Random;
@@ -92,21 +93,9 @@ public class AbstractByteHasherTest extends TestCase {
public void testCorrectExceptions() {
TestHasher hasher = new TestHasher();
- try {
- hasher.putBytes(new byte[8], -1, 4);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
- try {
- hasher.putBytes(new byte[8], 0, 16);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
- try {
- hasher.putBytes(new byte[8], 0, -1);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> hasher.putBytes(new byte[8], -1, 4));
+ assertThrows(IndexOutOfBoundsException.class, () -> hasher.putBytes(new byte[8], 0, 16));
+ assertThrows(IndexOutOfBoundsException.class, () -> hasher.putBytes(new byte[8], 0, -1));
}
private class TestHasher extends AbstractByteHasher {
diff --git a/guava-tests/test/com/google/common/hash/AbstractStreamingHasherTest.java b/guava-tests/test/com/google/common/hash/AbstractStreamingHasherTest.java
index 99b2c71a0..77b4e67cc 100644
--- a/guava-tests/test/com/google/common/hash/AbstractStreamingHasherTest.java
+++ b/guava-tests/test/com/google/common/hash/AbstractStreamingHasherTest.java
@@ -17,6 +17,7 @@
package com.google.common.hash;
import static com.google.common.base.Charsets.UTF_16LE;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -113,21 +114,9 @@ public class AbstractStreamingHasherTest extends TestCase {
public void testCorrectExceptions() {
Sink sink = new Sink(4);
- try {
- sink.putBytes(new byte[8], -1, 4);
- fail();
- } catch (IndexOutOfBoundsException ok) {
- }
- try {
- sink.putBytes(new byte[8], 0, 16);
- fail();
- } catch (IndexOutOfBoundsException ok) {
- }
- try {
- sink.putBytes(new byte[8], 0, -1);
- fail();
- } catch (IndexOutOfBoundsException ok) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> sink.putBytes(new byte[8], -1, 4));
+ assertThrows(IndexOutOfBoundsException.class, () -> sink.putBytes(new byte[8], 0, 16));
+ assertThrows(IndexOutOfBoundsException.class, () -> sink.putBytes(new byte[8], 0, -1));
}
/**
diff --git a/guava-tests/test/com/google/common/hash/BloomFilterTest.java b/guava-tests/test/com/google/common/hash/BloomFilterTest.java
index 95306661d..dd9a776d2 100644
--- a/guava-tests/test/com/google/common/hash/BloomFilterTest.java
+++ b/guava-tests/test/com/google/common/hash/BloomFilterTest.java
@@ -18,6 +18,7 @@ package com.google.common.hash;
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableSet;
@@ -36,7 +37,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
-import java.util.stream.Stream;
import junit.framework.TestCase;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -222,38 +222,31 @@ public class BloomFilterTest extends TestCase {
}
public void testPreconditions() {
- try {
- BloomFilter.create(Funnels.unencodedCharsFunnel(), -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- BloomFilter.create(Funnels.unencodedCharsFunnel(), -1, 0.03);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- BloomFilter.create(Funnels.unencodedCharsFunnel(), 1, 0.0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- BloomFilter.create(Funnels.unencodedCharsFunnel(), 1, 1.0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> BloomFilter.create(Funnels.unencodedCharsFunnel(), -1));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> BloomFilter.create(Funnels.unencodedCharsFunnel(), -1, 0.03));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> BloomFilter.create(Funnels.unencodedCharsFunnel(), 1, 0.0));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> BloomFilter.create(Funnels.unencodedCharsFunnel(), 1, 1.0));
}
public void testFailureWhenMoreThan255HashFunctionsAreNeeded() {
- try {
- int n = 1000;
- double p = 0.00000000000000000000000000000000000000000000000000000000000000000000000000000001;
- BloomFilter.create(Funnels.unencodedCharsFunnel(), n, p);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ int n = 1000;
+ double p = 0.00000000000000000000000000000000000000000000000000000000000000000000000000000001;
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ BloomFilter.create(Funnels.unencodedCharsFunnel(), n, p);
+ });
}
+ @AndroidIncompatible // see ImmutableTableTest.testNullPointerInstance
public void testNullPointers() {
NullPointerTester tester = new NullPointerTester();
tester.testAllPublicInstanceMethods(BloomFilter.create(Funnels.unencodedCharsFunnel(), 100));
@@ -290,15 +283,16 @@ public class BloomFilterTest extends TestCase {
// and some crazy values (this used to be capped to Integer.MAX_VALUE, now it can go bigger
assertEquals(3327428144502L, BloomFilter.optimalNumOfBits(Integer.MAX_VALUE, Double.MIN_VALUE));
- try {
- BloomFilter<String> unused =
- BloomFilter.create(HashTestUtils.BAD_FUNNEL, Integer.MAX_VALUE, Double.MIN_VALUE);
- fail("we can't represent such a large BF!");
- } catch (IllegalArgumentException expected) {
- assertThat(expected)
- .hasMessageThat()
- .isEqualTo("Could not create BloomFilter of 3327428144502 bits");
- }
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ BloomFilter<String> unused =
+ BloomFilter.create(HashTestUtils.BAD_FUNNEL, Integer.MAX_VALUE, Double.MIN_VALUE);
+ });
+ assertThat(expected)
+ .hasMessageThat()
+ .isEqualTo("Could not create BloomFilter of 3327428144502 bits");
}
@AndroidIncompatible // OutOfMemoryError
@@ -376,21 +370,6 @@ public class BloomFilterTest extends TestCase {
.testEquals();
}
- public void testCollector() {
- BloomFilter<String> bf1 = BloomFilter.create(Funnels.unencodedCharsFunnel(), 100);
- bf1.put("1");
- bf1.put("2");
-
- assertEquals(
- bf1,
- Stream.of("1", "2")
- .collect(BloomFilter.toBloomFilter(Funnels.unencodedCharsFunnel(), 100)));
- assertEquals(
- bf1,
- Stream.of("2", "1")
- .collect(BloomFilter.toBloomFilter(Funnels.unencodedCharsFunnel(), 100)));
- }
-
public void testEquals() {
BloomFilter<String> bf1 = BloomFilter.create(Funnels.unencodedCharsFunnel(), 100);
bf1.put("1");
@@ -472,29 +451,29 @@ public class BloomFilterTest extends TestCase {
BloomFilter<Integer> bf1 = BloomFilter.create(Funnels.integerFunnel(), 1);
BloomFilter<Integer> bf2 = BloomFilter.create(Funnels.integerFunnel(), 10);
- try {
- assertFalse(bf1.isCompatible(bf2));
- bf1.putAll(bf2);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertFalse(bf1.isCompatible(bf2));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ bf1.putAll(bf2);
+ });
- try {
- assertFalse(bf2.isCompatible(bf1));
- bf2.putAll(bf1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertFalse(bf2.isCompatible(bf1));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ bf2.putAll(bf1);
+ });
}
public void testPutAllWithSelf() {
BloomFilter<Integer> bf1 = BloomFilter.create(Funnels.integerFunnel(), 1);
- try {
- assertFalse(bf1.isCompatible(bf1));
- bf1.putAll(bf1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertFalse(bf1.isCompatible(bf1));
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ bf1.putAll(bf1);
+ });
}
public void testJavaSerialization() {
diff --git a/guava-tests/test/com/google/common/hash/HashCodeTest.java b/guava-tests/test/com/google/common/hash/HashCodeTest.java
index 231fd402b..fc0a7be1e 100644
--- a/guava-tests/test/com/google/common/hash/HashCodeTest.java
+++ b/guava-tests/test/com/google/common/hash/HashCodeTest.java
@@ -17,6 +17,7 @@
package com.google.common.hash;
import static com.google.common.io.BaseEncoding.base16;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
@@ -230,42 +231,22 @@ public class HashCodeTest extends TestCase {
}
public void testFromStringFailsWithInvalidHexChar() {
- try {
- HashCode.fromString("7f8005ff0z");
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> HashCode.fromString("7f8005ff0z"));
}
public void testFromStringFailsWithUpperCaseString() {
String string = Hashing.sha1().hashString("foo", Charsets.US_ASCII).toString().toUpperCase();
- try {
- HashCode.fromString(string);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> HashCode.fromString(string));
}
public void testFromStringFailsWithShortInputs() {
- try {
- HashCode.fromString("");
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- HashCode.fromString("7");
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> HashCode.fromString(""));
+ assertThrows(IllegalArgumentException.class, () -> HashCode.fromString("7"));
HashCode unused = HashCode.fromString("7f");
}
public void testFromStringFailsWithOddLengthInput() {
- try {
- HashCode.fromString("7f8");
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> HashCode.fromString("7f8"));
}
public void testIntWriteBytesTo() {
@@ -316,20 +297,12 @@ public class HashCodeTest extends TestCase {
public void testWriteBytesToUndersizedArray() {
byte[] dest = new byte[3];
- try {
- HASH_ABCD.writeBytesTo(dest, 0, 4);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> HASH_ABCD.writeBytesTo(dest, 0, 4));
}
public void testWriteBytesToUndersizedArrayLongMaxLength() {
byte[] dest = new byte[3];
- try {
- HASH_ABCD.writeBytesTo(dest, 0, 5);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> HASH_ABCD.writeBytesTo(dest, 0, 5));
}
public void testWriteBytesToUndersizedArrayShortMaxLength() {
diff --git a/guava-tests/test/com/google/common/hash/HashingTest.java b/guava-tests/test/com/google/common/hash/HashingTest.java
index aff5c254f..e70219265 100644
--- a/guava-tests/test/com/google/common/hash/HashingTest.java
+++ b/guava-tests/test/com/google/common/hash/HashingTest.java
@@ -18,6 +18,7 @@ package com.google.common.hash;
import static com.google.common.base.Charsets.UTF_8;
import static java.util.Arrays.asList;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableTable;
@@ -219,11 +220,7 @@ public class HashingTest extends TestCase {
private static final int MAX_SHARDS = 500;
public void testConsistentHash_outOfRange() {
- try {
- Hashing.consistentHash(5L, 0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Hashing.consistentHash(5L, 0));
}
public void testConsistentHash_ofHashCode() {
@@ -260,20 +257,19 @@ public class HashingTest extends TestCase {
private static final long RANDOM_SEED = 177L;
public void testCombineOrdered_empty() {
- try {
- Hashing.combineOrdered(Collections.<HashCode>emptySet());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Hashing.combineOrdered(Collections.<HashCode>emptySet()));
}
public void testCombineOrdered_differentBitLengths() {
- try {
- HashCode unused =
- Hashing.combineOrdered(ImmutableList.of(HashCode.fromInt(32), HashCode.fromLong(32L)));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ HashCode unused =
+ Hashing.combineOrdered(
+ ImmutableList.of(HashCode.fromInt(32), HashCode.fromLong(32L)));
+ });
}
public void testCombineOrdered() {
@@ -305,20 +301,19 @@ public class HashingTest extends TestCase {
}
public void testCombineUnordered_empty() {
- try {
- Hashing.combineUnordered(Collections.<HashCode>emptySet());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Hashing.combineUnordered(Collections.<HashCode>emptySet()));
}
public void testCombineUnordered_differentBitLengths() {
- try {
- HashCode unused =
- Hashing.combineUnordered(ImmutableList.of(HashCode.fromInt(32), HashCode.fromLong(32L)));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ HashCode unused =
+ Hashing.combineUnordered(
+ ImmutableList.of(HashCode.fromInt(32), HashCode.fromLong(32L)));
+ });
}
public void testCombineUnordered() {
diff --git a/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java b/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java
index 7783b5fc3..40c1f349e 100644
--- a/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java
+++ b/guava-tests/test/com/google/common/hash/MacHashFunctionTest.java
@@ -18,6 +18,7 @@ package com.google.common.hash;
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.io.BaseEncoding.base16;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableTable;
@@ -225,11 +226,7 @@ public class MacHashFunctionTest extends TestCase {
assertEquals(
"9753980fe94daa8ecaa82216519393a9",
hasher.putString("The quick brown fox jumps over the lazy dog", UTF_8).hash().toString());
- try {
- hasher.putInt(42);
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> hasher.putInt(42));
}
public void testHashTwice() {
@@ -238,11 +235,7 @@ public class MacHashFunctionTest extends TestCase {
assertEquals(
"9753980fe94daa8ecaa82216519393a9",
hasher.putString("The quick brown fox jumps over the lazy dog", UTF_8).hash().toString());
- try {
- hasher.hash();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> hasher.hash());
}
public void testToString() {
diff --git a/guava-tests/test/com/google/common/hash/MessageDigestHashFunctionTest.java b/guava-tests/test/com/google/common/hash/MessageDigestHashFunctionTest.java
index 535d45521..922df28da 100644
--- a/guava-tests/test/com/google/common/hash/MessageDigestHashFunctionTest.java
+++ b/guava-tests/test/com/google/common/hash/MessageDigestHashFunctionTest.java
@@ -16,6 +16,8 @@
package com.google.common.hash;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -65,11 +67,7 @@ public class MessageDigestHashFunctionTest extends TestCase {
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
.toString());
- try {
- sha1.putInt(42);
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> sha1.putInt(42));
}
public void testHashTwice() {
@@ -80,11 +78,7 @@ public class MessageDigestHashFunctionTest extends TestCase {
sha1.putString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)
.hash()
.toString());
- try {
- sha1.hash();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> sha1.hash());
}
public void testToString() {
diff --git a/guava-tests/test/com/google/common/io/AppendableWriterTest.java b/guava-tests/test/com/google/common/io/AppendableWriterTest.java
index dd0408362..bfc6a082f 100644
--- a/guava-tests/test/com/google/common/io/AppendableWriterTest.java
+++ b/guava-tests/test/com/google/common/io/AppendableWriterTest.java
@@ -16,6 +16,8 @@
package com.google.common.io;
+import static org.junit.Assert.assertThrows;
+
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
@@ -113,17 +115,9 @@ public class AppendableWriterTest extends IoTestCase {
writer.write("Hi");
writer.close();
- try {
- writer.write(" Greg");
- fail("Should have thrown IOException due to writer already closed");
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> writer.write(" Greg"));
- try {
- writer.flush();
- fail("Should have thrown IOException due to writer already closed");
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> writer.flush());
// close()ing already closed writer is allowed
writer.close();
diff --git a/guava-tests/test/com/google/common/io/ByteSinkTest.java b/guava-tests/test/com/google/common/io/ByteSinkTest.java
index 208a8fc5e..4ce3981c0 100644
--- a/guava-tests/test/com/google/common/io/ByteSinkTest.java
+++ b/guava-tests/test/com/google/common/io/ByteSinkTest.java
@@ -21,6 +21,7 @@ import static com.google.common.io.TestOption.OPEN_THROWS;
import static com.google.common.io.TestOption.READ_THROWS;
import static com.google.common.io.TestOption.WRITE_THROWS;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertThrows;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -82,11 +83,7 @@ public class ByteSinkTest extends IoTestCase {
for (TestOption option : EnumSet.of(OPEN_THROWS, READ_THROWS, CLOSE_THROWS)) {
TestByteSource failSource = new TestByteSource(new byte[10], option);
TestByteSink okSink = new TestByteSink();
- try {
- failSource.copyTo(okSink);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> failSource.copyTo(okSink));
// ensure stream was closed IF it was opened (depends on implementation whether or not it's
// opened at all if source.newInputStream() throws).
assertTrue(
@@ -97,22 +94,14 @@ public class ByteSinkTest extends IoTestCase {
public void testClosesOnErrors_whenWriteThrows() {
TestByteSink failSink = new TestByteSink(WRITE_THROWS);
- try {
- new TestByteSource(new byte[10]).copyTo(failSink);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> new TestByteSource(new byte[10]).copyTo(failSink));
assertTrue(failSink.wasStreamClosed());
}
- public void testClosesOnErrors_writingFromInputStreamThatThrows() {
+ public void testClosesOnErrors_writingFromInputStreamThatThrows() throws IOException {
TestByteSink okSink = new TestByteSink();
- try {
- TestInputStream in = new TestInputStream(new ByteArrayInputStream(new byte[10]), READ_THROWS);
- okSink.writeFrom(in);
- fail();
- } catch (IOException expected) {
- }
+ TestInputStream in = new TestInputStream(new ByteArrayInputStream(new byte[10]), READ_THROWS);
+ assertThrows(IOException.class, () -> okSink.writeFrom(in));
assertTrue(okSink.wasStreamClosed());
}
}
diff --git a/guava-tests/test/com/google/common/io/ByteSourceTest.java b/guava-tests/test/com/google/common/io/ByteSourceTest.java
index 58ad653c2..078b0f98b 100644
--- a/guava-tests/test/com/google/common/io/ByteSourceTest.java
+++ b/guava-tests/test/com/google/common/io/ByteSourceTest.java
@@ -24,6 +24,7 @@ import static com.google.common.io.TestOption.READ_THROWS;
import static com.google.common.io.TestOption.SKIP_THROWS;
import static com.google.common.io.TestOption.WRITE_THROWS;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
@@ -199,17 +200,9 @@ public class ByteSourceTest extends IoTestCase {
public void testSlice() throws IOException {
// Test preconditions
- try {
- source.slice(-1, 10);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> source.slice(-1, 10));
- try {
- source.slice(0, -1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> source.slice(0, -1));
assertCorrectSlice(0, 0, 0, 0);
assertCorrectSlice(0, 0, 1, 0);
@@ -320,11 +313,7 @@ public class ByteSourceTest extends IoTestCase {
public void testClosesOnErrors_copyingToByteSinkThatThrows() {
for (TestOption option : EnumSet.of(OPEN_THROWS, WRITE_THROWS, CLOSE_THROWS)) {
TestByteSource okSource = new TestByteSource(bytes);
- try {
- okSource.copyTo(new TestByteSink(option));
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> okSource.copyTo(new TestByteSink(option)));
// ensure stream was closed IF it was opened (depends on implementation whether or not it's
// opened at all if sink.newOutputStream() throws).
assertTrue(
@@ -335,22 +324,14 @@ public class ByteSourceTest extends IoTestCase {
public void testClosesOnErrors_whenReadThrows() {
TestByteSource failSource = new TestByteSource(bytes, READ_THROWS);
- try {
- failSource.copyTo(new TestByteSink());
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> failSource.copyTo(new TestByteSink()));
assertTrue(failSource.wasStreamClosed());
}
- public void testClosesOnErrors_copyingToOutputStreamThatThrows() {
+ public void testClosesOnErrors_copyingToOutputStreamThatThrows() throws IOException {
TestByteSource okSource = new TestByteSource(bytes);
- try {
- OutputStream out = new TestOutputStream(ByteStreams.nullOutputStream(), WRITE_THROWS);
- okSource.copyTo(out);
- fail();
- } catch (IOException expected) {
- }
+ OutputStream out = new TestOutputStream(ByteStreams.nullOutputStream(), WRITE_THROWS);
+ assertThrows(IOException.class, () -> okSource.copyTo(out));
assertTrue(okSource.wasStreamClosed());
}
diff --git a/guava-tests/test/com/google/common/io/ByteSourceTester.java b/guava-tests/test/com/google/common/io/ByteSourceTester.java
index fe10810f6..187c2d00a 100644
--- a/guava-tests/test/com/google/common/io/ByteSourceTester.java
+++ b/guava-tests/test/com/google/common/io/ByteSourceTester.java
@@ -19,6 +19,7 @@ package com.google.common.io;
import static com.google.common.io.SourceSinkFactory.ByteSourceFactory;
import static com.google.common.io.SourceSinkFactory.CharSourceFactory;
import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Charsets;
import com.google.common.base.Optional;
@@ -219,17 +220,15 @@ public class ByteSourceTester extends SourceSinkTester<ByteSource, byte[], ByteS
}
public void testSlice_illegalArguments() {
- try {
- source.slice(-1, 0);
- fail("expected IllegalArgumentException for call to slice with offset -1: " + source);
- } catch (IllegalArgumentException expected) {
- }
-
- try {
- source.slice(0, -1);
- fail("expected IllegalArgumentException for call to slice with length -1: " + source);
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ "expected IllegalArgumentException for call to slice with offset -1: " + source,
+ IllegalArgumentException.class,
+ () -> source.slice(-1, 0));
+
+ assertThrows(
+ "expected IllegalArgumentException for call to slice with length -1: " + source,
+ IllegalArgumentException.class,
+ () -> source.slice(0, -1));
}
// Test that you can not expand the readable data in a previously sliced ByteSource.
diff --git a/guava-tests/test/com/google/common/io/ByteStreamsTest.java b/guava-tests/test/com/google/common/io/ByteStreamsTest.java
index 2598b9fed..cd8332c21 100644
--- a/guava-tests/test/com/google/common/io/ByteStreamsTest.java
+++ b/guava-tests/test/com/google/common/io/ByteStreamsTest.java
@@ -17,6 +17,7 @@
package com.google.common.io;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Charsets;
import java.io.ByteArrayInputStream;
@@ -76,47 +77,24 @@ public class ByteStreamsTest extends IoTestCase {
public void testReadFully() throws IOException {
byte[] b = new byte[10];
- try {
- ByteStreams.readFully(newTestStream(10), null, 0, 10);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(
+ NullPointerException.class, () -> ByteStreams.readFully(newTestStream(10), null, 0, 10));
- try {
- ByteStreams.readFully(null, b, 0, 10);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> ByteStreams.readFully(null, b, 0, 10));
- try {
- ByteStreams.readFully(newTestStream(10), b, -1, 10);
- fail("expected exception");
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(
+ IndexOutOfBoundsException.class, () -> ByteStreams.readFully(newTestStream(10), b, -1, 10));
- try {
- ByteStreams.readFully(newTestStream(10), b, 0, -1);
- fail("expected exception");
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(
+ IndexOutOfBoundsException.class, () -> ByteStreams.readFully(newTestStream(10), b, 0, -1));
- try {
- ByteStreams.readFully(newTestStream(10), b, 0, -1);
- fail("expected exception");
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(
+ IndexOutOfBoundsException.class, () -> ByteStreams.readFully(newTestStream(10), b, 0, -1));
- try {
- ByteStreams.readFully(newTestStream(10), b, 2, 10);
- fail("expected exception");
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(
+ IndexOutOfBoundsException.class, () -> ByteStreams.readFully(newTestStream(10), b, 2, 10));
- try {
- ByteStreams.readFully(newTestStream(5), b, 0, 10);
- fail("expected exception");
- } catch (EOFException expected) {
- }
+ assertThrows(EOFException.class, () -> ByteStreams.readFully(newTestStream(5), b, 0, 10));
Arrays.fill(b, (byte) 0);
ByteStreams.readFully(newTestStream(10), b, 0, 0);
@@ -138,11 +116,7 @@ public class ByteStreamsTest extends IoTestCase {
skipHelper(50, 50, new SlowSkipper(new ByteArrayInputStream(bytes), 1));
skipHelper(50, 50, new SlowSkipper(new ByteArrayInputStream(bytes), 0));
skipHelper(100, -1, new ByteArrayInputStream(bytes));
- try {
- skipHelper(101, 0, new ByteArrayInputStream(bytes));
- fail("expected exception");
- } catch (EOFException expected) {
- }
+ assertThrows(EOFException.class, () -> skipHelper(101, 0, new ByteArrayInputStream(bytes)));
}
private static void skipHelper(long n, int expect, InputStream in) throws IOException {
@@ -156,22 +130,14 @@ public class ByteStreamsTest extends IoTestCase {
public void testNewDataInput_empty() {
byte[] b = new byte[0];
ByteArrayDataInput in = ByteStreams.newDataInput(b);
- try {
- in.readInt();
- fail("expected exception");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> in.readInt());
}
public void testNewDataInput_normal() {
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
assertEquals(0x12345678, in.readInt());
assertEquals(0x76543210, in.readInt());
- try {
- in.readInt();
- fail("expected exception");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> in.readInt());
}
public void testNewDataInput_readFully() {
@@ -184,12 +150,9 @@ public class ByteStreamsTest extends IoTestCase {
public void testNewDataInput_readFullyAndThenSome() {
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
byte[] actual = new byte[bytes.length * 2];
- try {
- in.readFully(actual);
- fail("expected exception");
- } catch (IllegalStateException ex) {
- assertThat(ex).hasCauseThat().isInstanceOf(EOFException.class);
- }
+ IllegalStateException ex =
+ assertThrows(IllegalStateException.class, () -> in.readFully(actual));
+ assertThat(ex).hasCauseThat().isInstanceOf(EOFException.class);
}
public void testNewDataInput_readFullyWithOffset() {
@@ -266,12 +229,8 @@ public class ByteStreamsTest extends IoTestCase {
for (byte aByte : bytes) {
assertEquals(aByte, in.readByte());
}
- try {
- in.readByte();
- fail("expected exception");
- } catch (IllegalStateException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(EOFException.class);
- }
+ IllegalStateException expected = assertThrows(IllegalStateException.class, () -> in.readByte());
+ assertThat(expected).hasCauseThat().isInstanceOf(EOFException.class);
}
public void testNewDataInput_readUnsignedByte() {
@@ -279,22 +238,15 @@ public class ByteStreamsTest extends IoTestCase {
for (byte aByte : bytes) {
assertEquals(aByte, in.readUnsignedByte());
}
- try {
- in.readUnsignedByte();
- fail("expected exception");
- } catch (IllegalStateException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(EOFException.class);
- }
+ IllegalStateException expected =
+ assertThrows(IllegalStateException.class, () -> in.readUnsignedByte());
+ assertThat(expected).hasCauseThat().isInstanceOf(EOFException.class);
}
public void testNewDataInput_offset() {
ByteArrayDataInput in = ByteStreams.newDataInput(bytes, 2);
assertEquals(0x56787654, in.readInt());
- try {
- in.readInt();
- fail("expected exception");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> in.readInt());
}
public void testNewDataInput_skip() {
@@ -572,37 +524,13 @@ public class ByteStreamsTest extends IoTestCase {
public void testNullOutputStream_exceptions() throws Exception {
OutputStream nos = ByteStreams.nullOutputStream();
- try {
- nos.write(null);
- fail();
- } catch (NullPointerException expected) {
- }
- try {
- nos.write(null, 0, 1);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> nos.write(null));
+ assertThrows(NullPointerException.class, () -> nos.write(null, 0, 1));
byte[] tenBytes = new byte[10];
- try {
- nos.write(tenBytes, -1, 1);
- fail("Expected exception from negative offset");
- } catch (IndexOutOfBoundsException expected) {
- }
- try {
- nos.write(tenBytes, 1, -1);
- fail("Expected exception from negative length");
- } catch (IndexOutOfBoundsException expected) {
- }
- try {
- nos.write(tenBytes, 9, 2);
- fail("Expected exception from offset+length > array size");
- } catch (IndexOutOfBoundsException expected) {
- }
- try {
- nos.write(tenBytes, 9, 100);
- fail("Expected exception from offset+length > array size");
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> nos.write(tenBytes, -1, 1));
+ assertThrows(IndexOutOfBoundsException.class, () -> nos.write(tenBytes, 1, -1));
+ assertThrows(IndexOutOfBoundsException.class, () -> nos.write(tenBytes, 9, 2));
+ assertThrows(IndexOutOfBoundsException.class, () -> nos.write(tenBytes, 9, 100));
}
public void testLimit() throws Exception {
@@ -679,23 +607,15 @@ public class ByteStreamsTest extends IoTestCase {
InputStream bin = new ByteArrayInputStream(big);
InputStream lin = ByteStreams.limit(bin, 2);
- try {
- lin.reset();
- fail();
- } catch (IOException expected) {
- assertThat(expected).hasMessageThat().isEqualTo("Mark not set");
- }
+ IOException expected = assertThrows(IOException.class, () -> lin.reset());
+ assertThat(expected).hasMessageThat().isEqualTo("Mark not set");
}
public void testLimit_markNotSupported() {
InputStream lin = ByteStreams.limit(new UnmarkableInputStream(), 2);
- try {
- lin.reset();
- fail();
- } catch (IOException expected) {
- assertThat(expected).hasMessageThat().isEqualTo("Mark not supported");
- }
+ IOException expected = assertThrows(IOException.class, () -> lin.reset());
+ assertThat(expected).hasMessageThat().isEqualTo("Mark not supported");
}
private static class UnmarkableInputStream extends InputStream {
diff --git a/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java b/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java
index dbe94fcf7..6a4b3c472 100644
--- a/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java
+++ b/guava-tests/test/com/google/common/io/CharSequenceReaderTest.java
@@ -16,6 +16,8 @@
package com.google.common.io;
+import static org.junit.Assert.assertThrows;
+
import java.io.IOException;
import java.nio.CharBuffer;
import junit.framework.TestCase;
@@ -73,106 +75,42 @@ public class CharSequenceReaderTest extends TestCase {
CharSequenceReader reader = new CharSequenceReader("12345");
char[] buf = new char[10];
- try {
- reader.read(buf, 0, 11);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> reader.read(buf, 0, 11));
- try {
- reader.read(buf, 10, 1);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> reader.read(buf, 10, 1));
- try {
- reader.read(buf, 11, 0);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> reader.read(buf, 11, 0));
- try {
- reader.read(buf, -1, 5);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> reader.read(buf, -1, 5));
- try {
- reader.read(buf, 5, -1);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> reader.read(buf, 5, -1));
- try {
- reader.read(buf, 0, 11);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> reader.read(buf, 0, 11));
- try {
- reader.skip(-1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> reader.skip(-1));
- try {
- reader.mark(-1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> reader.mark(-1));
}
public void testMethodsThrowWhenClosed() throws IOException {
CharSequenceReader reader = new CharSequenceReader("");
reader.close();
- try {
- reader.read();
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.read());
- try {
- reader.read(new char[10]);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.read(new char[10]));
- try {
- reader.read(new char[10], 0, 10);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.read(new char[10], 0, 10));
- try {
- reader.read(CharBuffer.allocate(10));
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.read(CharBuffer.allocate(10)));
- try {
- reader.skip(10);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.skip(10));
- try {
- reader.ready();
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.ready());
- try {
- reader.mark(10);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.mark(10));
- try {
- reader.reset();
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> reader.reset());
}
/**
diff --git a/guava-tests/test/com/google/common/io/CharSinkTest.java b/guava-tests/test/com/google/common/io/CharSinkTest.java
index e51b43cbb..ac07dc2ee 100644
--- a/guava-tests/test/com/google/common/io/CharSinkTest.java
+++ b/guava-tests/test/com/google/common/io/CharSinkTest.java
@@ -20,6 +20,7 @@ import static com.google.common.io.TestOption.CLOSE_THROWS;
import static com.google.common.io.TestOption.OPEN_THROWS;
import static com.google.common.io.TestOption.READ_THROWS;
import static com.google.common.io.TestOption.WRITE_THROWS;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
@@ -104,11 +105,7 @@ public class CharSinkTest extends IoTestCase {
for (TestOption option : EnumSet.of(OPEN_THROWS, READ_THROWS, CLOSE_THROWS)) {
TestCharSource failSource = new TestCharSource(STRING, option);
TestCharSink okSink = new TestCharSink();
- try {
- failSource.copyTo(okSink);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> failSource.copyTo(okSink));
// ensure writer was closed IF it was opened (depends on implementation whether or not it's
// opened at all if source.newReader() throws).
assertTrue(
@@ -119,21 +116,13 @@ public class CharSinkTest extends IoTestCase {
public void testClosesOnErrors_whenWriteThrows() {
TestCharSink failSink = new TestCharSink(WRITE_THROWS);
- try {
- new TestCharSource(STRING).copyTo(failSink);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> new TestCharSource(STRING).copyTo(failSink));
assertTrue(failSink.wasStreamClosed());
}
public void testClosesOnErrors_whenWritingFromReaderThatThrows() {
TestCharSink okSink = new TestCharSink();
- try {
- okSink.writeFrom(new TestReader(READ_THROWS));
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> okSink.writeFrom(new TestReader(READ_THROWS)));
assertTrue(okSink.wasStreamClosed());
}
}
diff --git a/guava-tests/test/com/google/common/io/CharSourceTest.java b/guava-tests/test/com/google/common/io/CharSourceTest.java
index 787d744b7..cf305fd61 100644
--- a/guava-tests/test/com/google/common/io/CharSourceTest.java
+++ b/guava-tests/test/com/google/common/io/CharSourceTest.java
@@ -21,6 +21,7 @@ import static com.google.common.io.TestOption.CLOSE_THROWS;
import static com.google.common.io.TestOption.OPEN_THROWS;
import static com.google.common.io.TestOption.READ_THROWS;
import static com.google.common.io.TestOption.WRITE_THROWS;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -210,11 +211,7 @@ public class CharSourceTest extends IoTestCase {
public void testClosesOnErrors_copyingToCharSinkThatThrows() {
for (TestOption option : EnumSet.of(OPEN_THROWS, WRITE_THROWS, CLOSE_THROWS)) {
TestCharSource okSource = new TestCharSource(STRING);
- try {
- okSource.copyTo(new TestCharSink(option));
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> okSource.copyTo(new TestCharSink(option)));
// ensure reader was closed IF it was opened (depends on implementation whether or not it's
// opened at all if sink.newWriter() throws).
assertTrue(
@@ -225,21 +222,13 @@ public class CharSourceTest extends IoTestCase {
public void testClosesOnErrors_whenReadThrows() {
TestCharSource failSource = new TestCharSource(STRING, READ_THROWS);
- try {
- failSource.copyTo(new TestCharSink());
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> failSource.copyTo(new TestCharSink()));
assertTrue(failSource.wasStreamClosed());
}
public void testClosesOnErrors_copyingToWriterThatThrows() {
TestCharSource okSource = new TestCharSource(STRING);
- try {
- okSource.copyTo(new TestWriter(WRITE_THROWS));
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> okSource.copyTo(new TestWriter(WRITE_THROWS)));
assertTrue(okSource.wasStreamClosed());
}
@@ -362,7 +351,9 @@ public class CharSourceTest extends IoTestCase {
}
}
- /** @return the number of exceptions that were suppressed on the expected thrown exception */
+ /**
+ * @return the number of exceptions that were suppressed on the expected thrown exception
+ */
private static int runSuppressionFailureTest(CharSource in, CharSink out) {
try {
in.copyTo(out);
diff --git a/guava-tests/test/com/google/common/io/CharStreamsTest.java b/guava-tests/test/com/google/common/io/CharStreamsTest.java
index 9b2c24e28..ea5e51c29 100644
--- a/guava-tests/test/com/google/common/io/CharStreamsTest.java
+++ b/guava-tests/test/com/google/common/io/CharStreamsTest.java
@@ -16,6 +16,8 @@
package com.google.common.io;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import java.io.EOFException;
@@ -118,11 +120,7 @@ public class CharStreamsTest extends IoTestCase {
public void testSkipFully_EOF() throws IOException {
Reader reader = new StringReader("abcde");
- try {
- CharStreams.skipFully(reader, 6);
- fail("expected EOFException");
- } catch (EOFException expected) {
- }
+ assertThrows(EOFException.class, () -> CharStreams.skipFully(reader, 6));
}
public void testSkipFully() throws IOException {
@@ -270,17 +268,9 @@ public class CharStreamsTest extends IoTestCase {
nullWriter.append(null);
nullWriter.append(null, 0, 4);
- try {
- nullWriter.append(null, -1, 4);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
-
- try {
- nullWriter.append(null, 0, 5);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> nullWriter.append(null, -1, 4));
+
+ assertThrows(IndexOutOfBoundsException.class, () -> nullWriter.append(null, 0, 5));
// nothing really to assert?
assertSame(CharStreams.nullWriter(), CharStreams.nullWriter());
diff --git a/guava-tests/test/com/google/common/io/CountingInputStreamTest.java b/guava-tests/test/com/google/common/io/CountingInputStreamTest.java
index 163027b49..945f5d023 100644
--- a/guava-tests/test/com/google/common/io/CountingInputStreamTest.java
+++ b/guava-tests/test/com/google/common/io/CountingInputStreamTest.java
@@ -17,6 +17,7 @@
package com.google.common.io;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -90,23 +91,15 @@ public class CountingInputStreamTest extends IoTestCase {
}
public void testMarkNotSet() {
- try {
- counter.reset();
- fail();
- } catch (IOException expected) {
- assertThat(expected).hasMessageThat().isEqualTo("Mark not set");
- }
+ IOException expected = assertThrows(IOException.class, () -> counter.reset());
+ assertThat(expected).hasMessageThat().isEqualTo("Mark not set");
}
public void testMarkNotSupported() {
counter = new CountingInputStream(new UnmarkableInputStream());
- try {
- counter.reset();
- fail();
- } catch (IOException expected) {
- assertThat(expected).hasMessageThat().isEqualTo("Mark not supported");
- }
+ IOException expected = assertThrows(IOException.class, () -> counter.reset());
+ assertThat(expected).hasMessageThat().isEqualTo("Mark not supported");
}
private static class UnmarkableInputStream extends InputStream {
diff --git a/guava-tests/test/com/google/common/io/CountingOutputStreamTest.java b/guava-tests/test/com/google/common/io/CountingOutputStreamTest.java
index 870692b32..d5023492b 100644
--- a/guava-tests/test/com/google/common/io/CountingOutputStreamTest.java
+++ b/guava-tests/test/com/google/common/io/CountingOutputStreamTest.java
@@ -16,6 +16,8 @@
package com.google.common.io;
+import static org.junit.Assert.assertThrows;
+
import java.io.ByteArrayOutputStream;
/**
@@ -54,11 +56,7 @@ public class CountingOutputStreamTest extends IoTestCase {
assertEquals(written, counter.getCount());
// Test that illegal arguments do not affect count
- try {
- counter.write(data, 0, data.length + 1);
- fail("expected exception");
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> counter.write(data, 0, data.length + 1));
assertEquals(written, out.size());
assertEquals(written, counter.getCount());
}
diff --git a/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java b/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java
index 3d756a88b..daf47a6f4 100644
--- a/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java
+++ b/guava-tests/test/com/google/common/io/FileBackedOutputStreamTest.java
@@ -137,11 +137,7 @@ public class FileBackedOutputStreamTest extends IoTestCase {
assertTrue(Arrays.equals(data, source.read()));
out.close();
- try {
- out.write(42);
- fail("expected exception");
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> out.write(42));
// Verify that write had no effect
assertTrue(Arrays.equals(data, source.read()));
diff --git a/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java b/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java
index a31c43770..381eef258 100644
--- a/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java
+++ b/guava-tests/test/com/google/common/io/FilesCreateTempDirTest.java
@@ -17,6 +17,7 @@
package com.google.common.io;
import static com.google.common.base.StandardSystemProperty.JAVA_IO_TMPDIR;
+import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.truth.Truth.assertThat;
import static java.nio.file.attribute.PosixFilePermission.OWNER_EXECUTE;
@@ -64,6 +65,44 @@ public class FilesCreateTempDirTest extends TestCase {
}
}
+ public void testBogusSystemPropertiesUsername() {
+ if (isAndroid()) {
+ /*
+ * The test calls directly into the "ACL-based filesystem" code, which isn't available under
+ * old versions of Android. Since Android doesn't use that code path, anyway, there's no need
+ * to test it.
+ */
+ return;
+ }
+
+ /*
+ * Only under Windows (or hypothetically when running with some other non-POSIX, ACL-based
+ * filesystem) does our prod code look up the username. Thus, this test doesn't necessarily test
+ * anything interesting under most environments. Still, we can run it (except for Android, at
+ * least old versions), so we mostly do. This is useful because we don't actually run our CI on
+ * Windows under Java 8, at least as of this writing.
+ *
+ * Under Windows in particular, we want to test that:
+ *
+ * - Under Java 9+, createTempDir() succeeds because it can look up the *real* username, rather
+ * than relying on the one from the system property.
+ *
+ * - Under Java 8, createTempDir() fails because it falls back to the bogus username from the
+ * system property.
+ */
+
+ String save = System.getProperty("user.name");
+ System.setProperty("user.name", "-this-is-definitely-not-the-username-we-are-running-as//?");
+ try {
+ TempFileCreator.testMakingUserPermissionsFromScratch();
+ assertThat(isJava8()).isFalse();
+ } catch (IOException expectedIfJava8) {
+ assertThat(isJava8()).isTrue();
+ } finally {
+ System.setProperty("user.name", save);
+ }
+ }
+
private static boolean isAndroid() {
return System.getProperty("java.runtime.name", "").contains("Android");
}
@@ -71,4 +110,8 @@ public class FilesCreateTempDirTest extends TestCase {
private static boolean isWindows() {
return OS_NAME.value().startsWith("Windows");
}
+
+ private static boolean isJava8() {
+ return JAVA_SPECIFICATION_VERSION.value().equals("1.8");
+ }
}
diff --git a/guava-tests/test/com/google/common/io/FilesTest.java b/guava-tests/test/com/google/common/io/FilesTest.java
index 6ffcf5c81..abe2c4e25 100644
--- a/guava-tests/test/com/google/common/io/FilesTest.java
+++ b/guava-tests/test/com/google/common/io/FilesTest.java
@@ -17,6 +17,7 @@
package com.google.common.io;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
@@ -133,11 +134,7 @@ public class FilesTest extends IoTestCase {
Files.write(data, temp);
assertTrue(Arrays.equals(data, Files.toByteArray(temp)));
- try {
- Files.write(null, temp);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Files.write(null, temp));
}
public void testAppendString() throws IOException {
@@ -176,22 +173,14 @@ public class FilesTest extends IoTestCase {
File temp2 = file(temp1.getPath());
assertEquals(temp1, temp2);
Files.write(ASCII, temp1, Charsets.UTF_8);
- try {
- Files.copy(temp1, temp2);
- fail("Expected an IAE to be thrown but wasn't");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Files.copy(temp1, temp2));
assertEquals(ASCII, Files.toString(temp1, Charsets.UTF_8));
}
public void testCopySameFile() throws IOException {
File temp = createTempFile();
Files.write(ASCII, temp, Charsets.UTF_8);
- try {
- Files.copy(temp, temp);
- fail("Expected an IAE to be thrown but wasn't");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Files.copy(temp, temp));
assertEquals(ASCII, Files.toString(temp, Charsets.UTF_8));
}
@@ -232,17 +221,9 @@ public class FilesTest extends IoTestCase {
public void testNewReader() throws IOException {
File asciiFile = getTestFile("ascii.txt");
- try {
- Files.newReader(asciiFile, null);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Files.newReader(asciiFile, null));
- try {
- Files.newReader(null, Charsets.UTF_8);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Files.newReader(null, Charsets.UTF_8));
BufferedReader r = Files.newReader(asciiFile, Charsets.US_ASCII);
try {
@@ -254,17 +235,9 @@ public class FilesTest extends IoTestCase {
public void testNewWriter() throws IOException {
File temp = createTempFile();
- try {
- Files.newWriter(temp, null);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Files.newWriter(temp, null));
- try {
- Files.newWriter(null, Charsets.UTF_8);
- fail("expected exception");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Files.newWriter(null, Charsets.UTF_8));
BufferedWriter w = Files.newWriter(temp, Charsets.UTF_8);
try {
@@ -287,19 +260,18 @@ public class FilesTest extends IoTestCase {
Files.touch(temp);
assertTrue(temp.exists());
- try {
- Files.touch(
- new File(temp.getPath()) {
- @Override
- public boolean setLastModified(long t) {
- return false;
- }
+ assertThrows(
+ IOException.class,
+ () ->
+ Files.touch(
+ new File(temp.getPath()) {
+ @Override
+ public boolean setLastModified(long t) {
+ return false;
+ }
- private static final long serialVersionUID = 0;
- });
- fail("expected exception");
- } catch (IOException expected) {
- }
+ private static final long serialVersionUID = 0;
+ }));
}
public void testTouchTime() throws IOException {
@@ -356,11 +328,7 @@ public class FilesTest extends IoTestCase {
File parent = getTestFile("ascii.txt");
assertTrue(parent.isFile());
File file = file(parent, "foo");
- try {
- Files.createParentDirs(file);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> Files.createParentDirs(file));
}
public void testMove() throws IOException {
@@ -391,12 +359,8 @@ public class FilesTest extends IoTestCase {
moveHelper(
false, new UnmovableFile(temp1, false, false), new UnmovableFile(temp2, true, false));
- try {
- File asciiFile = getTestFile("ascii.txt");
- moveHelper(false, asciiFile, asciiFile);
- fail("expected exception");
- } catch (IllegalArgumentException expected) {
- }
+ File asciiFile = getTestFile("ascii.txt");
+ assertThrows(IllegalArgumentException.class, () -> moveHelper(false, asciiFile, asciiFile));
}
private void moveHelper(boolean success, File from, File to) throws IOException {
@@ -547,11 +511,7 @@ public class FilesTest extends IoTestCase {
assertTrue(deleted);
// Test
- try {
- Files.map(file);
- fail("Should have thrown FileNotFoundException.");
- } catch (FileNotFoundException expected) {
- }
+ assertThrows(FileNotFoundException.class, () -> Files.map(file));
}
public void testMap_readWrite() throws IOException {
@@ -603,11 +563,9 @@ public class FilesTest extends IoTestCase {
// Setup
File file = createTempFile();
// Test
- try {
- Files.map(file, MapMode.READ_WRITE, (long) Integer.MAX_VALUE + 1);
- fail("Should throw when size exceeds Integer.MAX_VALUE");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Files.map(file, MapMode.READ_WRITE, (long) Integer.MAX_VALUE + 1));
}
public void testGetFileExtension() {
diff --git a/guava-tests/test/com/google/common/io/LittleEndianDataInputStreamTest.java b/guava-tests/test/com/google/common/io/LittleEndianDataInputStreamTest.java
index 160df410b..faa0b9549 100644
--- a/guava-tests/test/com/google/common/io/LittleEndianDataInputStreamTest.java
+++ b/guava-tests/test/com/google/common/io/LittleEndianDataInputStreamTest.java
@@ -17,6 +17,7 @@
package com.google.common.io;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.primitives.Bytes;
import java.io.ByteArrayInputStream;
@@ -75,32 +76,21 @@ public class LittleEndianDataInputStreamTest extends TestCase {
public void testReadUnsignedByte_eof() throws IOException {
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(new byte[0]));
- try {
- in.readUnsignedByte();
- fail();
- } catch (EOFException expected) {
- }
+ assertThrows(EOFException.class, () -> in.readUnsignedByte());
}
public void testReadUnsignedShort_eof() throws IOException {
byte[] buf = {23};
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(buf));
- try {
- in.readUnsignedShort();
- fail();
- } catch (EOFException expected) {
- }
+ assertThrows(EOFException.class, () -> in.readUnsignedShort());
}
@SuppressWarnings("DoNotCall")
public void testReadLine() throws IOException {
DataInput in = new LittleEndianDataInputStream(new ByteArrayInputStream(data));
- try {
- in.readLine();
- fail();
- } catch (UnsupportedOperationException expected) {
- assertThat(expected).hasMessageThat().isEqualTo("readLine is not supported");
- }
+ UnsupportedOperationException expected =
+ assertThrows(UnsupportedOperationException.class, () -> in.readLine());
+ assertThat(expected).hasMessageThat().isEqualTo("readLine is not supported");
}
public void testReadLittleEndian() throws IOException {
diff --git a/guava-tests/test/com/google/common/io/MoreFilesTest.java b/guava-tests/test/com/google/common/io/MoreFilesTest.java
index 8076eb352..2b9c20fb6 100644
--- a/guava-tests/test/com/google/common/io/MoreFilesTest.java
+++ b/guava-tests/test/com/google/common/io/MoreFilesTest.java
@@ -23,6 +23,7 @@ import static com.google.common.jimfs.Feature.SYMBOLIC_LINKS;
import static com.google.common.truth.Truth.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.LinkOption.NOFOLLOW_LINKS;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ObjectArrays;
import com.google.common.jimfs.Configuration;
@@ -138,11 +139,7 @@ public class MoreFilesTest extends TestCase {
assertThat(source.sizeIfKnown()).isAbsent();
- try {
- source.size();
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> source.size());
}
}
@@ -157,11 +154,7 @@ public class MoreFilesTest extends TestCase {
assertThat(source.sizeIfKnown()).isAbsent();
- try {
- source.size();
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> source.size());
}
}
@@ -190,11 +183,7 @@ public class MoreFilesTest extends TestCase {
assertThat(source.sizeIfKnown()).isAbsent();
- try {
- source.size();
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> source.size());
}
}
@@ -311,24 +300,14 @@ public class MoreFilesTest extends TestCase {
Path file = root().resolve("parent/nonexistent.file");
Path parent = file.getParent();
assertFalse(Files.exists(parent));
- try {
- MoreFiles.createParentDirectories(file);
- // Cleanup in case parent creation was [erroneously] successful.
- Files.delete(parent);
- fail("expected exception");
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> MoreFiles.createParentDirectories(file));
}
public void testCreateParentDirectories_nonDirectoryParentExists() throws IOException {
Path parent = createTempFile();
assertTrue(Files.isRegularFile(parent));
Path file = parent.resolve("foo");
- try {
- MoreFiles.createParentDirectories(file);
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> MoreFiles.createParentDirectories(file));
}
public void testCreateParentDirectories_symlinkParentExists() throws IOException {
@@ -435,8 +414,7 @@ public class MoreFilesTest extends TestCase {
static FileSystem newTestFileSystem(Feature... supportedFeatures) throws IOException {
FileSystem fs =
Jimfs.newFileSystem(
- Configuration.unix()
- .toBuilder()
+ Configuration.unix().toBuilder()
.setSupportedFeatures(ObjectArrays.concat(SYMBOLIC_LINKS, supportedFeatures))
.build());
Files.createDirectories(fs.getPath("dir/b/i/j/l"));
@@ -522,11 +500,7 @@ public class MoreFilesTest extends TestCase {
Path dir = fs.getPath("dir");
assertEquals(6, MoreFiles.listFiles(dir).size());
- try {
- method.delete(dir);
- fail("expected InsecureRecursiveDeleteException");
- } catch (InsecureRecursiveDeleteException expected) {
- }
+ assertThrows(InsecureRecursiveDeleteException.class, () -> method.delete(dir));
assertTrue(Files.exists(dir));
assertEquals(6, MoreFiles.listFiles(dir).size());
@@ -569,12 +543,11 @@ public class MoreFilesTest extends TestCase {
public void testDeleteRecursively_nonexistingFile_throwsNoSuchFileException() throws IOException {
try (FileSystem fs = newTestFileSystem()) {
- try {
- MoreFiles.deleteRecursively(fs.getPath("/work/nothere"), ALLOW_INSECURE);
- fail();
- } catch (NoSuchFileException expected) {
- assertThat(expected.getFile()).isEqualTo("/work/nothere");
- }
+ NoSuchFileException expected =
+ assertThrows(
+ NoSuchFileException.class,
+ () -> MoreFiles.deleteRecursively(fs.getPath("/work/nothere"), ALLOW_INSECURE));
+ assertThat(expected.getFile()).isEqualTo("/work/nothere");
}
}
diff --git a/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java b/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
index 94ab1f016..699b2a458 100644
--- a/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
+++ b/guava-tests/test/com/google/common/io/PatternFilenameFilterTest.java
@@ -16,6 +16,8 @@
package com.google.common.io;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.testing.NullPointerTester;
import com.google.common.testing.NullPointerTester.Visibility;
import java.io.File;
@@ -31,11 +33,7 @@ import junit.framework.TestCase;
public class PatternFilenameFilterTest extends TestCase {
public void testSyntaxException() {
- try {
- new PatternFilenameFilter("(");
- fail("expected exception");
- } catch (PatternSyntaxException expected) {
- }
+ assertThrows(PatternSyntaxException.class, () -> new PatternFilenameFilter("("));
}
public void testAccept() {
diff --git a/guava-tests/test/com/google/common/io/ResourcesTest.java b/guava-tests/test/com/google/common/io/ResourcesTest.java
index b1a46c698..4344ed1ca 100644
--- a/guava-tests/test/com/google/common/io/ResourcesTest.java
+++ b/guava-tests/test/com/google/common/io/ResourcesTest.java
@@ -18,6 +18,7 @@ package com.google.common.io;
import static com.google.common.base.CharMatcher.whitespace;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
@@ -104,12 +105,10 @@ public class ResourcesTest extends IoTestCase {
}
public void testGetResource_notFound() {
- try {
- Resources.getResource("no such resource");
- fail();
- } catch (IllegalArgumentException e) {
- assertThat(e).hasMessageThat().isEqualTo("resource no such resource not found.");
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class, () -> Resources.getResource("no such resource"));
+ assertThat(e).hasMessageThat().isEqualTo("resource no such resource not found.");
}
public void testGetResource() {
@@ -117,16 +116,15 @@ public class ResourcesTest extends IoTestCase {
}
public void testGetResource_relativePath_notFound() {
- try {
- Resources.getResource(getClass(), "com/google/common/io/testdata/i18n.txt");
- fail();
- } catch (IllegalArgumentException e) {
- assertThat(e)
- .hasMessageThat()
- .isEqualTo(
- "resource com/google/common/io/testdata/i18n.txt"
- + " relative to com.google.common.io.ResourcesTest not found.");
- }
+ IllegalArgumentException e =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Resources.getResource(getClass(), "com/google/common/io/testdata/i18n.txt"));
+ assertThat(e)
+ .hasMessageThat()
+ .isEqualTo(
+ "resource com/google/common/io/testdata/i18n.txt"
+ + " relative to com.google.common.io.ResourcesTest not found.");
}
public void testGetResource_relativePath() {
@@ -145,11 +143,7 @@ public class ResourcesTest extends IoTestCase {
// First check that we can't find it without setting the context loader.
// This is a sanity check that the test doesn't spuriously pass because
// the resource is visible to the system class loader.
- try {
- Resources.getResource(tempFile.getName());
- fail("Should get IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Resources.getResource(tempFile.getName()));
// Now set the context loader to one that should find the resource.
URL baseUrl = tempFile.getParentFile().toURI().toURL();
@@ -170,11 +164,7 @@ public class ResourcesTest extends IoTestCase {
try {
Thread.currentThread().setContextClassLoader(null);
assertNotNull(Resources.getResource("com/google/common/io/testdata/i18n.txt"));
- try {
- Resources.getResource("no such resource");
- fail("Should get IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Resources.getResource("no such resource"));
} finally {
Thread.currentThread().setContextClassLoader(oldContextLoader);
}
diff --git a/guava-tests/test/com/google/common/math/BigDecimalMathTest.java b/guava-tests/test/com/google/common/math/BigDecimalMathTest.java
index ff86fd52f..b200a3840 100644
--- a/guava-tests/test/com/google/common/math/BigDecimalMathTest.java
+++ b/guava-tests/test/com/google/common/math/BigDecimalMathTest.java
@@ -25,6 +25,7 @@ import static java.math.RoundingMode.HALF_UP;
import static java.math.RoundingMode.UNNECESSARY;
import static java.math.RoundingMode.UP;
import static java.math.RoundingMode.values;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import java.math.BigDecimal;
@@ -76,12 +77,10 @@ public class BigDecimalMathTest extends TestCase {
assertWithMessage("Expected roundUnnecessaryShouldThrow call")
.that(unnecessaryShouldThrow)
.isTrue();
- try {
- BigDecimalMath.roundToDouble(input, UNNECESSARY);
- fail("Expected ArithmeticException for roundToDouble(" + input + ", UNNECESSARY)");
- } catch (ArithmeticException expected) {
- // expected
- }
+ assertThrows(
+ "Expected ArithmeticException for roundToDouble(" + input + ", UNNECESSARY)",
+ ArithmeticException.class,
+ () -> BigDecimalMath.roundToDouble(input, UNNECESSARY));
}
}
}
diff --git a/guava-tests/test/com/google/common/math/DoubleUtilsTest.java b/guava-tests/test/com/google/common/math/DoubleUtilsTest.java
index 2f6263ea9..72224bc38 100644
--- a/guava-tests/test/com/google/common/math/DoubleUtilsTest.java
+++ b/guava-tests/test/com/google/common/math/DoubleUtilsTest.java
@@ -19,6 +19,7 @@ package com.google.common.math;
import static com.google.common.math.MathTesting.ALL_BIGINTEGER_CANDIDATES;
import static com.google.common.math.MathTesting.FINITE_DOUBLE_CANDIDATES;
import static com.google.common.math.MathTesting.POSITIVE_FINITE_DOUBLE_CANDIDATES;
+import static org.junit.Assert.assertThrows;
import java.lang.reflect.Method;
import java.math.BigInteger;
@@ -65,11 +66,7 @@ public class DoubleUtilsTest extends TestCase {
}
assertEquals(Double.POSITIVE_INFINITY, DoubleUtils.ensureNonNegative(Double.POSITIVE_INFINITY));
assertEquals(0.0, DoubleUtils.ensureNonNegative(Double.NEGATIVE_INFINITY));
- try {
- DoubleUtils.ensureNonNegative(Double.NaN);
- fail("Expected IllegalArgumentException from ensureNonNegative(Double.NaN)");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> DoubleUtils.ensureNonNegative(Double.NaN));
}
public void testOneBits() {
diff --git a/guava-tests/test/com/google/common/math/LinearTransformationTest.java b/guava-tests/test/com/google/common/math/LinearTransformationTest.java
index 36d5e8432..a9d028980 100644
--- a/guava-tests/test/com/google/common/math/LinearTransformationTest.java
+++ b/guava-tests/test/com/google/common/math/LinearTransformationTest.java
@@ -21,6 +21,7 @@ import static com.google.common.math.StatsTesting.assertHorizontalLinearTransfor
import static com.google.common.math.StatsTesting.assertLinearTransformationNaN;
import static com.google.common.math.StatsTesting.assertVerticalLinearTransformation;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import junit.framework.TestCase;
@@ -60,79 +61,59 @@ public class LinearTransformationTest extends TestCase {
}
public void testMapping_infiniteX1() {
- try {
- LinearTransformation.mapping(Double.POSITIVE_INFINITY, 3.4);
- fail("Expected IllegalArgumentException from mapping(x, y) with infinite x");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(Double.POSITIVE_INFINITY, 3.4));
}
public void testMapping_infiniteY1() {
- try {
- LinearTransformation.mapping(1.2, Double.NEGATIVE_INFINITY);
- fail("Expected IllegalArgumentException from mapping(x, y) with infinite y");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(1.2, Double.NEGATIVE_INFINITY));
}
public void testMappingAnd_infiniteX2() {
- try {
- LinearTransformation.mapping(1.2, 3.4).and(Double.NEGATIVE_INFINITY, 7.8);
- fail("Expected IllegalArgumentException from and(x, y) with infinite x");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(1.2, 3.4).and(Double.NEGATIVE_INFINITY, 7.8));
}
public void testMappingAnd_infiniteY2() {
- try {
- LinearTransformation.mapping(1.2, 3.4).and(5.6, Double.POSITIVE_INFINITY);
- fail("Expected IllegalArgumentException from and(x, y) with infinite y");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(1.2, 3.4).and(5.6, Double.POSITIVE_INFINITY));
}
public void testMapping_nanX1() {
- try {
- LinearTransformation.mapping(Double.NaN, 3.4);
- fail("Expected IllegalArgumentException from mapping(x, y) with NaN x");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> LinearTransformation.mapping(Double.NaN, 3.4));
}
public void testMapping_nanY1() {
- try {
- LinearTransformation.mapping(1.2, Double.NaN);
- fail("Expected IllegalArgumentException from mapping(x, y) with NaN y");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> LinearTransformation.mapping(1.2, Double.NaN));
}
public void testMappingAnd_nanX2() {
- try {
- LinearTransformation.mapping(1.2, 3.4).and(Double.NaN, 7.8);
- fail("Expected IllegalArgumentException from and(x, y) with NaN x");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(1.2, 3.4).and(Double.NaN, 7.8));
}
public void testMappingAnd_nanY2() {
- try {
- LinearTransformation.mapping(1.2, 3.4).and(5.6, Double.NaN);
- fail("Expected IllegalArgumentException from and(x, y) with NaN y");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(1.2, 3.4).and(5.6, Double.NaN));
}
public void testMappingAnd_samePointTwice() {
- try {
- double x = 1.2;
- double y = 3.4;
- LinearTransformation.mapping(x, y).and(x, y);
- fail(
- "Expected IllegalArgumentException from mapping(x1, y1).and(x2, y2) with"
- + " (x1 == x2) && (y1 == y2)");
- } catch (IllegalArgumentException expected) {
- }
+ double x = 1.2;
+ double y = 3.4;
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ LinearTransformation.mapping(x, y).and(x, y);
+ });
}
public void testMappingWithSlope_regular() {
@@ -184,11 +165,9 @@ public class LinearTransformationTest extends TestCase {
}
public void testMappingWithSlope_nanSlope() {
- try {
- LinearTransformation.mapping(1.2, 3.4).withSlope(Double.NaN);
- fail("Expected IllegalArgumentException from withSlope(slope) with NaN slope");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.mapping(1.2, 3.4).withSlope(Double.NaN));
}
public void testVertical_regular() {
@@ -198,19 +177,13 @@ public class LinearTransformationTest extends TestCase {
}
public void testVertical_infiniteX() {
- try {
- LinearTransformation.vertical(Double.NEGATIVE_INFINITY);
- fail("Expected IllegalArgumentException from vertical(x) with infinite x");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.vertical(Double.NEGATIVE_INFINITY));
}
public void testVertical_nanX() {
- try {
- LinearTransformation.vertical(Double.NaN);
- fail("Expected IllegalArgumentException from vertical(x) with NaN x");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> LinearTransformation.vertical(Double.NaN));
}
public void testHorizontal_regular() {
@@ -220,19 +193,13 @@ public class LinearTransformationTest extends TestCase {
}
public void testHorizontal_infiniteY() {
- try {
- LinearTransformation.horizontal(Double.POSITIVE_INFINITY);
- fail("Expected IllegalArgumentException from horizontal(y) with infinite y");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> LinearTransformation.horizontal(Double.POSITIVE_INFINITY));
}
public void testHorizontal_nanY() {
- try {
- LinearTransformation.horizontal(Double.NaN);
- fail("Expected IllegalArgumentException from horizontal(y) with NaN y");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> LinearTransformation.horizontal(Double.NaN));
}
public void testForNaN() {
diff --git a/guava-tests/test/com/google/common/math/PairedStatsAccumulatorTest.java b/guava-tests/test/com/google/common/math/PairedStatsAccumulatorTest.java
index 34f82e907..1f3d68ff6 100644
--- a/guava-tests/test/com/google/common/math/PairedStatsAccumulatorTest.java
+++ b/guava-tests/test/com/google/common/math/PairedStatsAccumulatorTest.java
@@ -44,6 +44,7 @@ import static com.google.common.math.StatsTesting.createFilledPairedStatsAccumul
import static com.google.common.math.StatsTesting.createPartitionedFilledPairedStatsAccumulator;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assert.assertThrows;
import com.google.common.math.StatsTesting.ManyValues;
import java.util.Collections;
@@ -174,16 +175,10 @@ public class PairedStatsAccumulatorTest extends TestCase {
}
public void testPopulationCovariance() {
- try {
- emptyAccumulator.populationCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyPairedStats.populationCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.populationCovariance());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyPairedStats.populationCovariance());
assertThat(oneValueAccumulator.populationCovariance()).isWithin(0.0).of(0.0);
assertThat(oneValueAccumulatorByAddAllEmptyPairedStats.populationCovariance())
.isWithin(0.0)
@@ -241,26 +236,14 @@ public class PairedStatsAccumulatorTest extends TestCase {
}
public void testSampleCovariance() {
- try {
- emptyAccumulator.sampleCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyPairedStats.sampleCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulator.sampleCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulatorByAddAllEmptyPairedStats.sampleCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.sampleCovariance());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyPairedStats.sampleCovariance());
+ assertThrows(IllegalStateException.class, () -> oneValueAccumulator.sampleCovariance());
+ assertThrows(
+ IllegalStateException.class,
+ () -> oneValueAccumulatorByAddAllEmptyPairedStats.sampleCovariance());
assertThat(twoValuesAccumulator.sampleCovariance())
.isWithin(ALLOWED_ERROR)
.of(TWO_VALUES_SUM_OF_PRODUCTS_OF_DELTAS);
@@ -288,26 +271,16 @@ public class PairedStatsAccumulatorTest extends TestCase {
}
public void testPearsonsCorrelationCoefficient() {
- try {
- emptyAccumulator.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyPairedStats.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulator.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulatorByAddAllEmptyPairedStats.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class, () -> emptyAccumulator.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyPairedStats.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class, () -> oneValueAccumulator.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> oneValueAccumulatorByAddAllEmptyPairedStats.pearsonsCorrelationCoefficient());
assertThat(twoValuesAccumulator.pearsonsCorrelationCoefficient())
.isWithin(ALLOWED_ERROR)
.of(
@@ -368,59 +341,41 @@ public class PairedStatsAccumulatorTest extends TestCase {
.populationStandardDeviation()));
}
}
- try {
- horizontalValuesAccumulator.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- horizontalValuesAccumulatorByAddAllPartitionedPairedStats.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- verticalValuesAccumulator.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- verticalValuesAccumulatorByAddAllPartitionedPairedStats.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- constantValuesAccumulator.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- constantValuesAccumulatorByAddAllPartitionedPairedStats.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> horizontalValuesAccumulator.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () ->
+ horizontalValuesAccumulatorByAddAllPartitionedPairedStats
+ .pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> verticalValuesAccumulator.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () ->
+ verticalValuesAccumulatorByAddAllPartitionedPairedStats
+ .pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> constantValuesAccumulator.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () ->
+ constantValuesAccumulatorByAddAllPartitionedPairedStats
+ .pearsonsCorrelationCoefficient());
}
public void testLeastSquaresFit() {
- try {
- emptyAccumulator.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyPairedStats.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulator.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulatorByAddAllEmptyPairedStats.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.leastSquaresFit());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyPairedStats.leastSquaresFit());
+ assertThrows(IllegalStateException.class, () -> oneValueAccumulator.leastSquaresFit());
+ assertThrows(
+ IllegalStateException.class,
+ () -> oneValueAccumulatorByAddAllEmptyPairedStats.leastSquaresFit());
assertDiagonalLinearTransformation(
twoValuesAccumulator.leastSquaresFit(),
twoValuesAccumulator.xStats().mean(),
@@ -483,15 +438,9 @@ public class PairedStatsAccumulatorTest extends TestCase {
assertVerticalLinearTransformation(
verticalValuesAccumulatorByAddAllPartitionedPairedStats.leastSquaresFit(),
verticalValuesAccumulatorByAddAllPartitionedPairedStats.xStats().mean());
- try {
- constantValuesAccumulator.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- constantValuesAccumulatorByAddAllPartitionedPairedStats.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> constantValuesAccumulator.leastSquaresFit());
+ assertThrows(
+ IllegalStateException.class,
+ () -> constantValuesAccumulatorByAddAllPartitionedPairedStats.leastSquaresFit());
}
}
diff --git a/guava-tests/test/com/google/common/math/PairedStatsTest.java b/guava-tests/test/com/google/common/math/PairedStatsTest.java
index 7dd9e94d6..3219bb5f9 100644
--- a/guava-tests/test/com/google/common/math/PairedStatsTest.java
+++ b/guava-tests/test/com/google/common/math/PairedStatsTest.java
@@ -48,6 +48,7 @@ import static com.google.common.math.StatsTesting.assertVerticalLinearTransforma
import static com.google.common.math.StatsTesting.createPairedStatsOf;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.math.StatsTesting.ManyValues;
@@ -87,11 +88,7 @@ public class PairedStatsTest extends TestCase {
}
public void testPopulationCovariance() {
- try {
- EMPTY_PAIRED_STATS.populationCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_PAIRED_STATS.populationCovariance());
assertThat(ONE_VALUE_PAIRED_STATS.populationCovariance()).isWithin(0.0).of(0.0);
assertThat(createSingleStats(Double.POSITIVE_INFINITY, 1.23).populationCovariance()).isNaN();
assertThat(createSingleStats(Double.NEGATIVE_INFINITY, 1.23).populationCovariance()).isNaN();
@@ -121,16 +118,8 @@ public class PairedStatsTest extends TestCase {
}
public void testSampleCovariance() {
- try {
- EMPTY_PAIRED_STATS.sampleCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- ONE_VALUE_PAIRED_STATS.sampleCovariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_PAIRED_STATS.sampleCovariance());
+ assertThrows(IllegalStateException.class, () -> ONE_VALUE_PAIRED_STATS.sampleCovariance());
assertThat(TWO_VALUES_PAIRED_STATS.sampleCovariance())
.isWithin(ALLOWED_ERROR)
.of(TWO_VALUES_SUM_OF_PRODUCTS_OF_DELTAS);
@@ -143,21 +132,13 @@ public class PairedStatsTest extends TestCase {
}
public void testPearsonsCorrelationCoefficient() {
- try {
- EMPTY_PAIRED_STATS.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- ONE_VALUE_PAIRED_STATS.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- createSingleStats(Double.POSITIVE_INFINITY, 1.23).pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class, () -> EMPTY_PAIRED_STATS.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class, () -> ONE_VALUE_PAIRED_STATS.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> createSingleStats(Double.POSITIVE_INFINITY, 1.23).pearsonsCorrelationCoefficient());
assertThat(TWO_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient())
.isWithin(ALLOWED_ERROR)
.of(
@@ -183,39 +164,23 @@ public class PairedStatsTest extends TestCase {
* stats.yStats().populationStandardDeviation()));
}
}
- try {
- HORIZONTAL_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- VERTICAL_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- CONSTANT_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> HORIZONTAL_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> VERTICAL_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient());
+ assertThrows(
+ IllegalStateException.class,
+ () -> CONSTANT_VALUES_PAIRED_STATS.pearsonsCorrelationCoefficient());
}
public void testLeastSquaresFit() {
- try {
- EMPTY_PAIRED_STATS.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- ONE_VALUE_PAIRED_STATS.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- createSingleStats(Double.POSITIVE_INFINITY, 1.23).leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_PAIRED_STATS.leastSquaresFit());
+ assertThrows(IllegalStateException.class, () -> ONE_VALUE_PAIRED_STATS.leastSquaresFit());
+ assertThrows(
+ IllegalStateException.class,
+ () -> createSingleStats(Double.POSITIVE_INFINITY, 1.23).leastSquaresFit());
assertDiagonalLinearTransformation(
TWO_VALUES_PAIRED_STATS.leastSquaresFit(),
TWO_VALUES_PAIRED_STATS.xStats().mean(),
@@ -244,11 +209,7 @@ public class PairedStatsTest extends TestCase {
assertVerticalLinearTransformation(
VERTICAL_VALUES_PAIRED_STATS.leastSquaresFit(),
VERTICAL_VALUES_PAIRED_STATS.xStats().mean());
- try {
- CONSTANT_VALUES_PAIRED_STATS.leastSquaresFit();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> CONSTANT_VALUES_PAIRED_STATS.leastSquaresFit());
}
public void testEqualsAndHashCode() {
@@ -303,19 +264,11 @@ public class PairedStatsTest extends TestCase {
}
public void testFromByteArray_withNullInputThrowsNullPointerException() {
- try {
- PairedStats.fromByteArray(null);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> PairedStats.fromByteArray(null));
}
public void testFromByteArray_withEmptyArrayInputThrowsIllegalArgumentException() {
- try {
- PairedStats.fromByteArray(new byte[0]);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> PairedStats.fromByteArray(new byte[0]));
}
public void testFromByteArray_withTooLongArrayInputThrowsIllegalArgumentException() {
@@ -326,11 +279,7 @@ public class PairedStatsTest extends TestCase {
.put(buffer)
.putChar('.')
.array();
- try {
- PairedStats.fromByteArray(tooLongByteArray);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> PairedStats.fromByteArray(tooLongByteArray));
}
public void testFromByteArrayWithTooShortArrayInputThrowsIllegalArgumentException() {
@@ -340,10 +289,7 @@ public class PairedStatsTest extends TestCase {
.order(ByteOrder.LITTLE_ENDIAN)
.put(buffer, 0, buffer.length - 1)
.array();
- try {
- PairedStats.fromByteArray(tooShortByteArray);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> PairedStats.fromByteArray(tooShortByteArray));
}
}
diff --git a/guava-tests/test/com/google/common/math/QuantilesTest.java b/guava-tests/test/com/google/common/math/QuantilesTest.java
index 9c8d8e65a..788abb7f7 100644
--- a/guava-tests/test/com/google/common/math/QuantilesTest.java
+++ b/guava-tests/test/com/google/common/math/QuantilesTest.java
@@ -27,6 +27,7 @@ import static java.lang.Double.POSITIVE_INFINITY;
import static java.math.RoundingMode.CEILING;
import static java.math.RoundingMode.FLOOR;
import static java.math.RoundingMode.UNNECESSARY;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -598,171 +599,103 @@ public class QuantilesTest extends TestCase {
private static final ImmutableList<Double> EMPTY_DATASET = ImmutableList.of();
public void testScale_zero() {
- try {
- Quantiles.scale(0);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Quantiles.scale(0));
}
public void testScale_negative() {
- try {
- Quantiles.scale(-4);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Quantiles.scale(-4));
}
public void testScale_index_negative() {
Quantiles.Scale intermediate = Quantiles.scale(10);
- try {
- intermediate.index(-1);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.index(-1));
}
public void testScale_index_tooHigh() {
Quantiles.Scale intermediate = Quantiles.scale(10);
- try {
- intermediate.index(11);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.index(11));
}
public void testScale_indexes_varargs_negative() {
Quantiles.Scale intermediate = Quantiles.scale(10);
- try {
- intermediate.indexes(1, -1, 3);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.indexes(1, -1, 3));
}
public void testScale_indexes_varargs_tooHigh() {
Quantiles.Scale intermediate = Quantiles.scale(10);
- try {
- intermediate.indexes(1, 11, 3);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.indexes(1, 11, 3));
}
public void testScale_indexes_collection_negative() {
Quantiles.Scale intermediate = Quantiles.scale(10);
- try {
- intermediate.indexes(ImmutableList.of(1, -1, 3));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> intermediate.indexes(ImmutableList.of(1, -1, 3)));
}
public void testScale_indexes_collection_tooHigh() {
Quantiles.Scale intermediate = Quantiles.scale(10);
- try {
- intermediate.indexes(ImmutableList.of(1, 11, 3));
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> intermediate.indexes(ImmutableList.of(1, 11, 3)));
}
public void testScale_index_compute_doubleCollection_empty() {
Quantiles.ScaleAndIndex intermediate = Quantiles.scale(10).index(3);
- try {
- intermediate.compute(EMPTY_DATASET);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(EMPTY_DATASET));
}
public void testScale_index_compute_doubleVarargs_empty() {
Quantiles.ScaleAndIndex intermediate = Quantiles.scale(10).index(3);
- try {
- intermediate.compute(new double[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(new double[] {}));
}
public void testScale_index_compute_longVarargs_empty() {
Quantiles.ScaleAndIndex intermediate = Quantiles.scale(10).index(3);
- try {
- intermediate.compute(new long[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(new long[] {}));
}
public void testScale_index_compute_intVarargs_empty() {
Quantiles.ScaleAndIndex intermediate = Quantiles.scale(10).index(3);
- try {
- intermediate.compute(new int[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(new int[] {}));
}
public void testScale_index_computeInPlace_empty() {
Quantiles.ScaleAndIndex intermediate = Quantiles.scale(10).index(3);
- try {
- intermediate.computeInPlace(new double[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> intermediate.computeInPlace(new double[] {}));
}
public void testScale_indexes_varargs_compute_doubleCollection_empty() {
Quantiles.ScaleAndIndexes intermediate = Quantiles.scale(10).indexes(1, 3, 5);
- try {
- intermediate.compute(EMPTY_DATASET);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(EMPTY_DATASET));
}
public void testScale_indexes_varargs_compute_doubleVarargs_empty() {
Quantiles.ScaleAndIndexes intermediate = Quantiles.scale(10).indexes(1, 3, 5);
- try {
- intermediate.compute(new double[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(new double[] {}));
}
public void testScale_indexes_varargs_compute_longVarargs_empty() {
Quantiles.ScaleAndIndexes intermediate = Quantiles.scale(10).indexes(1, 3, 5);
- try {
- intermediate.compute(new long[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(new long[] {}));
}
public void testScale_indexes_varargs_compute_intVarargs_empty() {
Quantiles.ScaleAndIndexes intermediate = Quantiles.scale(10).indexes(1, 3, 5);
- try {
- intermediate.compute(new int[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> intermediate.compute(new int[] {}));
}
public void testScale_indexes_varargs_computeInPlace_empty() {
Quantiles.ScaleAndIndexes intermediate = Quantiles.scale(10).indexes(1, 3, 5);
- try {
- intermediate.computeInPlace(new double[] {});
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> intermediate.computeInPlace(new double[] {}));
}
public void testScale_indexes_indexes_computeInPlace_empty() {
int[] emptyIndexes = {};
- try {
- Quantiles.ScaleAndIndexes unused = Quantiles.scale(10).indexes(emptyIndexes);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> {
+ Quantiles.ScaleAndIndexes unused = Quantiles.scale(10).indexes(emptyIndexes);
+ });
}
}
diff --git a/guava-tests/test/com/google/common/math/StatsAccumulatorTest.java b/guava-tests/test/com/google/common/math/StatsAccumulatorTest.java
index 2dba5fb27..c34c5b2a9 100644
--- a/guava-tests/test/com/google/common/math/StatsAccumulatorTest.java
+++ b/guava-tests/test/com/google/common/math/StatsAccumulatorTest.java
@@ -53,6 +53,7 @@ import static com.google.common.math.StatsTesting.megaPrimitiveDoubleStreamPart2
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static java.lang.Math.sqrt;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.math.StatsTesting.ManyValues;
@@ -195,21 +196,9 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testMean() {
- try {
- emptyAccumulator.mean();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.mean();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.mean();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.mean());
+ assertThrows(IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyIterable.mean());
+ assertThrows(IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyStats.mean());
assertThat(oneValueAccumulator.mean()).isWithin(ALLOWED_ERROR).of(ONE_VALUE);
assertThat(oneValueAccumulatorByAddAllEmptyStats.mean()).isWithin(ALLOWED_ERROR).of(ONE_VALUE);
assertThat(twoValuesAccumulator.mean()).isWithin(ALLOWED_ERROR).of(TWO_VALUES_MEAN);
@@ -329,21 +318,12 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testPopulationVariance() {
- try {
- emptyAccumulator.populationVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.populationVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.populationVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.populationVariance());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyIterable.populationVariance());
+ assertThrows(
+ IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyStats.populationVariance());
assertThat(oneValueAccumulator.populationVariance()).isWithin(0.0).of(0.0);
assertThat(oneValueAccumulatorByAddAllEmptyStats.populationVariance()).isWithin(0.0).of(0.0);
assertThat(twoValuesAccumulator.populationVariance())
@@ -412,21 +392,13 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testPopulationStandardDeviation() {
- try {
- emptyAccumulator.populationStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.populationStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.populationStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.populationStandardDeviation());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyIterable.populationStandardDeviation());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyStats.populationStandardDeviation());
assertThat(oneValueAccumulator.populationStandardDeviation()).isWithin(0.0).of(0.0);
assertThat(oneValueAccumulatorByAddAllEmptyStats.populationStandardDeviation())
.isWithin(0.0)
@@ -470,31 +442,14 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testSampleVariance() {
- try {
- emptyAccumulator.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulator.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulatorByAddAllEmptyStats.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.sampleVariance());
+ assertThrows(
+ IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyIterable.sampleVariance());
+ assertThrows(
+ IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyStats.sampleVariance());
+ assertThrows(IllegalStateException.class, () -> oneValueAccumulator.sampleVariance());
+ assertThrows(
+ IllegalStateException.class, () -> oneValueAccumulatorByAddAllEmptyStats.sampleVariance());
assertThat(twoValuesAccumulator.sampleVariance())
.isWithin(ALLOWED_ERROR)
.of(TWO_VALUES_SUM_OF_SQUARES_OF_DELTAS);
@@ -534,31 +489,17 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testSampleStandardDeviation() {
- try {
- emptyAccumulator.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulator.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- oneValueAccumulatorByAddAllEmptyStats.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.sampleStandardDeviation());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyIterable.sampleStandardDeviation());
+ assertThrows(
+ IllegalStateException.class,
+ () -> emptyAccumulatorByAddAllEmptyStats.sampleStandardDeviation());
+ assertThrows(IllegalStateException.class, () -> oneValueAccumulator.sampleStandardDeviation());
+ assertThrows(
+ IllegalStateException.class,
+ () -> oneValueAccumulatorByAddAllEmptyStats.sampleStandardDeviation());
assertThat(twoValuesAccumulator.sampleStandardDeviation())
.isWithin(ALLOWED_ERROR)
.of(sqrt(TWO_VALUES_SUM_OF_SQUARES_OF_DELTAS));
@@ -598,21 +539,9 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testMax() {
- try {
- emptyAccumulator.max();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.max();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.max();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.max());
+ assertThrows(IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyIterable.max());
+ assertThrows(IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyStats.max());
assertThat(oneValueAccumulator.max()).isEqualTo(ONE_VALUE);
assertThat(oneValueAccumulatorByAddAllEmptyStats.max()).isEqualTo(ONE_VALUE);
assertThat(twoValuesAccumulator.max()).isEqualTo(TWO_VALUES_MAX);
@@ -657,21 +586,9 @@ public class StatsAccumulatorTest extends TestCase {
}
public void testMin() {
- try {
- emptyAccumulator.min();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyIterable.min();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- emptyAccumulatorByAddAllEmptyStats.min();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> emptyAccumulator.min());
+ assertThrows(IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyIterable.min());
+ assertThrows(IllegalStateException.class, () -> emptyAccumulatorByAddAllEmptyStats.min());
assertThat(oneValueAccumulator.min()).isEqualTo(ONE_VALUE);
assertThat(oneValueAccumulatorByAddAllEmptyStats.min()).isEqualTo(ONE_VALUE);
assertThat(twoValuesAccumulator.min()).isEqualTo(TWO_VALUES_MIN);
diff --git a/guava-tests/test/com/google/common/math/StatsTest.java b/guava-tests/test/com/google/common/math/StatsTest.java
index 9112ef370..46640e8a7 100644
--- a/guava-tests/test/com/google/common/math/StatsTest.java
+++ b/guava-tests/test/com/google/common/math/StatsTest.java
@@ -16,7 +16,6 @@
package com.google.common.math;
-import static com.google.common.math.Stats.toStats;
import static com.google.common.math.StatsTesting.ALLOWED_ERROR;
import static com.google.common.math.StatsTesting.ALL_MANY_VALUES;
import static com.google.common.math.StatsTesting.ALL_STATS;
@@ -77,6 +76,7 @@ import static java.lang.Double.NaN;
import static java.lang.Double.POSITIVE_INFINITY;
import static java.lang.Math.sqrt;
import static java.util.Arrays.stream;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.math.StatsTesting.ManyValues;
@@ -84,7 +84,6 @@ import com.google.common.primitives.Ints;
import com.google.common.primitives.Longs;
import com.google.common.testing.EqualsTester;
import com.google.common.testing.SerializableTester;
-import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.DoubleSummaryStatistics;
@@ -114,16 +113,8 @@ public class StatsTest extends TestCase {
}
public void testMean() {
- try {
- EMPTY_STATS_VARARGS.mean();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.mean();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_VARARGS.mean());
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.mean());
assertThat(ONE_VALUE_STATS.mean()).isWithin(ALLOWED_ERROR).of(ONE_VALUE);
assertThat(Stats.of(POSITIVE_INFINITY).mean()).isPositiveInfinity();
assertThat(Stats.of(NEGATIVE_INFINITY).mean()).isNegativeInfinity();
@@ -206,16 +197,8 @@ public class StatsTest extends TestCase {
}
public void testPopulationVariance() {
- try {
- EMPTY_STATS_VARARGS.populationVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.populationVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_VARARGS.populationVariance());
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.populationVariance());
assertThat(ONE_VALUE_STATS.populationVariance()).isWithin(0.0).of(0.0);
assertThat(Stats.of(POSITIVE_INFINITY).populationVariance()).isNaN();
assertThat(Stats.of(NEGATIVE_INFINITY).populationVariance()).isNaN();
@@ -266,16 +249,10 @@ public class StatsTest extends TestCase {
}
public void testPopulationStandardDeviation() {
- try {
- EMPTY_STATS_VARARGS.populationStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.populationStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class, () -> EMPTY_STATS_VARARGS.populationStandardDeviation());
+ assertThrows(
+ IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.populationStandardDeviation());
assertThat(ONE_VALUE_STATS.populationStandardDeviation()).isWithin(0.0).of(0.0);
assertThat(TWO_VALUES_STATS.populationStandardDeviation())
.isWithin(ALLOWED_ERROR)
@@ -307,21 +284,9 @@ public class StatsTest extends TestCase {
}
public void testSampleVariance() {
- try {
- EMPTY_STATS_VARARGS.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- ONE_VALUE_STATS.sampleVariance();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_VARARGS.sampleVariance());
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.sampleVariance());
+ assertThrows(IllegalStateException.class, () -> ONE_VALUE_STATS.sampleVariance());
assertThat(TWO_VALUES_STATS.sampleVariance())
.isWithin(ALLOWED_ERROR)
.of(TWO_VALUES_SUM_OF_SQUARES_OF_DELTAS);
@@ -352,21 +317,9 @@ public class StatsTest extends TestCase {
}
public void testSampleStandardDeviation() {
- try {
- EMPTY_STATS_VARARGS.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- ONE_VALUE_STATS.sampleStandardDeviation();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_VARARGS.sampleStandardDeviation());
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.sampleStandardDeviation());
+ assertThrows(IllegalStateException.class, () -> ONE_VALUE_STATS.sampleStandardDeviation());
assertThat(TWO_VALUES_STATS.sampleStandardDeviation())
.isWithin(ALLOWED_ERROR)
.of(sqrt(TWO_VALUES_SUM_OF_SQUARES_OF_DELTAS));
@@ -397,16 +350,8 @@ public class StatsTest extends TestCase {
}
public void testMax() {
- try {
- EMPTY_STATS_VARARGS.max();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.max();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_VARARGS.max());
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.max());
assertThat(ONE_VALUE_STATS.max()).isEqualTo(ONE_VALUE);
assertThat(Stats.of(POSITIVE_INFINITY).max()).isPositiveInfinity();
assertThat(Stats.of(NEGATIVE_INFINITY).max()).isNegativeInfinity();
@@ -434,16 +379,8 @@ public class StatsTest extends TestCase {
}
public void testMin() {
- try {
- EMPTY_STATS_VARARGS.min();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
- try {
- EMPTY_STATS_ITERABLE.min();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_VARARGS.min());
+ assertThrows(IllegalStateException.class, () -> EMPTY_STATS_ITERABLE.min());
assertThat(ONE_VALUE_STATS.min()).isEqualTo(ONE_VALUE);
assertThat(Stats.of(POSITIVE_INFINITY).min()).isPositiveInfinity();
assertThat(Stats.of(NEGATIVE_INFINITY).min()).isNegativeInfinity();
@@ -505,28 +442,6 @@ public class StatsTest extends TestCase {
assertThat(stats.max()).isEqualTo(MEGA_STREAM_MAX);
}
- public void testBoxedDoubleStreamToStats() {
- Stats stats = megaPrimitiveDoubleStream().boxed().collect(toStats());
- assertThat(stats.count()).isEqualTo(MEGA_STREAM_COUNT);
- assertThat(stats.mean()).isWithin(ALLOWED_ERROR * MEGA_STREAM_COUNT).of(MEGA_STREAM_MEAN);
- assertThat(stats.populationVariance())
- .isWithin(ALLOWED_ERROR * MEGA_STREAM_COUNT)
- .of(MEGA_STREAM_POPULATION_VARIANCE);
- assertThat(stats.min()).isEqualTo(MEGA_STREAM_MIN);
- assertThat(stats.max()).isEqualTo(MEGA_STREAM_MAX);
- }
-
- public void testBoxedBigDecimalStreamToStats() {
- Stats stats = megaPrimitiveDoubleStream().mapToObj(BigDecimal::valueOf).collect(toStats());
- assertThat(stats.count()).isEqualTo(MEGA_STREAM_COUNT);
- assertThat(stats.mean()).isWithin(ALLOWED_ERROR * MEGA_STREAM_COUNT).of(MEGA_STREAM_MEAN);
- assertThat(stats.populationVariance())
- .isWithin(ALLOWED_ERROR * MEGA_STREAM_COUNT)
- .of(MEGA_STREAM_POPULATION_VARIANCE);
- assertThat(stats.min()).isEqualTo(MEGA_STREAM_MIN);
- assertThat(stats.max()).isEqualTo(MEGA_STREAM_MAX);
- }
-
public void testEqualsAndHashCode() {
new EqualsTester()
.addEqualityGroup(
@@ -570,16 +485,8 @@ public class StatsTest extends TestCase {
}
public void testMeanOf() {
- try {
- Stats.meanOf();
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
- try {
- Stats.meanOf(ImmutableList.<Number>of());
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Stats.meanOf());
+ assertThrows(IllegalArgumentException.class, () -> Stats.meanOf(ImmutableList.<Number>of()));
assertThat(Stats.meanOf(ONE_VALUE)).isWithin(ALLOWED_ERROR).of(ONE_VALUE);
assertThat(Stats.meanOf(POSITIVE_INFINITY)).isPositiveInfinity();
assertThat(Stats.meanOf(NEGATIVE_INFINITY)).isNegativeInfinity();
@@ -630,19 +537,11 @@ public class StatsTest extends TestCase {
}
public void testFromByteArray_withNullInputThrowsNullPointerException() {
- try {
- Stats.fromByteArray(null);
- fail("Expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Stats.fromByteArray(null));
}
public void testFromByteArray_withEmptyArrayInputThrowsIllegalArgumentException() {
- try {
- Stats.fromByteArray(new byte[0]);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Stats.fromByteArray(new byte[0]));
}
public void testFromByteArray_withTooLongArrayInputThrowsIllegalArgumentException() {
@@ -653,11 +552,7 @@ public class StatsTest extends TestCase {
.put(buffer)
.putChar('.')
.array();
- try {
- Stats.fromByteArray(tooLongByteArray);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Stats.fromByteArray(tooLongByteArray));
}
public void testFromByteArrayWithTooShortArrayInputThrowsIllegalArgumentException() {
@@ -667,11 +562,7 @@ public class StatsTest extends TestCase {
.order(ByteOrder.LITTLE_ENDIAN)
.put(buffer, 0, Stats.BYTES - 1)
.array();
- try {
- Stats.fromByteArray(tooShortByteArray);
- fail("Expected IllegalArgumentException");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Stats.fromByteArray(tooShortByteArray));
}
public void testEquivalentStreams() {
diff --git a/guava-tests/test/com/google/common/math/StatsTesting.java b/guava-tests/test/com/google/common/math/StatsTesting.java
index 9652a6af3..70373d469 100644
--- a/guava-tests/test/com/google/common/math/StatsTesting.java
+++ b/guava-tests/test/com/google/common/math/StatsTesting.java
@@ -17,6 +17,7 @@
package com.google.common.math;
import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
import static java.lang.Double.NEGATIVE_INFINITY;
import static java.lang.Double.NaN;
@@ -40,8 +41,8 @@ import java.util.stream.DoubleStream;
* @author Pete Gillin
*/
class StatsTesting {
-
- static final double ALLOWED_ERROR = 1e-10;
+ // TODO(cpovirk): Convince myself that this larger error makes sense.
+ static final double ALLOWED_ERROR = isAndroid() ? .25 : 1e-10;
// Inputs and their statistics:
@@ -234,11 +235,12 @@ class StatsTesting {
return DoubleStream.iterate(999_999.0, x -> x - 2.0).limit(MEGA_STREAM_COUNT / 2).parallel();
}
- static final long MEGA_STREAM_COUNT = 1_000_000;
- static final double MEGA_STREAM_MEAN = 999_999.0 / 2;
- static final double MEGA_STREAM_POPULATION_VARIANCE = 999_999.0 * 1_000_001.0 / 12;
+ static final long MEGA_STREAM_COUNT = isAndroid() ? 100 : 1_000_000;
static final double MEGA_STREAM_MIN = 0.0;
- static final double MEGA_STREAM_MAX = 999_999.0;
+ static final double MEGA_STREAM_MAX = MEGA_STREAM_COUNT - 1;
+ static final double MEGA_STREAM_MEAN = MEGA_STREAM_MAX / 2;
+ static final double MEGA_STREAM_POPULATION_VARIANCE =
+ (MEGA_STREAM_COUNT - 1) * (MEGA_STREAM_COUNT + 1) / 12.0;
// Stats instances:
@@ -530,5 +532,9 @@ class StatsTesting {
return accumulator;
}
+ private static boolean isAndroid() {
+ return checkNotNull(System.getProperty("java.runtime.name", "")).contains("Android");
+ }
+
private StatsTesting() {}
}
diff --git a/guava-tests/test/com/google/common/net/InetAddressesTest.java b/guava-tests/test/com/google/common/net/InetAddressesTest.java
index 7d070e404..241c6bbf5 100644
--- a/guava-tests/test/com/google/common/net/InetAddressesTest.java
+++ b/guava-tests/test/com/google/common/net/InetAddressesTest.java
@@ -17,6 +17,7 @@
package com.google.common.net;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableSet;
import com.google.common.testing.NullPointerTester;
@@ -109,21 +110,16 @@ public class InetAddressesTest extends TestCase {
":1:2:3:4:5:6:");
for (String bogusInput : bogusInputs) {
- try {
- InetAddresses.forString(bogusInput);
- fail("IllegalArgumentException expected for '" + bogusInput + "'");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ "IllegalArgumentException expected for '" + bogusInput + "'",
+ IllegalArgumentException.class,
+ () -> InetAddresses.forString(bogusInput));
assertFalse(InetAddresses.isInetAddress(bogusInput));
}
}
public void test3ff31() {
- try {
- InetAddresses.forString("3ffe:::1");
- fail("IllegalArgumentException expected");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.forString("3ffe:::1"));
assertFalse(InetAddresses.isInetAddress("016.016.016.016"));
}
@@ -327,71 +323,33 @@ public class InetAddressesTest extends TestCase {
}
public void testForUriStringBad() {
- try {
- InetAddresses.forUriString("");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.forUriString(""));
- try {
- InetAddresses.forUriString("192.168.999.888");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> InetAddresses.forUriString("192.168.999.888"));
- try {
- InetAddresses.forUriString("www.google.com");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> InetAddresses.forUriString("www.google.com"));
- try {
- InetAddresses.forUriString("[1:2e]");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.forUriString("[1:2e]"));
- try {
- InetAddresses.forUriString("[192.168.1.1]");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.forUriString("[192.168.1.1]"));
- try {
- InetAddresses.forUriString("192.168.1.1]");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.forUriString("192.168.1.1]"));
- try {
- InetAddresses.forUriString("[192.168.1.1");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.forUriString("[192.168.1.1"));
- try {
- InetAddresses.forUriString("[3ffe:0:0:0:0:0:0:1");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> InetAddresses.forUriString("[3ffe:0:0:0:0:0:0:1"));
- try {
- InetAddresses.forUriString("3ffe:0:0:0:0:0:0:1]");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> InetAddresses.forUriString("3ffe:0:0:0:0:0:0:1]"));
- try {
- InetAddresses.forUriString("3ffe:0:0:0:0:0:0:1");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> InetAddresses.forUriString("3ffe:0:0:0:0:0:0:1"));
- try {
- InetAddresses.forUriString("::ffff:192.0.2.1");
- fail("expected IllegalArgumentException"); // COV_NF_LINE
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> InetAddresses.forUriString("::ffff:192.0.2.1"));
}
public void testCompatIPv4Addresses() {
@@ -400,11 +358,10 @@ public class InetAddressesTest extends TestCase {
for (String nonCompatAddress : nonCompatAddresses) {
InetAddress ip = InetAddresses.forString(nonCompatAddress);
assertFalse(InetAddresses.isCompatIPv4Address((Inet6Address) ip));
- try {
- InetAddresses.getCompatIPv4Address((Inet6Address) ip);
- fail("IllegalArgumentException expected for '" + nonCompatAddress + "'");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ "IllegalArgumentException expected for '" + nonCompatAddress + "'",
+ IllegalArgumentException.class,
+ () -> InetAddresses.getCompatIPv4Address((Inet6Address) ip));
}
ImmutableSet<String> validCompatAddresses = ImmutableSet.of("::1.2.3.4", "::102:304");
@@ -470,11 +427,10 @@ public class InetAddressesTest extends TestCase {
for (String non6to4Address : non6to4Addresses) {
InetAddress ip = InetAddresses.forString(non6to4Address);
assertFalse(InetAddresses.is6to4Address((Inet6Address) ip));
- try {
- InetAddresses.get6to4IPv4Address((Inet6Address) ip);
- fail("IllegalArgumentException expected for '" + non6to4Address + "'");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ "IllegalArgumentException expected for '" + non6to4Address + "'",
+ IllegalArgumentException.class,
+ () -> InetAddresses.get6to4IPv4Address((Inet6Address) ip));
}
String valid6to4Address = "2002:0102:0304::1";
@@ -492,11 +448,10 @@ public class InetAddressesTest extends TestCase {
for (String nonTeredoAddress : nonTeredoAddresses) {
InetAddress ip = InetAddresses.forString(nonTeredoAddress);
assertFalse(InetAddresses.isTeredoAddress((Inet6Address) ip));
- try {
- InetAddresses.getTeredoInfo((Inet6Address) ip);
- fail("IllegalArgumentException expected for '" + nonTeredoAddress + "'");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ "IllegalArgumentException expected for '" + nonTeredoAddress + "'",
+ IllegalArgumentException.class,
+ () -> InetAddresses.getTeredoInfo((Inet6Address) ip));
}
String validTeredoAddress = "2001:0000:4136:e378:8000:63bf:3fff:fdd2";
@@ -559,11 +514,10 @@ public class InetAddressesTest extends TestCase {
for (String nonIsatapAddress : nonIsatapAddresses) {
InetAddress ip = InetAddresses.forString(nonIsatapAddress);
assertFalse(InetAddresses.isIsatapAddress((Inet6Address) ip));
- try {
- InetAddresses.getIsatapIPv4Address((Inet6Address) ip);
- fail("IllegalArgumentException expected for '" + nonIsatapAddress + "'");
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ "IllegalArgumentException expected for '" + nonIsatapAddress + "'",
+ IllegalArgumentException.class,
+ () -> InetAddresses.getIsatapIPv4Address((Inet6Address) ip));
}
}
@@ -683,12 +637,8 @@ public class InetAddressesTest extends TestCase {
InetAddress.getByAddress(
new byte[] {16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}));
- try {
- InetAddresses.fromLittleEndianByteArray(new byte[3]);
- fail("expected exception");
- } catch (UnknownHostException expected) {
- // success
- }
+ assertThrows(
+ UnknownHostException.class, () -> InetAddresses.fromLittleEndianByteArray(new byte[3]));
}
public void testIsMaximum() throws UnknownHostException {
@@ -720,12 +670,7 @@ public class InetAddressesTest extends TestCase {
assertEquals(address_67_0, address);
InetAddress address_ffffff = InetAddress.getByName("255.255.255.255");
- address = address_ffffff;
- try {
- address = InetAddresses.increment(address);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.increment(address_ffffff));
}
public void testIncrementIPv6() throws UnknownHostException {
@@ -743,12 +688,7 @@ public class InetAddressesTest extends TestCase {
assertEquals(addressV6_67_0, address);
InetAddress addressV6_ffffff = InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
- address = addressV6_ffffff;
- try {
- address = InetAddresses.increment(address);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.increment(addressV6_ffffff));
}
public void testDecrementIPv4() throws UnknownHostException {
@@ -767,12 +707,7 @@ public class InetAddressesTest extends TestCase {
assertEquals(address660, address);
InetAddress address0000 = InetAddress.getByName("0.0.0.0");
- address = address0000;
- try {
- address = InetAddresses.decrement(address);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.decrement(address0000));
}
public void testDecrementIPv6() throws UnknownHostException {
@@ -791,30 +726,23 @@ public class InetAddressesTest extends TestCase {
assertEquals(addressV6660, address);
InetAddress addressV6000000 = InetAddress.getByName("0:0:0:0:0:0:0:0");
- address = addressV6000000;
- try {
- address = InetAddresses.decrement(address);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> InetAddresses.decrement(addressV6000000));
}
public void testFromIpv4BigIntegerThrowsLessThanZero() {
- try {
- InetAddresses.fromIPv4BigInteger(BigInteger.valueOf(-1L));
- fail();
- } catch (IllegalArgumentException expected) {
- assertEquals("BigInteger must be greater than or equal to 0", expected.getMessage());
- }
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> InetAddresses.fromIPv4BigInteger(BigInteger.valueOf(-1L)));
+ assertEquals("BigInteger must be greater than or equal to 0", expected.getMessage());
}
public void testFromIpv6BigIntegerThrowsLessThanZero() {
- try {
- InetAddresses.fromIPv6BigInteger(BigInteger.valueOf(-1L));
- fail();
- } catch (IllegalArgumentException expected) {
- assertEquals("BigInteger must be greater than or equal to 0", expected.getMessage());
- }
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> InetAddresses.fromIPv6BigInteger(BigInteger.valueOf(-1L)));
+ assertEquals("BigInteger must be greater than or equal to 0", expected.getMessage());
}
public void testFromIpv4BigIntegerValid() {
@@ -840,27 +768,28 @@ public class InetAddressesTest extends TestCase {
}
public void testFromIpv4BigIntegerInputTooLarge() {
- try {
- InetAddresses.fromIPv4BigInteger(BigInteger.ONE.shiftLeft(32).add(BigInteger.ONE));
- fail();
- } catch (IllegalArgumentException expected) {
- assertEquals(
- "BigInteger cannot be converted to InetAddress because it has more than 4 bytes:"
- + " 4294967297",
- expected.getMessage());
- }
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ InetAddresses.fromIPv4BigInteger(BigInteger.ONE.shiftLeft(32).add(BigInteger.ONE)));
+ assertEquals(
+ "BigInteger cannot be converted to InetAddress because it has more than 4 bytes:"
+ + " 4294967297",
+ expected.getMessage());
}
public void testFromIpv6BigIntegerInputTooLarge() {
- try {
- InetAddresses.fromIPv6BigInteger(BigInteger.ONE.shiftLeft(128).add(BigInteger.ONE));
- fail();
- } catch (IllegalArgumentException expected) {
- assertEquals(
- "BigInteger cannot be converted to InetAddress because it has more than 16 bytes:"
- + " 340282366920938463463374607431768211457",
- expected.getMessage());
- }
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ InetAddresses.fromIPv6BigInteger(
+ BigInteger.ONE.shiftLeft(128).add(BigInteger.ONE)));
+ assertEquals(
+ "BigInteger cannot be converted to InetAddress because it has more than 16 bytes:"
+ + " 340282366920938463463374607431768211457",
+ expected.getMessage());
}
/** Checks that the IP converts to the big integer and the big integer converts to the IP. */
diff --git a/guava-tests/test/com/google/common/net/MediaTypeTest.java b/guava-tests/test/com/google/common/net/MediaTypeTest.java
index 574db68e8..a3428b32f 100644
--- a/guava-tests/test/com/google/common/net/MediaTypeTest.java
+++ b/guava-tests/test/com/google/common/net/MediaTypeTest.java
@@ -16,8 +16,6 @@
package com.google.common.net;
-import static com.google.common.base.Charsets.UTF_16;
-import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.net.MediaType.ANY_APPLICATION_TYPE;
import static com.google.common.net.MediaType.ANY_AUDIO_TYPE;
import static com.google.common.net.MediaType.ANY_IMAGE_TYPE;
@@ -31,6 +29,8 @@ import static com.google.common.truth.Truth.assertThat;
import static java.lang.reflect.Modifier.isFinal;
import static java.lang.reflect.Modifier.isPublic;
import static java.lang.reflect.Modifier.isStatic;
+import static java.nio.charset.StandardCharsets.UTF_16;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Arrays.asList;
import com.google.common.annotations.GwtCompatible;
@@ -512,6 +512,14 @@ public class MediaTypeTest extends TestCase {
}
}
+ // https://github.com/google/guava/issues/6663
+ public void testParse_spaceInParameterSeparator() {
+ assertThat(MediaType.parse("text/plain; charset =utf-8").charset()).hasValue(UTF_8);
+ assertThat(MediaType.parse("text/plain; charset= utf-8").charset()).hasValue(UTF_8);
+ assertThat(MediaType.parse("text/plain; charset = utf-8").charset()).hasValue(UTF_8);
+ assertThat(MediaType.parse("text/plain;charset =utf-8").charset()).hasValue(UTF_8);
+ }
+
public void testGetCharset() {
assertThat(MediaType.parse("text/plain").charset()).isAbsent();
assertThat(MediaType.parse("text/plain; charset=utf-8").charset()).hasValue(UTF_8);
@@ -556,6 +564,9 @@ public class MediaTypeTest extends TestCase {
MediaType.create("TEXT", "PLAIN"),
MediaType.parse("text/plain"),
MediaType.parse("TEXT/PLAIN"),
+ MediaType.parse("text /plain"),
+ MediaType.parse("TEXT/ plain"),
+ MediaType.parse("text / plain"),
MediaType.create("text", "plain").withParameter("a", "1").withoutParameters())
.addEqualityGroup(
MediaType.create("text", "plain").withCharset(UTF_8),
@@ -571,7 +582,11 @@ public class MediaTypeTest extends TestCase {
MediaType.parse("text/plain; charset=\"utf-8\""),
MediaType.parse("text/plain; charset=\"\\u\\tf-\\8\""),
MediaType.parse("text/plain; charset=UTF-8"),
- MediaType.parse("text/plain ; charset=utf-8"))
+ MediaType.parse("text/plain ; charset=utf-8"),
+ MediaType.parse("text/plain; charset =UTF-8"),
+ MediaType.parse("text/plain; charset= UTF-8"),
+ MediaType.parse("text/plain; charset = UTF-8"),
+ MediaType.parse("text/plain; charset=\tUTF-8"))
.addEqualityGroup(MediaType.parse("text/plain; charset=utf-8; charset=utf-8"))
.addEqualityGroup(
MediaType.create("text", "plain").withParameter("a", "value"),
diff --git a/guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java b/guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java
index 840ae97c3..10f9a662b 100644
--- a/guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java
+++ b/guava-tests/test/com/google/common/primitives/UnsignedBytesTest.java
@@ -18,6 +18,7 @@ package com.google.common.primitives;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.testing.Helpers;
import com.google.common.testing.NullPointerTester;
@@ -97,11 +98,7 @@ public class UnsignedBytesTest extends TestCase {
}
public void testMax_noArgs() {
- try {
- UnsignedBytes.max();
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> UnsignedBytes.max());
}
public void testMax() {
@@ -112,11 +109,7 @@ public class UnsignedBytesTest extends TestCase {
}
public void testMin_noArgs() {
- try {
- UnsignedBytes.min();
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> UnsignedBytes.min());
}
public void testMin() {
@@ -177,24 +170,16 @@ public class UnsignedBytesTest extends TestCase {
public void testParseUnsignedByteThrowsExceptionForInvalidRadix() {
// Valid radix values are Character.MIN_RADIX to Character.MAX_RADIX,
// inclusive.
- try {
- UnsignedBytes.parseUnsignedByte("0", Character.MIN_RADIX - 1);
- fail();
- } catch (NumberFormatException expected) {
- }
+ assertThrows(
+ NumberFormatException.class,
+ () -> UnsignedBytes.parseUnsignedByte("0", Character.MIN_RADIX - 1));
- try {
- UnsignedBytes.parseUnsignedByte("0", Character.MAX_RADIX + 1);
- fail();
- } catch (NumberFormatException expected) {
- }
+ assertThrows(
+ NumberFormatException.class,
+ () -> UnsignedBytes.parseUnsignedByte("0", Character.MAX_RADIX + 1));
// The radix is used as an array index, so try a negative value.
- try {
- UnsignedBytes.parseUnsignedByte("0", -1);
- fail();
- } catch (NumberFormatException expected) {
- }
+ assertThrows(NumberFormatException.class, () -> UnsignedBytes.parseUnsignedByte("0", -1));
}
public void testToString() {
diff --git a/guava-tests/test/com/google/common/reflect/ImmutableTypeToInstanceMapTest.java b/guava-tests/test/com/google/common/reflect/ImmutableTypeToInstanceMapTest.java
index 064c4b5c1..83b56c445 100644
--- a/guava-tests/test/com/google/common/reflect/ImmutableTypeToInstanceMapTest.java
+++ b/guava-tests/test/com/google/common/reflect/ImmutableTypeToInstanceMapTest.java
@@ -18,6 +18,7 @@ package com.google.common.reflect;
import static com.google.common.collect.Maps.immutableEntry;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.testing.MapTestSuiteBuilder;
@@ -121,21 +122,16 @@ public class ImmutableTypeToInstanceMapTest extends TestCase {
public void testGetInstance_containsTypeVariable() {
ImmutableTypeToInstanceMap<Iterable<Number>> map = ImmutableTypeToInstanceMap.of();
- try {
- map.getInstance(this.<Number>anyIterableType());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> map.getInstance(this.<Number>anyIterableType()));
}
public void testPut_containsTypeVariable() {
ImmutableTypeToInstanceMap.Builder<Iterable<Integer>> builder =
ImmutableTypeToInstanceMap.builder();
- try {
- builder.put(this.<Integer>anyIterableType(), ImmutableList.of(1));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> builder.put(this.<Integer>anyIterableType(), ImmutableList.of(1)));
}
private <T> TypeToken<Iterable<T>> anyIterableType() {
diff --git a/guava-tests/test/com/google/common/reflect/InvokableTest.java b/guava-tests/test/com/google/common/reflect/InvokableTest.java
index 60c8c15e4..721351a3b 100644
--- a/guava-tests/test/com/google/common/reflect/InvokableTest.java
+++ b/guava-tests/test/com/google/common/reflect/InvokableTest.java
@@ -17,6 +17,7 @@
package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -285,11 +286,7 @@ public class InvokableTest extends TestCase {
public void testConstructor_invalidReturning() throws Exception {
Invokable<?, Prepender> delegate = Prepender.constructor(String.class, int.class);
- try {
- delegate.returning(SubPrepender.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> delegate.returning(SubPrepender.class));
}
public void testStaticMethod_returnType() throws Exception {
@@ -352,11 +349,9 @@ public class InvokableTest extends TestCase {
public void testStaticMethod_invalidReturning() throws Exception {
Invokable<?, Object> delegate = Prepender.method("prepend", String.class, Iterable.class);
- try {
- delegate.returning(new TypeToken<Iterable<Integer>>() {});
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> delegate.returning(new TypeToken<Iterable<Integer>>() {}));
}
public void testInstanceMethod_returnType() throws Exception {
@@ -414,11 +409,9 @@ public class InvokableTest extends TestCase {
public void testInstanceMethod_invalidReturning() throws Exception {
Invokable<?, Object> delegate = Prepender.method("prepend", Iterable.class);
- try {
- delegate.returning(new TypeToken<Iterable<Integer>>() {});
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> delegate.returning(new TypeToken<Iterable<Integer>>() {}));
}
public void testPrivateInstanceMethod_isOverridable() throws Exception {
diff --git a/guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java b/guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java
index cea81e3a2..0ea574e46 100644
--- a/guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java
+++ b/guava-tests/test/com/google/common/reflect/MutableTypeToInstanceMapTest.java
@@ -18,6 +18,7 @@ package com.google.common.reflect;
import static com.google.common.collect.Maps.immutableEntry;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -81,30 +82,23 @@ public class MutableTypeToInstanceMapTest extends TestCase {
}
public void testPutThrows() {
- try {
- map.put(TypeToken.of(Integer.class), new Integer(5));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> map.put(TypeToken.of(Integer.class), new Integer(5)));
}
public void testPutAllThrows() {
- try {
- map.putAll(ImmutableMap.of(TypeToken.of(Integer.class), new Integer(5)));
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(
+ UnsupportedOperationException.class,
+ () -> map.putAll(ImmutableMap.of(TypeToken.of(Integer.class), new Integer(5))));
}
public void testEntrySetMutationThrows() {
map.putInstance(String.class, "test");
assertEquals(TypeToken.of(String.class), map.entrySet().iterator().next().getKey());
assertEquals("test", map.entrySet().iterator().next().getValue());
- try {
- map.entrySet().iterator().next().setValue(1);
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(
+ UnsupportedOperationException.class, () -> map.entrySet().iterator().next().setValue(1));
}
public void testEntrySetToArrayMutationThrows() {
@@ -113,11 +107,7 @@ public class MutableTypeToInstanceMapTest extends TestCase {
Entry<Object, Object> entry = (Entry<Object, Object>) map.entrySet().toArray()[0];
assertEquals(TypeToken.of(String.class), entry.getKey());
assertEquals("test", entry.getValue());
- try {
- entry.setValue(1);
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> entry.setValue(1));
}
public void testEntrySetToTypedArrayMutationThrows() {
@@ -126,11 +116,7 @@ public class MutableTypeToInstanceMapTest extends TestCase {
Entry<Object, Object> entry = map.entrySet().toArray(new Entry[0])[0];
assertEquals(TypeToken.of(String.class), entry.getKey());
assertEquals("test", entry.getValue());
- try {
- entry.setValue(1);
- fail();
- } catch (UnsupportedOperationException expected) {
- }
+ assertThrows(UnsupportedOperationException.class, () -> entry.setValue(1));
}
public void testPutAndGetInstance() {
@@ -147,11 +133,8 @@ public class MutableTypeToInstanceMapTest extends TestCase {
}
public void testNull() {
- try {
- map.putInstance((TypeToken) null, new Integer(1));
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(
+ NullPointerException.class, () -> map.putInstance((TypeToken) null, new Integer(1)));
map.putInstance(Integer.class, null);
assertTrue(map.containsKey(TypeToken.of(Integer.class)));
assertTrue(map.entrySet().contains(immutableEntry(TypeToken.of(Integer.class), null)));
@@ -208,19 +191,14 @@ public class MutableTypeToInstanceMapTest extends TestCase {
}
public void testGetInstance_withTypeVariable() {
- try {
- map.getInstance(this.<Number>anyIterableType());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> map.getInstance(this.<Number>anyIterableType()));
}
public void testPutInstance_withTypeVariable() {
- try {
- map.putInstance(this.<Integer>anyIterableType(), ImmutableList.of(1));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> map.putInstance(this.<Integer>anyIterableType(), ImmutableList.of(1)));
}
private <T> TypeToken<Iterable<T>> anyIterableType() {
diff --git a/guava-tests/test/com/google/common/reflect/ReflectionTest.java b/guava-tests/test/com/google/common/reflect/ReflectionTest.java
index 2885f8956..83d0168a6 100644
--- a/guava-tests/test/com/google/common/reflect/ReflectionTest.java
+++ b/guava-tests/test/com/google/common/reflect/ReflectionTest.java
@@ -16,6 +16,8 @@
package com.google.common.reflect;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.testing.NullPointerTester;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
@@ -39,11 +41,8 @@ public class ReflectionTest extends TestCase {
}
public void testNewProxyCantWorkOnAClass() throws Exception {
- try {
- Reflection.newProxy(Object.class, X_RETURNER);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> Reflection.newProxy(Object.class, X_RETURNER));
}
private static final InvocationHandler X_RETURNER =
diff --git a/guava-tests/test/com/google/common/reflect/TypeParameterTest.java b/guava-tests/test/com/google/common/reflect/TypeParameterTest.java
index b83e48596..ca49283a6 100644
--- a/guava-tests/test/com/google/common/reflect/TypeParameterTest.java
+++ b/guava-tests/test/com/google/common/reflect/TypeParameterTest.java
@@ -16,6 +16,8 @@
package com.google.common.reflect;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.testing.EqualsTester;
import com.google.common.testing.NullPointerTester;
import java.lang.reflect.Method;
@@ -38,11 +40,7 @@ public class TypeParameterTest extends TestCase {
}
public void testConcreteTypeRejected() {
- try {
- new TypeParameter<String>() {};
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> new TypeParameter<String>() {});
}
public <A, B> void testEquals() throws Exception {
diff --git a/guava-tests/test/com/google/common/reflect/TypeResolverTest.java b/guava-tests/test/com/google/common/reflect/TypeResolverTest.java
index e970a8d99..5eba7052d 100644
--- a/guava-tests/test/com/google/common/reflect/TypeResolverTest.java
+++ b/guava-tests/test/com/google/common/reflect/TypeResolverTest.java
@@ -16,6 +16,8 @@
package com.google.common.reflect;
+import static org.junit.Assert.assertThrows;
+
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
@@ -80,11 +82,7 @@ public class TypeResolverTest extends TestCase {
public <T> void testWhere_duplicateMapping() {
Type t = aTypeVariable();
TypeResolver resolver = new TypeResolver().where(t, String.class);
- try {
- resolver.where(t, String.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> resolver.where(t, String.class));
}
public <T1, T2 extends List<T1>> void testWhere_recursiveMapping() {
@@ -153,87 +151,77 @@ public class TypeResolverTest extends TestCase {
}
public <T> void testWhere_incompatibleGenericArrayMapping() {
- try {
- new TypeResolver().where(new TypeCapture<T[]>() {}.capture(), String.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new TypeResolver().where(new TypeCapture<T[]>() {}.capture(), String.class));
}
public <T> void testWhere_incompatibleParameterizedTypeMapping() {
- try {
- new TypeResolver().where(new TypeCapture<Iterable<T>>() {}.capture(), List.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new TypeResolver().where(new TypeCapture<Iterable<T>>() {}.capture(), List.class));
}
public <T> void testWhere_impossibleParameterizedTypeMapping() {
- try {
- new TypeResolver()
- .where(
- new TypeCapture<List<T>>() {}.capture(),
- new TypeCapture<Map<String, Integer>>() {}.capture());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new TypeResolver()
+ .where(
+ new TypeCapture<List<T>>() {}.capture(),
+ new TypeCapture<Map<String, Integer>>() {}.capture()));
}
public <T> void testWhere_incompatibleWildcardUpperBound() {
- try {
- new TypeResolver()
- .where(
- new TypeCapture<List<? extends String>>() {}.capture(),
- new TypeCapture<List<? extends Integer>>() {}.capture());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new TypeResolver()
+ .where(
+ new TypeCapture<List<? extends String>>() {}.capture(),
+ new TypeCapture<List<? extends Integer>>() {}.capture()));
}
public <T> void testWhere_incompatibleWildcardLowerBound() {
- try {
- new TypeResolver()
- .where(
- new TypeCapture<List<? super String>>() {}.capture(),
- new TypeCapture<List<? super Integer>>() {}.capture());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new TypeResolver()
+ .where(
+ new TypeCapture<List<? super String>>() {}.capture(),
+ new TypeCapture<List<? super Integer>>() {}.capture()));
}
public <T> void testWhere_incompatibleWildcardBounds() {
- try {
- new TypeResolver()
- .where(
- new TypeCapture<List<? extends T>>() {}.capture(),
- new TypeCapture<List<? super String>>() {}.capture());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new TypeResolver()
+ .where(
+ new TypeCapture<List<? extends T>>() {}.capture(),
+ new TypeCapture<List<? super String>>() {}.capture()));
}
public <T> void testWhere_wrongOrder() {
- try {
- new TypeResolver().where(String.class, aTypeVariable());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new TypeResolver().where(String.class, aTypeVariable()));
}
public <T> void testWhere_mapFromConcreteParameterizedType() {
- try {
- new TypeResolver().where(new TypeCapture<List<String>>() {}.capture(), aTypeVariable());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new TypeResolver()
+ .where(new TypeCapture<List<String>>() {}.capture(), aTypeVariable()));
}
public <T> void testWhere_mapFromConcreteGenericArrayType() {
- try {
- new TypeResolver().where(new TypeCapture<List<String>>() {}.capture(), aTypeVariable());
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ new TypeResolver()
+ .where(new TypeCapture<List<String>>() {}.capture(), aTypeVariable()));
}
public <K, V> void testWhere_actualArgHasWildcard() {
diff --git a/guava-tests/test/com/google/common/reflect/TypeTokenResolutionTest.java b/guava-tests/test/com/google/common/reflect/TypeTokenResolutionTest.java
index b8f5edbe0..0a7a9da32 100644
--- a/guava-tests/test/com/google/common/reflect/TypeTokenResolutionTest.java
+++ b/guava-tests/test/com/google/common/reflect/TypeTokenResolutionTest.java
@@ -17,6 +17,7 @@
package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
@@ -248,11 +249,7 @@ public class TypeTokenResolutionTest extends TestCase {
TypeToken.of(StringIterable.class)
.resolveType(Iterable.class.getTypeParameters()[0])
.getType());
- try {
- TypeToken.of(this.getClass()).resolveType(null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> TypeToken.of(this.getClass()).resolveType(null));
}
public void testContextIsParameterizedType() throws Exception {
diff --git a/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java b/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java
index b25aab57c..067f03c37 100644
--- a/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java
+++ b/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java
@@ -17,6 +17,7 @@
package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import java.io.Serializable;
import java.util.Comparator;
@@ -39,12 +40,10 @@ public class TypeTokenSubtypeTest extends TestCase {
* recursively bounded.
*/
public void testRecursiveWildcardSubtypeBug() throws Exception {
- try {
- new RecursiveTypeBoundBugExample<>().testAllDeclarations();
- fail();
- } catch (Exception e) {
- assertThat(e).hasCauseThat().isInstanceOf(AssertionError.class);
- }
+ Exception e =
+ assertThrows(
+ Exception.class, () -> new RecursiveTypeBoundBugExample<>().testAllDeclarations());
+ assertThat(e).hasCauseThat().isInstanceOf(AssertionError.class);
}
@SuppressWarnings("RestrictedApiChecker") // crashes under JDK8, which EP no longer supports
@@ -96,11 +95,7 @@ public class TypeTokenSubtypeTest extends TestCase {
public void testGetSubtypeOf_impossibleWildcard() {
TypeToken<List<? extends Number>> numberList = new TypeToken<List<? extends Number>>() {};
abstract class StringList implements List<String> {}
- try {
- numberList.getSubtype(StringList.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> numberList.getSubtype(StringList.class));
}
private static class OwnerTypeSubtypingTests extends SubtypeTester {
diff --git a/guava-tests/test/com/google/common/reflect/TypeTokenTest.java b/guava-tests/test/com/google/common/reflect/TypeTokenTest.java
index 5d66b840b..409d02b70 100644
--- a/guava-tests/test/com/google/common/reflect/TypeTokenTest.java
+++ b/guava-tests/test/com/google/common/reflect/TypeTokenTest.java
@@ -17,6 +17,7 @@
package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
@@ -65,6 +66,11 @@ public class TypeTokenTest extends TestCase {
}
public <T> void testVariableTypeTokenNotAllowed() {
+ /*
+ * We'd use assertThrows here, but that causes no exception to be thrown under Java 8,
+ * presumably because the ThrowingRunnable lambda triggers some kind of bug in Java 8's
+ * reflection implementation.
+ */
try {
new TypeToken<T>() {};
fail();
@@ -1147,11 +1153,9 @@ public class TypeTokenTest extends TestCase {
@SuppressWarnings({"rawtypes", "unchecked"}) // purpose is to test raw type
public void testGetSupertype_notSupertype() {
- try {
- new TypeToken<List<String>>() {}.getSupertype((Class) String.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new TypeToken<List<String>>() {}.getSupertype((Class) String.class));
}
public void testGetSupertype_fromArray() {
@@ -1235,11 +1239,7 @@ public class TypeTokenTest extends TestCase {
TypeToken<? super Iterable<String>> type =
(TypeToken<? super Iterable<String>>)
TypeToken.of(Types.supertypeOf(new TypeToken<ImmutableList<String>>() {}.getType()));
- try {
- type.getSubtype(List.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> type.getSubtype(List.class));
}
public void testGetSubtype_fromWildcard_upperBounded() {
@@ -1247,14 +1247,15 @@ public class TypeTokenTest extends TestCase {
TypeToken<? extends Iterable<String>> type =
(TypeToken<? extends Iterable<String>>)
TypeToken.of(Types.subtypeOf(new TypeToken<Iterable<String>>() {}.getType()));
- try {
- type.getSubtype(Iterable.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> type.getSubtype(Iterable.class));
}
public <T extends Iterable<String>> void testGetSubtype_fromTypeVariable() {
+ /*
+ * We'd use assertThrows here, but that causes capture() to return null under Java 8, presumably
+ * because the ThrowingRunnable lambda triggers some kind of bug in Java 8's reflection
+ * implementation.
+ */
try {
TypeToken.of(new TypeCapture<T>() {}.capture()).getSubtype(List.class);
fail();
@@ -1450,13 +1451,12 @@ public class TypeTokenTest extends TestCase {
@SuppressWarnings("unchecked") // To construct TypeToken<T> with TypeToken.of()
public <T> void testWhere_circleRejected() {
TypeToken<List<T>> type = new TypeToken<List<T>>() {};
- try {
- type.where(
- new TypeParameter<T>() {},
- (TypeToken<T>) TypeToken.of(new TypeCapture<T>() {}.capture()));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ type.where(
+ new TypeParameter<T>() {},
+ (TypeToken<T>) TypeToken.of(new TypeCapture<T>() {}.capture())));
}
public void testWhere() {
@@ -1587,11 +1587,7 @@ public class TypeTokenTest extends TestCase {
public void testMethod_notDeclaredByType() throws NoSuchMethodException {
Method sizeMethod = Map.class.getMethod("size");
- try {
- TypeToken.of(List.class).method(sizeMethod);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> TypeToken.of(List.class).method(sizeMethod));
}
public void testMethod_declaredBySuperclass() throws Exception {
@@ -1654,20 +1650,14 @@ public class TypeTokenTest extends TestCase {
public void testConstructor_notDeclaredByType() throws NoSuchMethodException {
Constructor<String> constructor = String.class.getConstructor();
- try {
- TypeToken.of(Object.class).constructor(constructor);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> TypeToken.of(Object.class).constructor(constructor));
}
public void testConstructor_declaredBySuperclass() throws NoSuchMethodException {
Constructor<Object> constructor = Object.class.getConstructor();
- try {
- TypeToken.of(String.class).constructor(constructor);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> TypeToken.of(String.class).constructor(constructor));
}
public void testConstructor_equals() throws NoSuchMethodException {
@@ -1840,19 +1830,13 @@ public class TypeTokenTest extends TestCase {
reserialize(new TypeToken<Map<String, Integer>>() {});
reserialize(new IKnowMyType<Map<? super String, ? extends int[]>>() {}.type());
reserialize(TypeToken.of(new TypeCapture<B>() {}.capture()).getTypes().rawTypes());
- try {
- SerializableTester.reserialize(TypeToken.of(new TypeCapture<B>() {}.capture()));
- fail();
- } catch (RuntimeException expected) {
- }
+ assertThrows(
+ RuntimeException.class,
+ () -> SerializableTester.reserialize(TypeToken.of(new TypeCapture<B>() {}.capture())));
}
public <A> void testSerializable_typeVariableNotSupported() {
- try {
- new ITryToSerializeMyTypeVariable<String>().go();
- fail();
- } catch (RuntimeException expected) {
- }
+ assertThrows(RuntimeException.class, () -> new ITryToSerializeMyTypeVariable<String>().go());
}
private static class ITryToSerializeMyTypeVariable<T> {
diff --git a/guava-tests/test/com/google/common/reflect/TypesTest.java b/guava-tests/test/com/google/common/reflect/TypesTest.java
index 436b2bbff..b33afce0b 100644
--- a/guava-tests/test/com/google/common/reflect/TypesTest.java
+++ b/guava-tests/test/com/google/common/reflect/TypesTest.java
@@ -18,6 +18,7 @@ package com.google.common.reflect;
import static com.google.common.truth.Truth.assertThat;
import static java.util.Arrays.asList;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.Lists;
import com.google.common.testing.EqualsTester;
@@ -117,11 +118,9 @@ public class TypesTest extends TestCase {
}
public void testNewParameterizedType_ownerMismatch() {
- try {
- Types.newParameterizedTypeWithOwner(Number.class, List.class, String.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Types.newParameterizedTypeWithOwner(Number.class, List.class, String.class));
}
public void testNewParameterizedType_ownerMissing() {
@@ -131,19 +130,15 @@ public class TypesTest extends TestCase {
}
public void testNewParameterizedType_invalidTypeParameters() {
- try {
- Types.newParameterizedTypeWithOwner(Map.class, Entry.class, String.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Types.newParameterizedTypeWithOwner(Map.class, Entry.class, String.class));
}
public void testNewParameterizedType_primitiveTypeParameters() {
- try {
- Types.newParameterizedTypeWithOwner(Map.class, Entry.class, int.class, int.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Types.newParameterizedTypeWithOwner(Map.class, Entry.class, int.class, int.class));
}
public void testNewArrayType() {
@@ -234,11 +229,7 @@ public class TypesTest extends TestCase {
}
public void testNewWildcardType_primitiveTypeBound() {
- try {
- Types.subtypeOf(int.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> Types.subtypeOf(int.class));
}
public void testNewWildcardType_serializable() {
@@ -301,19 +292,15 @@ public class TypesTest extends TestCase {
}
public void testNewTypeVariable_primitiveTypeBound() {
- try {
- Types.newArtificialTypeVariable(List.class, "E", int.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Types.newArtificialTypeVariable(List.class, "E", int.class));
}
public void testNewTypeVariable_serializable() throws Exception {
- try {
- SerializableTester.reserialize(Types.newArtificialTypeVariable(List.class, "E"));
- fail();
- } catch (RuntimeException expected) {
- }
+ assertThrows(
+ RuntimeException.class,
+ () -> SerializableTester.reserialize(Types.newArtificialTypeVariable(List.class, "E")));
}
private static <D extends GenericDeclaration> TypeVariable<D> withBounds(
@@ -372,11 +359,9 @@ public class TypesTest extends TestCase {
}
public void testNewParameterizedTypeWithWrongNumberOfTypeArguments() {
- try {
- Types.newParameterizedType(Map.class, String.class, Integer.class, Long.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> Types.newParameterizedType(Map.class, String.class, Integer.class, Long.class));
}
public void testToString() {
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractChainedListenableFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractChainedListenableFutureTest.java
index 85c4e14a5..d0d8e89c8 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractChainedListenableFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractChainedListenableFutureTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.testing.MockFutureListener;
import java.util.concurrent.TimeUnit;
@@ -49,11 +50,7 @@ public abstract class AbstractChainedListenableFutureTest<T> extends TestCase {
public void testFutureGetBeforeCallback() throws Exception {
// Verify that get throws a timeout exception before the callback is called.
- try {
- resultFuture.get(1L, TimeUnit.MILLISECONDS);
- fail("The data is not yet ready, so a TimeoutException is expected");
- } catch (TimeoutException expected) {
- }
+ assertThrows(TimeoutException.class, () -> resultFuture.get(1L, TimeUnit.MILLISECONDS));
}
public void testFutureGetThrowsWrappedException() throws Exception {
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractClosingFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractClosingFutureTest.java
index ecccd784c..b6ca74e8e 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractClosingFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractClosingFutureTest.java
@@ -30,6 +30,7 @@ import static com.google.common.util.concurrent.Uninterruptibles.getUninterrupti
import static java.util.Arrays.asList;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
@@ -739,11 +740,7 @@ public abstract class AbstractClosingFutureTest extends TestCase {
waitUntilClosed(closingFuture);
assertStillOpen(closeable2);
assertClosed(closeable1);
- try {
- capturedPeeker.get().getDone(input1);
- fail("Peeker should not be able to peek except during call.");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> capturedPeeker.get().getDone(input1));
}
public void testWhenAllComplete_call_cancelledPipeline() throws Exception {
@@ -825,11 +822,7 @@ public abstract class AbstractClosingFutureTest extends TestCase {
assertThat(getFinalValue(closingFuture)).isSameInstanceAs(closeable2);
waitUntilClosed(closingFuture);
assertClosed(closeable1, closeable2);
- try {
- capturedPeeker.get().getDone(input1);
- fail("Peeker should not be able to peek except during call.");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> capturedPeeker.get().getDone(input1));
}
public void testWhenAllComplete_callAsync_cancelledPipeline() throws Exception {
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
index 9b3f0f867..ad2a676c3 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractExecutionThreadServiceTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.testing.TearDown;
import com.google.common.testing.TearDownStack;
@@ -175,12 +176,9 @@ public class AbstractExecutionThreadServiceTest extends TestCase {
assertFalse(service.startUpCalled);
service.startAsync();
- try {
- service.awaitRunning();
- fail();
- } catch (IllegalStateException expected) {
- assertThat(expected).hasCauseThat().hasMessageThat().isEqualTo("kaboom!");
- }
+ IllegalStateException expected =
+ assertThrows(IllegalStateException.class, () -> service.awaitRunning());
+ assertThat(expected).hasCauseThat().hasMessageThat().isEqualTo("kaboom!");
executionThread.join();
assertTrue(service.startUpCalled);
@@ -212,14 +210,11 @@ public class AbstractExecutionThreadServiceTest extends TestCase {
ThrowOnRunService service = new ThrowOnRunService();
service.startAsync();
- try {
- service.awaitTerminated();
- fail();
- } catch (IllegalStateException expected) {
- executionThread.join();
- assertThat(expected).hasCauseThat().isEqualTo(service.failureCause());
- assertThat(expected).hasCauseThat().hasMessageThat().isEqualTo("kaboom!");
- }
+ IllegalStateException expected =
+ assertThrows(IllegalStateException.class, () -> service.awaitTerminated());
+ executionThread.join();
+ assertThat(expected).hasCauseThat().isEqualTo(service.failureCause());
+ assertThat(expected).hasCauseThat().hasMessageThat().isEqualTo("kaboom!");
assertTrue(service.shutDownCalled);
assertEquals(Service.State.FAILED, service.state());
}
@@ -229,15 +224,11 @@ public class AbstractExecutionThreadServiceTest extends TestCase {
service.throwOnShutDown = true;
service.startAsync();
- try {
- service.awaitTerminated();
- fail();
- } catch (IllegalStateException expected) {
- executionThread.join();
- assertThat(expected).hasCauseThat().isEqualTo(service.failureCause());
- assertThat(expected).hasCauseThat().hasMessageThat().isEqualTo("kaboom!");
- }
-
+ IllegalStateException expected =
+ assertThrows(IllegalStateException.class, () -> service.awaitTerminated());
+ executionThread.join();
+ assertThat(expected).hasCauseThat().isEqualTo(service.failureCause());
+ assertThat(expected).hasCauseThat().hasMessageThat().isEqualTo("kaboom!");
assertTrue(service.shutDownCalled);
assertEquals(Service.State.FAILED, service.state());
}
@@ -303,12 +294,11 @@ public class AbstractExecutionThreadServiceTest extends TestCase {
public void testServiceTimeoutOnStartUp() throws Exception {
TimeoutOnStartUp service = new TimeoutOnStartUp();
- try {
- service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
- fail();
- } catch (TimeoutException e) {
- assertThat(e.getMessage()).contains(Service.State.STARTING.toString());
- }
+ TimeoutException e =
+ assertThrows(
+ TimeoutException.class,
+ () -> service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS));
+ assertThat(e.getMessage()).contains(Service.State.STARTING.toString());
}
private class TimeoutOnStartUp extends AbstractExecutionThreadService {
@@ -377,14 +367,13 @@ public class AbstractExecutionThreadServiceTest extends TestCase {
return "Foo";
}
};
- try {
- service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
- fail("Expected timeout");
- } catch (TimeoutException e) {
- assertThat(e)
- .hasMessageThat()
- .isEqualTo("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
- }
+ TimeoutException e =
+ assertThrows(
+ TimeoutException.class,
+ () -> service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS));
+ assertThat(e)
+ .hasMessageThat()
+ .isEqualTo("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
}
private class FakeService extends AbstractExecutionThreadService implements TearDown {
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java
index 9aee78029..d00f95f31 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureCancellationCauseTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import java.lang.reflect.Method;
import java.net.URLClassLoader;
@@ -89,12 +90,8 @@ public class AbstractFutureCancellationCauseTest extends TestCase {
assertTrue(future.isCancelled());
assertTrue(future.isDone());
assertNull(tryInternalFastPathGetFailure(future));
- try {
- future.get();
- fail("Expected CancellationException");
- } catch (CancellationException e) {
- assertNotNull(e.getCause());
- }
+ CancellationException e = assertThrows(CancellationException.class, () -> future.get());
+ assertNotNull(e.getCause());
}
public void testCancel_notDoneInterrupt() throws Exception {
@@ -103,12 +100,8 @@ public class AbstractFutureCancellationCauseTest extends TestCase {
assertTrue(future.isCancelled());
assertTrue(future.isDone());
assertNull(tryInternalFastPathGetFailure(future));
- try {
- future.get();
- fail("Expected CancellationException");
- } catch (CancellationException e) {
- assertNotNull(e.getCause());
- }
+ CancellationException e = assertThrows(CancellationException.class, () -> future.get());
+ assertNotNull(e.getCause());
}
public void testSetFuture_misbehavingFutureDoesNotThrow() throws Exception {
@@ -151,13 +144,9 @@ public class AbstractFutureCancellationCauseTest extends TestCase {
"setFuture",
future.getClass().getClassLoader().loadClass(ListenableFuture.class.getName()))
.invoke(future, badFuture);
- try {
- future.get();
- fail();
- } catch (CancellationException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
- assertThat(expected).hasCauseThat().hasMessageThat().contains(badFuture.toString());
- }
+ CancellationException expected = assertThrows(CancellationException.class, () -> future.get());
+ assertThat(expected).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
+ assertThat(expected).hasCauseThat().hasMessageThat().contains(badFuture.toString());
}
private Future<?> newFutureInstance() throws Exception {
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java
index 89d92c8c4..6bf4c99d1 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractFutureTest.java
@@ -20,6 +20,8 @@ import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_V
import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.Iterables;
@@ -97,13 +99,8 @@ public class AbstractFutureTest extends TestCase {
assertTrue(future.isDone());
assertFalse(future.wasInterrupted());
assertFalse(future.interruptTaskWasCalled);
- try {
- future.get();
- fail("Expected CancellationException");
- } catch (CancellationException e) {
- // See AbstractFutureCancellationCauseTest for how to set causes
- assertThat(e).hasCauseThat().isNull();
- }
+ CancellationException e = assertThrows(CancellationException.class, () -> future.get());
+ assertThat(e).hasCauseThat().isNull();
}
public void testCancel_notDoneInterrupt() throws Exception {
@@ -113,13 +110,8 @@ public class AbstractFutureTest extends TestCase {
assertTrue(future.isDone());
assertTrue(future.wasInterrupted());
assertTrue(future.interruptTaskWasCalled);
- try {
- future.get();
- fail("Expected CancellationException");
- } catch (CancellationException e) {
- // See AbstractFutureCancellationCauseTest for how to set causes
- assertThat(e).hasCauseThat().isNull();
- }
+ CancellationException e = assertThrows(CancellationException.class, () -> future.get());
+ assertThat(e).hasCauseThat().isNull();
}
public void testCancel_done() throws Exception {
@@ -156,12 +148,8 @@ public class AbstractFutureTest extends TestCase {
AbstractFuture<String> normalFuture = new AbstractFuture<String>() {};
normalFuture.setFuture(evilFuture);
assertTrue(normalFuture.isDone());
- try {
- normalFuture.get();
- fail();
- } catch (ExecutionException e) {
- assertThat(e).hasCauseThat().isSameInstanceAs(exception);
- }
+ ExecutionException e = assertThrows(ExecutionException.class, () -> normalFuture.get());
+ assertThat(e).hasCauseThat().isSameInstanceAs(exception);
}
public void testRemoveWaiter_interruption() throws Exception {
@@ -266,13 +254,10 @@ public class AbstractFutureTest extends TestCase {
assertThat(testFuture.toString())
.matches(
"[^\\[]+\\[status=PENDING, info=\\[cause=\\[Because this test isn't done\\]\\]\\]");
- try {
- testFuture.get(1, TimeUnit.NANOSECONDS);
- fail();
- } catch (TimeoutException e) {
- assertThat(e.getMessage()).contains("1 nanoseconds");
- assertThat(e.getMessage()).contains("Because this test isn't done");
- }
+ TimeoutException e =
+ assertThrows(TimeoutException.class, () -> testFuture.get(1, TimeUnit.NANOSECONDS));
+ assertThat(e.getMessage()).contains("1 nanoseconds");
+ assertThat(e.getMessage()).contains("Because this test isn't done");
}
public void testToString_completesDuringToString() throws Exception {
@@ -1072,6 +1057,25 @@ public class AbstractFutureTest extends TestCase {
t.join();
}
+ public void testCatchesUndeclaredThrowableFromListener() {
+ AbstractFuture<String> f = new AbstractFuture<String>() {};
+ f.set("foo");
+ f.addListener(() -> sneakyThrow(new SomeCheckedException()), directExecutor());
+ }
+
+ private static final class SomeCheckedException extends Exception {}
+
+ /** Throws an undeclared checked exception. */
+ private static void sneakyThrow(Throwable t) {
+ class SneakyThrower<T extends Throwable> {
+ @SuppressWarnings("unchecked") // intentionally unsafe for test
+ void throwIt(Throwable t) throws T {
+ throw (T) t;
+ }
+ }
+ new SneakyThrower<Error>().throwIt(t);
+ }
+
public void testTrustedGetFailure_Completed() {
SettableFuture<String> future = SettableFuture.create();
future.set("261");
@@ -1171,12 +1175,8 @@ public class AbstractFutureTest extends TestCase {
SettableFuture<String> normalFuture = SettableFuture.create();
normalFuture.setFuture(new FailFuture(exception));
assertTrue(normalFuture.isDone());
- try {
- normalFuture.get();
- fail();
- } catch (ExecutionException e) {
- assertSame(exception, e.getCause());
- }
+ ExecutionException e = assertThrows(ExecutionException.class, () -> normalFuture.get());
+ assertSame(exception, e.getCause());
}
private static void awaitUnchecked(final CyclicBarrier barrier) {
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractIdleServiceTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractIdleServiceTest.java
index 0444c31be..6d4b9c9d4 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractIdleServiceTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractIdleServiceTest.java
@@ -18,6 +18,7 @@ package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.Lists;
import java.util.List;
@@ -53,12 +54,9 @@ public class AbstractIdleServiceTest extends TestCase {
}
};
assertEquals(0, service.startUpCalled);
- try {
- service.startAsync().awaitRunning();
- fail();
- } catch (RuntimeException e) {
- assertThat(e).hasCauseThat().isSameInstanceAs(exception);
- }
+ RuntimeException e =
+ assertThrows(RuntimeException.class, () -> service.startAsync().awaitRunning());
+ assertThat(e).hasCauseThat().isSameInstanceAs(exception);
assertEquals(1, service.startUpCalled);
assertEquals(Service.State.FAILED, service.state());
assertThat(service.transitionStates).containsExactly(Service.State.STARTING);
@@ -100,12 +98,9 @@ public class AbstractIdleServiceTest extends TestCase {
service.startAsync().awaitRunning();
assertEquals(1, service.startUpCalled);
assertEquals(0, service.shutDownCalled);
- try {
- service.stopAsync().awaitTerminated();
- fail();
- } catch (RuntimeException e) {
- assertThat(e).hasCauseThat().isSameInstanceAs(exception);
- }
+ RuntimeException e =
+ assertThrows(RuntimeException.class, () -> service.stopAsync().awaitTerminated());
+ assertThat(e).hasCauseThat().isSameInstanceAs(exception);
assertEquals(1, service.startUpCalled);
assertEquals(1, service.shutDownCalled);
assertEquals(Service.State.FAILED, service.state());
@@ -140,14 +135,13 @@ public class AbstractIdleServiceTest extends TestCase {
return "Foo";
}
};
- try {
- service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
- fail("Expected timeout");
- } catch (TimeoutException e) {
- assertThat(e)
- .hasMessageThat()
- .isEqualTo("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
- }
+ TimeoutException e =
+ assertThrows(
+ TimeoutException.class,
+ () -> service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS));
+ assertThat(e)
+ .hasMessageThat()
+ .isEqualTo("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
}
private static class TestService extends AbstractIdleService {
@@ -206,12 +200,9 @@ public class AbstractIdleServiceTest extends TestCase {
throw exception;
}
};
- try {
- service.startAsync().awaitRunning();
- fail();
- } catch (RuntimeException e) {
- assertThat(e).hasCauseThat().isSameInstanceAs(exception);
- }
+ RuntimeException e =
+ assertThrows(RuntimeException.class, () -> service.startAsync().awaitRunning());
+ assertThat(e).hasCauseThat().isSameInstanceAs(exception);
assertEquals(Service.State.FAILED, service.state());
}
@@ -225,12 +216,9 @@ public class AbstractIdleServiceTest extends TestCase {
}
};
service.startAsync().awaitRunning();
- try {
- service.stopAsync().awaitTerminated();
- fail();
- } catch (RuntimeException e) {
- assertThat(e).hasCauseThat().isSameInstanceAs(exception);
- }
+ RuntimeException e =
+ assertThrows(RuntimeException.class, () -> service.stopAsync().awaitTerminated());
+ assertThat(e).hasCauseThat().isSameInstanceAs(exception);
assertEquals(Service.State.FAILED, service.state());
}
}
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
index f7266b274..b3c606986 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractScheduledServiceTest.java
@@ -22,6 +22,7 @@ import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.AbstractScheduledService.Cancellable;
import com.google.common.util.concurrent.AbstractScheduledService.Scheduler;
@@ -97,11 +98,7 @@ public class AbstractScheduledServiceTest extends TestCase {
service.startAsync().awaitRunning();
service.runFirstBarrier.await();
service.runSecondBarrier.await();
- try {
- future.get();
- fail();
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> future.get());
// An execution exception holds a runtime exception (from throwables.propagate) that holds our
// original exception.
assertEquals(service.runException, service.failureCause());
@@ -111,12 +108,9 @@ public class AbstractScheduledServiceTest extends TestCase {
public void testFailOnExceptionFromStartUp() {
TestService service = new TestService();
service.startUpException = new Exception();
- try {
- service.startAsync().awaitRunning();
- fail();
- } catch (IllegalStateException e) {
- assertThat(e).hasCauseThat().isEqualTo(service.startUpException);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.startAsync().awaitRunning());
+ assertThat(e).hasCauseThat().isEqualTo(service.startUpException);
assertEquals(0, service.numberOfTimesRunCalled.get());
assertEquals(Service.State.FAILED, service.state());
}
@@ -154,12 +148,9 @@ public class AbstractScheduledServiceTest extends TestCase {
service.runFirstBarrier.await();
service.stopAsync();
service.runSecondBarrier.await();
- try {
- service.awaitTerminated();
- fail();
- } catch (IllegalStateException e) {
- assertThat(e).hasCauseThat().isEqualTo(service.shutDownException);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.awaitTerminated());
+ assertThat(e).hasCauseThat().isEqualTo(service.shutDownException);
assertEquals(Service.State.FAILED, service.state());
}
@@ -246,11 +237,7 @@ public class AbstractScheduledServiceTest extends TestCase {
}
};
- try {
- service.startAsync().awaitRunning();
- fail("Expected service to fail during startup");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.startAsync().awaitRunning());
assertTrue(executor.get().awaitTermination(100, MILLISECONDS));
}
@@ -295,14 +282,12 @@ public class AbstractScheduledServiceTest extends TestCase {
return "Foo";
}
};
- try {
- service.startAsync().awaitRunning(1, MILLISECONDS);
- fail("Expected timeout");
- } catch (TimeoutException e) {
- assertThat(e)
- .hasMessageThat()
- .isEqualTo("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
- }
+ TimeoutException e =
+ assertThrows(
+ TimeoutException.class, () -> service.startAsync().awaitRunning(1, MILLISECONDS));
+ assertThat(e)
+ .hasMessageThat()
+ .isEqualTo("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
}
private class TestService extends AbstractScheduledService {
@@ -453,11 +438,7 @@ public class AbstractScheduledServiceTest extends TestCase {
}
};
service.startAsync().awaitRunning();
- try {
- service.firstBarrier.await(5, SECONDS);
- fail();
- } catch (TimeoutException expected) {
- }
+ assertThrows(TimeoutException.class, () -> service.firstBarrier.await(5, SECONDS));
assertEquals(0, service.numIterations.get());
service.stopAsync();
service.awaitTerminated();
@@ -478,11 +459,7 @@ public class AbstractScheduledServiceTest extends TestCase {
}
};
service.startAsync().awaitRunning();
- try {
- service.firstBarrier.await(5, SECONDS);
- fail();
- } catch (TimeoutException expected) {
- }
+ assertThrows(TimeoutException.class, () -> service.firstBarrier.await(5, SECONDS));
assertEquals(0, service.numIterations.get());
service.stopAsync();
service.awaitTerminated();
@@ -639,12 +616,10 @@ public class AbstractScheduledServiceTest extends TestCase {
service.secondBarrier.await();
}
Thread.sleep(1000);
- try {
- service.stopAsync().awaitTerminated(100, SECONDS);
- fail();
- } catch (IllegalStateException e) {
- assertEquals(State.FAILED, service.state());
- }
+ IllegalStateException e =
+ assertThrows(
+ IllegalStateException.class, () -> service.stopAsync().awaitTerminated(100, SECONDS));
+ assertEquals(State.FAILED, service.state());
}
private static class TestFailingCustomScheduledService extends AbstractScheduledService {
diff --git a/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java b/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java
index 5f4210621..e4d310331 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AbstractServiceTest.java
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -449,12 +450,9 @@ public class AbstractServiceTest extends TestCase {
service.notifyFailed(new Exception("1"));
service.notifyFailed(new Exception("2"));
assertThat(service.failureCause()).hasMessageThat().isEqualTo("1");
- try {
- service.awaitRunning();
- fail();
- } catch (IllegalStateException e) {
- assertThat(e).hasCauseThat().hasMessageThat().isEqualTo("1");
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.awaitRunning());
+ assertThat(e).hasCauseThat().hasMessageThat().isEqualTo("1");
}
private class ThreadedService extends AbstractService {
@@ -531,11 +529,7 @@ public class AbstractServiceTest extends TestCase {
service.stopAsync();
assertEquals(State.TERMINATED, service.state());
- try {
- service.startAsync();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.startAsync());
assertEquals(State.TERMINATED, Iterables.getOnlyElement(listener.getStateHistory()));
}
@@ -543,13 +537,10 @@ public class AbstractServiceTest extends TestCase {
StartFailingService service = new StartFailingService();
RecordingListener listener = RecordingListener.record(service);
- try {
- service.startAsync().awaitRunning();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(EXCEPTION, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.startAsync().awaitRunning());
+ assertEquals(EXCEPTION, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
assertEquals(ImmutableList.of(State.STARTING, State.FAILED), listener.getStateHistory());
}
@@ -558,13 +549,10 @@ public class AbstractServiceTest extends TestCase {
RecordingListener listener = RecordingListener.record(service);
service.startAsync().awaitRunning();
- try {
- service.stopAsync().awaitTerminated();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(EXCEPTION, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.stopAsync().awaitTerminated());
+ assertEquals(EXCEPTION, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
assertEquals(
ImmutableList.of(State.STARTING, State.RUNNING, State.STOPPING, State.FAILED),
listener.getStateHistory());
@@ -575,13 +563,10 @@ public class AbstractServiceTest extends TestCase {
RecordingListener listener = RecordingListener.record(service);
service.startAsync();
- try {
- service.awaitRunning();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(EXCEPTION, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.awaitRunning());
+ assertEquals(EXCEPTION, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
assertEquals(
ImmutableList.of(State.STARTING, State.RUNNING, State.FAILED), listener.getStateHistory());
}
@@ -590,13 +575,10 @@ public class AbstractServiceTest extends TestCase {
StartThrowingService service = new StartThrowingService();
RecordingListener listener = RecordingListener.record(service);
- try {
- service.startAsync().awaitRunning();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(service.exception, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(service.exception);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.startAsync().awaitRunning());
+ assertEquals(service.exception, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(service.exception);
assertEquals(ImmutableList.of(State.STARTING, State.FAILED), listener.getStateHistory());
}
@@ -605,13 +587,10 @@ public class AbstractServiceTest extends TestCase {
RecordingListener listener = RecordingListener.record(service);
service.startAsync().awaitRunning();
- try {
- service.stopAsync().awaitTerminated();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(service.exception, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(service.exception);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.stopAsync().awaitTerminated());
+ assertEquals(service.exception, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(service.exception);
assertEquals(
ImmutableList.of(State.STARTING, State.RUNNING, State.STOPPING, State.FAILED),
listener.getStateHistory());
@@ -622,37 +601,23 @@ public class AbstractServiceTest extends TestCase {
RecordingListener listener = RecordingListener.record(service);
service.startAsync();
- try {
- service.awaitTerminated();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(service.exception, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(service.exception);
- }
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.awaitTerminated());
+ assertEquals(service.exception, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(service.exception);
assertEquals(
ImmutableList.of(State.STARTING, State.RUNNING, State.FAILED), listener.getStateHistory());
}
public void testFailureCause_throwsIfNotFailed() {
StopFailingService service = new StopFailingService();
- try {
- service.failureCause();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.failureCause());
service.startAsync().awaitRunning();
- try {
- service.failureCause();
- fail();
- } catch (IllegalStateException expected) {
- }
- try {
- service.stopAsync().awaitTerminated();
- fail();
- } catch (IllegalStateException e) {
- assertEquals(EXCEPTION, service.failureCause());
- assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
- }
+ assertThrows(IllegalStateException.class, () -> service.failureCause());
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> service.stopAsync().awaitTerminated());
+ assertEquals(EXCEPTION, service.failureCause());
+ assertThat(e).hasCauseThat().isEqualTo(EXCEPTION);
}
public void testAddListenerAfterFailureDoesntCauseDeadlock() throws InterruptedException {
@@ -912,40 +877,24 @@ public class AbstractServiceTest extends TestCase {
public void testNotifyStartedWhenNotStarting() {
AbstractService service = new DefaultService();
- try {
- service.notifyStarted();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.notifyStarted());
}
public void testNotifyStoppedWhenNotRunning() {
AbstractService service = new DefaultService();
- try {
- service.notifyStopped();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.notifyStopped());
}
public void testNotifyFailedWhenNotStarted() {
AbstractService service = new DefaultService();
- try {
- service.notifyFailed(new Exception());
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.notifyFailed(new Exception()));
}
public void testNotifyFailedWhenTerminated() {
NoOpService service = new NoOpService();
service.startAsync().awaitRunning();
service.stopAsync().awaitTerminated();
- try {
- service.notifyFailed(new Exception());
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> service.notifyFailed(new Exception()));
}
private static class DefaultService extends AbstractService {
diff --git a/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java b/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java
index de7d58a9c..ef752cd1d 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java
@@ -14,6 +14,7 @@
package com.google.common.util.concurrent;
import static java.lang.Math.max;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.testing.NullPointerTester;
@@ -70,11 +71,7 @@ public class AtomicDoubleArrayTest extends JSR166TestCase {
/** constructor with null array throws NPE */
public void testConstructor2NPE() {
double[] a = null;
- try {
- new AtomicDoubleArray(a);
- fail();
- } catch (NullPointerException success) {
- }
+ assertThrows(NullPointerException.class, () -> new AtomicDoubleArray(a));
}
/** constructor with array is of same size and has all elements */
@@ -90,63 +87,27 @@ public class AtomicDoubleArrayTest extends JSR166TestCase {
public void testConstructorEmptyArray() {
AtomicDoubleArray aa = new AtomicDoubleArray(new double[0]);
assertEquals(0, aa.length());
- try {
- aa.get(0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.get(0));
}
/** constructor with length zero has size 0 and contains no elements */
public void testConstructorZeroLength() {
AtomicDoubleArray aa = new AtomicDoubleArray(0);
assertEquals(0, aa.length());
- try {
- aa.get(0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.get(0));
}
/** get and set for out of bound indices throw IndexOutOfBoundsException */
public void testIndexing() {
AtomicDoubleArray aa = new AtomicDoubleArray(SIZE);
for (int index : new int[] {-1, SIZE}) {
- try {
- aa.get(index);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
- try {
- aa.set(index, 1.0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
- try {
- aa.lazySet(index, 1.0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
- try {
- aa.compareAndSet(index, 1.0, 2.0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
- try {
- aa.weakCompareAndSet(index, 1.0, 2.0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
- try {
- aa.getAndAdd(index, 1.0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
- try {
- aa.addAndGet(index, 1.0);
- fail();
- } catch (IndexOutOfBoundsException success) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.get(index));
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.set(index, 1.0));
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.lazySet(index, 1.0));
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.compareAndSet(index, 1.0, 2.0));
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.weakCompareAndSet(index, 1.0, 2.0));
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.getAndAdd(index, 1.0));
+ assertThrows(IndexOutOfBoundsException.class, () -> aa.addAndGet(index, 1.0));
}
}
diff --git a/guava-tests/test/com/google/common/util/concurrent/AtomicsTest.java b/guava-tests/test/com/google/common/util/concurrent/AtomicsTest.java
index b903e6ce8..90f0f6f76 100644
--- a/guava-tests/test/com/google/common/util/concurrent/AtomicsTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/AtomicsTest.java
@@ -16,6 +16,8 @@
package com.google.common.util.concurrent;
+import static org.junit.Assert.assertThrows;
+
import com.google.common.testing.NullPointerTester;
import java.util.concurrent.atomic.AtomicReferenceArray;
import junit.framework.TestCase;
@@ -44,19 +46,11 @@ public class AtomicsTest extends TestCase {
for (int i = 0; i < length; ++i) {
assertEquals(null, refArray.get(i));
}
- try {
- refArray.get(length);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> refArray.get(length));
}
public void testNewReferenceArray_withNegativeLength() throws Exception {
- try {
- Atomics.newReferenceArray(-1);
- fail();
- } catch (NegativeArraySizeException expected) {
- }
+ assertThrows(NegativeArraySizeException.class, () -> Atomics.newReferenceArray(-1));
}
public void testNewReferenceArray_withStringArray() throws Exception {
@@ -65,19 +59,11 @@ public class AtomicsTest extends TestCase {
for (int i = 0; i < array.length; ++i) {
assertEquals(array[i], refArray.get(i));
}
- try {
- refArray.get(array.length);
- fail();
- } catch (IndexOutOfBoundsException expected) {
- }
+ assertThrows(IndexOutOfBoundsException.class, () -> refArray.get(array.length));
}
public void testNewReferenceArray_withNullArray() throws Exception {
- try {
- Atomics.newReferenceArray(null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> Atomics.newReferenceArray(null));
}
public void testNullPointers() {
diff --git a/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToFutureTest.java
index 79288eb2a..29ce341e1 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToFutureTest.java
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.Futures.immediateFuture;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.ClosingFuture.ClosingCallable;
import com.google.common.util.concurrent.ClosingFuture.DeferredCloser;
@@ -39,11 +40,11 @@ public class ClosingFutureFinishToFutureTest extends AbstractClosingFutureTest {
},
executor);
FluentFuture<Closeable> unused = closingFuture.finishToFuture();
- try {
- FluentFuture<Closeable> unused2 = closingFuture.finishToFuture();
- fail("should have thrown");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> {
+ FluentFuture<Closeable> unused2 = closingFuture.finishToFuture();
+ });
}
public void testFinishToFuture_throwsAfterCallingFinishToValueAndCloser() throws Exception {
@@ -57,11 +58,11 @@ public class ClosingFutureFinishToFutureTest extends AbstractClosingFutureTest {
},
executor);
closingFuture.finishToValueAndCloser(new NoOpValueAndCloserConsumer<>(), directExecutor());
- try {
- FluentFuture<Closeable> unused = closingFuture.finishToFuture();
- fail("should have thrown");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () -> {
+ FluentFuture<Closeable> unused = closingFuture.finishToFuture();
+ });
}
public void testFinishToFuture_preventsFurtherDerivation() {
diff --git a/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToValueAndCloserTest.java b/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToValueAndCloserTest.java
index ac3cf5569..c249eca34 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToValueAndCloserTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ClosingFutureFinishToValueAndCloserTest.java
@@ -22,6 +22,7 @@ import static com.google.common.util.concurrent.MoreExecutors.shutdownAndAwaitTe
import static com.google.common.util.concurrent.Uninterruptibles.awaitUninterruptibly;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.ClosingFuture.ClosingCallable;
import com.google.common.util.concurrent.ClosingFuture.DeferredCloser;
@@ -61,12 +62,11 @@ public class ClosingFutureFinishToValueAndCloserTest extends AbstractClosingFutu
executor);
closingFuture.finishToValueAndCloser(
new NoOpValueAndCloserConsumer<>(), finishToValueAndCloserExecutor);
- try {
- closingFuture.finishToValueAndCloser(
- new NoOpValueAndCloserConsumer<>(), finishToValueAndCloserExecutor);
- fail("should have thrown");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () ->
+ closingFuture.finishToValueAndCloser(
+ new NoOpValueAndCloserConsumer<>(), finishToValueAndCloserExecutor));
}
public void testFinishToValueAndCloser_throwsAfterCallingFinishToFuture() throws Exception {
@@ -80,12 +80,11 @@ public class ClosingFutureFinishToValueAndCloserTest extends AbstractClosingFutu
},
executor);
FluentFuture<Closeable> unused = closingFuture.finishToFuture();
- try {
- closingFuture.finishToValueAndCloser(
- new NoOpValueAndCloserConsumer<>(), finishToValueAndCloserExecutor);
- fail("should have thrown");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(
+ IllegalStateException.class,
+ () ->
+ closingFuture.finishToValueAndCloser(
+ new NoOpValueAndCloserConsumer<>(), finishToValueAndCloserExecutor));
}
@Override
diff --git a/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java b/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java
index bf388b0ba..3e88ecb11 100644
--- a/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/CycleDetectingLockFactoryTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Joiner;
import com.google.common.util.concurrent.CycleDetectingLockFactory.Policies;
@@ -102,24 +103,15 @@ public class CycleDetectingLockFactoryTest extends TestCase {
// The opposite order should fail (Policies.THROW).
PotentialDeadlockException firstException = null;
lockB.lock();
- try {
- lockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockB -> LockA", "LockA -> LockB");
- firstException = expected;
- }
-
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> lockA.lock());
+ checkMessage(expected, "LockB -> LockA", "LockA -> LockB");
+ firstException = expected;
// Second time should also fail, with a cached causal chain.
- try {
- lockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockB -> LockA", "LockA -> LockB");
- // The causal chain should be cached.
- assertSame(firstException.getCause(), expected.getCause());
- }
-
+ expected = assertThrows(PotentialDeadlockException.class, () -> lockA.lock());
+ checkMessage(expected, "LockB -> LockA", "LockA -> LockB");
+ // The causal chain should be cached.
+ assertSame(firstException.getCause(), expected.getCause());
// lockA should work after lockB is released.
lockB.unlock();
lockA.lock();
@@ -139,12 +131,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
lockB.unlock();
// lockC -> lockA should fail.
- try {
- lockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockC -> LockA", "LockB -> LockC", "LockA -> LockB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> lockA.lock());
+ checkMessage(expected, "LockC -> LockA", "LockB -> LockC", "LockA -> LockB");
}
public void testReentrancy_noDeadlock() {
@@ -163,29 +152,18 @@ public class CycleDetectingLockFactoryTest extends TestCase {
public void testExplicitOrdering_violations() {
lock3.lock();
- try {
- lock2.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "MyOrder.THIRD -> MyOrder.SECOND");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> lock2.lock());
+ checkMessage(expected, "MyOrder.THIRD -> MyOrder.SECOND");
- try {
- lock1.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "MyOrder.THIRD -> MyOrder.FIRST");
- }
+ expected = assertThrows(PotentialDeadlockException.class, () -> lock1.lock());
+ checkMessage(expected, "MyOrder.THIRD -> MyOrder.FIRST");
lock3.unlock();
lock2.lock();
- try {
- lock1.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "MyOrder.SECOND -> MyOrder.FIRST");
- }
+ expected = assertThrows(PotentialDeadlockException.class, () -> lock1.lock());
+ checkMessage(expected, "MyOrder.SECOND -> MyOrder.FIRST");
}
public void testDifferentOrderings_noViolations() {
@@ -198,26 +176,18 @@ public class CycleDetectingLockFactoryTest extends TestCase {
lock01.lock(); // OtherOrder, ordinal() == 1
lock3.unlock();
- try {
- lock3.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(
- expected, "OtherOrder.FIRST -> MyOrder.THIRD", "MyOrder.THIRD -> OtherOrder.FIRST");
- }
-
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> lock3.lock());
+ checkMessage(
+ expected, "OtherOrder.FIRST -> MyOrder.THIRD", "MyOrder.THIRD -> OtherOrder.FIRST");
lockA.lock();
lock01.unlock();
lockB.lock();
lockA.unlock();
- try {
- lock01.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(
- expected, "LockB -> OtherOrder.FIRST", "LockA -> LockB", "OtherOrder.FIRST -> LockA");
- }
+ expected = assertThrows(PotentialDeadlockException.class, () -> lock01.lock());
+ checkMessage(
+ expected, "LockB -> OtherOrder.FIRST", "LockA -> LockB", "OtherOrder.FIRST -> LockA");
}
public void testExplicitOrdering_cycleWithUnorderedLock() {
@@ -226,16 +196,13 @@ public class CycleDetectingLockFactoryTest extends TestCase {
myLock.lock();
lock03.unlock();
- try {
- lock01.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(
- expected,
- "MyLock -> OtherOrder.FIRST",
- "OtherOrder.THIRD -> MyLock",
- "OtherOrder.FIRST -> OtherOrder.THIRD");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> lock01.lock());
+ checkMessage(
+ expected,
+ "MyLock -> OtherOrder.FIRST",
+ "OtherOrder.THIRD -> MyLock",
+ "OtherOrder.FIRST -> OtherOrder.THIRD");
}
public void testExplicitOrdering_reentrantAcquisition() {
@@ -261,11 +228,7 @@ public class CycleDetectingLockFactoryTest extends TestCase {
Lock lockB = factory.newReentrantReadWriteLock(OtherOrder.FIRST).readLock();
lockA.lock();
- try {
- lockB.lock();
- fail("Expected IllegalStateException");
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> lockB.lock());
lockA.unlock();
lockB.lock();
@@ -278,12 +241,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
readLockA.unlock();
lockB.lock();
- try {
- readLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockB -> ReadWriteA", "ReadWriteA -> LockB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> readLockA.lock());
+ checkMessage(expected, "LockB -> ReadWriteA", "ReadWriteA -> LockB");
}
public void testReadLock_transitive() {
@@ -300,13 +260,10 @@ public class CycleDetectingLockFactoryTest extends TestCase {
// readLockC -> readLockA
readLockC.lock();
- try {
- readLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(
- expected, "ReadWriteC -> ReadWriteA", "LockB -> ReadWriteC", "ReadWriteA -> LockB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> readLockA.lock());
+ checkMessage(
+ expected, "ReadWriteC -> ReadWriteA", "LockB -> ReadWriteC", "ReadWriteA -> LockB");
}
public void testWriteLock_threeLockDeadLock() {
@@ -322,16 +279,13 @@ public class CycleDetectingLockFactoryTest extends TestCase {
writeLockB.unlock();
// writeLockC -> writeLockA should fail.
- try {
- writeLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(
- expected,
- "ReadWriteC -> ReadWriteA",
- "ReadWriteB -> ReadWriteC",
- "ReadWriteA -> ReadWriteB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> writeLockA.lock());
+ checkMessage(
+ expected,
+ "ReadWriteC -> ReadWriteA",
+ "ReadWriteB -> ReadWriteC",
+ "ReadWriteA -> ReadWriteB");
}
public void testWriteToReadLockDowngrading() {
@@ -343,12 +297,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
readLockA.unlock();
// lockB -> writeLockA should fail
- try {
- writeLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockB -> ReadWriteA", "ReadWriteA -> LockB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> writeLockA.lock());
+ checkMessage(expected, "LockB -> ReadWriteA", "ReadWriteA -> LockB");
}
public void testReadWriteLockDeadlock() {
@@ -359,12 +310,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
// lockB -> readLockA should fail.
lockB.lock();
- try {
- readLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockB -> ReadWriteA", "ReadWriteA -> LockB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> readLockA.lock());
+ checkMessage(expected, "LockB -> ReadWriteA", "ReadWriteA -> LockB");
}
public void testReadWriteLockDeadlock_transitive() {
@@ -381,12 +329,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
// lockC -> writeLockA should fail.
lockC.lock();
- try {
- writeLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockC -> ReadWriteA", "LockB -> LockC", "ReadWriteA -> LockB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> writeLockA.lock());
+ checkMessage(expected, "LockC -> ReadWriteA", "LockB -> LockC", "ReadWriteA -> LockB");
}
public void testReadWriteLockDeadlock_treatedEquivalently() {
@@ -397,12 +342,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
// readLockB -> writeLockA should fail.
readLockB.lock();
- try {
- writeLockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "ReadWriteB -> ReadWriteA", "ReadWriteA -> ReadWriteB");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> writeLockA.lock());
+ checkMessage(expected, "ReadWriteB -> ReadWriteA", "ReadWriteA -> ReadWriteB");
}
public void testDifferentLockFactories() {
@@ -417,12 +359,9 @@ public class CycleDetectingLockFactoryTest extends TestCase {
// lockD -> lockA should fail even though lockD is from a different factory.
lockD.lock();
- try {
- lockA.lock();
- fail("Expected PotentialDeadlockException");
- } catch (PotentialDeadlockException expected) {
- checkMessage(expected, "LockD -> LockA", "LockA -> LockD");
- }
+ PotentialDeadlockException expected =
+ assertThrows(PotentialDeadlockException.class, () -> lockA.lock());
+ checkMessage(expected, "LockD -> LockA", "LockA -> LockD");
}
public void testDifferentLockFactories_policyExecution() {
diff --git a/guava-tests/test/com/google/common/util/concurrent/FakeTimeLimiterTest.java b/guava-tests/test/com/google/common/util/concurrent/FakeTimeLimiterTest.java
index a0e063469..4eb72e3b7 100644
--- a/guava-tests/test/com/google/common/util/concurrent/FakeTimeLimiterTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/FakeTimeLimiterTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -51,22 +52,24 @@ public class FakeTimeLimiterTest extends TestCase {
public void testCallWithTimeout_wrapsCheckedException() throws Exception {
Exception exception = new SampleCheckedException();
- try {
- timeLimiter.callWithTimeout(callableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS);
- fail("Expected ExecutionException");
- } catch (ExecutionException e) {
- assertThat(e.getCause()).isEqualTo(exception);
- }
+ ExecutionException e =
+ assertThrows(
+ ExecutionException.class,
+ () ->
+ timeLimiter.callWithTimeout(
+ callableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS));
+ assertThat(e.getCause()).isEqualTo(exception);
}
public void testCallWithTimeout_wrapsUncheckedException() throws Exception {
Exception exception = new RuntimeException("test");
- try {
- timeLimiter.callWithTimeout(callableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS);
- fail("Expected UncheckedExecutionException");
- } catch (UncheckedExecutionException e) {
- assertThat(e.getCause()).isEqualTo(exception);
- }
+ UncheckedExecutionException e =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () ->
+ timeLimiter.callWithTimeout(
+ callableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS));
+ assertThat(e.getCause()).isEqualTo(exception);
}
public void testCallUninterruptiblyWithTimeout_propagatesReturnValue() throws Exception {
@@ -83,23 +86,24 @@ public class FakeTimeLimiterTest extends TestCase {
public void testRunWithTimeout_wrapsUncheckedException() throws Exception {
RuntimeException exception = new RuntimeException("test");
- try {
- timeLimiter.runWithTimeout(runnableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS);
- fail("Expected UncheckedExecutionException");
- } catch (UncheckedExecutionException e) {
- assertThat(e.getCause()).isEqualTo(exception);
- }
+ UncheckedExecutionException e =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () ->
+ timeLimiter.runWithTimeout(
+ runnableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS));
+ assertThat(e.getCause()).isEqualTo(exception);
}
public void testRunUninterruptiblyWithTimeout_wrapsUncheckedException() throws Exception {
RuntimeException exception = new RuntimeException("test");
- try {
- timeLimiter.runUninterruptiblyWithTimeout(
- runnableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS);
- fail("Expected UncheckedExecutionException");
- } catch (UncheckedExecutionException e) {
- assertThat(e.getCause()).isEqualTo(exception);
- }
+ UncheckedExecutionException e =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () ->
+ timeLimiter.runUninterruptiblyWithTimeout(
+ runnableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS));
+ assertThat(e.getCause()).isEqualTo(exception);
}
public static <T> Callable<T> callableThrowing(final Exception exception) {
diff --git a/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
index ab53f5383..48d5c8e5a 100644
--- a/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/FluentFutureTest.java
@@ -23,6 +23,7 @@ import static com.google.common.util.concurrent.Futures.immediateFuture;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static java.util.concurrent.Executors.newScheduledThreadPool;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -138,12 +139,8 @@ public class FluentFutureTest extends TestCase {
try {
FluentFuture<?> f =
FluentFuture.from(SettableFuture.create()).withTimeout(0, SECONDS, executor);
- try {
- f.get();
- fail();
- } catch (ExecutionException e) {
- assertThat(e).hasCauseThat().isInstanceOf(TimeoutException.class);
- }
+ ExecutionException e = assertThrows(ExecutionException.class, () -> f.get());
+ assertThat(e).hasCauseThat().isInstanceOf(TimeoutException.class);
} finally {
executor.shutdown();
}
diff --git a/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedInputs.java b/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedInputs.java
index 27916d8a1..0ae248837 100644
--- a/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedInputs.java
+++ b/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedInputs.java
@@ -18,6 +18,7 @@ import static com.google.common.util.concurrent.Futures.immediateFailedFuture;
import com.google.common.annotations.GwtCompatible;
import java.util.concurrent.Future;
+import javax.annotation.CheckForNull;
/**
* Classes and futures used in {@link FuturesGetCheckedTest} and {@link FuturesGetUncheckedTest}.
@@ -58,6 +59,47 @@ final class FuturesGetCheckedInputs {
}
}
+ public static final class ExceptionWithManyConstructorsButOnlyOneThrowable extends Exception {
+ @CheckForNull private Throwable antecedent;
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(String message, String a1) {
+ super(message);
+ }
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(String message, String a1, String a2) {
+ super(message);
+ }
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(
+ String message, String a1, String a2, String a3) {
+ super(message);
+ }
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(String message, Throwable antecedent) {
+ super(message);
+ this.antecedent = antecedent;
+ }
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(
+ String message, String a1, String a2, String a3, String a4) {
+ super(message);
+ }
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(
+ String message, String a1, String a2, String a3, String a4, String a5) {
+ super(message);
+ }
+
+ public ExceptionWithManyConstructorsButOnlyOneThrowable(
+ String message, String a1, String a2, String a3, String a4, String a5, String a6) {
+ super(message);
+ }
+
+ public Throwable getAntecedent() {
+ return antecedent;
+ }
+ }
+
@SuppressWarnings("unused") // we're testing that they're not used
public static final class ExceptionWithSomePrivateConstructors extends Exception {
private ExceptionWithSomePrivateConstructors(String a) {}
diff --git a/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java b/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java
index 666a18929..fa615133a 100644
--- a/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/FuturesGetCheckedTest.java
@@ -30,11 +30,13 @@ import static com.google.common.util.concurrent.FuturesGetCheckedInputs.RUNTIME_
import static com.google.common.util.concurrent.FuturesGetCheckedInputs.RUNTIME_EXCEPTION_FUTURE;
import static com.google.common.util.concurrent.FuturesGetCheckedInputs.UNCHECKED_EXCEPTION;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.testing.GcFinalization;
import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithBadConstructor;
import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithGoodAndBadConstructor;
import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithManyConstructors;
+import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithManyConstructorsButOnlyOneThrowable;
import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithPrivateConstructor;
import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithSomePrivateConstructors;
import com.google.common.util.concurrent.FuturesGetCheckedInputs.ExceptionWithWrongTypesConstructor;
@@ -74,57 +76,49 @@ public class FuturesGetCheckedTest extends TestCase {
public void testGetCheckedUntimed_cancelled() throws TwoArgConstructorException {
SettableFuture<String> future = SettableFuture.create();
future.cancel(true);
- try {
- getChecked(future, TwoArgConstructorException.class);
- fail();
- } catch (CancellationException expected) {
- }
+ assertThrows(
+ CancellationException.class, () -> getChecked(future, TwoArgConstructorException.class));
}
public void testGetCheckedUntimed_ExecutionExceptionChecked() {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, TwoArgConstructorException.class);
- fail();
- } catch (TwoArgConstructorException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(CHECKED_EXCEPTION);
- }
+ TwoArgConstructorException expected =
+ assertThrows(
+ TwoArgConstructorException.class,
+ () -> getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, TwoArgConstructorException.class));
+ assertThat(expected).hasCauseThat().isEqualTo(CHECKED_EXCEPTION);
}
public void testGetCheckedUntimed_ExecutionExceptionUnchecked()
throws TwoArgConstructorException {
- try {
- getChecked(FAILED_FUTURE_UNCHECKED_EXCEPTION, TwoArgConstructorException.class);
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(UNCHECKED_EXCEPTION);
- }
+ UncheckedExecutionException expected =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () -> getChecked(FAILED_FUTURE_UNCHECKED_EXCEPTION, TwoArgConstructorException.class));
+ assertThat(expected).hasCauseThat().isEqualTo(UNCHECKED_EXCEPTION);
}
public void testGetCheckedUntimed_ExecutionExceptionError() throws TwoArgConstructorException {
- try {
- getChecked(FAILED_FUTURE_ERROR, TwoArgConstructorException.class);
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isEqualTo(ERROR);
- }
+ ExecutionError expected =
+ assertThrows(
+ ExecutionError.class,
+ () -> getChecked(FAILED_FUTURE_ERROR, TwoArgConstructorException.class));
+ assertThat(expected).hasCauseThat().isEqualTo(ERROR);
}
public void testGetCheckedUntimed_ExecutionExceptionOtherThrowable() {
- try {
- getChecked(FAILED_FUTURE_OTHER_THROWABLE, TwoArgConstructorException.class);
- fail();
- } catch (TwoArgConstructorException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(OTHER_THROWABLE);
- }
+ TwoArgConstructorException expected =
+ assertThrows(
+ TwoArgConstructorException.class,
+ () -> getChecked(FAILED_FUTURE_OTHER_THROWABLE, TwoArgConstructorException.class));
+ assertThat(expected).hasCauseThat().isEqualTo(OTHER_THROWABLE);
}
public void testGetCheckedUntimed_RuntimeException() throws TwoArgConstructorException {
- try {
- getChecked(RUNTIME_EXCEPTION_FUTURE, TwoArgConstructorException.class);
- fail();
- } catch (RuntimeException expected) {
- assertEquals(RUNTIME_EXCEPTION, expected);
- }
+ RuntimeException expected =
+ assertThrows(
+ RuntimeException.class,
+ () -> getChecked(RUNTIME_EXCEPTION_FUTURE, TwoArgConstructorException.class));
+ assertEquals(RUNTIME_EXCEPTION, expected);
}
public void testGetCheckedUntimed_Error() throws TwoArgConstructorException {
@@ -139,29 +133,26 @@ public class FuturesGetCheckedTest extends TestCase {
public void testGetCheckedUntimed_badExceptionConstructor_failsEvenForSuccessfulInput()
throws Exception {
- try {
- getChecked(immediateFuture("x"), ExceptionWithBadConstructor.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> getChecked(immediateFuture("x"), ExceptionWithBadConstructor.class));
}
public void testGetCheckedUntimed_badExceptionConstructor_wrapsOriginalChecked()
throws Exception {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithBadConstructor.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithBadConstructor.class));
}
public void testGetCheckedUntimed_withGoodAndBadExceptionConstructor() throws Exception {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithGoodAndBadConstructor.class);
- fail();
- } catch (ExceptionWithGoodAndBadConstructor expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(CHECKED_EXCEPTION);
- }
+ ExceptionWithGoodAndBadConstructor expected =
+ assertThrows(
+ ExceptionWithGoodAndBadConstructor.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithGoodAndBadConstructor.class));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(CHECKED_EXCEPTION);
}
// Boring timed-get tests:
@@ -188,56 +179,59 @@ public class FuturesGetCheckedTest extends TestCase {
public void testGetCheckedTimed_cancelled() throws TwoArgConstructorException {
SettableFuture<String> future = SettableFuture.create();
future.cancel(true);
- try {
- getChecked(future, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (CancellationException expected) {
- }
+ assertThrows(
+ CancellationException.class,
+ () -> getChecked(future, TwoArgConstructorException.class, 0, SECONDS));
}
public void testGetCheckedTimed_ExecutionExceptionChecked() {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (TwoArgConstructorException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(CHECKED_EXCEPTION);
- }
+ TwoArgConstructorException expected =
+ assertThrows(
+ TwoArgConstructorException.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION, TwoArgConstructorException.class, 0, SECONDS));
+ assertThat(expected).hasCauseThat().isEqualTo(CHECKED_EXCEPTION);
}
public void testGetCheckedTimed_ExecutionExceptionUnchecked() throws TwoArgConstructorException {
- try {
- getChecked(FAILED_FUTURE_UNCHECKED_EXCEPTION, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (UncheckedExecutionException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(UNCHECKED_EXCEPTION);
- }
+ UncheckedExecutionException expected =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_UNCHECKED_EXCEPTION,
+ TwoArgConstructorException.class,
+ 0,
+ SECONDS));
+ assertThat(expected).hasCauseThat().isEqualTo(UNCHECKED_EXCEPTION);
}
public void testGetCheckedTimed_ExecutionExceptionError() throws TwoArgConstructorException {
- try {
- getChecked(FAILED_FUTURE_ERROR, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (ExecutionError expected) {
- assertThat(expected).hasCauseThat().isEqualTo(ERROR);
- }
+ ExecutionError expected =
+ assertThrows(
+ ExecutionError.class,
+ () -> getChecked(FAILED_FUTURE_ERROR, TwoArgConstructorException.class, 0, SECONDS));
+ assertThat(expected).hasCauseThat().isEqualTo(ERROR);
}
public void testGetCheckedTimed_ExecutionExceptionOtherThrowable() {
- try {
- getChecked(FAILED_FUTURE_OTHER_THROWABLE, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (TwoArgConstructorException expected) {
- assertThat(expected).hasCauseThat().isEqualTo(OTHER_THROWABLE);
- }
+ TwoArgConstructorException expected =
+ assertThrows(
+ TwoArgConstructorException.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_OTHER_THROWABLE, TwoArgConstructorException.class, 0, SECONDS));
+ assertThat(expected).hasCauseThat().isEqualTo(OTHER_THROWABLE);
}
public void testGetCheckedTimed_RuntimeException() throws TwoArgConstructorException {
- try {
- getChecked(RUNTIME_EXCEPTION_FUTURE, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (RuntimeException expected) {
- assertEquals(RUNTIME_EXCEPTION, expected);
- }
+ RuntimeException expected =
+ assertThrows(
+ RuntimeException.class,
+ () ->
+ getChecked(RUNTIME_EXCEPTION_FUTURE, TwoArgConstructorException.class, 0, SECONDS));
+ assertEquals(RUNTIME_EXCEPTION, expected);
}
public void testGetCheckedTimed_Error() throws TwoArgConstructorException {
@@ -252,101 +246,109 @@ public class FuturesGetCheckedTest extends TestCase {
public void testGetCheckedTimed_TimeoutException() {
SettableFuture<String> future = SettableFuture.create();
- try {
- getChecked(future, TwoArgConstructorException.class, 0, SECONDS);
- fail();
- } catch (TwoArgConstructorException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(TimeoutException.class);
- }
+ TwoArgConstructorException expected =
+ assertThrows(
+ TwoArgConstructorException.class,
+ () -> getChecked(future, TwoArgConstructorException.class, 0, SECONDS));
+ assertThat(expected).hasCauseThat().isInstanceOf(TimeoutException.class);
}
public void testGetCheckedTimed_badExceptionConstructor_failsEvenForSuccessfulInput()
throws Exception {
- try {
- getChecked(immediateFuture("x"), ExceptionWithBadConstructor.class, 1, TimeUnit.SECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ getChecked(
+ immediateFuture("x"), ExceptionWithBadConstructor.class, 1, TimeUnit.SECONDS));
}
public void testGetCheckedTimed_badExceptionConstructor_wrapsOriginalChecked() throws Exception {
- try {
- getChecked(
- FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithBadConstructor.class, 1, TimeUnit.SECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION,
+ ExceptionWithBadConstructor.class,
+ 1,
+ TimeUnit.SECONDS));
}
public void testGetCheckedTimed_withGoodAndBadExceptionConstructor() {
- try {
- getChecked(
- FAILED_FUTURE_CHECKED_EXCEPTION,
- ExceptionWithGoodAndBadConstructor.class,
- 1,
- TimeUnit.SECONDS);
- fail();
- } catch (ExceptionWithGoodAndBadConstructor expected) {
- assertThat(expected).hasCauseThat().isSameInstanceAs(CHECKED_EXCEPTION);
- }
+ ExceptionWithGoodAndBadConstructor expected =
+ assertThrows(
+ ExceptionWithGoodAndBadConstructor.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION,
+ ExceptionWithGoodAndBadConstructor.class,
+ 1,
+ TimeUnit.SECONDS));
+ assertThat(expected).hasCauseThat().isSameInstanceAs(CHECKED_EXCEPTION);
}
// Edge case tests of the exception-construction code through untimed get():
@SuppressWarnings("FuturesGetCheckedIllegalExceptionType")
public void testGetCheckedUntimed_exceptionClassIsRuntimeException() {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, TwoArgConstructorRuntimeException.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, TwoArgConstructorRuntimeException.class));
}
public void testGetCheckedUntimed_exceptionClassSomePrivateConstructors() {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithSomePrivateConstructors.class);
- fail();
- } catch (ExceptionWithSomePrivateConstructors expected) {
- }
+ assertThrows(
+ ExceptionWithSomePrivateConstructors.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithSomePrivateConstructors.class));
}
@SuppressWarnings("FuturesGetCheckedIllegalExceptionType")
public void testGetCheckedUntimed_exceptionClassNoPublicConstructor()
throws ExceptionWithPrivateConstructor {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithPrivateConstructor.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithPrivateConstructor.class));
}
@SuppressWarnings("FuturesGetCheckedIllegalExceptionType")
public void testGetCheckedUntimed_exceptionClassPublicConstructorWrongType()
throws ExceptionWithWrongTypesConstructor {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithWrongTypesConstructor.class);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithWrongTypesConstructor.class));
}
public void testGetCheckedUntimed_exceptionClassPrefersStringConstructor() {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithManyConstructors.class);
- fail();
- } catch (ExceptionWithManyConstructors expected) {
- assertTrue(expected.usedExpectedConstructor);
- }
+ ExceptionWithManyConstructors expected =
+ assertThrows(
+ ExceptionWithManyConstructors.class,
+ () -> getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithManyConstructors.class));
+ assertTrue(expected.usedExpectedConstructor);
}
public void testGetCheckedUntimed_exceptionClassUsedInitCause() {
- try {
- getChecked(FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithoutThrowableConstructor.class);
- fail();
- } catch (ExceptionWithoutThrowableConstructor expected) {
- assertThat(expected).hasMessageThat().contains("mymessage");
- assertThat(expected).hasCauseThat().isEqualTo(CHECKED_EXCEPTION);
- }
+ ExceptionWithoutThrowableConstructor expected =
+ assertThrows(
+ ExceptionWithoutThrowableConstructor.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION, ExceptionWithoutThrowableConstructor.class));
+ assertThat(expected).hasMessageThat().contains("mymessage");
+ assertThat(expected).hasCauseThat().isEqualTo(CHECKED_EXCEPTION);
+ }
+
+ public void testPrefersConstructorWithThrowableParameter() {
+ ExceptionWithManyConstructorsButOnlyOneThrowable exception =
+ assertThrows(
+ ExceptionWithManyConstructorsButOnlyOneThrowable.class,
+ () ->
+ getChecked(
+ FAILED_FUTURE_CHECKED_EXCEPTION,
+ ExceptionWithManyConstructorsButOnlyOneThrowable.class));
+ assertThat(exception).hasMessageThat().contains("mymessage");
+ assertThat(exception.getAntecedent()).isEqualTo(CHECKED_EXCEPTION);
}
// Class unloading test:
diff --git a/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java b/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
index 24990200d..e0d579249 100644
--- a/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/FuturesTransformAsyncTest.java
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.Futures.transformAsync;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static com.google.common.util.concurrent.Uninterruptibles.awaitUninterruptibly;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.ForwardingListenableFuture.SimpleForwardingListenableFuture;
import java.util.concurrent.CancellationException;
@@ -82,23 +83,13 @@ public class FuturesTransformAsyncTest extends AbstractChainedListenableFutureTe
public void testFutureGetThrowsCancellationIfInputCancelled() throws Exception {
inputFuture.cancel(true); // argument is ignored
- try {
- resultFuture.get();
- fail("Result future must throw CancellationException" + " if input future is cancelled.");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> resultFuture.get());
}
public void testFutureGetThrowsCancellationIfOutputCancelled() throws Exception {
inputFuture.set(SLOW_OUTPUT_VALID_INPUT_DATA);
outputFuture.cancel(true); // argument is ignored
- try {
- resultFuture.get();
- fail(
- "Result future must throw CancellationException"
- + " if function output future is cancelled.");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> resultFuture.get());
}
public void testAsyncToString() throws Exception {
@@ -111,11 +102,7 @@ public class FuturesTransformAsyncTest extends AbstractChainedListenableFutureTe
assertTrue(resultFuture.isCancelled());
assertTrue(inputFuture.isCancelled());
assertFalse(outputFuture.isCancelled());
- try {
- resultFuture.get();
- fail("Result future is cancelled and should have thrown a" + " CancellationException");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> resultFuture.get());
}
public void testFutureCancellableBeforeOutputCompletion() throws Exception {
@@ -124,11 +111,7 @@ public class FuturesTransformAsyncTest extends AbstractChainedListenableFutureTe
assertTrue(resultFuture.isCancelled());
assertFalse(inputFuture.isCancelled());
assertTrue(outputFuture.isCancelled());
- try {
- resultFuture.get();
- fail("Result future is cancelled and should have thrown a" + " CancellationException");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> resultFuture.get());
}
public void testFutureCancellableBeforeFunctionCompletion() throws Exception {
@@ -146,20 +129,10 @@ public class FuturesTransformAsyncTest extends AbstractChainedListenableFutureTe
assertTrue(resultFuture.isCancelled());
assertFalse(inputFuture.isCancelled());
assertFalse(outputFuture.isCancelled());
- try {
- resultFuture.get();
- fail("Result future is cancelled and should have thrown a" + " CancellationException");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> resultFuture.get());
funcCompletionLatch.countDown(); // allow the function to complete
- try {
- outputFuture.get();
- fail(
- "The function output future is cancelled and should have thrown a"
- + " CancellationException");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> outputFuture.get());
}
public void testFutureCancelAfterCompletion() throws Exception {
@@ -174,12 +147,8 @@ public class FuturesTransformAsyncTest extends AbstractChainedListenableFutureTe
public void testFutureGetThrowsRuntimeException() throws Exception {
BadFuture badInput = new BadFuture(Futures.immediateFuture(20));
ListenableFuture<String> chain = buildChainingFuture(badInput);
- try {
- chain.get();
- fail("Future.get must throw an exception when the input future fails.");
- } catch (ExecutionException e) {
- assertSame(RuntimeException.class, e.getCause().getClass());
- }
+ ExecutionException e = assertThrows(ExecutionException.class, () -> chain.get());
+ assertSame(RuntimeException.class, e.getCause().getClass());
}
/** Proxy to throw a {@link RuntimeException} out of the {@link #get()} method. */
diff --git a/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java b/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
index 6d1591354..32bbe0c25 100644
--- a/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
@@ -16,6 +16,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.InterruptibleTask.Blocker;
import java.nio.channels.spi.AbstractInterruptibleChannel;
@@ -61,14 +62,10 @@ public final class InterruptibleTaskTest extends TestCase {
Thread runner = new Thread(task);
runner.start();
isInterruptibleRegistered.await();
- try {
- task.interruptTask();
- fail();
- } catch (RuntimeException expected) {
- assertThat(expected)
- .hasMessageThat()
- .isEqualTo("I bet you didn't think Thread.interrupt could throw");
- }
+ RuntimeException expected = assertThrows(RuntimeException.class, () -> task.interruptTask());
+ assertThat(expected)
+ .hasMessageThat()
+ .isEqualTo("I bet you didn't think Thread.interrupt could throw");
// We need to wait for the runner to exit. It used to be that the runner would get stuck in the
// busy loop when interrupt threw.
runner.join(TimeUnit.SECONDS.toMillis(10));
diff --git a/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java b/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java
index fd51a7329..7b501dc3d 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTaskTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
+import static org.junit.Assert.assertThrows;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
@@ -113,12 +114,9 @@ public class ListenableFutureTaskTest extends TestCase {
runLatch.await();
taskLatch.countDown();
- try {
- task.get(5, TimeUnit.SECONDS);
- fail("Should have propagated the failure.");
- } catch (ExecutionException e) {
- assertEquals(IllegalStateException.class, e.getCause().getClass());
- }
+ ExecutionException e =
+ assertThrows(ExecutionException.class, () -> task.get(5, TimeUnit.SECONDS));
+ assertEquals(IllegalStateException.class, e.getCause().getClass());
assertTrue(listenerLatch.await(5, TimeUnit.SECONDS));
assertTrue(task.isDone());
diff --git a/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java b/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java
index 5c99bc881..b551ff0f8 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ListenableFutureTester.java
@@ -22,6 +22,7 @@ import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
+import static org.junit.Assert.assertThrows;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CountDownLatch;
@@ -87,11 +88,7 @@ public class ListenableFutureTester {
assertTrue(future.isDone());
assertTrue(future.isCancelled());
- try {
- future.get();
- fail("Future should throw CancellationException on cancel.");
- } catch (CancellationException expected) {
- }
+ assertThrows(CancellationException.class, () -> future.get());
}
public void testFailedFuture(@Nullable String message) throws InterruptedException {
diff --git a/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java b/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
index dab6d92f9..ae72e4176 100644
--- a/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/MoreExecutorsTest.java
@@ -38,6 +38,7 @@ import static com.google.common.util.concurrent.MoreExecutors.renamingDecorator;
import static com.google.common.util.concurrent.MoreExecutors.shutdownAndAwaitTermination;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -220,12 +221,7 @@ public class MoreExecutorsTest extends JSR166TestCase {
executor.shutdown();
assertTrue(executor.isShutdown());
- try {
- executor.submit(doNothingRunnable);
- fail("Should have encountered RejectedExecutionException");
- } catch (RejectedExecutionException ex) {
- // good to go
- }
+ assertThrows(RejectedExecutionException.class, () -> executor.submit(doNothingRunnable));
assertFalse(executor.isTerminated());
// WAIT #2
@@ -237,12 +233,7 @@ public class MoreExecutorsTest extends JSR166TestCase {
assertTrue(executor.awaitTermination(1, TimeUnit.SECONDS));
assertTrue(executor.awaitTermination(0, TimeUnit.SECONDS));
assertTrue(executor.isShutdown());
- try {
- executor.submit(doNothingRunnable);
- fail("Should have encountered RejectedExecutionException");
- } catch (RejectedExecutionException ex) {
- // good to go
- }
+ assertThrows(RejectedExecutionException.class, () -> executor.submit(doNothingRunnable));
assertTrue(executor.isTerminated());
otherThread.join(1000);
@@ -309,11 +300,7 @@ public class MoreExecutorsTest extends JSR166TestCase {
public void testExecuteAfterShutdown() {
ExecutorService executor = newDirectExecutorService();
executor.shutdown();
- try {
- executor.execute(EMPTY_RUNNABLE);
- fail();
- } catch (RejectedExecutionException expected) {
- }
+ assertThrows(RejectedExecutionException.class, () -> executor.execute(EMPTY_RUNNABLE));
}
public <T> void testListeningExecutorServiceInvokeAllJavadocCodeCompiles() throws Exception {
diff --git a/guava-tests/test/com/google/common/util/concurrent/RateLimiterTest.java b/guava-tests/test/com/google/common/util/concurrent/RateLimiterTest.java
index bdd9e7885..e7874f35b 100644
--- a/guava-tests/test/com/google/common/util/concurrent/RateLimiterTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/RateLimiterTest.java
@@ -21,6 +21,7 @@ import static java.util.concurrent.TimeUnit.MICROSECONDS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.collect.ImmutableSet;
@@ -75,50 +76,18 @@ public class RateLimiterTest extends TestCase {
limiter.setRate(10.0);
assertEquals(10.0, limiter.getRate());
- try {
- limiter.setRate(0.0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- limiter.setRate(-10.0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> limiter.setRate(0.0));
+ assertThrows(IllegalArgumentException.class, () -> limiter.setRate(-10.0));
}
public void testAcquireParameterValidation() {
RateLimiter limiter = RateLimiter.create(999);
- try {
- limiter.acquire(0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- limiter.acquire(-1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- limiter.tryAcquire(0);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- limiter.tryAcquire(-1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- limiter.tryAcquire(0, 1, SECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
- try {
- limiter.tryAcquire(-1, 1, SECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> limiter.acquire(0));
+ assertThrows(IllegalArgumentException.class, () -> limiter.acquire(-1));
+ assertThrows(IllegalArgumentException.class, () -> limiter.tryAcquire(0));
+ assertThrows(IllegalArgumentException.class, () -> limiter.tryAcquire(-1));
+ assertThrows(IllegalArgumentException.class, () -> limiter.tryAcquire(0, 1, SECONDS));
+ assertThrows(IllegalArgumentException.class, () -> limiter.tryAcquire(-1, 1, SECONDS));
}
public void testSimpleWithWait() {
@@ -169,17 +138,9 @@ public class RateLimiterTest extends TestCase {
unused = RateLimiter.create(1.0, 1, NANOSECONDS);
unused = RateLimiter.create(1.0, 0, NANOSECONDS);
- try {
- RateLimiter.create(0.0, 1, NANOSECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> RateLimiter.create(0.0, 1, NANOSECONDS));
- try {
- RateLimiter.create(1.0, -1, NANOSECONDS);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> RateLimiter.create(1.0, -1, NANOSECONDS));
}
@AndroidIncompatible // difference in String.format rounding?
diff --git a/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java b/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
index cbb6c1c82..3ebff11c8 100644
--- a/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
@@ -19,6 +19,7 @@ package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.newSequentialExecutor;
import static com.google.common.util.concurrent.Uninterruptibles.awaitUninterruptibly;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
@@ -79,11 +80,7 @@ public class SequentialExecutorTest extends TestCase {
}
public void testConstructingWithNullExecutor_fails() {
- try {
- new SequentialExecutor(null);
- fail("Should have failed with NullPointerException.");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> new SequentialExecutor(null));
}
public void testBasics() {
@@ -263,11 +260,7 @@ public class SequentialExecutorTest extends TestCase {
numCalls.incrementAndGet();
}
};
- try {
- executor.execute(task);
- fail();
- } catch (RejectedExecutionException expected) {
- }
+ assertThrows(RejectedExecutionException.class, () -> executor.execute(task));
assertEquals(0, numCalls.get());
reject.set(false);
executor.execute(task);
@@ -344,18 +337,11 @@ public class SequentialExecutorTest extends TestCase {
}
});
future.get(10, TimeUnit.SECONDS);
- try {
- executor.execute(Runnables.doNothing());
- fail();
- } catch (RejectedExecutionException expected) {
- }
+ assertThrows(RejectedExecutionException.class, () -> executor.execute(Runnables.doNothing()));
latch.countDown();
- try {
- first.get(10, TimeUnit.SECONDS);
- fail();
- } catch (ExecutionException expected) {
- assertThat(expected).hasCauseThat().isInstanceOf(RejectedExecutionException.class);
- }
+ ExecutionException expected =
+ assertThrows(ExecutionException.class, () -> first.get(10, TimeUnit.SECONDS));
+ assertThat(expected).hasCauseThat().isInstanceOf(RejectedExecutionException.class);
}
public void testToString() {
diff --git a/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java b/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
index 9f22a10cd..44a667d14 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ServiceManagerTest.java
@@ -16,10 +16,13 @@
package com.google.common.util.concurrent;
+import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION;
+import static com.google.common.base.StandardSystemProperty.OS_NAME;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static java.util.Arrays.asList;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -121,6 +124,10 @@ public class ServiceManagerTest extends TestCase {
}
public void testServiceStartupTimes() {
+ if (isWindows() && isJava8()) {
+ // Flaky there: https://github.com/google/guava/pull/6731#issuecomment-1736298607
+ return;
+ }
Service a = new NoOpDelayedService(150);
Service b = new NoOpDelayedService(353);
ServiceManager serviceManager = new ServiceManager(asList(a, b));
@@ -132,6 +139,10 @@ public class ServiceManagerTest extends TestCase {
}
public void testServiceStartupDurations() {
+ if (isWindows() && isJava8()) {
+ // Flaky there: https://github.com/google/guava/pull/6731#issuecomment-1736298607
+ return;
+ }
Service a = new NoOpDelayedService(150);
Service b = new NoOpDelayedService(353);
ServiceManager serviceManager = new ServiceManager(asList(a, b));
@@ -207,11 +218,7 @@ public class ServiceManagerTest extends TestCase {
RecordingListener listener = new RecordingListener();
manager.addListener(listener, directExecutor());
assertState(manager, Service.State.NEW, a, b, c, d, e);
- try {
- manager.startAsync().awaitHealthy();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> manager.startAsync().awaitHealthy());
assertFalse(listener.healthyCalled);
assertState(manager, Service.State.RUNNING, a, c, e);
assertEquals(ImmutableSet.of(b, d), listener.failedServices);
@@ -231,11 +238,7 @@ public class ServiceManagerTest extends TestCase {
RecordingListener listener = new RecordingListener();
manager.addListener(listener, directExecutor());
assertState(manager, Service.State.NEW, a, b);
- try {
- manager.startAsync().awaitHealthy();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> manager.startAsync().awaitHealthy());
assertTrue(listener.healthyCalled);
assertEquals(ImmutableSet.of(b), listener.failedServices);
@@ -278,19 +281,11 @@ public class ServiceManagerTest extends TestCase {
Service a = new NoOpDelayedService(50);
ServiceManager manager = new ServiceManager(asList(a));
manager.startAsync();
- try {
- manager.awaitHealthy(1, TimeUnit.MILLISECONDS);
- fail();
- } catch (TimeoutException expected) {
- }
+ assertThrows(TimeoutException.class, () -> manager.awaitHealthy(1, TimeUnit.MILLISECONDS));
manager.awaitHealthy(5, SECONDS); // no exception thrown
manager.stopAsync();
- try {
- manager.awaitStopped(1, TimeUnit.MILLISECONDS);
- fail();
- } catch (TimeoutException expected) {
- }
+ assertThrows(TimeoutException.class, () -> manager.awaitStopped(1, TimeUnit.MILLISECONDS));
manager.awaitStopped(5, SECONDS); // no exception thrown
}
@@ -303,11 +298,7 @@ public class ServiceManagerTest extends TestCase {
ServiceManager manager = new ServiceManager(asList(a));
RecordingListener listener = new RecordingListener();
manager.addListener(listener, directExecutor());
- try {
- manager.startAsync().awaitHealthy();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> manager.startAsync().awaitHealthy());
assertTrue(listener.stoppedCalled);
}
@@ -320,11 +311,7 @@ public class ServiceManagerTest extends TestCase {
ServiceManager manager = new ServiceManager(asList(a));
RecordingListener listener = new RecordingListener();
manager.addListener(listener, directExecutor());
- try {
- manager.startAsync().awaitHealthy();
- fail();
- } catch (IllegalStateException expected) {
- }
+ assertThrows(IllegalStateException.class, () -> manager.startAsync().awaitHealthy());
assertFalse(listener.healthyCalled);
}
@@ -523,11 +510,7 @@ public class ServiceManagerTest extends TestCase {
logger.addHandler(logHandler);
NoOpService service = new NoOpService();
service.startAsync();
- try {
- new ServiceManager(Arrays.asList(service));
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(IllegalArgumentException.class, () -> new ServiceManager(Arrays.asList(service)));
service.stopAsync();
// Nothing was logged!
assertEquals(0, logHandler.getStoredLogRecords().size());
@@ -548,6 +531,7 @@ public class ServiceManagerTest extends TestCase {
service1.startAsync();
delegate.addListener(listener, executor);
}
+
// Delegates from here on down
@Override
public final Service startAsync() {
@@ -594,12 +578,11 @@ public class ServiceManagerTest extends TestCase {
return delegate.failureCause();
}
};
- try {
- new ServiceManager(Arrays.asList(service1, service2));
- fail();
- } catch (IllegalArgumentException expected) {
- assertThat(expected.getMessage()).contains("started transitioning asynchronously");
- }
+ IllegalArgumentException expected =
+ assertThrows(
+ IllegalArgumentException.class,
+ () -> new ServiceManager(Arrays.asList(service1, service2)));
+ assertThat(expected.getMessage()).contains("started transitioning asynchronously");
}
/**
@@ -678,4 +661,12 @@ public class ServiceManagerTest extends TestCase {
failedServices.add(service);
}
}
+
+ private static boolean isWindows() {
+ return OS_NAME.value().startsWith("Windows");
+ }
+
+ private static boolean isJava8() {
+ return JAVA_SPECIFICATION_VERSION.value().equals("1.8");
+ }
}
diff --git a/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
index 105e8de04..84b5c6757 100644
--- a/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/SettableFutureTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
@@ -44,11 +45,7 @@ public class SettableFutureTest extends TestCase {
}
public void testDefaultState() throws Exception {
- try {
- future.get(5, TimeUnit.MILLISECONDS);
- fail();
- } catch (TimeoutException expected) {
- }
+ assertThrows(TimeoutException.class, () -> future.get(5, TimeUnit.MILLISECONDS));
}
public void testSetValue() throws Exception {
@@ -62,11 +59,7 @@ public class SettableFutureTest extends TestCase {
}
public void testSetFailureNull() throws Exception {
- try {
- future.setException(null);
- fail();
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> future.setException(null));
assertFalse(future.isDone());
assertTrue(future.setException(new Exception("failure")));
tester.testFailedFuture("failure");
@@ -108,12 +101,8 @@ public class SettableFutureTest extends TestCase {
// Check that the future has been set properly.
assertTrue(future.isDone());
assertFalse(future.isCancelled());
- try {
- future.get();
- fail("Expected ExecutionException");
- } catch (ExecutionException ee) {
- assertThat(ee).hasCauseThat().isSameInstanceAs(e);
- }
+ ExecutionException ee = assertThrows(ExecutionException.class, () -> future.get());
+ assertThat(ee).hasCauseThat().isSameInstanceAs(e);
}
public void testSetFuture() throws Exception {
@@ -127,12 +116,7 @@ public class SettableFutureTest extends TestCase {
// Check that the future has been set properly.
assertFalse(future.isDone());
assertFalse(future.isCancelled());
- try {
- future.get(0, TimeUnit.MILLISECONDS);
- fail("Expected TimeoutException");
- } catch (TimeoutException expected) {
- /* expected */
- }
+ assertThrows(TimeoutException.class, () -> future.get(0, TimeUnit.MILLISECONDS));
nested.set("foo");
assertTrue(future.isDone());
assertFalse(future.isCancelled());
@@ -154,12 +138,7 @@ public class SettableFutureTest extends TestCase {
// Check that the future has been set properly.
assertFalse(future.isDone());
assertFalse(future.isCancelled());
- try {
- future.get(0, TimeUnit.MILLISECONDS);
- fail("Expected TimeoutException");
- } catch (TimeoutException expected) {
- /* expected */
- }
+ assertThrows(TimeoutException.class, () -> future.get(0, TimeUnit.MILLISECONDS));
FooChild value = new FooChild();
nested.set(value);
assertTrue(future.isDone());
@@ -173,12 +152,7 @@ public class SettableFutureTest extends TestCase {
async.setFuture(inner);
inner.cancel(true);
assertTrue(async.isCancelled());
- try {
- async.get();
- fail("Expected CancellationException");
- } catch (CancellationException expected) {
- /* expected */
- }
+ assertThrows(CancellationException.class, () -> async.get());
}
public void testCancel_resultCancelsInner_interrupted() throws Exception {
@@ -188,12 +162,7 @@ public class SettableFutureTest extends TestCase {
async.cancel(true);
assertTrue(inner.isCancelled());
assertTrue(inner.wasInterrupted());
- try {
- inner.get();
- fail("Expected CancellationException");
- } catch (CancellationException expected) {
- /* expected */
- }
+ assertThrows(CancellationException.class, () -> inner.get());
}
public void testCancel_resultCancelsInner() throws Exception {
@@ -203,12 +172,7 @@ public class SettableFutureTest extends TestCase {
async.cancel(false);
assertTrue(inner.isCancelled());
assertFalse(inner.wasInterrupted());
- try {
- inner.get();
- fail("Expected CancellationException");
- } catch (CancellationException expected) {
- /* expected */
- }
+ assertThrows(CancellationException.class, () -> inner.get());
}
public void testCancel_beforeSet() throws Exception {
diff --git a/guava-tests/test/com/google/common/util/concurrent/SimpleTimeLimiterTest.java b/guava-tests/test/com/google/common/util/concurrent/SimpleTimeLimiterTest.java
index 37ef84f66..f66b9ed47 100644
--- a/guava-tests/test/com/google/common/util/concurrent/SimpleTimeLimiterTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/SimpleTimeLimiterTest.java
@@ -18,6 +18,7 @@ package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.base.Stopwatch;
import com.google.common.collect.Range;
@@ -108,11 +109,7 @@ public class SimpleTimeLimiterTest extends TestCase {
Sample proxy = service.newProxy(target, Sample.class, NOT_ENOUGH_MS, MILLISECONDS);
Stopwatch stopwatch = Stopwatch.createStarted();
- try {
- proxy.sleepThenReturnInput("x");
- fail("no exception thrown");
- } catch (UncheckedTimeoutException expected) {
- }
+ assertThrows(UncheckedTimeoutException.class, () -> proxy.sleepThenReturnInput("x"));
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(NOT_ENOUGH_MS, DELAY_MS * 2));
// Is it still computing away anyway?
@@ -126,11 +123,7 @@ public class SimpleTimeLimiterTest extends TestCase {
Sample proxy = service.newProxy(target, Sample.class, ENOUGH_MS, MILLISECONDS);
Stopwatch stopwatch = Stopwatch.createStarted();
- try {
- proxy.sleepThenThrowException();
- fail("no exception thrown");
- } catch (SampleException expected) {
- }
+ assertThrows(SampleException.class, () -> proxy.sleepThenThrowException());
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(DELAY_MS, ENOUGH_MS));
}
@@ -140,11 +133,7 @@ public class SimpleTimeLimiterTest extends TestCase {
Sample proxy = service.newProxy(target, Sample.class, NOT_ENOUGH_MS, MILLISECONDS);
Stopwatch stopwatch = Stopwatch.createStarted();
- try {
- proxy.sleepThenThrowException();
- fail("no exception thrown");
- } catch (UncheckedTimeoutException expected) {
- }
+ assertThrows(UncheckedTimeoutException.class, () -> proxy.sleepThenThrowException());
assertThat(stopwatch.elapsed(MILLISECONDS)).isIn(Range.closed(NOT_ENOUGH_MS, DELAY_MS * 2));
}
@@ -159,20 +148,17 @@ public class SimpleTimeLimiterTest extends TestCase {
}
public void testCallWithTimeout_goodCallableWithNotEnoughTime() throws Exception {
- try {
- service.callWithTimeout(GOOD_CALLABLE, NOT_ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (TimeoutException expected) {
- }
+ assertThrows(
+ TimeoutException.class,
+ () -> service.callWithTimeout(GOOD_CALLABLE, NOT_ENOUGH_MS, MILLISECONDS));
}
public void testCallWithTimeout_badCallableWithEnoughTime() throws Exception {
- try {
- service.callWithTimeout(BAD_CALLABLE, ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (ExecutionException expected) {
- assertThat(expected.getCause()).isInstanceOf(SampleException.class);
- }
+ ExecutionException expected =
+ assertThrows(
+ ExecutionException.class,
+ () -> service.callWithTimeout(BAD_CALLABLE, ENOUGH_MS, MILLISECONDS));
+ assertThat(expected.getCause()).isInstanceOf(SampleException.class);
}
public void testCallUninterruptiblyWithTimeout_goodCallableWithEnoughTime() throws Exception {
@@ -185,20 +171,17 @@ public class SimpleTimeLimiterTest extends TestCase {
}
public void testCallUninterruptiblyWithTimeout_goodCallableWithNotEnoughTime() throws Exception {
- try {
- service.callUninterruptiblyWithTimeout(GOOD_CALLABLE, NOT_ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (TimeoutException expected) {
- }
+ assertThrows(
+ TimeoutException.class,
+ () -> service.callUninterruptiblyWithTimeout(GOOD_CALLABLE, NOT_ENOUGH_MS, MILLISECONDS));
}
public void testCallUninterruptiblyWithTimeout_badCallableWithEnoughTime() throws Exception {
- try {
- service.callUninterruptiblyWithTimeout(BAD_CALLABLE, ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (ExecutionException expected) {
- assertThat(expected.getCause()).isInstanceOf(SampleException.class);
- }
+ ExecutionException expected =
+ assertThrows(
+ ExecutionException.class,
+ () -> service.callUninterruptiblyWithTimeout(BAD_CALLABLE, ENOUGH_MS, MILLISECONDS));
+ assertThat(expected.getCause()).isInstanceOf(SampleException.class);
}
public void testRunWithTimeout_goodRunnableWithEnoughTime() throws Exception {
@@ -210,20 +193,17 @@ public class SimpleTimeLimiterTest extends TestCase {
}
public void testRunWithTimeout_goodRunnableWithNotEnoughTime() throws Exception {
- try {
- service.runWithTimeout(GOOD_RUNNABLE, NOT_ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (TimeoutException expected) {
- }
+ assertThrows(
+ TimeoutException.class,
+ () -> service.runWithTimeout(GOOD_RUNNABLE, NOT_ENOUGH_MS, MILLISECONDS));
}
public void testRunWithTimeout_badRunnableWithEnoughTime() throws Exception {
- try {
- service.runWithTimeout(BAD_RUNNABLE, ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (UncheckedExecutionException expected) {
- assertThat(expected.getCause()).isInstanceOf(SampleRuntimeException.class);
- }
+ UncheckedExecutionException expected =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () -> service.runWithTimeout(BAD_RUNNABLE, ENOUGH_MS, MILLISECONDS));
+ assertThat(expected.getCause()).isInstanceOf(SampleRuntimeException.class);
}
public void testRunUninterruptiblyWithTimeout_goodRunnableWithEnoughTime() throws Exception {
@@ -235,20 +215,17 @@ public class SimpleTimeLimiterTest extends TestCase {
}
public void testRunUninterruptiblyWithTimeout_goodRunnableWithNotEnoughTime() throws Exception {
- try {
- service.runUninterruptiblyWithTimeout(GOOD_RUNNABLE, NOT_ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (TimeoutException expected) {
- }
+ assertThrows(
+ TimeoutException.class,
+ () -> service.runUninterruptiblyWithTimeout(GOOD_RUNNABLE, NOT_ENOUGH_MS, MILLISECONDS));
}
public void testRunUninterruptiblyWithTimeout_badRunnableWithEnoughTime() throws Exception {
- try {
- service.runUninterruptiblyWithTimeout(BAD_RUNNABLE, ENOUGH_MS, MILLISECONDS);
- fail("no exception thrown");
- } catch (UncheckedExecutionException expected) {
- assertThat(expected.getCause()).isInstanceOf(SampleRuntimeException.class);
- }
+ UncheckedExecutionException expected =
+ assertThrows(
+ UncheckedExecutionException.class,
+ () -> service.runUninterruptiblyWithTimeout(BAD_RUNNABLE, ENOUGH_MS, MILLISECONDS));
+ assertThat(expected.getCause()).isInstanceOf(SampleRuntimeException.class);
}
private interface Sample {
diff --git a/guava-tests/test/com/google/common/util/concurrent/SupplementalMonitorTest.java b/guava-tests/test/com/google/common/util/concurrent/SupplementalMonitorTest.java
index 5b77f9a59..62b69aec7 100644
--- a/guava-tests/test/com/google/common/util/concurrent/SupplementalMonitorTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/SupplementalMonitorTest.java
@@ -18,6 +18,7 @@ package com.google.common.util.concurrent;
import static com.google.common.util.concurrent.GeneratedMonitorTest.startThread;
import static com.google.common.util.concurrent.Uninterruptibles.joinUninterruptibly;
+import static org.junit.Assert.assertThrows;
import com.google.common.util.concurrent.GeneratedMonitorTest.FlagGuard;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -37,41 +38,25 @@ public class SupplementalMonitorTest extends TestCase {
public void testLeaveWithoutEnterThrowsIMSE() {
Monitor monitor = new Monitor();
- try {
- monitor.leave();
- fail("expected IllegalMonitorStateException");
- } catch (IllegalMonitorStateException expected) {
- }
+ assertThrows(IllegalMonitorStateException.class, () -> monitor.leave());
}
public void testGetWaitQueueLengthWithWrongMonitorThrowsIMSE() {
Monitor monitor1 = new Monitor();
Monitor monitor2 = new Monitor();
FlagGuard guard = new FlagGuard(monitor2);
- try {
- monitor1.getWaitQueueLength(guard);
- fail("expected IllegalMonitorStateException");
- } catch (IllegalMonitorStateException expected) {
- }
+ assertThrows(IllegalMonitorStateException.class, () -> monitor1.getWaitQueueLength(guard));
}
public void testHasWaitersWithWrongMonitorThrowsIMSE() {
Monitor monitor1 = new Monitor();
Monitor monitor2 = new Monitor();
FlagGuard guard = new FlagGuard(monitor2);
- try {
- monitor1.hasWaiters(guard);
- fail("expected IllegalMonitorStateException");
- } catch (IllegalMonitorStateException expected) {
- }
+ assertThrows(IllegalMonitorStateException.class, () -> monitor1.hasWaiters(guard));
}
public void testNullMonitorInGuardConstructorThrowsNPE() {
- try {
- new FlagGuard(null);
- fail("expected NullPointerException");
- } catch (NullPointerException expected) {
- }
+ assertThrows(NullPointerException.class, () -> new FlagGuard(null));
}
public void testIsFair() {
diff --git a/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java b/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
index a3a7b8e79..09b3ec7ee 100644
--- a/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/ThreadFactoryBuilderTest.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertThrows;
import com.google.common.testing.NullPointerTester;
import java.lang.Thread.UncaughtExceptionHandler;
@@ -129,19 +130,13 @@ public class ThreadFactoryBuilderTest extends TestCase {
}
public void testPriority_tooLow() {
- try {
- builder.setPriority(Thread.MIN_PRIORITY - 1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> builder.setPriority(Thread.MIN_PRIORITY - 1));
}
public void testPriority_tooHigh() {
- try {
- builder.setPriority(Thread.MAX_PRIORITY + 1);
- fail();
- } catch (IllegalArgumentException expected) {
- }
+ assertThrows(
+ IllegalArgumentException.class, () -> builder.setPriority(Thread.MAX_PRIORITY + 1));
}
public void testUncaughtExceptionHandler_custom() {
diff --git a/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java b/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java
index 3f91b8123..f857c6edf 100644
--- a/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java
+++ b/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java
@@ -20,6 +20,7 @@ import static com.google.common.util.concurrent.InterruptionUtil.repeatedlyInter
import static com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertThrows;
import com.google.common.testing.TearDown;
import com.google.common.testing.TearDownStack;
@@ -120,11 +121,9 @@ public class UninterruptibleFutureTest extends TestCase {
repeatedlyInterruptTestThread(100, tearDownStack);
- try {
- getUninterruptibly(delayedFuture, 500, TimeUnit.MILLISECONDS);
- fail("expected to time out");
- } catch (TimeoutException expected) {
- }
+ assertThrows(
+ TimeoutException.class,
+ () -> getUninterruptibly(delayedFuture, 500, TimeUnit.MILLISECONDS));
assertTrue(Thread.interrupted()); // clears the interrupt state, too
assertFalse(sleeper.completed);
@@ -217,13 +216,9 @@ public class UninterruptibleFutureTest extends TestCase {
Thread waitingThread = new Thread(wasInterrupted);
waitingThread.start();
waitingThread.interrupt();
- try {
- wasInterrupted.get();
- fail();
- } catch (ExecutionException expected) {
- assertTrue(
- expected.getCause().toString(), expected.getCause() instanceof InterruptedException);
- }
+ ExecutionException expected =
+ assertThrows(ExecutionException.class, () -> wasInterrupted.get());
+ assertTrue(expected.getCause().toString(), expected.getCause() instanceof InterruptedException);
}
public void testMakeUninterruptible_timedGetZeroTimeoutAttempted()
diff --git a/guava/module.json b/guava/module.json
index 9d78db10f..0e7e5d85d 100644
--- a/guava/module.json
+++ b/guava/module.json
@@ -28,19 +28,9 @@
"dependencies": [
{
"group": "com.google.guava",
- "module": "guava-parent",
- "version": {
- "requires": "${pom.version}"
- },
- "attributes": {
- "org.gradle.category": "platform"
- }
- },
- {
- "group": "com.google.guava",
"module": "failureaccess",
"version": {
- "requires": "1.0.1"
+ "requires": "1.0.2"
}
},
{
@@ -52,19 +42,31 @@
},
{
"group": "com.google.code.findbugs",
- "module": "jsr305"
+ "module": "jsr305",
+ "version": {
+ "requires": "${jsr305.version}"
+ }
},
{
"group": "org.checkerframework",
- "module": "checker-qual"
+ "module": "checker-qual",
+ "version": {
+ "requires": "${checker.version}"
+ }
},
{
"group": "com.google.errorprone",
- "module": "error_prone_annotations"
+ "module": "error_prone_annotations",
+ "version": {
+ "requires": "${errorprone.version}"
+ }
},
{
"group": "com.google.j2objc",
- "module": "j2objc-annotations"
+ "module": "j2objc-annotations",
+ "version": {
+ "requires": "${j2objc.version}"
+ }
}
],
"files": [
@@ -99,19 +101,9 @@
"dependencies": [
{
"group": "com.google.guava",
- "module": "guava-parent",
- "version": {
- "requires": "${pom.version}"
- },
- "attributes": {
- "org.gradle.category": "platform"
- }
- },
- {
- "group": "com.google.guava",
"module": "failureaccess",
"version": {
- "requires": "1.0.1"
+ "requires": "1.0.2"
}
},
{
@@ -123,15 +115,24 @@
},
{
"group": "com.google.code.findbugs",
- "module": "jsr305"
+ "module": "jsr305",
+ "version": {
+ "requires": "${jsr305.version}"
+ }
},
{
"group": "org.checkerframework",
- "module": "checker-qual"
+ "module": "checker-qual",
+ "version": {
+ "requires": "${checker.version}"
+ }
},
{
"group": "com.google.errorprone",
- "module": "error_prone_annotations"
+ "module": "error_prone_annotations",
+ "version": {
+ "requires": "${errorprone.version}"
+ }
}
],
"files": [
@@ -166,19 +167,9 @@
"dependencies": [
{
"group": "com.google.guava",
- "module": "guava-parent",
- "version": {
- "requires": "${otherVariant.version}"
- },
- "attributes": {
- "org.gradle.category": "platform"
- }
- },
- {
- "group": "com.google.guava",
"module": "failureaccess",
"version": {
- "requires": "1.0.1"
+ "requires": "1.0.2"
}
},
{
@@ -190,19 +181,31 @@
},
{
"group": "com.google.code.findbugs",
- "module": "jsr305"
+ "module": "jsr305",
+ "version": {
+ "requires": "${jsr305.version}"
+ }
},
{
"group": "org.checkerframework",
- "module": "checker-qual"
+ "module": "checker-qual",
+ "version": {
+ "requires": "${checker.version}"
+ }
},
{
"group": "com.google.errorprone",
- "module": "error_prone_annotations"
+ "module": "error_prone_annotations",
+ "version": {
+ "requires": "${errorprone.version}"
+ }
},
{
"group": "com.google.j2objc",
- "module": "j2objc-annotations"
+ "module": "j2objc-annotations",
+ "version": {
+ "requires": "${j2objc.version}"
+ }
}
],
"files": [
@@ -237,19 +240,9 @@
"dependencies": [
{
"group": "com.google.guava",
- "module": "guava-parent",
- "version": {
- "requires": "${otherVariant.version}"
- },
- "attributes": {
- "org.gradle.category": "platform"
- }
- },
- {
- "group": "com.google.guava",
"module": "failureaccess",
"version": {
- "requires": "1.0.1"
+ "requires": "1.0.2"
}
},
{
@@ -261,15 +254,24 @@
},
{
"group": "com.google.code.findbugs",
- "module": "jsr305"
+ "module": "jsr305",
+ "version": {
+ "requires": "${jsr305.version}"
+ }
},
{
"group": "org.checkerframework",
- "module": "checker-qual"
+ "module": "checker-qual",
+ "version": {
+ "requires": "${checker.version}"
+ }
},
{
"group": "com.google.errorprone",
- "module": "error_prone_annotations"
+ "module": "error_prone_annotations",
+ "version": {
+ "requires": "${errorprone.version}"
+ }
}
],
"files": [
diff --git a/guava/pom.xml b/guava/pom.xml
index d87aa8952..7bf8ceb17 100644
--- a/guava/pom.xml
+++ b/guava/pom.xml
@@ -21,7 +21,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>failureaccess</artifactId>
- <version>1.0.1</version>
+ <version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
@@ -200,16 +200,6 @@
</links>
<overview>../overview.html</overview>
</configuration>
- <executions>
- <execution>
- <id>attach-docs</id>
- </execution>
- <execution>
- <id>generate-javadoc-site-report</id>
- <phase>site</phase>
- <goals><goal>javadoc</goal></goals>
- </execution>
- </executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
diff --git a/guava/src/com/google/common/base/CharMatcher.java b/guava/src/com/google/common/base/CharMatcher.java
index 4ed1e9a90..42dfca3d8 100644
--- a/guava/src/com/google/common/base/CharMatcher.java
+++ b/guava/src/com/google/common/base/CharMatcher.java
@@ -971,7 +971,7 @@ public abstract class CharMatcher implements Predicate<Character> {
}
/** Negation of a {@link FastMatcher}. */
- static class NegatedFastMatcher extends Negated {
+ private static class NegatedFastMatcher extends Negated {
NegatedFastMatcher(CharMatcher original) {
super(original);
@@ -1015,7 +1015,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #any()}. */
private static final class Any extends NamedFastMatcher {
- static final Any INSTANCE = new Any();
+ static final CharMatcher INSTANCE = new Any();
private Any() {
super("CharMatcher.any()");
@@ -1112,7 +1112,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #none()}. */
private static final class None extends NamedFastMatcher {
- static final None INSTANCE = new None();
+ static final CharMatcher INSTANCE = new None();
private None() {
super("CharMatcher.none()");
@@ -1228,7 +1228,7 @@ public abstract class CharMatcher implements Predicate<Character> {
static final int MULTIPLIER = 1682554634;
static final int SHIFT = Integer.numberOfLeadingZeros(TABLE.length() - 1);
- static final Whitespace INSTANCE = new Whitespace();
+ static final CharMatcher INSTANCE = new Whitespace();
Whitespace() {
super("CharMatcher.whitespace()");
@@ -1286,7 +1286,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #ascii()}. */
private static final class Ascii extends NamedFastMatcher {
- static final Ascii INSTANCE = new Ascii();
+ static final CharMatcher INSTANCE = new Ascii();
Ascii() {
super("CharMatcher.ascii()");
@@ -1360,7 +1360,7 @@ public abstract class CharMatcher implements Predicate<Character> {
return nines;
}
- static final Digit INSTANCE = new Digit();
+ static final CharMatcher INSTANCE = new Digit();
private Digit() {
super("CharMatcher.digit()", zeroes(), nines());
@@ -1370,7 +1370,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #javaDigit()}. */
private static final class JavaDigit extends CharMatcher {
- static final JavaDigit INSTANCE = new JavaDigit();
+ static final CharMatcher INSTANCE = new JavaDigit();
@Override
public boolean matches(char c) {
@@ -1386,7 +1386,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #javaLetter()}. */
private static final class JavaLetter extends CharMatcher {
- static final JavaLetter INSTANCE = new JavaLetter();
+ static final CharMatcher INSTANCE = new JavaLetter();
@Override
public boolean matches(char c) {
@@ -1402,7 +1402,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #javaLetterOrDigit()}. */
private static final class JavaLetterOrDigit extends CharMatcher {
- static final JavaLetterOrDigit INSTANCE = new JavaLetterOrDigit();
+ static final CharMatcher INSTANCE = new JavaLetterOrDigit();
@Override
public boolean matches(char c) {
@@ -1418,7 +1418,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #javaUpperCase()}. */
private static final class JavaUpperCase extends CharMatcher {
- static final JavaUpperCase INSTANCE = new JavaUpperCase();
+ static final CharMatcher INSTANCE = new JavaUpperCase();
@Override
public boolean matches(char c) {
@@ -1434,7 +1434,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #javaLowerCase()}. */
private static final class JavaLowerCase extends CharMatcher {
- static final JavaLowerCase INSTANCE = new JavaLowerCase();
+ static final CharMatcher INSTANCE = new JavaLowerCase();
@Override
public boolean matches(char c) {
@@ -1450,7 +1450,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #javaIsoControl()}. */
private static final class JavaIsoControl extends NamedFastMatcher {
- static final JavaIsoControl INSTANCE = new JavaIsoControl();
+ static final CharMatcher INSTANCE = new JavaIsoControl();
private JavaIsoControl() {
super("CharMatcher.javaIsoControl()");
@@ -1475,7 +1475,7 @@ public abstract class CharMatcher implements Predicate<Character> {
"\u0020\u00a0\u00ad\u0605\u061c\u06dd\u070f\u0891\u08e2\u1680\u180e\u200f\u202f\u2064\u206f"
+ "\u3000\uf8ff\ufeff\ufffb";
- static final Invisible INSTANCE = new Invisible();
+ static final CharMatcher INSTANCE = new Invisible();
private Invisible() {
super("CharMatcher.invisible()", RANGE_STARTS.toCharArray(), RANGE_ENDS.toCharArray());
@@ -1485,7 +1485,7 @@ public abstract class CharMatcher implements Predicate<Character> {
/** Implementation of {@link #singleWidth()}. */
private static final class SingleWidth extends RangesMatcher {
- static final SingleWidth INSTANCE = new SingleWidth();
+ static final CharMatcher INSTANCE = new SingleWidth();
private SingleWidth() {
super(
diff --git a/guava/src/com/google/common/base/Converter.java b/guava/src/com/google/common/base/Converter.java
index 63f4394f4..a34c734ab 100644
--- a/guava/src/com/google/common/base/Converter.java
+++ b/guava/src/com/google/common/base/Converter.java
@@ -571,7 +571,7 @@ public abstract class Converter<A, B> implements Function<A, B> {
* "pass-through type".
*/
private static final class IdentityConverter<T> extends Converter<T, T> implements Serializable {
- static final IdentityConverter<?> INSTANCE = new IdentityConverter<>();
+ static final Converter<?, ?> INSTANCE = new IdentityConverter<>();
@Override
protected T doForward(T t) {
diff --git a/guava/src/com/google/common/base/Joiner.java b/guava/src/com/google/common/base/Joiner.java
index fe1b40a5e..acb7d8d12 100644
--- a/guava/src/com/google/common/base/Joiner.java
+++ b/guava/src/com/google/common/base/Joiner.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.util.AbstractList;
import java.util.Arrays;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.CheckForNull;
@@ -129,7 +130,9 @@ public class Joiner {
@CanIgnoreReturnValue
public final <A extends Appendable> A appendTo(A appendable, @Nullable Object[] parts)
throws IOException {
- return appendTo(appendable, Arrays.asList(parts));
+ @SuppressWarnings("nullness") // TODO: b/316358623 - Remove suppression after fixing checker
+ List<?> partsList = Arrays.<@Nullable Object>asList(parts);
+ return appendTo(appendable, partsList);
}
/** Appends to {@code appendable} the string representation of each of the remaining arguments. */
@@ -179,7 +182,9 @@ public class Joiner {
*/
@CanIgnoreReturnValue
public final StringBuilder appendTo(StringBuilder builder, @Nullable Object[] parts) {
- return appendTo(builder, Arrays.asList(parts));
+ @SuppressWarnings("nullness") // TODO: b/316358623 - Remove suppression after fixing checker
+ List<?> partsList = Arrays.<@Nullable Object>asList(parts);
+ return appendTo(builder, partsList);
}
/**
@@ -219,7 +224,9 @@ public class Joiner {
* previously configured separator between each.
*/
public final String join(@Nullable Object[] parts) {
- return join(Arrays.asList(parts));
+ @SuppressWarnings("nullness") // TODO: b/316358623 - Remove suppression after fixing checker
+ List<?> partsList = Arrays.<@Nullable Object>asList(parts);
+ return join(partsList);
}
/**
diff --git a/guava/src/com/google/common/base/MoreObjects.java b/guava/src/com/google/common/base/MoreObjects.java
index f3826d96f..1074336f5 100644
--- a/guava/src/com/google/common/base/MoreObjects.java
+++ b/guava/src/com/google/common/base/MoreObjects.java
@@ -439,7 +439,7 @@ public final class MoreObjects {
}
// Holder object for values that might be null and/or empty.
- private static class ValueHolder {
+ static class ValueHolder {
@CheckForNull String name;
@CheckForNull Object value;
@CheckForNull ValueHolder next;
diff --git a/guava/src/com/google/common/base/PatternCompiler.java b/guava/src/com/google/common/base/PatternCompiler.java
index 6a7b620b2..32505217f 100644
--- a/guava/src/com/google/common/base/PatternCompiler.java
+++ b/guava/src/com/google/common/base/PatternCompiler.java
@@ -16,6 +16,7 @@ package com.google.common.base;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
+import com.google.errorprone.annotations.RestrictedApi;
/**
* Pluggable interface for compiling a regex pattern. By default this package uses the {@code
@@ -31,11 +32,17 @@ interface PatternCompiler {
*
* @throws IllegalArgumentException if the pattern is invalid
*/
+ @RestrictedApi(
+ explanation = "PatternCompiler is an implementation detail of com.google.common.base",
+ allowedOnPath = ".*/com/google/common/base/.*")
CommonPattern compile(String pattern);
/**
* Returns {@code true} if the regex implementation behaves like Perl -- notably, by supporting
* possessive quantifiers but also being susceptible to catastrophic backtracking.
*/
+ @RestrictedApi(
+ explanation = "PatternCompiler is an implementation detail of com.google.common.base",
+ allowedOnPath = ".*/com/google/common/base/.*")
boolean isPcreLike();
}
diff --git a/guava/src/com/google/common/base/Splitter.java b/guava/src/com/google/common/base/Splitter.java
index f8415a79a..de8f24441 100644
--- a/guava/src/com/google/common/base/Splitter.java
+++ b/guava/src/com/google/common/base/Splitter.java
@@ -217,10 +217,11 @@ public final class Splitter {
@J2ktIncompatible
@GwtIncompatible // java.util.regex
public static Splitter on(Pattern separatorPattern) {
- return on(new JdkPattern(separatorPattern));
+ return onPatternInternal(new JdkPattern(separatorPattern));
}
- private static Splitter on(final CommonPattern separatorPattern) {
+ /** Internal utility; see {@link #on(Pattern)} instead. */
+ static Splitter onPatternInternal(final CommonPattern separatorPattern) {
checkArgument(
!separatorPattern.matcher("").matches(),
"The pattern may not match the empty string: %s",
@@ -261,7 +262,7 @@ public final class Splitter {
@J2ktIncompatible
@GwtIncompatible // java.util.regex
public static Splitter onPattern(String separatorPattern) {
- return on(Platform.compilePattern(separatorPattern));
+ return onPatternInternal(Platform.compilePattern(separatorPattern));
}
/**
diff --git a/guava/src/com/google/common/base/Throwables.java b/guava/src/com/google/common/base/Throwables.java
index 23936897d..e37a3d99d 100644
--- a/guava/src/com/google/common/base/Throwables.java
+++ b/guava/src/com/google/common/base/Throwables.java
@@ -140,18 +140,7 @@ public final class Throwables {
/**
* Propagates {@code throwable} exactly as-is, if and only if it is an instance of {@link
- * RuntimeException} or {@link Error}. Example usage:
- *
- * <pre>
- * try {
- * someMethodThatCouldThrowAnything();
- * } catch (IKnowWhatToDoWithThisException e) {
- * handle(e);
- * } catch (Throwable t) {
- * Throwables.propagateIfPossible(t);
- * throw new RuntimeException("unexpected", t);
- * }
- * </pre>
+ * RuntimeException} or {@link Error}.
*
* @deprecated Use {@link #throwIfUnchecked}, which has the same behavior but rejects {@code
* null}.
@@ -167,18 +156,10 @@ public final class Throwables {
/**
* Propagates {@code throwable} exactly as-is, if and only if it is an instance of {@link
- * RuntimeException}, {@link Error}, or {@code declaredType}. Example usage:
+ * RuntimeException}, {@link Error}, or {@code declaredType}.
*
- * <pre>
- * try {
- * someMethodThatCouldThrowAnything();
- * } catch (IKnowWhatToDoWithThisException e) {
- * handle(e);
- * } catch (Throwable t) {
- * Throwables.propagateIfPossible(t, OtherException.class);
- * throw new RuntimeException("unexpected", t);
- * }
- * </pre>
+ * <p><b>Discouraged</b> in favor of calling {@link #throwIfInstanceOf} and {@link
+ * #throwIfUnchecked}.
*
* @param throwable the Throwable to possibly propagate
* @param declaredType the single checked exception type declared by the calling method
@@ -193,10 +174,10 @@ public final class Throwables {
/**
* Propagates {@code throwable} exactly as-is, if and only if it is an instance of {@link
- * RuntimeException}, {@link Error}, {@code declaredType1}, or {@code declaredType2}. In the
- * unlikely case that you have three or more declared checked exception types, you can handle them
- * all by invoking these methods repeatedly. See usage example in {@link
- * #propagateIfPossible(Throwable, Class)}.
+ * RuntimeException}, {@link Error}, {@code declaredType1}, or {@code declaredType2}.
+ *
+ * <p><b>Discouraged</b> in favor of calling {@link #throwIfInstanceOf} and {@link
+ * #throwIfUnchecked}.
*
* @param throwable the Throwable to possibly propagate
* @param declaredType1 any checked exception type declared by the calling method
@@ -235,10 +216,11 @@ public final class Throwables {
* @param throwable the Throwable to propagate
* @return nothing will ever be returned; this return type is only for your convenience, as
* illustrated in the example above
- * @deprecated Use {@code throw e} or {@code throw new RuntimeException(e)} directly, or use a
- * combination of {@link #throwIfUnchecked} and {@code throw new RuntimeException(e)}. For
- * background on the deprecation, read <a href="https://goo.gl/Ivn2kc">Why we deprecated
- * {@code Throwables.propagate}</a>.
+ * @deprecated To preserve behavior, use {@code throw e} or {@code throw new RuntimeException(e)}
+ * directly, or use a combination of {@link #throwIfUnchecked} and {@code throw new
+ * RuntimeException(e)}. But consider whether users would be better off if your API threw a
+ * different type of exception. For background on the deprecation, read <a
+ * href="https://goo.gl/Ivn2kc">Why we deprecated {@code Throwables.propagate}</a>.
*/
@CanIgnoreReturnValue
@J2ktIncompatible
diff --git a/guava/src/com/google/common/base/internal/Finalizer.java b/guava/src/com/google/common/base/internal/Finalizer.java
index b45ec1578..e8ddf320c 100644
--- a/guava/src/com/google/common/base/internal/Finalizer.java
+++ b/guava/src/com/google/common/base/internal/Finalizer.java
@@ -153,41 +153,62 @@ public class Finalizer implements Runnable {
}
/**
- * Cleans up a single reference. Catches and logs all throwables.
+ * Cleans up the given reference and any other references already in the queue. Catches and logs
+ * all throwables.
*
- * @return true if the caller should continue, false if the associated FinalizableReferenceQueue
- * is no longer referenced.
+ * @return true if the caller should continue to wait for more references to be added to the
+ * queue, false if the associated FinalizableReferenceQueue is no longer referenced.
*/
- private boolean cleanUp(Reference<?> reference) {
+ private boolean cleanUp(Reference<?> firstReference) {
Method finalizeReferentMethod = getFinalizeReferentMethod();
if (finalizeReferentMethod == null) {
return false;
}
- do {
- /*
- * This is for the benefit of phantom references. Weak and soft references will have already
- * been cleared by this point.
- */
- reference.clear();
- if (reference == frqReference) {
- /*
- * The client no longer has a reference to the FinalizableReferenceQueue. We can stop.
- */
+ if (!finalizeReference(firstReference, finalizeReferentMethod)) {
+ return false;
+ }
+
+ /*
+ * Loop as long as we have references available so as not to waste CPU looking up the Method
+ * over and over again.
+ */
+ while (true) {
+ Reference<?> furtherReference = queue.poll();
+ if (furtherReference == null) {
+ return true;
+ }
+ if (!finalizeReference(furtherReference, finalizeReferentMethod)) {
return false;
}
+ }
+ }
- try {
- finalizeReferentMethod.invoke(reference);
- } catch (Throwable t) {
- logger.log(Level.SEVERE, "Error cleaning up after reference.", t);
- }
+ /**
+ * Cleans up the given reference. Catches and logs all throwables.
+ *
+ * @return true if the caller should continue to clean up references from the queue, false if the
+ * associated FinalizableReferenceQueue is no longer referenced.
+ */
+ private boolean finalizeReference(Reference<?> reference, Method finalizeReferentMethod) {
+ /*
+ * This is for the benefit of phantom references. Weak and soft references will have already
+ * been cleared by this point.
+ */
+ reference.clear();
+ if (reference == frqReference) {
/*
- * Loop as long as we have references available so as not to waste CPU looking up the Method
- * over and over again.
+ * The client no longer has a reference to the FinalizableReferenceQueue. We can stop.
*/
- } while ((reference = queue.poll()) != null);
+ return false;
+ }
+
+ try {
+ finalizeReferentMethod.invoke(reference);
+ } catch (Throwable t) {
+ logger.log(Level.SEVERE, "Error cleaning up after reference.", t);
+ }
return true;
}
diff --git a/guava/src/com/google/common/cache/CacheBuilder.java b/guava/src/com/google/common/cache/CacheBuilder.java
index bbb2b185b..6a964a290 100644
--- a/guava/src/com/google/common/cache/CacheBuilder.java
+++ b/guava/src/com/google/common/cache/CacheBuilder.java
@@ -569,8 +569,8 @@ public final class CacheBuilder<K, V> {
*
* @param weigher the weigher to use in calculating the weight of cache entries
* @return this {@code CacheBuilder} instance (for chaining)
- * @throws IllegalArgumentException if {@code size} is negative
- * @throws IllegalStateException if a maximum size was already set
+ * @throws IllegalStateException if a weigher was already set or {@link #maximumSize} was
+ * previously called
* @since 11.0
*/
@GwtIncompatible // To be supported
diff --git a/guava/src/com/google/common/cache/LocalCache.java b/guava/src/com/google/common/cache/LocalCache.java
index 00fb43575..dd3590357 100644
--- a/guava/src/com/google/common/cache/LocalCache.java
+++ b/guava/src/com/google/common/cache/LocalCache.java
@@ -281,7 +281,8 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
// will result in random eviction behavior.
int segmentShift = 0;
int segmentCount = 1;
- while (segmentCount < concurrencyLevel && (!evictsBySize() || segmentCount * 20 <= maxWeight)) {
+ while (segmentCount < concurrencyLevel
+ && (!evictsBySize() || segmentCount * 20L <= maxWeight)) {
++segmentShift;
segmentCount <<= 1;
}
@@ -2183,12 +2184,7 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
if (createNewEntry) {
try {
- // Synchronizes on the entry to allow failing fast when a recursive load is
- // detected. This may be circumvented when an entry is copied, but will fail fast most
- // of the time.
- synchronized (e) {
- return loadSync(key, hash, loadingValueReference, loader);
- }
+ return loadSync(key, hash, loadingValueReference, loader);
} finally {
statsCounter.recordMisses(1);
}
@@ -2204,7 +2200,22 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
throw new AssertionError();
}
- checkState(!Thread.holdsLock(e), "Recursive load of: %s", key);
+ // As of this writing, the only prod ValueReference implementation for which isLoading() is
+ // true is LoadingValueReference. (Note, however, that not all LoadingValueReference instances
+ // have isLoading()==true: LoadingValueReference has a subclass, ComputingValueReference, for
+ // which isLoading() is false!) However, that might change, and we already have a *test*
+ // implementation for which it doesn't hold. So we check instanceof to be safe.
+ if (valueReference instanceof LoadingValueReference) {
+ // We check whether the thread that is loading the entry is our current thread, which would
+ // mean that we are both loading and waiting for the entry. In this case, we fail fast
+ // instead of deadlocking.
+ checkState(
+ ((LoadingValueReference<K, V>) valueReference).getLoadingThread()
+ != Thread.currentThread(),
+ "Recursive load of: %s",
+ key);
+ }
+
// don't consider expiration as we're concurrent with loading
try {
V value = valueReference.waitForValue();
@@ -2220,7 +2231,11 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
}
}
- V compute(K key, int hash, BiFunction<? super K, ? super @Nullable V, ? extends V> function) {
+ @CheckForNull
+ V compute(
+ K key,
+ int hash,
+ BiFunction<? super K, ? super @Nullable V, ? extends @Nullable V> function) {
ReferenceEntry<K, V> e;
ValueReference<K, V> valueReference = null;
ComputingValueReference<K, V> computingValueReference = null;
@@ -3512,12 +3527,15 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
final SettableFuture<V> futureValue = SettableFuture.create();
final Stopwatch stopwatch = Stopwatch.createUnstarted();
+ final Thread loadingThread;
+
public LoadingValueReference() {
this(null);
}
- public LoadingValueReference(ValueReference<K, V> oldValue) {
+ public LoadingValueReference(@CheckForNull ValueReference<K, V> oldValue) {
this.oldValue = (oldValue == null) ? LocalCache.unset() : oldValue;
+ this.loadingThread = Thread.currentThread();
}
@Override
@@ -3593,7 +3611,9 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
}
}
- public V compute(K key, BiFunction<? super K, ? super @Nullable V, ? extends V> function) {
+ @CheckForNull
+ public V compute(
+ K key, BiFunction<? super K, ? super @Nullable V, ? extends @Nullable V> function) {
stopwatch.start();
V previousValue;
try {
@@ -3640,6 +3660,10 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
ReferenceQueue<V> queue, @CheckForNull V value, ReferenceEntry<K, V> entry) {
return this;
}
+
+ Thread getLoadingThread() {
+ return this.loadingThread;
+ }
}
static class ComputingValueReference<K, V> extends LoadingValueReference<K, V> {
@@ -4255,7 +4279,9 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
}
@Override
- public V compute(K key, BiFunction<? super K, ? super @Nullable V, ? extends V> function) {
+ @CheckForNull
+ public V compute(
+ K key, BiFunction<? super K, ? super @Nullable V, ? extends @Nullable V> function) {
checkNotNull(key);
checkNotNull(function);
int hash = hash(key);
@@ -4270,7 +4296,9 @@ class LocalCache<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K, V>
}
@Override
- public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> function) {
+ @CheckForNull
+ public V computeIfPresent(
+ K key, BiFunction<? super K, ? super V, ? extends @Nullable V> function) {
checkNotNull(key);
checkNotNull(function);
return compute(key, (k, oldValue) -> (oldValue == null) ? null : function.apply(k, oldValue));
diff --git a/guava/src/com/google/common/collect/AbstractBiMap.java b/guava/src/com/google/common/collect/AbstractBiMap.java
index 0563ea0e8..fab709a54 100644
--- a/guava/src/com/google/common/collect/AbstractBiMap.java
+++ b/guava/src/com/google/common/collect/AbstractBiMap.java
@@ -19,6 +19,7 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -502,7 +503,7 @@ abstract class AbstractBiMap<K extends @Nullable Object, V extends @Nullable Obj
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- setInverse((AbstractBiMap<V, K>) stream.readObject());
+ setInverse((AbstractBiMap<V, K>) requireNonNull(stream.readObject()));
}
@GwtIncompatible // Not needed in the emulated source.
diff --git a/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java b/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
index 1e48281bf..d9108f16c 100644
--- a/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
+++ b/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
@@ -1063,7 +1063,7 @@ abstract class AbstractMapBasedMultimap<K extends @Nullable Object, V extends @N
}
@WeakOuter
- class NavigableKeySet extends SortedKeySet implements NavigableSet<K> {
+ private final class NavigableKeySet extends SortedKeySet implements NavigableSet<K> {
NavigableKeySet(NavigableMap<K, Collection<V>> subMap) {
super(subMap);
}
@@ -1552,7 +1552,7 @@ abstract class AbstractMapBasedMultimap<K extends @Nullable Object, V extends @N
}
}
- class NavigableAsMap extends SortedAsMap implements NavigableMap<K, Collection<V>> {
+ private final class NavigableAsMap extends SortedAsMap implements NavigableMap<K, Collection<V>> {
NavigableAsMap(NavigableMap<K, Collection<V>> submap) {
super(submap);
diff --git a/guava/src/com/google/common/collect/CartesianList.java b/guava/src/com/google/common/collect/CartesianList.java
index 4c31b1299..a93fb032f 100644
--- a/guava/src/com/google/common/collect/CartesianList.java
+++ b/guava/src/com/google/common/collect/CartesianList.java
@@ -17,6 +17,8 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkElementIndex;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.math.IntMath;
import java.util.AbstractList;
import java.util.List;
@@ -132,6 +134,15 @@ final class CartesianList<E> extends AbstractList<List<E>> implements RandomAcce
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @J2ktIncompatible // serialization
+ @Override
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
diff --git a/guava/src/com/google/common/collect/CollectCollectors.java b/guava/src/com/google/common/collect/CollectCollectors.java
index e0982ab0f..2b23bd25a 100644
--- a/guava/src/com/google/common/collect/CollectCollectors.java
+++ b/guava/src/com/google/common/collect/CollectCollectors.java
@@ -195,14 +195,13 @@ final class CollectCollectors {
ImmutableMap.Builder<K, V>::new,
(builder, input) -> builder.put(keyFunction.apply(input), valueFunction.apply(input)),
ImmutableMap.Builder::combine,
- ImmutableMap.Builder::build);
+ ImmutableMap.Builder::buildOrThrow);
}
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction) {
+ static <T extends @Nullable Object, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
checkNotNull(keyFunction);
checkNotNull(valueFunction);
checkNotNull(mergeFunction);
@@ -227,7 +226,7 @@ final class CollectCollectors {
() -> new ImmutableSortedMap.Builder<K, V>(comparator),
(builder, input) -> builder.put(keyFunction.apply(input), valueFunction.apply(input)),
ImmutableSortedMap.Builder::combine,
- ImmutableSortedMap.Builder::build,
+ ImmutableSortedMap.Builder::buildOrThrow,
Collector.Characteristics.UNORDERED);
}
@@ -256,7 +255,7 @@ final class CollectCollectors {
ImmutableBiMap.Builder<K, V>::new,
(builder, input) -> builder.put(keyFunction.apply(input), valueFunction.apply(input)),
ImmutableBiMap.Builder::combine,
- ImmutableBiMap.Builder::build,
+ ImmutableBiMap.Builder::buildOrThrow,
new Collector.Characteristics[0]);
}
@@ -464,4 +463,6 @@ final class CollectCollectors {
return multimap1;
});
}
+
+ private CollectCollectors() {}
}
diff --git a/guava/src/com/google/common/collect/ConcurrentHashMultiset.java b/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
index 723ab0696..a84e3cee7 100644
--- a/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
+++ b/guava/src/com/google/common/collect/ConcurrentHashMultiset.java
@@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
@@ -599,7 +600,7 @@ public final class ConcurrentHashMultiset<E> extends AbstractMultiset<E> impleme
stream.defaultReadObject();
@SuppressWarnings("unchecked") // reading data stored by writeObject
ConcurrentMap<E, Integer> deserializedCountMap =
- (ConcurrentMap<E, Integer>) stream.readObject();
+ (ConcurrentMap<E, Integer>) requireNonNull(stream.readObject());
FieldSettersHolder.COUNT_MAP_FIELD_SETTER.set(this, deserializedCountMap);
}
diff --git a/guava/src/com/google/common/collect/ContiguousSet.java b/guava/src/com/google/common/collect/ContiguousSet.java
index d0792054e..539c67383 100644
--- a/guava/src/com/google/common/collect/ContiguousSet.java
+++ b/guava/src/com/google/common/collect/ContiguousSet.java
@@ -20,6 +20,7 @@ import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.DoNotCall;
import java.util.Collections;
import java.util.NoSuchElementException;
@@ -259,4 +260,13 @@ public abstract class ContiguousSet<C extends Comparable> extends ImmutableSorte
public static <E> ImmutableSortedSet.Builder<E> builder() {
throw new UnsupportedOperationException();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @J2ktIncompatible // serialization
+ @Override
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/DenseImmutableTable.java b/guava/src/com/google/common/collect/DenseImmutableTable.java
index 9de77c57f..a8e96e382 100644
--- a/guava/src/com/google/common/collect/DenseImmutableTable.java
+++ b/guava/src/com/google/common/collect/DenseImmutableTable.java
@@ -17,6 +17,8 @@ package com.google.common.collect;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.collect.ImmutableMap.IteratorBasedImmutableMap;
import com.google.errorprone.annotations.Immutable;
import com.google.j2objc.annotations.WeakOuter;
@@ -144,6 +146,15 @@ final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
}
};
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @J2ktIncompatible // serialization
+ @Override
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
private final class Row extends ImmutableArrayMap<C, V> {
@@ -169,6 +180,15 @@ final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
private final class Column extends ImmutableArrayMap<R, V> {
@@ -194,6 +214,15 @@ final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@WeakOuter
@@ -216,6 +245,15 @@ final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
boolean isPartialView() {
return false;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@WeakOuter
@@ -238,6 +276,15 @@ final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
boolean isPartialView() {
return false;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@Override
@@ -285,7 +332,9 @@ final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
}
@Override
- SerializedForm createSerializedForm() {
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
return SerializedForm.create(this, cellRowIndices, cellColumnIndices);
}
}
diff --git a/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java b/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java
index 181731cc4..931c3e72c 100644
--- a/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java
+++ b/guava/src/com/google/common/collect/DescendingImmutableSortedMultiset.java
@@ -15,6 +15,7 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import javax.annotation.CheckForNull;
/**
@@ -83,4 +84,12 @@ final class DescendingImmutableSortedMultiset<E> extends ImmutableSortedMultiset
boolean isPartialView() {
return forward.isPartialView();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java b/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java
index 88c7d6b5c..10b3fa866 100644
--- a/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java
+++ b/guava/src/com/google/common/collect/DescendingImmutableSortedSet.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import javax.annotation.CheckForNull;
/**
@@ -121,4 +122,12 @@ final class DescendingImmutableSortedSet<E> extends ImmutableSortedSet<E> {
boolean isPartialView() {
return forward.isPartialView();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/EnumBiMap.java b/guava/src/com/google/common/collect/EnumBiMap.java
index c4b540b56..b7d297272 100644
--- a/guava/src/com/google/common/collect/EnumBiMap.java
+++ b/guava/src/com/google/common/collect/EnumBiMap.java
@@ -19,6 +19,7 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Platform.getDeclaringClassOrObjectForJ2cl;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -151,8 +152,8 @@ public final class EnumBiMap<K extends Enum<K>, V extends Enum<V>> extends Abstr
@GwtIncompatible // java.io.ObjectInputStream
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- keyTypeOrObjectUnderJ2cl = (Class<K>) stream.readObject();
- valueTypeOrObjectUnderJ2cl = (Class<V>) stream.readObject();
+ keyTypeOrObjectUnderJ2cl = (Class<K>) requireNonNull(stream.readObject());
+ valueTypeOrObjectUnderJ2cl = (Class<V>) requireNonNull(stream.readObject());
setDelegates(
new EnumMap<K, V>(keyTypeOrObjectUnderJ2cl), new EnumMap<V, K>(valueTypeOrObjectUnderJ2cl));
Serialization.populateMap(this, stream);
diff --git a/guava/src/com/google/common/collect/EnumHashBiMap.java b/guava/src/com/google/common/collect/EnumHashBiMap.java
index 33b45b95c..c7432d404 100644
--- a/guava/src/com/google/common/collect/EnumHashBiMap.java
+++ b/guava/src/com/google/common/collect/EnumHashBiMap.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -128,7 +129,7 @@ public final class EnumHashBiMap<K extends Enum<K>, V extends @Nullable Object>
@GwtIncompatible // java.io.ObjectInputStream
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- keyTypeOrObjectUnderJ2cl = (Class<K>) stream.readObject();
+ keyTypeOrObjectUnderJ2cl = (Class<K>) requireNonNull(stream.readObject());
/*
* TODO: cpovirk - Pre-size the HashMap based on the number of enum values? (But *not* based on
* the number of entries in the map, as that makes it easy for hostile inputs to trigger lots of
diff --git a/guava/src/com/google/common/collect/EnumMultiset.java b/guava/src/com/google/common/collect/EnumMultiset.java
index d6ced718b..04126f8aa 100644
--- a/guava/src/com/google/common/collect/EnumMultiset.java
+++ b/guava/src/com/google/common/collect/EnumMultiset.java
@@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static com.google.common.collect.CollectPreconditions.checkRemove;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -309,7 +310,7 @@ public final class EnumMultiset<E extends Enum<E>> extends AbstractMultiset<E>
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
@SuppressWarnings("unchecked") // reading data stored by writeObject
- Class<E> localType = (Class<E>) stream.readObject();
+ Class<E> localType = (Class<E>) requireNonNull(stream.readObject());
type = localType;
enumConstants = type.getEnumConstants();
counts = new int[enumConstants.length];
diff --git a/guava/src/com/google/common/collect/HashBiMap.java b/guava/src/com/google/common/collect/HashBiMap.java
index f6ce5d42b..066056774 100644
--- a/guava/src/com/google/common/collect/HashBiMap.java
+++ b/guava/src/com/google/common/collect/HashBiMap.java
@@ -90,7 +90,7 @@ public final class HashBiMap<K extends @Nullable Object, V extends @Nullable Obj
return bimap;
}
- private static final class BiEntry<K extends @Nullable Object, V extends @Nullable Object>
+ static final class BiEntry<K extends @Nullable Object, V extends @Nullable Object>
extends ImmutableEntry<K, V> {
final int keyHash;
final int valueHash;
@@ -438,7 +438,7 @@ public final class HashBiMap<K extends @Nullable Object, V extends @Nullable Obj
return size;
}
- abstract class Itr<T extends @Nullable Object> implements Iterator<T> {
+ private abstract class Itr<T extends @Nullable Object> implements Iterator<T> {
@CheckForNull BiEntry<K, V> next = firstInKeyInsertionOrder;
@CheckForNull BiEntry<K, V> toRemove = null;
int expectedModCount = modCount;
@@ -531,7 +531,7 @@ public final class HashBiMap<K extends @Nullable Object, V extends @Nullable Obj
}
class MapEntry extends AbstractMapEntry<K, V> {
- BiEntry<K, V> delegate;
+ private BiEntry<K, V> delegate;
MapEntry(BiEntry<K, V> entry) {
this.delegate = entry;
@@ -708,7 +708,7 @@ public final class HashBiMap<K extends @Nullable Object, V extends @Nullable Obj
}
class InverseEntry extends AbstractMapEntry<V, K> {
- BiEntry<K, V> delegate;
+ private BiEntry<K, V> delegate;
InverseEntry(BiEntry<K, V> entry) {
this.delegate = entry;
diff --git a/guava/src/com/google/common/collect/ImmutableBiMap.java b/guava/src/com/google/common/collect/ImmutableBiMap.java
index c0d3ed715..f1777e62e 100644
--- a/guava/src/com/google/common/collect/ImmutableBiMap.java
+++ b/guava/src/com/google/common/collect/ImmutableBiMap.java
@@ -30,6 +30,7 @@ import java.io.ObjectInputStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
+import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
@@ -45,8 +46,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*/
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
-public abstract class ImmutableBiMap<K, V> extends ImmutableBiMapFauxverideShim<K, V>
- implements BiMap<K, V> {
+public abstract class ImmutableBiMap<K, V> extends ImmutableMap<K, V> implements BiMap<K, V> {
/**
* Returns a {@link Collector} that accumulates elements into an {@code ImmutableBiMap} whose keys
@@ -642,4 +642,40 @@ public abstract class ImmutableBiMap<K, V> extends ImmutableBiMapFauxverideShim<
private void readObject(ObjectInputStream stream) throws InvalidObjectException {
throw new InvalidObjectException("Use SerializedForm");
}
+
+ /**
+ * Not supported. Use {@link #toImmutableBiMap} instead. This method exists only to hide {@link
+ * ImmutableMap#toImmutableMap(Function, Function)} from consumers of {@code ImmutableBiMap}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableBiMap#toImmutableBiMap}.
+ */
+ @Deprecated
+ @DoNotCall("Use toImmutableBiMap")
+ public static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. This method does not make sense for {@code BiMap}. This method exists only to
+ * hide {@link ImmutableMap#toImmutableMap(Function, Function, BinaryOperator)} from consumers of
+ * {@code ImmutableBiMap}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated
+ */
+ @Deprecated
+ @DoNotCall("Use toImmutableBiMap")
+ public static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ throw new UnsupportedOperationException();
+ }
+
+ private static final long serialVersionUID = 0xcafebabe;
}
diff --git a/guava/src/com/google/common/collect/ImmutableBiMapFauxverideShim.java b/guava/src/com/google/common/collect/ImmutableBiMapFauxverideShim.java
deleted file mode 100644
index 2f1f25c82..000000000
--- a/guava/src/com/google/common/collect/ImmutableBiMapFauxverideShim.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2015 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.collect;
-
-import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
-import java.util.function.BinaryOperator;
-import java.util.function.Function;
-import java.util.stream.Collector;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/**
- * "Overrides" the {@link ImmutableMap} static methods that lack {@link ImmutableBiMap} equivalents
- * with deprecated, exception-throwing versions. See {@link ImmutableSortedSetFauxverideShim} for
- * details.
- *
- * @author Louis Wasserman
- */
-@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-abstract class ImmutableBiMapFauxverideShim<K, V> extends ImmutableMap<K, V> {
- /**
- * Not supported. Use {@link ImmutableBiMap#toImmutableBiMap} instead. This method exists only to
- * hide {@link ImmutableMap#toImmutableMap(Function, Function)} from consumers of {@code
- * ImmutableBiMap}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Use {@link ImmutableBiMap#toImmutableBiMap}.
- */
- @Deprecated
- @DoNotCall("Use toImmutableBiMap")
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. This method does not make sense for {@code BiMap}. This method exists only to
- * hide {@link ImmutableMap#toImmutableMap(Function, Function, BinaryOperator)} from consumers of
- * {@code ImmutableBiMap}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated
- */
- @Deprecated
- @DoNotCall("Use toImmutableBiMap")
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/guava/src/com/google/common/collect/ImmutableCollection.java b/guava/src/com/google/common/collect/ImmutableCollection.java
index 68b175ffa..ee18f0d9c 100644
--- a/guava/src/com/google/common/collect/ImmutableCollection.java
+++ b/guava/src/com/google/common/collect/ImmutableCollection.java
@@ -19,6 +19,7 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotCall;
@@ -392,6 +393,7 @@ public abstract class ImmutableCollection<E> extends AbstractCollection<E> imple
}
@J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
Object writeReplace() {
// We serialize by default to ImmutableList, the simplest thing that works.
return new ImmutableList.SerializedForm(toArray());
@@ -504,4 +506,6 @@ public abstract class ImmutableCollection<E> extends AbstractCollection<E> imple
*/
public abstract ImmutableCollection<E> build();
}
+
+ private static final long serialVersionUID = 0xcafebabe;
}
diff --git a/guava/src/com/google/common/collect/ImmutableList.java b/guava/src/com/google/common/collect/ImmutableList.java
index 9c60caf3f..7c7801dbc 100644
--- a/guava/src/com/google/common/collect/ImmutableList.java
+++ b/guava/src/com/google/common/collect/ImmutableList.java
@@ -26,6 +26,7 @@ import static com.google.common.collect.RegularImmutableList.EMPTY;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -444,6 +445,12 @@ public abstract class ImmutableList<E> extends ImmutableCollection<E>
* Returns an immutable list of the elements between the specified {@code fromIndex}, inclusive,
* and {@code toIndex}, exclusive. (If {@code fromIndex} and {@code toIndex} are equal, the empty
* immutable list is returned.)
+ *
+ * <p><b>Note:</b> in almost all circumstances, the returned {@link ImmutableList} retains a
+ * strong reference to {@code this}, which may prevent the original list from being garbage
+ * collected. If you want the original list to be eligible for garbage collection, you should
+ * create and use a copy of the sub list (e.g., {@code
+ * ImmutableList.copyOf(originalList.subList(...))}).
*/
@Override
public ImmutableList<E> subList(int fromIndex, int toIndex) {
@@ -498,6 +505,15 @@ public abstract class ImmutableList<E> extends ImmutableCollection<E>
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
/**
@@ -678,6 +694,15 @@ public abstract class ImmutableList<E> extends ImmutableCollection<E>
boolean isPartialView() {
return forwardList.isPartialView();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@Override
@@ -724,6 +749,7 @@ public abstract class ImmutableList<E> extends ImmutableCollection<E>
@Override
@J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
Object writeReplace() {
return new SerializedForm(toArray());
}
@@ -901,4 +927,6 @@ public abstract class ImmutableList<E> extends ImmutableCollection<E>
return asImmutableList(contents, size);
}
}
+
+ private static final long serialVersionUID = 0xcafebabe;
}
diff --git a/guava/src/com/google/common/collect/ImmutableListMultimap.java b/guava/src/com/google/common/collect/ImmutableListMultimap.java
index b46e7ae40..e70927484 100644
--- a/guava/src/com/google/common/collect/ImmutableListMultimap.java
+++ b/guava/src/com/google/common/collect/ImmutableListMultimap.java
@@ -16,6 +16,8 @@
package com.google.common.collect;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
@@ -473,7 +475,7 @@ public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V>
int tmpSize = 0;
for (int i = 0; i < keyCount; i++) {
- Object key = stream.readObject();
+ Object key = requireNonNull(stream.readObject());
int valueCount = stream.readInt();
if (valueCount <= 0) {
throw new InvalidObjectException("Invalid value count " + valueCount);
@@ -481,7 +483,7 @@ public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V>
ImmutableList.Builder<Object> valuesBuilder = ImmutableList.builder();
for (int j = 0; j < valueCount; j++) {
- valuesBuilder.add(stream.readObject());
+ valuesBuilder.add(requireNonNull(stream.readObject()));
}
builder.put(key, valuesBuilder.build());
tmpSize += valueCount;
diff --git a/guava/src/com/google/common/collect/ImmutableMap.java b/guava/src/com/google/common/collect/ImmutableMap.java
index c370e5248..7a185b5d3 100644
--- a/guava/src/com/google/common/collect/ImmutableMap.java
+++ b/guava/src/com/google/common/collect/ImmutableMap.java
@@ -23,6 +23,7 @@ import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -96,8 +97,11 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
* and values are the result of applying the provided mapping functions to the input elements.
*
* <p>If the mapped keys contain duplicates (according to {@link Object#equals(Object)}), the
- * values are merged using the specified merging function. Entries will appear in the encounter
- * order of the first occurrence of the key.
+ * values are merged using the specified merging function. If the merging function returns {@code
+ * null}, then the collector removes the value that has been computed for the key thus far (though
+ * future occurrences of the key would reinsert it).
+ *
+ * <p>Entries will appear in the encounter order of the first occurrence of the key.
*
* @since 21.0
*/
@@ -754,6 +758,15 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
public UnmodifiableIterator<Entry<K, V>> iterator() {
return entryIterator();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
return new EntrySetImpl();
}
@@ -762,6 +775,15 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
ImmutableCollection<V> createValues() {
return new ImmutableMapValues<>(this);
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
ImmutableMap() {}
@@ -845,8 +867,9 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
@Deprecated
@Override
@DoNotCall("Always throws UnsupportedOperationException")
+ @CheckForNull
public final V computeIfPresent(
- K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
+ K key, BiFunction<? super K, ? super V, ? extends @Nullable V> remappingFunction) {
throw new UnsupportedOperationException();
}
@@ -859,8 +882,9 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
@Deprecated
@Override
@DoNotCall("Always throws UnsupportedOperationException")
+ @CheckForNull
public final V compute(
- K key, BiFunction<? super K, ? super @Nullable V, ? extends V> remappingFunction) {
+ K key, BiFunction<? super K, ? super @Nullable V, ? extends @Nullable V> remappingFunction) {
throw new UnsupportedOperationException();
}
@@ -1165,6 +1189,15 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
}
};
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@Override
@@ -1282,4 +1315,6 @@ public abstract class ImmutableMap<K, V> implements Map<K, V>, Serializable {
private void readObject(ObjectInputStream stream) throws InvalidObjectException {
throw new InvalidObjectException("Use SerializedForm");
}
+
+ private static final long serialVersionUID = 0xcafebabe;
}
diff --git a/guava/src/com/google/common/collect/ImmutableMapEntrySet.java b/guava/src/com/google/common/collect/ImmutableMapEntrySet.java
index 46df158b0..19f75cbbb 100644
--- a/guava/src/com/google/common/collect/ImmutableMapEntrySet.java
+++ b/guava/src/com/google/common/collect/ImmutableMapEntrySet.java
@@ -80,6 +80,15 @@ abstract class ImmutableMapEntrySet<K, V> extends ImmutableSet.CachingAsList<Ent
ImmutableList<Entry<K, V>> createAsList() {
return new RegularImmutableAsList<>(this, entries);
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
ImmutableMapEntrySet() {}
diff --git a/guava/src/com/google/common/collect/ImmutableMapKeySet.java b/guava/src/com/google/common/collect/ImmutableMapKeySet.java
index 6d1b51671..fb2661f47 100644
--- a/guava/src/com/google/common/collect/ImmutableMapKeySet.java
+++ b/guava/src/com/google/common/collect/ImmutableMapKeySet.java
@@ -77,6 +77,15 @@ final class ImmutableMapKeySet<K, V> extends IndexedImmutableSet<K> {
return true;
}
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
+
// No longer used for new writes, but kept so that old data can still be read.
@GwtIncompatible // serialization
@J2ktIncompatible
diff --git a/guava/src/com/google/common/collect/ImmutableMapValues.java b/guava/src/com/google/common/collect/ImmutableMapValues.java
index 8884c1af6..831364599 100644
--- a/guava/src/com/google/common/collect/ImmutableMapValues.java
+++ b/guava/src/com/google/common/collect/ImmutableMapValues.java
@@ -92,6 +92,15 @@ final class ImmutableMapValues<K, V> extends ImmutableCollection<V> {
ImmutableCollection<V> delegateCollection() {
return ImmutableMapValues.this;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
@@ -102,6 +111,15 @@ final class ImmutableMapValues<K, V> extends ImmutableCollection<V> {
map.forEach((k, v) -> action.accept(v));
}
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
+
// No longer used for new writes, but kept so that old data can still be read.
@GwtIncompatible // serialization
@J2ktIncompatible
diff --git a/guava/src/com/google/common/collect/ImmutableMultimap.java b/guava/src/com/google/common/collect/ImmutableMultimap.java
index f1f654645..02dbd5e67 100644
--- a/guava/src/com/google/common/collect/ImmutableMultimap.java
+++ b/guava/src/com/google/common/collect/ImmutableMultimap.java
@@ -578,6 +578,15 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V
return false;
}
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
+
private static final long serialVersionUID = 0;
}
@@ -781,6 +790,15 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V
return true;
}
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
+
@J2ktIncompatible // serialization
private static final long serialVersionUID = 0;
}
diff --git a/guava/src/com/google/common/collect/ImmutableMultiset.java b/guava/src/com/google/common/collect/ImmutableMultiset.java
index cdc9f405a..f0197433f 100644
--- a/guava/src/com/google/common/collect/ImmutableMultiset.java
+++ b/guava/src/com/google/common/collect/ImmutableMultiset.java
@@ -630,6 +630,15 @@ public abstract class ImmutableMultiset<E> extends ImmutableMultisetGwtSerializa
public int size() {
return entries.size();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@J2ktIncompatible
@@ -660,4 +669,6 @@ public abstract class ImmutableMultiset<E> extends ImmutableMultisetGwtSerializa
private static final long serialVersionUID = 0;
}
+
+ private static final long serialVersionUID = 0xcafebabe;
}
diff --git a/guava/src/com/google/common/collect/ImmutableRangeMap.java b/guava/src/com/google/common/collect/ImmutableRangeMap.java
index 72444245f..88ad7d889 100644
--- a/guava/src/com/google/common/collect/ImmutableRangeMap.java
+++ b/guava/src/com/google/common/collect/ImmutableRangeMap.java
@@ -372,6 +372,14 @@ public class ImmutableRangeMap<K extends Comparable<?>, V> implements RangeMap<K
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
final ImmutableRangeMap<K, V> outer = this;
return new ImmutableRangeMap<K, V>(subRanges, values.subList(lowerIndex, upperIndex)) {
@@ -383,6 +391,14 @@ public class ImmutableRangeMap<K extends Comparable<?>, V> implements RangeMap<K
return ImmutableRangeMap.of();
}
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
diff --git a/guava/src/com/google/common/collect/ImmutableRangeSet.java b/guava/src/com/google/common/collect/ImmutableRangeSet.java
index afd421cd7..165b6e652 100644
--- a/guava/src/com/google/common/collect/ImmutableRangeSet.java
+++ b/guava/src/com/google/common/collect/ImmutableRangeSet.java
@@ -368,6 +368,14 @@ public final class ImmutableRangeSet<C extends Comparable> extends AbstractRange
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@Override
@@ -487,6 +495,15 @@ public final class ImmutableRangeSet<C extends Comparable> extends AbstractRange
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
}
diff --git a/guava/src/com/google/common/collect/ImmutableSet.java b/guava/src/com/google/common/collect/ImmutableSet.java
index f4912a328..eeed833bf 100644
--- a/guava/src/com/google/common/collect/ImmutableSet.java
+++ b/guava/src/com/google/common/collect/ImmutableSet.java
@@ -22,6 +22,7 @@ import static com.google.common.collect.CollectPreconditions.checkNonnegative;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.math.IntMath;
@@ -354,6 +355,15 @@ public abstract class ImmutableSet<E> extends ImmutableCollection<E> implements
ImmutableList<E> createAsList() {
return new RegularImmutableAsList<E>(this, toArray());
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
abstract static class Indexed<E> extends CachingAsList<E> {
@@ -395,8 +405,26 @@ public abstract class ImmutableSet<E> extends ImmutableCollection<E> implements
Indexed<E> delegateCollection() {
return Indexed.this;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
/*
@@ -989,4 +1017,6 @@ public abstract class ImmutableSet<E> extends ImmutableCollection<E> implements
}
}
}
+
+ private static final long serialVersionUID = 0xcafebabe;
}
diff --git a/guava/src/com/google/common/collect/ImmutableSetMultimap.java b/guava/src/com/google/common/collect/ImmutableSetMultimap.java
index 4887ae79b..b1f8438cd 100644
--- a/guava/src/com/google/common/collect/ImmutableSetMultimap.java
+++ b/guava/src/com/google/common/collect/ImmutableSetMultimap.java
@@ -17,6 +17,7 @@
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
@@ -552,6 +553,15 @@ public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V>
boolean isPartialView() {
return false;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
private static <V> ImmutableSet<V> valueSet(
@@ -615,7 +625,7 @@ public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V>
int tmpSize = 0;
for (int i = 0; i < keyCount; i++) {
- Object key = stream.readObject();
+ Object key = requireNonNull(stream.readObject());
int valueCount = stream.readInt();
if (valueCount <= 0) {
throw new InvalidObjectException("Invalid value count " + valueCount);
@@ -623,7 +633,7 @@ public class ImmutableSetMultimap<K, V> extends ImmutableMultimap<K, V>
ImmutableSet.Builder<Object> valuesBuilder = valuesBuilder(valueComparator);
for (int j = 0; j < valueCount; j++) {
- valuesBuilder.add(stream.readObject());
+ valuesBuilder.add(requireNonNull(stream.readObject()));
}
ImmutableSet<Object> valueSet = valuesBuilder.build();
if (valueSet.size() != valueCount) {
diff --git a/guava/src/com/google/common/collect/ImmutableSortedAsList.java b/guava/src/com/google/common/collect/ImmutableSortedAsList.java
index 30f19a02e..1736f2b8e 100644
--- a/guava/src/com/google/common/collect/ImmutableSortedAsList.java
+++ b/guava/src/com/google/common/collect/ImmutableSortedAsList.java
@@ -16,6 +16,7 @@ package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import java.util.Comparator;
import java.util.Spliterator;
import javax.annotation.CheckForNull;
@@ -93,4 +94,13 @@ final class ImmutableSortedAsList<E> extends RegularImmutableAsList<E>
delegateList()::get,
comparator());
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/ImmutableSortedMap.java b/guava/src/com/google/common/collect/ImmutableSortedMap.java
index f38922e43..ba0b91c95 100644
--- a/guava/src/com/google/common/collect/ImmutableSortedMap.java
+++ b/guava/src/com/google/common/collect/ImmutableSortedMap.java
@@ -23,6 +23,7 @@ import static com.google.common.collect.Maps.keyOrNull;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotCall;
@@ -64,7 +65,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*/
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
-public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxverideShim<K, V>
+public final class ImmutableSortedMap<K, V> extends ImmutableMap<K, V>
implements NavigableMap<K, V> {
/**
* Returns a {@link Collector} that accumulates elements into an {@code ImmutableSortedMap} whose
@@ -844,6 +845,15 @@ public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxveride
ImmutableCollection<Entry<K, V>> delegateCollection() {
return EntrySet.this;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
@@ -851,6 +861,15 @@ public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxveride
ImmutableMap<K, V> map() {
return ImmutableSortedMap.this;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
return isEmpty() ? ImmutableSet.<Entry<K, V>>of() : new EntrySet();
}
@@ -1167,4 +1186,290 @@ public final class ImmutableSortedMap<K, V> extends ImmutableSortedMapFauxveride
// This class is never actually serialized directly, but we have to make the
// warning go away (and suppressing would suppress for all nested classes too)
private static final long serialVersionUID = 0;
+
+ /**
+ * Not supported. Use {@link #toImmutableSortedMap}, which offers better type-safety, instead.
+ * This method exists only to hide {@link ImmutableMap#toImmutableMap} from consumers of {@code
+ * ImmutableSortedMap}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedMap#toImmutableSortedMap}.
+ */
+ @DoNotCall("Use toImmutableSortedMap")
+ @Deprecated
+ public static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. Use {@link #toImmutableSortedMap}, which offers better type-safety, instead.
+ * This method exists only to hide {@link ImmutableMap#toImmutableMap} from consumers of {@code
+ * ImmutableSortedMap}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedMap#toImmutableSortedMap}.
+ */
+ @DoNotCall("Use toImmutableSortedMap")
+ @Deprecated
+ public static <T extends @Nullable Object, K, V>
+ Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
+ Function<? super T, ? extends K> keyFunction,
+ Function<? super T, ? extends V> valueFunction,
+ BinaryOperator<V> mergeFunction) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. Use {@link #naturalOrder}, which offers better type-safety, instead. This method
+ * exists only to hide {@link ImmutableMap#builder} from consumers of {@code ImmutableSortedMap}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedMap#naturalOrder}, which offers better type-safety.
+ */
+ @DoNotCall("Use naturalOrder")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap.Builder<K, V> builder() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported for ImmutableSortedMap.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Not supported for ImmutableSortedMap.
+ */
+ @DoNotCall("Use naturalOrder (which does not accept an expected size)")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap.Builder<K, V> builderWithExpectedSize(int expectedSize) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain a non-{@code Comparable}
+ * key.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this dummy
+ * version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass a key of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass a key of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls to will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(
+ K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(
+ K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(
+ K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(
+ K k1,
+ V v1,
+ K k2,
+ V v2,
+ K k3,
+ V v3,
+ K k4,
+ V v4,
+ K k5,
+ V v5,
+ K k6,
+ V v6,
+ K k7,
+ V v7,
+ K k8,
+ V v8) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(
+ K k1,
+ V v1,
+ K k2,
+ V v2,
+ K k3,
+ V v3,
+ K k4,
+ V v4,
+ K k5,
+ V v5,
+ K k6,
+ V v6,
+ K k7,
+ V v7,
+ K k8,
+ V v8,
+ K k9,
+ V v9) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
+ * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
+ * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
+ * Comparable, Object, Comparable, Object)}.</b>
+ */
+ @DoNotCall("Pass keys of type Comparable")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> of(
+ K k1,
+ V v1,
+ K k2,
+ V v2,
+ K k3,
+ V v3,
+ K k4,
+ V v4,
+ K k5,
+ V v5,
+ K k6,
+ V v6,
+ K k7,
+ V v7,
+ K k8,
+ V v8,
+ K k9,
+ V v9,
+ K k10,
+ V v10) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
+ *
+ * @deprecated Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
+ */
+ @DoNotCall("ImmutableSortedMap.ofEntries not currently available; use ImmutableSortedMap.copyOf")
+ @Deprecated
+ public static <K, V> ImmutableSortedMap<K, V> ofEntries(
+ Entry<? extends K, ? extends V>... entries) {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java b/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java
deleted file mode 100644
index 7b2e4d755..000000000
--- a/guava/src/com/google/common/collect/ImmutableSortedMapFauxverideShim.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Copyright (C) 2009 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.collect;
-
-import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
-import java.util.function.BinaryOperator;
-import java.util.function.Function;
-import java.util.stream.Collector;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/**
- * "Overrides" the {@link ImmutableMap} static methods that lack {@link ImmutableSortedMap}
- * equivalents with deprecated, exception-throwing versions. See {@link
- * ImmutableSortedSetFauxverideShim} for details.
- *
- * @author Chris Povirk
- */
-@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-abstract class ImmutableSortedMapFauxverideShim<K, V> extends ImmutableMap<K, V> {
- /**
- * Not supported. Use {@link ImmutableSortedMap#toImmutableSortedMap}, which offers better
- * type-safety, instead. This method exists only to hide {@link ImmutableMap#toImmutableMap} from
- * consumers of {@code ImmutableSortedMap}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Use {@link ImmutableSortedMap#toImmutableSortedMap}.
- */
- @DoNotCall("Use toImmutableSortedMap")
- @Deprecated
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. Use {@link ImmutableSortedMap#toImmutableSortedMap}, which offers better
- * type-safety, instead. This method exists only to hide {@link ImmutableMap#toImmutableMap} from
- * consumers of {@code ImmutableSortedMap}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Use {@link ImmutableSortedMap#toImmutableSortedMap}.
- */
- @DoNotCall("Use toImmutableSortedMap")
- @Deprecated
- public static <T extends @Nullable Object, K, V>
- Collector<T, ?, ImmutableMap<K, V>> toImmutableMap(
- Function<? super T, ? extends K> keyFunction,
- Function<? super T, ? extends V> valueFunction,
- BinaryOperator<V> mergeFunction) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. Use {@link ImmutableSortedMap#naturalOrder}, which offers better type-safety,
- * instead. This method exists only to hide {@link ImmutableMap#builder} from consumers of {@code
- * ImmutableSortedMap}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Use {@link ImmutableSortedMap#naturalOrder}, which offers better type-safety.
- */
- @DoNotCall("Use naturalOrder")
- @Deprecated
- public static <K, V> ImmutableSortedMap.Builder<K, V> builder() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported for ImmutableSortedMap.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Not supported for ImmutableSortedMap.
- */
- @DoNotCall("Use naturalOrder (which does not accept an expected size)")
- @Deprecated
- public static <K, V> ImmutableSortedMap.Builder<K, V> builderWithExpectedSize(int expectedSize) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain a non-{@code Comparable}
- * key.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this dummy
- * version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass a key of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object)}.</b>
- */
- @DoNotCall("Pass a key of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls to will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a map that may contain non-{@code Comparable}
- * keys.</b> Proper calls will resolve to the version in {@code ImmutableSortedMap}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass keys of type {@code Comparable} to use {@link
- * ImmutableSortedMap#of(Comparable, Object, Comparable, Object, Comparable, Object,
- * Comparable, Object, Comparable, Object)}.</b>
- */
- @DoNotCall("Pass keys of type Comparable")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> of(
- K k1,
- V v1,
- K k2,
- V v2,
- K k3,
- V v3,
- K k4,
- V v4,
- K k5,
- V v5,
- K k6,
- V v6,
- K k7,
- V v7,
- K k8,
- V v8,
- K k9,
- V v9,
- K k10,
- V v10) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
- *
- * @deprecated Use {@code ImmutableSortedMap.copyOf(ImmutableMap.ofEntries(...))}.
- */
- @DoNotCall("ImmutableSortedMap.ofEntries not currently available; use ImmutableSortedMap.copyOf")
- @Deprecated
- public static <K, V> ImmutableSortedMap<K, V> ofEntries(
- Entry<? extends K, ? extends V>... entries) {
- throw new UnsupportedOperationException();
- }
-
- // No copyOf() fauxveride; see ImmutableSortedSetFauxverideShim.
-}
diff --git a/guava/src/com/google/common/collect/ImmutableSortedMultiset.java b/guava/src/com/google/common/collect/ImmutableSortedMultiset.java
index d2991bce9..454a77569 100644
--- a/guava/src/com/google/common/collect/ImmutableSortedMultiset.java
+++ b/guava/src/com/google/common/collect/ImmutableSortedMultiset.java
@@ -55,7 +55,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*/
@GwtIncompatible // hasn't been tested yet
@ElementTypesAreNonnullByDefault
-public abstract class ImmutableSortedMultiset<E> extends ImmutableSortedMultisetFauxverideShim<E>
+public abstract class ImmutableSortedMultiset<E> extends ImmutableMultiset<E>
implements SortedMultiset<E> {
// TODO(lowasser): GWT compatibility
@@ -606,4 +606,162 @@ public abstract class ImmutableSortedMultiset<E> extends ImmutableSortedMultiset
private void readObject(ObjectInputStream stream) throws InvalidObjectException {
throw new InvalidObjectException("Use SerializedForm");
}
+
+ /**
+ * Not supported. Use {@link #toImmutableSortedMultiset} instead. This method exists only to hide
+ * {@link ImmutableMultiset#toImmutableMultiset} from consumers of {@code
+ * ImmutableSortedMultiset}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset}.
+ * @since 21.0
+ */
+ @DoNotCall("Use toImmutableSortedMultiset.")
+ @Deprecated
+ public static <E> Collector<E, ?, ImmutableMultiset<E>> toImmutableMultiset() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. Use {@link #toImmutableSortedMultiset} instead. This method exists only to hide
+ * {@link ImmutableMultiset#toImmutableMultiset} from consumers of {@code
+ * ImmutableSortedMultiset}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset}.
+ * @since 22.0
+ */
+ @DoNotCall("Use toImmutableSortedMultiset.")
+ @Deprecated
+ public static <T extends @Nullable Object, E>
+ Collector<T, ?, ImmutableMultiset<E>> toImmutableMultiset(
+ Function<? super T, ? extends E> elementFunction,
+ ToIntFunction<? super T> countFunction) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. Use {@link #naturalOrder}, which offers better type-safety, instead. This method
+ * exists only to hide {@link ImmutableMultiset#builder} from consumers of {@code
+ * ImmutableSortedMultiset}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better type-safety.
+ */
+ @DoNotCall("Use naturalOrder.")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset.Builder<E> builder() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
+ * Comparable} element.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#of(Comparable)}.</b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset<E> of(E element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
+ * Comparable} element.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#of(Comparable, Comparable)}.</b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset<E> of(E e1, E e2) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
+ * Comparable} element.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable)}.</b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
+ * Comparable} element.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable)}. </b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
+ * Comparable} element.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable)} .
+ * </b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4, E e5) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
+ * Comparable} element.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable,
+ * Comparable, Comparable...)} . </b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ public static <E> ImmutableSortedMultiset<E> of(
+ E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a multiset that may contain non-{@code
+ * Comparable} elements.</b> Proper calls will resolve to the version in {@code
+ * ImmutableSortedMultiset}, not this dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedMultiset#copyOf(Comparable[])}.</b>
+ */
+ @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
+ @Deprecated
+ // The usage of "Z" here works around bugs in Javadoc (JDK-8318093) and JDiff.
+ public static <Z> ImmutableSortedMultiset<Z> copyOf(Z[] elements) {
+ throw new UnsupportedOperationException();
+ }
+
+ private static final long serialVersionUID = 0xcafebabe;
}
diff --git a/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java b/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java
deleted file mode 100644
index 94a2f560d..000000000
--- a/guava/src/com/google/common/collect/ImmutableSortedMultisetFauxverideShim.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (C) 2011 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.collect;
-
-import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
-import java.util.function.Function;
-import java.util.function.ToIntFunction;
-import java.util.stream.Collector;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/**
- * "Overrides" the {@link ImmutableMultiset} static methods that lack {@link
- * ImmutableSortedMultiset} equivalents with deprecated, exception-throwing versions. This prevents
- * accidents like the following:
- *
- * <pre>{@code
- * List<Object> objects = ...;
- * // Sort them:
- * Set<Object> sorted = ImmutableSortedMultiset.copyOf(objects);
- * // BAD CODE! The returned multiset is actually an unsorted ImmutableMultiset!
- * }</pre>
- *
- * <p>While we could put the overrides in {@link ImmutableSortedMultiset} itself, it seems clearer
- * to separate these "do not call" methods from those intended for normal use.
- *
- * @author Louis Wasserman
- */
-@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-abstract class ImmutableSortedMultisetFauxverideShim<E> extends ImmutableMultiset<E> {
- /**
- * Not supported. Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset} instead. This
- * method exists only to hide {@link ImmutableMultiset#toImmutableMultiset} from consumers of
- * {@code ImmutableSortedMultiset}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset}.
- * @since 21.0
- */
- @DoNotCall("Use toImmutableSortedMultiset.")
- @Deprecated
- public static <E> Collector<E, ?, ImmutableMultiset<E>> toImmutableMultiset() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset} instead. This
- * method exists only to hide {@link ImmutableMultiset#toImmutableMultiset} from consumers of
- * {@code ImmutableSortedMultiset}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Use {@link ImmutableSortedMultiset#toImmutableSortedMultiset}.
- * @since 22.0
- */
- @DoNotCall("Use toImmutableSortedMultiset.")
- @Deprecated
- public static <T extends @Nullable Object, E>
- Collector<T, ?, ImmutableMultiset<E>> toImmutableMultiset(
- Function<? super T, ? extends E> elementFunction,
- ToIntFunction<? super T> countFunction) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better
- * type-safety, instead. This method exists only to hide {@link ImmutableMultiset#builder} from
- * consumers of {@code ImmutableSortedMultiset}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Use {@link ImmutableSortedMultiset#naturalOrder}, which offers better type-safety.
- */
- @DoNotCall("Use naturalOrder.")
- @Deprecated
- public static <E> ImmutableSortedMultiset.Builder<E> builder() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
- * Comparable} element.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#of(Comparable)}.</b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> of(E element) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
- * Comparable} element.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#of(Comparable, Comparable)}.</b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> of(E e1, E e2) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
- * Comparable} element.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable)}.</b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
- * Comparable} element.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable)}. </b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
- * Comparable} element.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable)} .
- * </b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> of(E e1, E e2, E e3, E e4, E e5) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain a non-{@code
- * Comparable} element.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#of(Comparable, Comparable, Comparable, Comparable, Comparable,
- * Comparable, Comparable...)} . </b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> of(
- E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a multiset that may contain non-{@code
- * Comparable} elements.</b> Proper calls will resolve to the version in {@code
- * ImmutableSortedMultiset}, not this dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass parameters of type {@code Comparable} to use {@link
- * ImmutableSortedMultiset#copyOf(Comparable[])}.</b>
- */
- @DoNotCall("Elements must be Comparable. (Or, pass a Comparator to orderedBy or copyOf.)")
- @Deprecated
- public static <E> ImmutableSortedMultiset<E> copyOf(E[] elements) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * We would like to include an unsupported "<E> copyOf(Iterable<E>)" here, providing only the
- * properly typed "<E extends Comparable<E>> copyOf(Iterable<E>)" in ImmutableSortedMultiset (and
- * likewise for the Iterator equivalent). However, due to a change in Sun's interpretation of the
- * JLS (as described at http://bugs.sun.com/view_bug.do?bug_id=6182950), the OpenJDK 7 compiler
- * available as of this writing rejects our attempts. To maintain compatibility with that version
- * and with any other compilers that interpret the JLS similarly, there is no definition of
- * copyOf() here, and the definition in ImmutableSortedMultiset matches that in
- * ImmutableMultiset.
- *
- * The result is that ImmutableSortedMultiset.copyOf() may be called on non-Comparable elements.
- * We have not discovered a better solution. In retrospect, the static factory methods should
- * have gone in a separate class so that ImmutableSortedMultiset wouldn't "inherit"
- * too-permissive factory methods from ImmutableMultiset.
- */
-}
diff --git a/guava/src/com/google/common/collect/ImmutableSortedSet.java b/guava/src/com/google/common/collect/ImmutableSortedSet.java
index c730fa496..dc88e3983 100644
--- a/guava/src/com/google/common/collect/ImmutableSortedSet.java
+++ b/guava/src/com/google/common/collect/ImmutableSortedSet.java
@@ -64,7 +64,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
-public abstract class ImmutableSortedSet<E> extends ImmutableSortedSetFauxverideShim<E>
+public abstract class ImmutableSortedSet<E> extends ImmutableSet.CachingAsList<E>
implements NavigableSet<E>, SortedIterable<E> {
static final int SPLITERATOR_CHARACTERISTICS =
ImmutableSet.SPLITERATOR_CHARACTERISTICS | Spliterator.SORTED;
@@ -854,4 +854,153 @@ public abstract class ImmutableSortedSet<E> extends ImmutableSortedSetFauxveride
Object writeReplace() {
return new SerializedForm<E>(comparator, toArray());
}
+
+ /**
+ * Not supported. Use {@link #toImmutableSortedSet} instead. This method exists only to hide
+ * {@link ImmutableSet#toImmutableSet} from consumers of {@code ImmutableSortedSet}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedSet#toImmutableSortedSet}.
+ * @since 21.0
+ */
+ @DoNotCall("Use toImmutableSortedSet")
+ @Deprecated
+ public static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. Use {@link #naturalOrder}, which offers better type-safety, instead. This method
+ * exists only to hide {@link ImmutableSet#builder} from consumers of {@code ImmutableSortedSet}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Use {@link ImmutableSortedSet#naturalOrder}, which offers better type-safety.
+ */
+ @DoNotCall("Use naturalOrder")
+ @Deprecated
+ public static <E> ImmutableSortedSet.Builder<E> builder() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. This method exists only to hide {@link ImmutableSet#builderWithExpectedSize}
+ * from consumers of {@code ImmutableSortedSet}.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated Not supported by ImmutableSortedSet.
+ */
+ @DoNotCall("Use naturalOrder (which does not accept an expected size)")
+ @Deprecated
+ public static <E> ImmutableSortedSet.Builder<E> builderWithExpectedSize(int expectedSize) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
+ * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#of(Comparable)}.</b>
+ */
+ @DoNotCall("Pass a parameter of type Comparable")
+ @Deprecated
+ public static <E> ImmutableSortedSet<E> of(E element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
+ * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#of(Comparable, Comparable)}.</b>
+ */
+ @DoNotCall("Pass parameters of type Comparable")
+ @Deprecated
+ public static <E> ImmutableSortedSet<E> of(E e1, E e2) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
+ * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#of(Comparable, Comparable, Comparable)}.</b>
+ */
+ @DoNotCall("Pass parameters of type Comparable")
+ @Deprecated
+ public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
+ * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable)}. </b>
+ */
+ @DoNotCall("Pass parameters of type Comparable")
+ @Deprecated
+ public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
+ * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#of( Comparable, Comparable, Comparable, Comparable, Comparable)}. </b>
+ */
+ @DoNotCall("Pass parameters of type Comparable")
+ @Deprecated
+ public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
+ * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable, Comparable,
+ * Comparable, Comparable...)}. </b>
+ */
+ @DoNotCall("Pass parameters of type Comparable")
+ @Deprecated
+ public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Not supported. <b>You are attempting to create a set that may contain non-{@code Comparable}
+ * elements.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
+ * dummy version.
+ *
+ * @throws UnsupportedOperationException always
+ * @deprecated <b>Pass parameters of type {@code Comparable} to use {@link
+ * ImmutableSortedSet#copyOf(Comparable[])}.</b>
+ */
+ @DoNotCall("Pass parameters of type Comparable")
+ @Deprecated
+ // The usage of "Z" here works around bugs in Javadoc (JDK-8318093) and JDiff.
+ public static <Z> ImmutableSortedSet<Z> copyOf(Z[] elements) {
+ throw new UnsupportedOperationException();
+ }
+
+ private static final long serialVersionUID = 0xcafebabe;
}
diff --git a/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java b/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java
deleted file mode 100644
index ff3ac12d5..000000000
--- a/guava/src/com/google/common/collect/ImmutableSortedSetFauxverideShim.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (C) 2009 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.collect;
-
-import com.google.common.annotations.GwtIncompatible;
-import com.google.errorprone.annotations.DoNotCall;
-import java.util.stream.Collector;
-
-/**
- * "Overrides" the {@link ImmutableSet} static methods that lack {@link ImmutableSortedSet}
- * equivalents with deprecated, exception-throwing versions. This prevents accidents like the
- * following:
- *
- * <pre>{@code
- * List<Object> objects = ...;
- * // Sort them:
- * Set<Object> sorted = ImmutableSortedSet.copyOf(objects);
- * // BAD CODE! The returned set is actually an unsorted ImmutableSet!
- * }</pre>
- *
- * <p>While we could put the overrides in {@link ImmutableSortedSet} itself, it seems clearer to
- * separate these "do not call" methods from those intended for normal use.
- *
- * @author Chris Povirk
- */
-@GwtIncompatible
-@ElementTypesAreNonnullByDefault
-abstract class ImmutableSortedSetFauxverideShim<E> extends ImmutableSet.CachingAsList<E> {
- /**
- * Not supported. Use {@link ImmutableSortedSet#toImmutableSortedSet} instead. This method exists
- * only to hide {@link ImmutableSet#toImmutableSet} from consumers of {@code ImmutableSortedSet}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Use {@link ImmutableSortedSet#toImmutableSortedSet}.
- * @since 21.0
- */
- @DoNotCall("Use toImmutableSortedSet")
- @Deprecated
- public static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. Use {@link ImmutableSortedSet#naturalOrder}, which offers better type-safety,
- * instead. This method exists only to hide {@link ImmutableSet#builder} from consumers of {@code
- * ImmutableSortedSet}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Use {@link ImmutableSortedSet#naturalOrder}, which offers better type-safety.
- */
- @DoNotCall("Use naturalOrder")
- @Deprecated
- public static <E> ImmutableSortedSet.Builder<E> builder() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. This method exists only to hide {@link ImmutableSet#builderWithExpectedSize}
- * from consumers of {@code ImmutableSortedSet}.
- *
- * @throws UnsupportedOperationException always
- * @deprecated Not supported by ImmutableSortedSet.
- */
- @DoNotCall("Use naturalOrder (which does not accept an expected size)")
- @Deprecated
- public static <E> ImmutableSortedSet.Builder<E> builderWithExpectedSize(int expectedSize) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
- * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass a parameter of type {@code Comparable} to use {@link
- * ImmutableSortedSet#of(Comparable)}.</b>
- */
- @DoNotCall("Pass a parameter of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> of(E element) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
- * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedSet#of(Comparable, Comparable)}.</b>
- */
- @DoNotCall("Pass parameters of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> of(E e1, E e2) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
- * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedSet#of(Comparable, Comparable, Comparable)}.</b>
- */
- @DoNotCall("Pass parameters of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
- * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable)}. </b>
- */
- @DoNotCall("Pass parameters of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
- * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedSet#of( Comparable, Comparable, Comparable, Comparable, Comparable)}. </b>
- */
- @DoNotCall("Pass parameters of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain a non-{@code Comparable}
- * element.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass the parameters of type {@code Comparable} to use {@link
- * ImmutableSortedSet#of(Comparable, Comparable, Comparable, Comparable, Comparable,
- * Comparable, Comparable...)}. </b>
- */
- @DoNotCall("Pass parameters of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E... remaining) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Not supported. <b>You are attempting to create a set that may contain non-{@code Comparable}
- * elements.</b> Proper calls will resolve to the version in {@code ImmutableSortedSet}, not this
- * dummy version.
- *
- * @throws UnsupportedOperationException always
- * @deprecated <b>Pass parameters of type {@code Comparable} to use {@link
- * ImmutableSortedSet#copyOf(Comparable[])}.</b>
- */
- @DoNotCall("Pass parameters of type Comparable")
- @Deprecated
- public static <E> ImmutableSortedSet<E> copyOf(E[] elements) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * We would like to include an unsupported "<E> copyOf(Iterable<E>)" here,
- * providing only the properly typed
- * "<E extends Comparable<E>> copyOf(Iterable<E>)" in ImmutableSortedSet (and
- * likewise for the Iterator equivalent). However, due to a change in Sun's
- * interpretation of the JLS (as described at
- * http://bugs.sun.com/view_bug.do?bug_id=6182950), the OpenJDK 7 compiler
- * available as of this writing rejects our attempts. To maintain
- * compatibility with that version and with any other compilers that interpret
- * the JLS similarly, there is no definition of copyOf() here, and the
- * definition in ImmutableSortedSet matches that in ImmutableSet.
- *
- * The result is that ImmutableSortedSet.copyOf() may be called on
- * non-Comparable elements. We have not discovered a better solution. In
- * retrospect, the static factory methods should have gone in a separate class
- * so that ImmutableSortedSet wouldn't "inherit" too-permissive factory
- * methods from ImmutableSet.
- */
-}
diff --git a/guava/src/com/google/common/collect/ImmutableTable.java b/guava/src/com/google/common/collect/ImmutableTable.java
index 62cae079f..e1db67c93 100644
--- a/guava/src/com/google/common/collect/ImmutableTable.java
+++ b/guava/src/com/google/common/collect/ImmutableTable.java
@@ -445,9 +445,6 @@ public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V>
throw new UnsupportedOperationException();
}
- /** Creates the common serialized form for this table. */
- abstract SerializedForm createSerializedForm();
-
/**
* Serialized type for all ImmutableTable instances. It captures the logical contents and
* preserves iteration order of all views.
@@ -503,9 +500,9 @@ public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V>
private static final long serialVersionUID = 0;
}
- final Object writeReplace() {
- return createSerializedForm();
- }
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ abstract Object writeReplace();
@GwtIncompatible // serialization
@J2ktIncompatible
diff --git a/guava/src/com/google/common/collect/IndexedImmutableSet.java b/guava/src/com/google/common/collect/IndexedImmutableSet.java
index 20dfacbab..396ce6b0f 100644
--- a/guava/src/com/google/common/collect/IndexedImmutableSet.java
+++ b/guava/src/com/google/common/collect/IndexedImmutableSet.java
@@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import java.util.Spliterator;
import java.util.function.Consumer;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -76,6 +77,24 @@ abstract class IndexedImmutableSet<E> extends ImmutableSet.CachingAsList<E> {
ImmutableCollection<E> delegateCollection() {
return IndexedImmutableSet.this;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/Iterators.java b/guava/src/com/google/common/collect/Iterators.java
index 0699202fe..009a41cef 100644
--- a/guava/src/com/google/common/collect/Iterators.java
+++ b/guava/src/com/google/common/collect/Iterators.java
@@ -42,7 +42,6 @@ import java.util.Deque;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
@@ -1056,47 +1055,40 @@ public final class Iterators {
*/
@SafeVarargs
public static <T extends @Nullable Object> UnmodifiableIterator<T> forArray(T... array) {
- return forArray(array, 0, array.length, 0);
+ return forArrayWithPosition(array, 0);
}
/**
- * Returns a list iterator containing the elements in the specified range of {@code array} in
- * order, starting at the specified index.
+ * Returns a list iterator containing the elements in the specified {@code array} in order,
+ * starting at the specified {@code position}.
*
* <p>The {@code Iterable} equivalent of this method is {@code
- * Arrays.asList(array).subList(offset, offset + length).listIterator(index)}.
+ * Arrays.asList(array).listIterator(position)}.
*/
- static <T extends @Nullable Object> UnmodifiableListIterator<T> forArray(
- T[] array, int offset, int length, int index) {
- checkArgument(length >= 0);
- int end = offset + length;
-
- // Technically we should give a slightly more descriptive error on overflow
- Preconditions.checkPositionIndexes(offset, end, array.length);
- Preconditions.checkPositionIndex(index, length);
- if (length == 0) {
+ static <T extends @Nullable Object> UnmodifiableListIterator<T> forArrayWithPosition(
+ T[] array, int position) {
+ if (array.length == 0) {
+ Preconditions.checkPositionIndex(position, array.length); // otherwise checked in ArrayItr
return emptyListIterator();
}
- return new ArrayItr<>(array, offset, length, index);
+ return new ArrayItr<>(array, position);
}
private static final class ArrayItr<T extends @Nullable Object>
extends AbstractIndexedListIterator<T> {
- static final UnmodifiableListIterator<Object> EMPTY = new ArrayItr<>(new Object[0], 0, 0, 0);
+ static final UnmodifiableListIterator<Object> EMPTY = new ArrayItr<>(new Object[0], 0);
private final T[] array;
- private final int offset;
- ArrayItr(T[] array, int offset, int length, int index) {
- super(length, index);
+ ArrayItr(T[] array, int position) {
+ super(array.length, position);
this.array = array;
- this.offset = offset;
}
@Override
@ParametricNullness
protected T get(int index) {
- return array[offset + index];
+ return array[index];
}
}
@@ -1107,24 +1099,36 @@ public final class Iterators {
*/
public static <T extends @Nullable Object> UnmodifiableIterator<T> singletonIterator(
@ParametricNullness T value) {
- return new UnmodifiableIterator<T>() {
- boolean done;
+ return new SingletonIterator<>(value);
+ }
- @Override
- public boolean hasNext() {
- return !done;
- }
+ private static final class SingletonIterator<T extends @Nullable Object>
+ extends UnmodifiableIterator<T> {
+ private static final Object SENTINEL = new Object();
- @Override
- @ParametricNullness
- public T next() {
- if (done) {
- throw new NoSuchElementException();
- }
- done = true;
- return value;
+ private Object valueOrSentinel;
+
+ SingletonIterator(T value) {
+ this.valueOrSentinel = value;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return valueOrSentinel != SENTINEL;
+ }
+
+ @Override
+ @ParametricNullness
+ public T next() {
+ if (valueOrSentinel == SENTINEL) {
+ throw new NoSuchElementException();
}
- };
+ // The field held either a T or SENTINEL, and it turned out not to be SENTINEL.
+ @SuppressWarnings("unchecked")
+ T t = (T) valueOrSentinel;
+ valueOrSentinel = SENTINEL;
+ return t;
+ }
}
/**
@@ -1444,9 +1448,4 @@ public final class Iterators {
toRemove = null;
}
}
-
- /** Used to avoid http://bugs.sun.com/view_bug.do?bug_id=6558557 */
- static <T extends @Nullable Object> ListIterator<T> cast(Iterator<T> iterator) {
- return (ListIterator<T>) iterator;
- }
}
diff --git a/guava/src/com/google/common/collect/JdkBackedImmutableBiMap.java b/guava/src/com/google/common/collect/JdkBackedImmutableBiMap.java
index f126fdea3..bf45138f7 100644
--- a/guava/src/com/google/common/collect/JdkBackedImmutableBiMap.java
+++ b/guava/src/com/google/common/collect/JdkBackedImmutableBiMap.java
@@ -18,6 +18,8 @@ package com.google.common.collect;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.RetainedWith;
@@ -102,6 +104,15 @@ final class JdkBackedImmutableBiMap<K, V> extends ImmutableBiMap<K, V> {
public int size() {
return entries.size();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@Override
@@ -124,4 +135,13 @@ final class JdkBackedImmutableBiMap<K, V> extends ImmutableBiMap<K, V> {
boolean isPartialView() {
return false;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/JdkBackedImmutableMap.java b/guava/src/com/google/common/collect/JdkBackedImmutableMap.java
index 222c4deb8..0dd791923 100644
--- a/guava/src/com/google/common/collect/JdkBackedImmutableMap.java
+++ b/guava/src/com/google/common/collect/JdkBackedImmutableMap.java
@@ -21,6 +21,8 @@ import static com.google.common.collect.RegularImmutableMap.makeImmutable;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;
@@ -130,4 +132,13 @@ final class JdkBackedImmutableMap<K, V> extends ImmutableMap<K, V> {
boolean isPartialView() {
return false;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/JdkBackedImmutableMultiset.java b/guava/src/com/google/common/collect/JdkBackedImmutableMultiset.java
index 41d95f045..8c116b351 100644
--- a/guava/src/com/google/common/collect/JdkBackedImmutableMultiset.java
+++ b/guava/src/com/google/common/collect/JdkBackedImmutableMultiset.java
@@ -17,6 +17,8 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.primitives.Ints;
import com.google.errorprone.annotations.concurrent.LazyInit;
import java.util.Collection;
@@ -89,4 +91,13 @@ final class JdkBackedImmutableMultiset<E> extends ImmutableMultiset<E> {
public int size() {
return Ints.saturatedCast(size);
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/JdkBackedImmutableSet.java b/guava/src/com/google/common/collect/JdkBackedImmutableSet.java
index c00167713..bee7076fa 100644
--- a/guava/src/com/google/common/collect/JdkBackedImmutableSet.java
+++ b/guava/src/com/google/common/collect/JdkBackedImmutableSet.java
@@ -15,6 +15,8 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import java.util.Set;
import javax.annotation.CheckForNull;
@@ -55,4 +57,13 @@ final class JdkBackedImmutableSet<E> extends IndexedImmutableSet<E> {
public int size() {
return delegateList.size();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/LinkedHashMultimap.java b/guava/src/com/google/common/collect/LinkedHashMultimap.java
index 78afd3268..61f2a0202 100644
--- a/guava/src/com/google/common/collect/LinkedHashMultimap.java
+++ b/guava/src/com/google/common/collect/LinkedHashMultimap.java
@@ -193,11 +193,11 @@ public final class LinkedHashMultimap<K extends @Nullable Object, V extends @Nul
* frameworks like Android that define post-construct hooks like Activity.onCreate, etc.
*/
- @CheckForNull ValueSetLink<K, V> predecessorInValueSet;
- @CheckForNull ValueSetLink<K, V> successorInValueSet;
+ @CheckForNull private ValueSetLink<K, V> predecessorInValueSet;
+ @CheckForNull private ValueSetLink<K, V> successorInValueSet;
- @CheckForNull ValueEntry<K, V> predecessorInMultimap;
- @CheckForNull ValueEntry<K, V> successorInMultimap;
+ @CheckForNull private ValueEntry<K, V> predecessorInMultimap;
+ @CheckForNull private ValueEntry<K, V> successorInMultimap;
ValueEntry(
@ParametricNullness K key,
diff --git a/guava/src/com/google/common/collect/LinkedListMultimap.java b/guava/src/com/google/common/collect/LinkedListMultimap.java
index d88564ca5..d5edcb8ce 100644
--- a/guava/src/com/google/common/collect/LinkedListMultimap.java
+++ b/guava/src/com/google/common/collect/LinkedListMultimap.java
@@ -107,7 +107,7 @@ public class LinkedListMultimap<K extends @Nullable Object, V extends @Nullable
* ValueForKeyIterator} in constant time.
*/
- private static final class Node<K extends @Nullable Object, V extends @Nullable Object>
+ static final class Node<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMapEntry<K, V> {
@ParametricNullness final K key;
@ParametricNullness V value;
diff --git a/guava/src/com/google/common/collect/Lists.java b/guava/src/com/google/common/collect/Lists.java
index 0816b754a..a9c99e27a 100644
--- a/guava/src/com/google/common/collect/Lists.java
+++ b/guava/src/com/google/common/collect/Lists.java
@@ -780,6 +780,15 @@ public final class Lists {
public int size() {
return string.length();
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
private static final class CharSequenceAsList extends AbstractList<Character> {
diff --git a/guava/src/com/google/common/collect/Maps.java b/guava/src/com/google/common/collect/Maps.java
index 173447caf..9bc33913e 100644
--- a/guava/src/com/google/common/collect/Maps.java
+++ b/guava/src/com/google/common/collect/Maps.java
@@ -1737,22 +1737,33 @@ public final class Maps {
throw new UnsupportedOperationException();
}
+ /*
+ * TODO(cpovirk): Uncomment the @NonNull annotations below once our JDK stubs and J2KT
+ * emulations include them.
+ */
@Override
+ @CheckForNull
public V computeIfPresent(
- K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
+ K key,
+ BiFunction<? super K, ? super /*@NonNull*/ V, ? extends @Nullable V> remappingFunction) {
throw new UnsupportedOperationException();
}
@Override
+ @CheckForNull
public V compute(
- K key, BiFunction<? super K, ? super @Nullable V, ? extends V> remappingFunction) {
+ K key,
+ BiFunction<? super K, ? super @Nullable V, ? extends @Nullable V> remappingFunction) {
throw new UnsupportedOperationException();
}
@Override
@CheckForNull
public V merge(
- K key, V value, BiFunction<? super V, ? super V, ? extends @Nullable V> function) {
+ K key,
+ /*@NonNull*/ V value,
+ BiFunction<? super /*@NonNull*/ V, ? super /*@NonNull*/ V, ? extends @Nullable V>
+ function) {
throw new UnsupportedOperationException();
}
@@ -3644,22 +3655,33 @@ public final class Maps {
throw new UnsupportedOperationException();
}
+ /*
+ * TODO(cpovirk): Uncomment the @NonNull annotations below once our JDK stubs and J2KT
+ * emulations include them.
+ */
@Override
+ @CheckForNull
public V computeIfPresent(
- K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
+ K key,
+ BiFunction<? super K, ? super /*@NonNull*/ V, ? extends @Nullable V> remappingFunction) {
throw new UnsupportedOperationException();
}
@Override
+ @CheckForNull
public V compute(
- K key, BiFunction<? super K, ? super @Nullable V, ? extends V> remappingFunction) {
+ K key,
+ BiFunction<? super K, ? super @Nullable V, ? extends @Nullable V> remappingFunction) {
throw new UnsupportedOperationException();
}
@Override
@CheckForNull
public V merge(
- K key, V value, BiFunction<? super V, ? super V, ? extends @Nullable V> function) {
+ K key,
+ /*@NonNull*/ V value,
+ BiFunction<? super /*@NonNull*/ V, ? super /*@NonNull*/ V, ? extends @Nullable V>
+ function) {
throw new UnsupportedOperationException();
}
diff --git a/guava/src/com/google/common/collect/MinMaxPriorityQueue.java b/guava/src/com/google/common/collect/MinMaxPriorityQueue.java
index 877d6bc0b..0dfa2b2fc 100644
--- a/guava/src/com/google/common/collect/MinMaxPriorityQueue.java
+++ b/guava/src/com/google/common/collect/MinMaxPriorityQueue.java
@@ -521,7 +521,7 @@ public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
* sake they are stored interleaved on alternate heap levels in the same array (MMPQ.queue).
*/
@WeakOuter
- private class Heap {
+ class Heap {
final Ordering<E> ordering;
@SuppressWarnings("nullness:initialization.field.uninitialized")
diff --git a/guava/src/com/google/common/collect/Multimaps.java b/guava/src/com/google/common/collect/Multimaps.java
index c614764c5..c158c6519 100644
--- a/guava/src/com/google/common/collect/Multimaps.java
+++ b/guava/src/com/google/common/collect/Multimaps.java
@@ -122,7 +122,7 @@ public final class Multimaps {
java.util.function.Function<? super T, ? extends K> keyFunction,
java.util.function.Function<? super T, ? extends V> valueFunction,
java.util.function.Supplier<M> multimapSupplier) {
- return CollectCollectors.toMultimap(keyFunction, valueFunction, multimapSupplier);
+ return CollectCollectors.<T, K, V, M>toMultimap(keyFunction, valueFunction, multimapSupplier);
}
/**
@@ -167,7 +167,8 @@ public final class Multimaps {
java.util.function.Function<? super T, ? extends K> keyFunction,
java.util.function.Function<? super T, ? extends Stream<? extends V>> valueFunction,
java.util.function.Supplier<M> multimapSupplier) {
- return CollectCollectors.flatteningToMultimap(keyFunction, valueFunction, multimapSupplier);
+ return CollectCollectors.<T, K, V, M>flatteningToMultimap(
+ keyFunction, valueFunction, multimapSupplier);
}
/**
@@ -285,8 +286,8 @@ public final class Multimaps {
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- factory = (Supplier<? extends Collection<V>>) stream.readObject();
- Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject();
+ factory = (Supplier<? extends Collection<V>>) requireNonNull(stream.readObject());
+ Map<K, Collection<V>> map = (Map<K, Collection<V>>) requireNonNull(stream.readObject());
setMap(map);
}
@@ -371,8 +372,8 @@ public final class Multimaps {
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- factory = (Supplier<? extends List<V>>) stream.readObject();
- Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject();
+ factory = (Supplier<? extends List<V>>) requireNonNull(stream.readObject());
+ Map<K, Collection<V>> map = (Map<K, Collection<V>>) requireNonNull(stream.readObject());
setMap(map);
}
@@ -479,8 +480,8 @@ public final class Multimaps {
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- factory = (Supplier<? extends Set<V>>) stream.readObject();
- Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject();
+ factory = (Supplier<? extends Set<V>>) requireNonNull(stream.readObject());
+ Map<K, Collection<V>> map = (Map<K, Collection<V>>) requireNonNull(stream.readObject());
setMap(map);
}
@@ -573,9 +574,9 @@ public final class Multimaps {
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
- factory = (Supplier<? extends SortedSet<V>>) stream.readObject();
+ factory = (Supplier<? extends SortedSet<V>>) requireNonNull(stream.readObject());
valueComparator = factory.get().comparator();
- Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject();
+ Map<K, Collection<V>> map = (Map<K, Collection<V>>) requireNonNull(stream.readObject());
setMap(map);
}
diff --git a/guava/src/com/google/common/collect/Multisets.java b/guava/src/com/google/common/collect/Multisets.java
index fcc674472..7a0eb10a3 100644
--- a/guava/src/com/google/common/collect/Multisets.java
+++ b/guava/src/com/google/common/collect/Multisets.java
@@ -196,6 +196,11 @@ public final class Multisets {
}
@Override
+ public boolean removeIf(java.util.function.Predicate<? super E> filter) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public boolean retainAll(Collection<?> elementsToRetain) {
throw new UnsupportedOperationException();
}
@@ -1166,7 +1171,7 @@ public final class Multisets {
}
private static final class DecreasingCount implements Comparator<Entry<?>> {
- static final DecreasingCount INSTANCE = new DecreasingCount();
+ static final Comparator<Entry<?>> INSTANCE = new DecreasingCount();
@Override
public int compare(Entry<?> entry1, Entry<?> entry2) {
diff --git a/guava/src/com/google/common/collect/Platform.java b/guava/src/com/google/common/collect/Platform.java
index 3f118764e..7ae061c83 100644
--- a/guava/src/com/google/common/collect/Platform.java
+++ b/guava/src/com/google/common/collect/Platform.java
@@ -32,8 +32,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
final class Platform {
- private static final java.util.logging.Logger logger =
- java.util.logging.Logger.getLogger(Platform.class.getName());
/** Returns the platform preferred implementation of a map based on a hash table. */
static <K extends @Nullable Object, V extends @Nullable Object>
@@ -82,7 +80,7 @@ final class Platform {
* for insertions.
*/
static <E extends @Nullable Object> Set<E> preservesInsertionOrderOnAddsSet() {
- return Sets.newLinkedHashSet();
+ return CompactHashSet.create();
}
/**
diff --git a/guava/src/com/google/common/collect/RegularContiguousSet.java b/guava/src/com/google/common/collect/RegularContiguousSet.java
index 9c2e5a26f..8159d107b 100644
--- a/guava/src/com/google/common/collect/RegularContiguousSet.java
+++ b/guava/src/com/google/common/collect/RegularContiguousSet.java
@@ -143,6 +143,15 @@ final class RegularContiguousSet<C extends Comparable> extends ContiguousSet<C>
checkElementIndex(i, size());
return domain.offset(first(), i);
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
} else {
return super.createAsList();
diff --git a/guava/src/com/google/common/collect/RegularImmutableAsList.java b/guava/src/com/google/common/collect/RegularImmutableAsList.java
index 0e3fe4ec8..bc4d8ae5d 100644
--- a/guava/src/com/google/common/collect/RegularImmutableAsList.java
+++ b/guava/src/com/google/common/collect/RegularImmutableAsList.java
@@ -18,6 +18,7 @@ package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import java.util.function.Consumer;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -91,4 +92,13 @@ class RegularImmutableAsList<E> extends ImmutableAsList<E> {
public E get(int index) {
return delegateList.get(index);
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/RegularImmutableBiMap.java b/guava/src/com/google/common/collect/RegularImmutableBiMap.java
index 333b80177..e97a86934 100644
--- a/guava/src/com/google/common/collect/RegularImmutableBiMap.java
+++ b/guava/src/com/google/common/collect/RegularImmutableBiMap.java
@@ -25,6 +25,7 @@ import static com.google.common.collect.RegularImmutableMap.checkNoConflictInKey
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMapEntry.NonTerminalImmutableBiMapEntry;
@@ -285,8 +286,26 @@ class RegularImmutableBiMap<K, V> extends ImmutableBiMap<K, V> {
ImmutableCollection<Entry<V, K>> delegateCollection() {
return InverseEntrySet.this;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
@Override
@@ -296,6 +315,7 @@ class RegularImmutableBiMap<K, V> extends ImmutableBiMap<K, V> {
@Override
@J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
Object writeReplace() {
return new InverseSerializedForm<>(RegularImmutableBiMap.this);
}
@@ -320,4 +340,13 @@ class RegularImmutableBiMap<K, V> extends ImmutableBiMap<K, V> {
private static final long serialVersionUID = 1;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/RegularImmutableList.java b/guava/src/com/google/common/collect/RegularImmutableList.java
index 397147d70..915c6e2c7 100644
--- a/guava/src/com/google/common/collect/RegularImmutableList.java
+++ b/guava/src/com/google/common/collect/RegularImmutableList.java
@@ -17,6 +17,8 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import java.util.Spliterator;
import java.util.Spliterators;
@@ -82,7 +84,7 @@ class RegularImmutableList<E> extends ImmutableList<E> {
public UnmodifiableListIterator<E> listIterator(int index) {
// for performance
// The fake cast to E is safe because the creation methods only allow E's
- return (UnmodifiableListIterator<E>) Iterators.forArray(array, 0, array.length, index);
+ return (UnmodifiableListIterator<E>) Iterators.forArrayWithPosition(array, index);
}
@Override
@@ -91,4 +93,13 @@ class RegularImmutableList<E> extends ImmutableList<E> {
}
// TODO(lowasser): benchmark optimizations for equals() and see if they're worthwhile
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/RegularImmutableMap.java b/guava/src/com/google/common/collect/RegularImmutableMap.java
index 42649109a..32aa2507a 100644
--- a/guava/src/com/google/common/collect/RegularImmutableMap.java
+++ b/guava/src/com/google/common/collect/RegularImmutableMap.java
@@ -346,6 +346,15 @@ final class RegularImmutableMap<K, V> extends ImmutableMap<K, V> {
return map.size();
}
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
+
// No longer used for new writes, but kept so that old data can still be read.
@GwtIncompatible // serialization
@J2ktIncompatible
@@ -394,6 +403,15 @@ final class RegularImmutableMap<K, V> extends ImmutableMap<K, V> {
return true;
}
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
+
// No longer used for new writes, but kept so that old data can still be read.
@GwtIncompatible // serialization
@J2ktIncompatible
@@ -414,6 +432,15 @@ final class RegularImmutableMap<K, V> extends ImmutableMap<K, V> {
}
}
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
+
// This class is never actually serialized directly, but we have to make the
// warning go away (and suppressing would suppress for all nested classes too)
@J2ktIncompatible // serialization
diff --git a/guava/src/com/google/common/collect/RegularImmutableMultiset.java b/guava/src/com/google/common/collect/RegularImmutableMultiset.java
index 026919e0d..8b50345b3 100644
--- a/guava/src/com/google/common/collect/RegularImmutableMultiset.java
+++ b/guava/src/com/google/common/collect/RegularImmutableMultiset.java
@@ -17,6 +17,8 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Objects;
import com.google.common.collect.Multisets.ImmutableEntry;
@@ -194,4 +196,13 @@ class RegularImmutableMultiset<E> extends ImmutableMultiset<E> {
public int hashCode() {
return hashCode;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/RegularImmutableSet.java b/guava/src/com/google/common/collect/RegularImmutableSet.java
index 211c89304..0db235d69 100644
--- a/guava/src/com/google/common/collect/RegularImmutableSet.java
+++ b/guava/src/com/google/common/collect/RegularImmutableSet.java
@@ -17,6 +17,8 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import java.util.Spliterator;
import java.util.Spliterators;
@@ -124,4 +126,13 @@ final class RegularImmutableSet<E> extends ImmutableSet.CachingAsList<E> {
boolean isHashCodeFast() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java b/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java
index 4b7ba8742..258f7aa09 100644
--- a/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java
+++ b/guava/src/com/google/common/collect/RegularImmutableSortedMultiset.java
@@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkPositionIndexes;
import static com.google.common.collect.BoundType.CLOSED;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.primitives.Ints;
import java.util.Comparator;
@@ -133,4 +134,12 @@ final class RegularImmutableSortedMultiset<E> extends ImmutableSortedMultiset<E>
boolean isPartialView() {
return offset > 0 || length < cumulativeCounts.length - 1;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/RegularImmutableSortedSet.java b/guava/src/com/google/common/collect/RegularImmutableSortedSet.java
index 572e0acbf..970e85112 100644
--- a/guava/src/com/google/common/collect/RegularImmutableSortedSet.java
+++ b/guava/src/com/google/common/collect/RegularImmutableSortedSet.java
@@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -329,4 +330,13 @@ final class RegularImmutableSortedSet<E> extends ImmutableSortedSet<E> {
? emptySet(reversedOrder)
: new RegularImmutableSortedSet<E>(elements.reverse(), reversedOrder);
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/RegularImmutableTable.java b/guava/src/com/google/common/collect/RegularImmutableTable.java
index 337f123b6..03def2cbc 100644
--- a/guava/src/com/google/common/collect/RegularImmutableTable.java
+++ b/guava/src/com/google/common/collect/RegularImmutableTable.java
@@ -18,6 +18,8 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.j2objc.annotations.WeakOuter;
import java.util.Collections;
import java.util.Comparator;
@@ -69,6 +71,15 @@ abstract class RegularImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
boolean isPartialView() {
return false;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
abstract V getValue(int iterationIndex);
@@ -94,6 +105,15 @@ abstract class RegularImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
static <R, C, V> RegularImmutableTable<R, C, V> forCells(
@@ -181,4 +201,10 @@ abstract class RegularImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
newValue,
existingValue);
}
+
+ // redeclare to satisfy our test for b/310253115
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ abstract Object writeReplace();
}
diff --git a/guava/src/com/google/common/collect/Sets.java b/guava/src/com/google/common/collect/Sets.java
index da3814881..c38181001 100644
--- a/guava/src/com/google/common/collect/Sets.java
+++ b/guava/src/com/google/common/collect/Sets.java
@@ -1432,6 +1432,15 @@ public final class Sets {
boolean isPartialView() {
return true;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
};
return new CartesianSet<E>(axes, new CartesianList<E>(listAxes));
}
@@ -1473,7 +1482,11 @@ public final class Sets {
CartesianSet<?> that = (CartesianSet<?>) object;
return this.axes.equals(that.axes);
}
- return super.equals(object);
+ if (object instanceof Set) {
+ Set<?> that = (Set<?>) object;
+ return this.size() == that.size() && this.containsAll(that);
+ }
+ return false;
}
@Override
diff --git a/guava/src/com/google/common/collect/SingletonImmutableBiMap.java b/guava/src/com/google/common/collect/SingletonImmutableBiMap.java
index c5fb2b298..c2f4ae137 100644
--- a/guava/src/com/google/common/collect/SingletonImmutableBiMap.java
+++ b/guava/src/com/google/common/collect/SingletonImmutableBiMap.java
@@ -20,6 +20,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkEntryNotNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.google.j2objc.annotations.RetainedWith;
import java.util.function.BiConsumer;
@@ -110,4 +112,13 @@ final class SingletonImmutableBiMap<K, V> extends ImmutableBiMap<K, V> {
}
}
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/SingletonImmutableList.java b/guava/src/com/google/common/collect/SingletonImmutableList.java
index a7ac8b30e..ba1b1a713 100644
--- a/guava/src/com/google/common/collect/SingletonImmutableList.java
+++ b/guava/src/com/google/common/collect/SingletonImmutableList.java
@@ -19,6 +19,8 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.base.Preconditions;
import java.util.Collections;
import java.util.Spliterator;
@@ -75,4 +77,13 @@ final class SingletonImmutableList<E> extends ImmutableList<E> {
boolean isPartialView() {
return false;
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/SingletonImmutableSet.java b/guava/src/com/google/common/collect/SingletonImmutableSet.java
index 088cb802f..15db1c5e5 100644
--- a/guava/src/com/google/common/collect/SingletonImmutableSet.java
+++ b/guava/src/com/google/common/collect/SingletonImmutableSet.java
@@ -17,6 +17,8 @@
package com.google.common.collect;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.common.base.Preconditions;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -80,4 +82,13 @@ final class SingletonImmutableSet<E> extends ImmutableSet<E> {
public String toString() {
return '[' + element.toString() + ']';
}
+
+ // redeclare to help optimizers with b/310253115
+ @SuppressWarnings("RedundantOverride")
+ @Override
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
+ return super.writeReplace();
+ }
}
diff --git a/guava/src/com/google/common/collect/SingletonImmutableTable.java b/guava/src/com/google/common/collect/SingletonImmutableTable.java
index cfaeadb41..6f839ceb4 100644
--- a/guava/src/com/google/common/collect/SingletonImmutableTable.java
+++ b/guava/src/com/google/common/collect/SingletonImmutableTable.java
@@ -19,6 +19,8 @@ package com.google.common.collect;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import java.util.Map;
/**
@@ -77,7 +79,9 @@ class SingletonImmutableTable<R, C, V> extends ImmutableTable<R, C, V> {
}
@Override
- SerializedForm createSerializedForm() {
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
return SerializedForm.create(this, new int[] {0}, new int[] {0});
}
}
diff --git a/guava/src/com/google/common/collect/SparseImmutableTable.java b/guava/src/com/google/common/collect/SparseImmutableTable.java
index 44881fde7..f7222b120 100644
--- a/guava/src/com/google/common/collect/SparseImmutableTable.java
+++ b/guava/src/com/google/common/collect/SparseImmutableTable.java
@@ -17,6 +17,8 @@ package com.google.common.collect;
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
+import com.google.common.annotations.GwtIncompatible;
+import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.Immutable;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -130,7 +132,9 @@ final class SparseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V>
}
@Override
- SerializedForm createSerializedForm() {
+ @J2ktIncompatible // serialization
+ @GwtIncompatible // serialization
+ Object writeReplace() {
Map<C, Integer> columnKeyToIndex = Maps.indexMap(columnKeySet());
int[] cellColumnIndices = new int[cellSet().size()];
int i = 0;
diff --git a/guava/src/com/google/common/collect/StandardTable.java b/guava/src/com/google/common/collect/StandardTable.java
index 6ec3c6b23..f9d6f1b8e 100644
--- a/guava/src/com/google/common/collect/StandardTable.java
+++ b/guava/src/com/google/common/collect/StandardTable.java
@@ -846,7 +846,7 @@ class StandardTable<R, C, V> extends AbstractTable<R, C, V> implements Serializa
}
@WeakOuter
- class EntrySet extends TableSet<Entry<R, Map<C, V>>> {
+ private final class EntrySet extends TableSet<Entry<R, Map<C, V>>> {
@Override
public Iterator<Entry<R, Map<C, V>>> iterator() {
return Maps.asMapEntryIterator(
@@ -935,7 +935,7 @@ class StandardTable<R, C, V> extends AbstractTable<R, C, V> implements Serializa
}
@WeakOuter
- class ColumnMapEntrySet extends TableSet<Entry<C, Map<R, V>>> {
+ private final class ColumnMapEntrySet extends TableSet<Entry<C, Map<R, V>>> {
@Override
public Iterator<Entry<C, Map<R, V>>> iterator() {
return Maps.asMapEntryIterator(
diff --git a/guava/src/com/google/common/collect/Streams.java b/guava/src/com/google/common/collect/Streams.java
index 0b6e88ce2..8209cedb5 100644
--- a/guava/src/com/google/common/collect/Streams.java
+++ b/guava/src/com/google/common/collect/Streams.java
@@ -148,11 +148,40 @@ public final class Streams {
return optional.isPresent() ? DoubleStream.of(optional.getAsDouble()) : DoubleStream.empty();
}
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private static void closeAll(BaseStream<?, ?>[] toClose) {
+ // If one of the streams throws an exception, continue closing the others, then throw the
+ // exception later. If more than one stream throws an exception, the later ones are added to the
+ // first as suppressed exceptions. We don't catch Error on the grounds that it should be allowed
+ // to propagate immediately.
+ Exception exception = null;
for (BaseStream<?, ?> stream : toClose) {
- // TODO(b/80534298): Catch exceptions, rethrowing later with extras as suppressed exceptions.
- stream.close();
+ try {
+ stream.close();
+ } catch (Exception e) { // sneaky checked exception
+ if (exception == null) {
+ exception = e;
+ } else {
+ exception.addSuppressed(e);
+ }
+ }
+ }
+ if (exception != null) {
+ // Normally this is a RuntimeException that doesn't need sneakyThrow.
+ // But theoretically we could see sneaky checked exception
+ sneakyThrow(exception);
+ }
+ }
+
+ /** Throws an undeclared checked exception. */
+ private static void sneakyThrow(Throwable t) {
+ class SneakyThrower<T extends Throwable> {
+ @SuppressWarnings("unchecked") // not really safe, but that's the point
+ void throwIt(Throwable t) throws T {
+ throw (T) t;
+ }
}
+ new SneakyThrower<Error>().throwIt(t);
}
/**
diff --git a/guava/src/com/google/common/collect/Synchronized.java b/guava/src/com/google/common/collect/Synchronized.java
index b1422e316..89916cd4d 100644
--- a/guava/src/com/google/common/collect/Synchronized.java
+++ b/guava/src/com/google/common/collect/Synchronized.java
@@ -369,8 +369,8 @@ final class Synchronized {
: new SynchronizedList<E>(list, mutex);
}
- private static class SynchronizedList<E extends @Nullable Object>
- extends SynchronizedCollection<E> implements List<E> {
+ static class SynchronizedList<E extends @Nullable Object> extends SynchronizedCollection<E>
+ implements List<E> {
SynchronizedList(List<E> delegate, @CheckForNull Object mutex) {
super(delegate, mutex);
}
@@ -480,7 +480,7 @@ final class Synchronized {
private static final long serialVersionUID = 0;
}
- private static class SynchronizedRandomAccessList<E extends @Nullable Object>
+ static final class SynchronizedRandomAccessList<E extends @Nullable Object>
extends SynchronizedList<E> implements RandomAccess {
SynchronizedRandomAccessList(List<E> list, @CheckForNull Object mutex) {
super(list, mutex);
@@ -497,7 +497,7 @@ final class Synchronized {
return new SynchronizedMultiset<E>(multiset, mutex);
}
- private static class SynchronizedMultiset<E extends @Nullable Object>
+ static final class SynchronizedMultiset<E extends @Nullable Object>
extends SynchronizedCollection<E> implements Multiset<E> {
@CheckForNull transient Set<E> elementSet;
@CheckForNull transient Set<Multiset.Entry<E>> entrySet;
@@ -594,7 +594,7 @@ final class Synchronized {
return new SynchronizedMultimap<>(multimap, mutex);
}
- private static class SynchronizedMultimap<K extends @Nullable Object, V extends @Nullable Object>
+ static class SynchronizedMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedObject implements Multimap<K, V> {
@CheckForNull transient Set<K> keySet;
@CheckForNull transient Collection<V> valuesCollection;
@@ -788,7 +788,7 @@ final class Synchronized {
return new SynchronizedListMultimap<>(multimap, mutex);
}
- private static class SynchronizedListMultimap<
+ static final class SynchronizedListMultimap<
K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedMultimap<K, V> implements ListMultimap<K, V> {
SynchronizedListMultimap(ListMultimap<K, V> delegate, @CheckForNull Object mutex) {
@@ -832,8 +832,7 @@ final class Synchronized {
return new SynchronizedSetMultimap<>(multimap, mutex);
}
- private static class SynchronizedSetMultimap<
- K extends @Nullable Object, V extends @Nullable Object>
+ static class SynchronizedSetMultimap<K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedMultimap<K, V> implements SetMultimap<K, V> {
@CheckForNull transient Set<Map.Entry<K, V>> entrySet;
@@ -889,7 +888,7 @@ final class Synchronized {
return new SynchronizedSortedSetMultimap<>(multimap, mutex);
}
- private static class SynchronizedSortedSetMultimap<
+ static final class SynchronizedSortedSetMultimap<
K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedSetMultimap<K, V> implements SortedSetMultimap<K, V> {
SynchronizedSortedSetMultimap(SortedSetMultimap<K, V> delegate, @CheckForNull Object mutex) {
@@ -956,7 +955,7 @@ final class Synchronized {
}
}
- private static class SynchronizedAsMapEntries<
+ static final class SynchronizedAsMapEntries<
K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedSet<Map.Entry<K, Collection<V>>> {
SynchronizedAsMapEntries(
@@ -1063,7 +1062,7 @@ final class Synchronized {
return new SynchronizedMap<>(map, mutex);
}
- private static class SynchronizedMap<K extends @Nullable Object, V extends @Nullable Object>
+ static class SynchronizedMap<K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedObject implements Map<K, V> {
@CheckForNull transient Set<K> keySet;
@CheckForNull transient Collection<V> values;
@@ -1188,17 +1187,25 @@ final class Synchronized {
}
}
+ /*
+ * TODO(cpovirk): Uncomment the @NonNull annotations below once our JDK stubs and J2KT
+ * emulations include them.
+ */
@Override
+ @CheckForNull
public V computeIfPresent(
- K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
+ K key,
+ BiFunction<? super K, ? super /*@NonNull*/ V, ? extends @Nullable V> remappingFunction) {
synchronized (mutex) {
return delegate().computeIfPresent(key, remappingFunction);
}
}
@Override
+ @CheckForNull
public V compute(
- K key, BiFunction<? super K, ? super @Nullable V, ? extends V> remappingFunction) {
+ K key,
+ BiFunction<? super K, ? super @Nullable V, ? extends @Nullable V> remappingFunction) {
synchronized (mutex) {
return delegate().compute(key, remappingFunction);
}
@@ -1207,7 +1214,10 @@ final class Synchronized {
@Override
@CheckForNull
public V merge(
- K key, V value, BiFunction<? super V, ? super V, ? extends @Nullable V> remappingFunction) {
+ K key,
+ /*@NonNull*/ V value,
+ BiFunction<? super /*@NonNull*/ V, ? super /*@NonNull*/ V, ? extends @Nullable V>
+ remappingFunction) {
synchronized (mutex) {
return delegate().merge(key, value, remappingFunction);
}
@@ -1350,8 +1360,7 @@ final class Synchronized {
return new SynchronizedBiMap<>(bimap, mutex, null);
}
- @VisibleForTesting
- static class SynchronizedBiMap<K extends @Nullable Object, V extends @Nullable Object>
+ static final class SynchronizedBiMap<K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedMap<K, V> implements BiMap<K, V>, Serializable {
@CheckForNull private transient Set<V> valueSet;
@RetainedWith @CheckForNull private transient BiMap<V, K> inverse;
@@ -1398,7 +1407,7 @@ final class Synchronized {
private static final long serialVersionUID = 0;
}
- private static class SynchronizedAsMap<K extends @Nullable Object, V extends @Nullable Object>
+ static final class SynchronizedAsMap<K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedMap<K, Collection<V>> {
@CheckForNull transient Set<Map.Entry<K, Collection<V>>> asMapEntrySet;
@CheckForNull transient Collection<Collection<V>> asMapValues;
@@ -1445,7 +1454,7 @@ final class Synchronized {
private static final long serialVersionUID = 0;
}
- private static class SynchronizedAsMapValues<V extends @Nullable Object>
+ static final class SynchronizedAsMapValues<V extends @Nullable Object>
extends SynchronizedCollection<Collection<V>> {
SynchronizedAsMapValues(Collection<Collection<V>> delegate, @CheckForNull Object mutex) {
super(delegate, mutex);
@@ -1467,8 +1476,8 @@ final class Synchronized {
@GwtIncompatible // NavigableSet
@VisibleForTesting
- static class SynchronizedNavigableSet<E extends @Nullable Object> extends SynchronizedSortedSet<E>
- implements NavigableSet<E> {
+ static final class SynchronizedNavigableSet<E extends @Nullable Object>
+ extends SynchronizedSortedSet<E> implements NavigableSet<E> {
SynchronizedNavigableSet(NavigableSet<E> delegate, @CheckForNull Object mutex) {
super(delegate, mutex);
}
@@ -1611,7 +1620,8 @@ final class Synchronized {
@GwtIncompatible // NavigableMap
@VisibleForTesting
- static class SynchronizedNavigableMap<K extends @Nullable Object, V extends @Nullable Object>
+ static final class SynchronizedNavigableMap<
+ K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedSortedMap<K, V> implements NavigableMap<K, V> {
SynchronizedNavigableMap(NavigableMap<K, V> delegate, @CheckForNull Object mutex) {
@@ -1812,7 +1822,7 @@ final class Synchronized {
}
@GwtIncompatible // works but is needed only for NavigableMap
- private static class SynchronizedEntry<K extends @Nullable Object, V extends @Nullable Object>
+ static final class SynchronizedEntry<K extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedObject implements Map.Entry<K, V> {
SynchronizedEntry(Map.Entry<K, V> delegate, @CheckForNull Object mutex) {
@@ -1867,8 +1877,8 @@ final class Synchronized {
return (queue instanceof SynchronizedQueue) ? queue : new SynchronizedQueue<E>(queue, mutex);
}
- private static class SynchronizedQueue<E extends @Nullable Object>
- extends SynchronizedCollection<E> implements Queue<E> {
+ static class SynchronizedQueue<E extends @Nullable Object> extends SynchronizedCollection<E>
+ implements Queue<E> {
SynchronizedQueue(Queue<E> delegate, @CheckForNull Object mutex) {
super(delegate, mutex);
@@ -1923,8 +1933,8 @@ final class Synchronized {
return new SynchronizedDeque<E>(deque, mutex);
}
- private static final class SynchronizedDeque<E extends @Nullable Object>
- extends SynchronizedQueue<E> implements Deque<E> {
+ static final class SynchronizedDeque<E extends @Nullable Object> extends SynchronizedQueue<E>
+ implements Deque<E> {
SynchronizedDeque(Deque<E> delegate, @CheckForNull Object mutex) {
super(delegate, mutex);
@@ -2066,7 +2076,7 @@ final class Synchronized {
return new SynchronizedTable<>(table, mutex);
}
- private static final class SynchronizedTable<
+ static final class SynchronizedTable<
R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
extends SynchronizedObject implements Table<R, C, V> {
diff --git a/guava/src/com/google/common/collect/TableCollectors.java b/guava/src/com/google/common/collect/TableCollectors.java
index 16fcb1669..0257954ee 100644
--- a/guava/src/com/google/common/collect/TableCollectors.java
+++ b/guava/src/com/google/common/collect/TableCollectors.java
@@ -90,7 +90,7 @@ final class TableCollectors {
java.util.function.Function<? super T, ? extends C> columnFunction,
java.util.function.Function<? super T, ? extends V> valueFunction,
java.util.function.Supplier<I> tableSupplier) {
- return toTable(
+ return TableCollectors.<T, R, C, V, I>toTable(
rowFunction,
columnFunction,
valueFunction,
diff --git a/guava/src/com/google/common/collect/Tables.java b/guava/src/com/google/common/collect/Tables.java
index 525c05355..a9d0bb654 100644
--- a/guava/src/com/google/common/collect/Tables.java
+++ b/guava/src/com/google/common/collect/Tables.java
@@ -77,7 +77,8 @@ public final class Tables {
java.util.function.Function<? super T, ? extends C> columnFunction,
java.util.function.Function<? super T, ? extends V> valueFunction,
java.util.function.Supplier<I> tableSupplier) {
- return TableCollectors.toTable(rowFunction, columnFunction, valueFunction, tableSupplier);
+ return TableCollectors.<T, R, C, V, I>toTable(
+ rowFunction, columnFunction, valueFunction, tableSupplier);
}
/**
@@ -106,7 +107,7 @@ public final class Tables {
java.util.function.Function<? super T, ? extends V> valueFunction,
BinaryOperator<V> mergeFunction,
java.util.function.Supplier<I> tableSupplier) {
- return TableCollectors.toTable(
+ return TableCollectors.<T, R, C, V, I>toTable(
rowFunction, columnFunction, valueFunction, mergeFunction, tableSupplier);
}
@@ -674,7 +675,7 @@ public final class Tables {
return new UnmodifiableRowSortedMap<>(table);
}
- static final class UnmodifiableRowSortedMap<
+ private static final class UnmodifiableRowSortedMap<
R extends @Nullable Object, C extends @Nullable Object, V extends @Nullable Object>
extends UnmodifiableTable<R, C, V> implements RowSortedTable<R, C, V> {
diff --git a/guava/src/com/google/common/collect/TransformedListIterator.java b/guava/src/com/google/common/collect/TransformedListIterator.java
index 66b42e4c6..22b4b7c42 100644
--- a/guava/src/com/google/common/collect/TransformedListIterator.java
+++ b/guava/src/com/google/common/collect/TransformedListIterator.java
@@ -36,7 +36,7 @@ abstract class TransformedListIterator<F extends @Nullable Object, T extends @Nu
}
private ListIterator<? extends F> backingIterator() {
- return Iterators.cast(backingIterator);
+ return (ListIterator<? extends F>) backingIterator;
}
@Override
diff --git a/guava/src/com/google/common/collect/TreeMultiset.java b/guava/src/com/google/common/collect/TreeMultiset.java
index 7efafd8ec..8024f5ebb 100644
--- a/guava/src/com/google/common/collect/TreeMultiset.java
+++ b/guava/src/com/google/common/collect/TreeMultiset.java
@@ -1088,7 +1088,7 @@ public final class TreeMultiset<E extends @Nullable Object> extends AbstractSort
stream.defaultReadObject();
@SuppressWarnings("unchecked")
// reading data stored by writeObject
- Comparator<? super E> comparator = (Comparator<? super E>) stream.readObject();
+ Comparator<? super E> comparator = (Comparator<? super E>) requireNonNull(stream.readObject());
Serialization.getFieldSetter(AbstractSortedMultiset.class, "comparator").set(this, comparator);
Serialization.getFieldSetter(TreeMultiset.class, "range")
.set(this, GeneralRange.all(comparator));
diff --git a/guava/src/com/google/common/escape/Platform.java b/guava/src/com/google/common/escape/Platform.java
index dc6610c04..67efe4551 100644
--- a/guava/src/com/google/common/escape/Platform.java
+++ b/guava/src/com/google/common/escape/Platform.java
@@ -14,6 +14,8 @@
package com.google.common.escape;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.GwtCompatible;
/**
@@ -28,7 +30,8 @@ final class Platform {
/** Returns a thread-local 1024-char array. */
static char[] charBufferFromThreadLocal() {
- return DEST_TL.get();
+ // requireNonNull accommodates Android's @RecentlyNullable annotation on ThreadLocal.get
+ return requireNonNull(DEST_TL.get());
}
/**
diff --git a/guava/src/com/google/common/eventbus/Dispatcher.java b/guava/src/com/google/common/eventbus/Dispatcher.java
index 412bb789e..44f7c46ba 100644
--- a/guava/src/com/google/common/eventbus/Dispatcher.java
+++ b/guava/src/com/google/common/eventbus/Dispatcher.java
@@ -15,6 +15,7 @@
package com.google.common.eventbus;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.collect.Queues;
import java.util.Iterator;
@@ -97,7 +98,8 @@ abstract class Dispatcher {
void dispatch(Object event, Iterator<Subscriber> subscribers) {
checkNotNull(event);
checkNotNull(subscribers);
- Queue<Event> queueForThread = queue.get();
+ // requireNonNull accommodates Android's @RecentlyNullable annotation on ThreadLocal.get
+ Queue<Event> queueForThread = requireNonNull(queue.get());
queueForThread.offer(new Event(event, subscribers));
if (!dispatching.get()) {
diff --git a/guava/src/com/google/common/graph/StandardMutableValueGraph.java b/guava/src/com/google/common/graph/StandardMutableValueGraph.java
index 0ea641a5b..1ad474083 100644
--- a/guava/src/com/google/common/graph/StandardMutableValueGraph.java
+++ b/guava/src/com/google/common/graph/StandardMutableValueGraph.java
@@ -24,6 +24,7 @@ import static com.google.common.graph.Graphs.checkNonNegative;
import static com.google.common.graph.Graphs.checkPositive;
import static java.util.Objects.requireNonNull;
+import com.google.common.collect.ImmutableList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import javax.annotation.CheckForNull;
@@ -136,17 +137,21 @@ final class StandardMutableValueGraph<N, V> extends StandardValueGraph<N, V>
}
}
- for (N successor : connections.successors()) {
+ for (N successor : ImmutableList.copyOf(connections.successors())) {
// requireNonNull is safe because the node is a successor.
requireNonNull(nodeConnections.getWithoutCaching(successor)).removePredecessor(node);
+ requireNonNull(connections.removeSuccessor(successor));
--edgeCount;
}
if (isDirected()) { // In undirected graphs, the successor and predecessor sets are equal.
- for (N predecessor : connections.predecessors()) {
+ // Since views are returned, we need to copy the predecessors that will be removed.
+ // Thus we avoid modifying the underlying view while iterating over it.
+ for (N predecessor : ImmutableList.copyOf(connections.predecessors())) {
// requireNonNull is safe because the node is a predecessor.
checkState(
requireNonNull(nodeConnections.getWithoutCaching(predecessor)).removeSuccessor(node)
!= null);
+ connections.removePredecessor(predecessor);
--edgeCount;
}
}
diff --git a/guava/src/com/google/common/hash/BloomFilter.java b/guava/src/com/google/common/hash/BloomFilter.java
index 3f1079ee8..fb0542f89 100644
--- a/guava/src/com/google/common/hash/BloomFilter.java
+++ b/guava/src/com/google/common/hash/BloomFilter.java
@@ -597,6 +597,7 @@ public final class BloomFilter<T extends @Nullable Object> implements Predicate<
* @throws IOException if the InputStream throws an {@code IOException}, or if its data does not
* appear to be a BloomFilter serialized using the {@linkplain #writeTo(OutputStream)} method.
*/
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public static <T extends @Nullable Object> BloomFilter<T> readFrom(
InputStream in, Funnel<? super T> funnel) throws IOException {
checkNotNull(in, "InputStream");
@@ -621,7 +622,9 @@ public final class BloomFilter<T extends @Nullable Object> implements Predicate<
}
return new BloomFilter<T>(dataArray, numHashFunctions, funnel, strategy);
- } catch (RuntimeException e) {
+ } catch (IOException e) {
+ throw e;
+ } catch (Exception e) { // sneaky checked exception
String message =
"Unable to deserialize BloomFilter from InputStream."
+ " strategyOrdinal: "
@@ -633,4 +636,6 @@ public final class BloomFilter<T extends @Nullable Object> implements Predicate<
throw new IOException(message, e);
}
}
+
+ private static final long serialVersionUID = 0xcafebabe;
}
diff --git a/guava/src/com/google/common/io/BaseEncoding.java b/guava/src/com/google/common/io/BaseEncoding.java
index 50a8ff7e4..c176d0b00 100644
--- a/guava/src/com/google/common/io/BaseEncoding.java
+++ b/guava/src/com/google/common/io/BaseEncoding.java
@@ -433,7 +433,7 @@ public abstract class BaseEncoding {
return BASE16;
}
- private static final class Alphabet {
+ static final class Alphabet {
private final String name;
// this is meant to be immutable -- don't modify it!
private final char[] chars;
diff --git a/guava/src/com/google/common/io/TempFileCreator.java b/guava/src/com/google/common/io/TempFileCreator.java
index 966323599..769761280 100644
--- a/guava/src/com/google/common/io/TempFileCreator.java
+++ b/guava/src/com/google/common/io/TempFileCreator.java
@@ -16,17 +16,22 @@ package com.google.common.io;
import static com.google.common.base.StandardSystemProperty.JAVA_IO_TMPDIR;
import static com.google.common.base.StandardSystemProperty.USER_NAME;
+import static com.google.common.base.Throwables.throwIfUnchecked;
import static java.nio.file.attribute.AclEntryFlag.DIRECTORY_INHERIT;
import static java.nio.file.attribute.AclEntryFlag.FILE_INHERIT;
import static java.nio.file.attribute.AclEntryType.ALLOW;
import static java.nio.file.attribute.PosixFilePermissions.asFileAttribute;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.j2objc.annotations.J2ObjCIncompatible;
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.nio.file.FileSystems;
import java.nio.file.Paths;
import java.nio.file.attribute.AclEntry;
@@ -98,6 +103,20 @@ abstract class TempFileCreator {
return new JavaIoCreator();
}
+ /**
+ * Creates the permissions normally used for Windows filesystems, looking up the user afresh, even
+ * if previous calls have initialized the {@code PermissionSupplier} fields.
+ *
+ * <p>This lets us test the effects of different values of the {@code user.name} system property
+ * without needing a separate VM or classloader.
+ */
+ @IgnoreJRERequirement // used only when Path is available (and only from tests)
+ @VisibleForTesting
+ static void testMakingUserPermissionsFromScratch() throws IOException {
+ // All we're testing is whether it throws.
+ FileAttribute<?> unused = JavaNioCreator.userPermissions().get();
+ }
+
@IgnoreJRERequirement // used only when Path is available
private static final class JavaNioCreator extends TempFileCreator {
@Override
@@ -150,7 +169,7 @@ abstract class TempFileCreator {
UserPrincipal user =
FileSystems.getDefault()
.getUserPrincipalLookupService()
- .lookupPrincipalByName(USER_NAME.value());
+ .lookupPrincipalByName(getUsername());
ImmutableList<AclEntry> acl =
ImmutableList.of(
AclEntry.newBuilder()
@@ -179,6 +198,62 @@ abstract class TempFileCreator {
};
}
}
+
+ private static String getUsername() {
+ /*
+ * https://github.com/google/guava/issues/6634: ProcessHandle has more accurate information,
+ * but that class isn't available under all environments that we support. We use it if
+ * available and fall back if not.
+ */
+ String fromSystemProperty = requireNonNull(USER_NAME.value());
+
+ try {
+ Class<?> processHandleClass = Class.forName("java.lang.ProcessHandle");
+ Class<?> processHandleInfoClass = Class.forName("java.lang.ProcessHandle$Info");
+ Class<?> optionalClass = Class.forName("java.util.Optional");
+ /*
+ * We don't *need* to use reflection to access Optional: It's available on all JDKs we
+ * support, and Android code won't get this far, anyway, because ProcessHandle is
+ * unavailable. But given how much other reflection we're using, we might as well use it
+ * here, too, so that we don't need to also suppress an AndroidApiChecker error.
+ */
+
+ Method currentMethod = processHandleClass.getMethod("current");
+ Method infoMethod = processHandleClass.getMethod("info");
+ Method userMethod = processHandleInfoClass.getMethod("user");
+ Method orElseMethod = optionalClass.getMethod("orElse", Object.class);
+
+ Object current = currentMethod.invoke(null);
+ Object info = infoMethod.invoke(current);
+ Object user = userMethod.invoke(info);
+ return (String) requireNonNull(orElseMethod.invoke(user, fromSystemProperty));
+ } catch (ClassNotFoundException runningUnderAndroidOrJava8) {
+ /*
+ * I'm not sure that we could actually get here for *Android*: I would expect us to enter
+ * the POSIX code path instead. And if we tried this code path, we'd have trouble unless we
+ * were running under a new enough version of Android to support NIO.
+ *
+ * So this is probably just the "Windows Java 8" case. In that case, if we wanted *another*
+ * layer of fallback before consulting the system property, we could try
+ * com.sun.security.auth.module.NTSystem.
+ *
+ * But for now, we use the value from the system property as our best guess.
+ */
+ return fromSystemProperty;
+ } catch (InvocationTargetException e) {
+ throwIfUnchecked(e.getCause()); // in case it's an Error or something
+ return fromSystemProperty; // should be impossible
+ } catch (NoSuchMethodException shouldBeImpossible) {
+ return fromSystemProperty;
+ } catch (IllegalAccessException shouldBeImpossible) {
+ /*
+ * We don't merge these into `catch (ReflectiveOperationException ...)` or an equivalent
+ * multicatch because ReflectiveOperationException isn't available under Android:
+ * b/124188803
+ */
+ return fromSystemProperty;
+ }
+ }
}
private static final class JavaIoCreator extends TempFileCreator {
diff --git a/guava/src/com/google/common/net/HostAndPort.java b/guava/src/com/google/common/net/HostAndPort.java
index a27eb65ff..0ec28198c 100644
--- a/guava/src/com/google/common/net/HostAndPort.java
+++ b/guava/src/com/google/common/net/HostAndPort.java
@@ -209,7 +209,7 @@ public final class HostAndPort implements Serializable {
/**
* Parses a bracketed host-port string, throwing IllegalArgumentException if parsing fails.
*
- * @param hostPortString the full bracketed host-port specification. Post might not be specified.
+ * @param hostPortString the full bracketed host-port specification. Port might not be specified.
* @return an array with 2 strings: host and port, in that order.
* @throws IllegalArgumentException if parsing the bracketed host-port string fails.
*/
diff --git a/guava/src/com/google/common/net/HttpHeaders.java b/guava/src/com/google/common/net/HttpHeaders.java
index 4c1f865b5..714cb313c 100644
--- a/guava/src/com/google/common/net/HttpHeaders.java
+++ b/guava/src/com/google/common/net/HttpHeaders.java
@@ -855,6 +855,25 @@ public final class HttpHeaders {
* @since 32.0.0
*/
public static final String OBSERVE_BROWSING_TOPICS = "Observe-Browsing-Topics";
+
+ /**
+ * The HTTP <a
+ * href="https://wicg.github.io/turtledove/#handling-direct-from-seller-signals">{@code
+ * Sec-Ad-Auction-Fetch}</a> header field name.
+ *
+ * @since 33.0.0
+ */
+ public static final String SEC_AD_AUCTION_FETCH = "Sec-Ad-Auction-Fetch";
+
+ /**
+ * The HTTP <a
+ * href="https://wicg.github.io/turtledove/#handling-direct-from-seller-signals">{@code
+ * Ad-Auction-Signals}</a> header field name.
+ *
+ * @since 33.0.0
+ */
+ public static final String AD_AUCTION_SIGNALS = "Ad-Auction-Signals";
+
/**
* The HTTP <a href="https://tools.ietf.org/html/rfc8586">{@code CDN-Loop}</a> header field name.
*
diff --git a/guava/src/com/google/common/net/InetAddresses.java b/guava/src/com/google/common/net/InetAddresses.java
index 6d8309381..540a21986 100644
--- a/guava/src/com/google/common/net/InetAddresses.java
+++ b/guava/src/com/google/common/net/InetAddresses.java
@@ -16,6 +16,7 @@ package com.google.common.net;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
@@ -409,7 +410,8 @@ public final class InetAddresses {
checkNotNull(ip);
if (ip instanceof Inet4Address) {
// For IPv4, Java's formatting is good enough.
- return ip.getHostAddress();
+ // requireNonNull accommodates Android's @RecentlyNullable annotation on getHostAddress
+ return requireNonNull(ip.getHostAddress());
}
checkArgument(ip instanceof Inet6Address);
byte[] bytes = ip.getAddress();
diff --git a/guava/src/com/google/common/net/MediaType.java b/guava/src/com/google/common/net/MediaType.java
index c7da53491..99d47dca7 100644
--- a/guava/src/com/google/common/net/MediaType.java
+++ b/guava/src/com/google/common/net/MediaType.java
@@ -1052,15 +1052,13 @@ public final class MediaType {
Tokenizer tokenizer = new Tokenizer(input);
try {
String type = tokenizer.consumeToken(TOKEN_MATCHER);
- tokenizer.consumeCharacter('/');
+ consumeSeparator(tokenizer, '/');
String subtype = tokenizer.consumeToken(TOKEN_MATCHER);
ImmutableListMultimap.Builder<String, String> parameters = ImmutableListMultimap.builder();
while (tokenizer.hasMore()) {
- tokenizer.consumeTokenIfPresent(LINEAR_WHITE_SPACE);
- tokenizer.consumeCharacter(';');
- tokenizer.consumeTokenIfPresent(LINEAR_WHITE_SPACE);
+ consumeSeparator(tokenizer, ';');
String attribute = tokenizer.consumeToken(TOKEN_MATCHER);
- tokenizer.consumeCharacter('=');
+ consumeSeparator(tokenizer, '=');
String value;
if ('"' == tokenizer.previewChar()) {
tokenizer.consumeCharacter('"');
@@ -1086,6 +1084,12 @@ public final class MediaType {
}
}
+ private static void consumeSeparator(Tokenizer tokenizer, char c) {
+ tokenizer.consumeTokenIfPresent(LINEAR_WHITE_SPACE);
+ tokenizer.consumeCharacter(c);
+ tokenizer.consumeTokenIfPresent(LINEAR_WHITE_SPACE);
+ }
+
private static final class Tokenizer {
final String input;
int position = 0;
diff --git a/guava/src/com/google/common/primitives/Doubles.java b/guava/src/com/google/common/primitives/Doubles.java
index f5133ecde..7fcbae957 100644
--- a/guava/src/com/google/common/primitives/Doubles.java
+++ b/guava/src/com/google/common/primitives/Doubles.java
@@ -289,7 +289,7 @@ public final class Doubles extends DoublesMethodsForWeb {
private static final class DoubleConverter extends Converter<String, Double>
implements Serializable {
- static final DoubleConverter INSTANCE = new DoubleConverter();
+ static final Converter<String, Double> INSTANCE = new DoubleConverter();
@Override
protected Double doForward(String value) {
diff --git a/guava/src/com/google/common/primitives/Floats.java b/guava/src/com/google/common/primitives/Floats.java
index d7f156b1e..c42f2f1ee 100644
--- a/guava/src/com/google/common/primitives/Floats.java
+++ b/guava/src/com/google/common/primitives/Floats.java
@@ -284,7 +284,7 @@ public final class Floats extends FloatsMethodsForWeb {
private static final class FloatConverter extends Converter<String, Float>
implements Serializable {
- static final FloatConverter INSTANCE = new FloatConverter();
+ static final Converter<String, Float> INSTANCE = new FloatConverter();
@Override
protected Float doForward(String value) {
diff --git a/guava/src/com/google/common/primitives/Ints.java b/guava/src/com/google/common/primitives/Ints.java
index 4eaa5a6a4..afd4a7b4a 100644
--- a/guava/src/com/google/common/primitives/Ints.java
+++ b/guava/src/com/google/common/primitives/Ints.java
@@ -337,7 +337,7 @@ public final class Ints extends IntsMethodsForWeb {
private static final class IntConverter extends Converter<String, Integer>
implements Serializable {
- static final IntConverter INSTANCE = new IntConverter();
+ static final Converter<String, Integer> INSTANCE = new IntConverter();
@Override
protected Integer doForward(String value) {
diff --git a/guava/src/com/google/common/primitives/Longs.java b/guava/src/com/google/common/primitives/Longs.java
index 8369973cc..7c5a5d3bb 100644
--- a/guava/src/com/google/common/primitives/Longs.java
+++ b/guava/src/com/google/common/primitives/Longs.java
@@ -440,7 +440,7 @@ public final class Longs {
}
private static final class LongConverter extends Converter<String, Long> implements Serializable {
- static final LongConverter INSTANCE = new LongConverter();
+ static final Converter<String, Long> INSTANCE = new LongConverter();
@Override
protected Long doForward(String value) {
diff --git a/guava/src/com/google/common/primitives/Shorts.java b/guava/src/com/google/common/primitives/Shorts.java
index 85ffd3ba8..e7cc8538b 100644
--- a/guava/src/com/google/common/primitives/Shorts.java
+++ b/guava/src/com/google/common/primitives/Shorts.java
@@ -335,7 +335,7 @@ public final class Shorts extends ShortsMethodsForWeb {
private static final class ShortConverter extends Converter<String, Short>
implements Serializable {
- static final ShortConverter INSTANCE = new ShortConverter();
+ static final Converter<String, Short> INSTANCE = new ShortConverter();
@Override
protected Short doForward(String value) {
diff --git a/guava/src/com/google/common/reflect/Invokable.java b/guava/src/com/google/common/reflect/Invokable.java
index 29f4a4ed9..2e2c04193 100644
--- a/guava/src/com/google/common/reflect/Invokable.java
+++ b/guava/src/com/google/common/reflect/Invokable.java
@@ -117,13 +117,14 @@ public abstract class Invokable<T, R> implements AnnotatedElement, Member {
}
/** See {@link java.lang.reflect.AccessibleObject#trySetAccessible()}. */
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public final boolean trySetAccessible() {
// We can't call accessibleObject.trySetAccessible since that was added in Java 9 and this code
// should work on Java 8. So we emulate it this way.
try {
accessibleObject.setAccessible(true);
return true;
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
return false;
}
}
@@ -341,8 +342,7 @@ public abstract class Invokable<T, R> implements AnnotatedElement, Member {
abstract Type[] getGenericParameterTypes();
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker"})
- @IgnoreJRERequirement
+ @SuppressWarnings("Java7ApiChecker")
abstract AnnotatedType[] getAnnotatedParameterTypes();
/** This should never return a type that's not a subtype of Throwable. */
@@ -355,12 +355,9 @@ public abstract class Invokable<T, R> implements AnnotatedElement, Member {
/**
* Returns the {@link AnnotatedType} for the return type.
*
- * <p>This method will fail if run under an Android VM.
- *
- * @since 14.0 for guava-jre (available since 32.0.0 in guava-android)
+ * @since 14.0
*/
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker"})
- @IgnoreJRERequirement
+ @SuppressWarnings("Java7ApiChecker")
public abstract AnnotatedType getAnnotatedReturnType();
static class MethodInvokable<T> extends Invokable<T, Object> {
@@ -390,15 +387,13 @@ public abstract class Invokable<T, R> implements AnnotatedElement, Member {
}
@Override
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker"})
- @IgnoreJRERequirement
+ @SuppressWarnings("Java7ApiChecker")
AnnotatedType[] getAnnotatedParameterTypes() {
return method.getAnnotatedParameterTypes();
}
@Override
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker", "DoNotCall"})
- @IgnoreJRERequirement
+ @SuppressWarnings("Java7ApiChecker")
public AnnotatedType getAnnotatedReturnType() {
return method.getAnnotatedReturnType();
}
@@ -481,15 +476,13 @@ public abstract class Invokable<T, R> implements AnnotatedElement, Member {
}
@Override
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker"})
- @IgnoreJRERequirement
+ @SuppressWarnings("Java7ApiChecker")
AnnotatedType[] getAnnotatedParameterTypes() {
return constructor.getAnnotatedParameterTypes();
}
@Override
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker", "DoNotCall"})
- @IgnoreJRERequirement
+ @SuppressWarnings("Java7ApiChecker")
public AnnotatedType getAnnotatedReturnType() {
return constructor.getAnnotatedReturnType();
}
diff --git a/guava/src/com/google/common/reflect/Parameter.java b/guava/src/com/google/common/reflect/Parameter.java
index c80d18571..e0e244b05 100644
--- a/guava/src/com/google/common/reflect/Parameter.java
+++ b/guava/src/com/google/common/reflect/Parameter.java
@@ -40,7 +40,7 @@ public final class Parameter implements AnnotatedElement {
private final ImmutableList<Annotation> annotations;
/**
- * An {@link AnnotatedType} instance, or {@code null} under Android VMs (possible only when using
+ * An {@code AnnotatedType} instance, or {@code null} under Android VMs (possible only when using
* the Android flavor of Guava). The field is declared with a type of {@code Object} to avoid
* compatibility problems on Android VMs. The corresponding accessor method, however, can have the
* more specific return type as long as users are careful to guard calls to it with version checks
@@ -93,7 +93,9 @@ public final class Parameter implements AnnotatedElement {
return getDeclaredAnnotations();
}
- /** @since 18.0 */
+ /**
+ * @since 18.0
+ */
@Override
public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType) {
return getDeclaredAnnotationsByType(annotationType);
@@ -105,7 +107,9 @@ public final class Parameter implements AnnotatedElement {
return annotations.toArray(new Annotation[0]);
}
- /** @since 18.0 */
+ /**
+ * @since 18.0
+ */
@Override
@CheckForNull
public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationType) {
@@ -113,7 +117,9 @@ public final class Parameter implements AnnotatedElement {
return FluentIterable.from(annotations).filter(annotationType).first().orNull();
}
- /** @since 18.0 */
+ /**
+ * @since 18.0
+ */
@Override
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationType) {
@Nullable
@@ -126,12 +132,9 @@ public final class Parameter implements AnnotatedElement {
/**
* Returns the {@link AnnotatedType} of the parameter.
*
- * <p>This method will fail if run under an Android VM.
- *
- * @since 25.1 for guava-jre (available since 32.0.0 in guava-android)
+ * @since 25.1 for guava-jre
*/
- @SuppressWarnings({"Java7ApiChecker", "AndroidJdkLibsChecker"})
- @IgnoreJRERequirement
+ @SuppressWarnings("Java7ApiChecker")
public AnnotatedType getAnnotatedType() {
return requireNonNull((AnnotatedType) annotatedType);
}
diff --git a/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java b/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java
index e5df53835..8fa650028 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractCatchingFuture.java
@@ -108,8 +108,8 @@ abstract class AbstractCatchingFuture<
+ e.getClass()
+ " without a cause");
}
- } catch (RuntimeException | Error e) { // this includes cancellation exception
- throwable = e;
+ } catch (Throwable t) { // this includes CancellationException and sneaky checked exception
+ throwable = t;
}
if (throwable == null) {
diff --git a/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java b/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
index c52f9d456..512d80955 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractExecutionThreadService.java
@@ -24,7 +24,6 @@ import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* Base class for services that can implement {@link #startUp}, {@link #run} and {@link #shutDown}
@@ -38,8 +37,7 @@ import java.util.logging.Logger;
@J2ktIncompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractExecutionThreadService implements Service {
- private static final Logger logger =
- Logger.getLogger(AbstractExecutionThreadService.class.getName());
+ private static final LazyLogger logger = new LazyLogger(AbstractExecutionThreadService.class);
/* use AbstractService for state management */
private final Service delegate =
@@ -66,10 +64,12 @@ public abstract class AbstractExecutionThreadService implements Service {
// TODO(lukes): if guava ever moves to java7, this would be a good
// candidate for a suppressed exception, or maybe we could generalize
// Closer.Suppressor
- logger.log(
- Level.WARNING,
- "Error while attempting to shut down the service after failure.",
- ignored);
+ logger
+ .get()
+ .log(
+ Level.WARNING,
+ "Error while attempting to shut down the service after failure.",
+ ignored);
}
notifyFailed(t);
return;
diff --git a/guava/src/com/google/common/util/concurrent/AbstractFuture.java b/guava/src/com/google/common/util/concurrent/AbstractFuture.java
index 42ec5264c..a886f10c2 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractFuture.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractFuture.java
@@ -42,7 +42,6 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.concurrent.locks.LockSupport;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -141,8 +140,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
}
}
- // Logger to log exceptions caught when running listeners.
- private static final Logger log = Logger.getLogger(AbstractFuture.class.getName());
+ static final LazyLogger log = new LazyLogger(AbstractFuture.class);
// A heuristic for timed gets. If the remaining timeout is less than this, spin instead of
// blocking. This value is what AbstractQueuedSynchronizer uses.
@@ -157,7 +155,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
try {
helper = new UnsafeAtomicHelper();
- } catch (RuntimeException | Error unsafeFailure) {
+ } catch (Exception | Error unsafeFailure) { // sneaky checked exception
thrownUnsafeFailure = unsafeFailure;
// catch absolutely everything and fall through to our 'SafeAtomicHelper'
// The access control checks that ARFU does means the caller class has to be AbstractFuture
@@ -170,7 +168,8 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
newUpdater(AbstractFuture.class, Waiter.class, "waiters"),
newUpdater(AbstractFuture.class, Listener.class, "listeners"),
newUpdater(AbstractFuture.class, Object.class, "value"));
- } catch (RuntimeException | Error atomicReferenceFieldUpdaterFailure) {
+ } catch (Exception // sneaky checked exception
+ | Error atomicReferenceFieldUpdaterFailure) {
// Some Android 5.0.x Samsung devices have bugs in JDK reflection APIs that cause
// getDeclaredField to throw a NoSuchFieldException when the field is definitely there.
// For these users fallback to a suboptimal implementation, based on synchronized. This will
@@ -189,9 +188,12 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
// Log after all static init is finished; if an installed logger uses any Futures methods, it
// shouldn't break in cases where reflection is missing/broken.
if (thrownAtomicReferenceFieldUpdaterFailure != null) {
- log.log(Level.SEVERE, "UnsafeAtomicHelper is broken!", thrownUnsafeFailure);
- log.log(
- Level.SEVERE, "SafeAtomicHelper is broken!", thrownAtomicReferenceFieldUpdaterFailure);
+ log.get().log(Level.SEVERE, "UnsafeAtomicHelper is broken!", thrownUnsafeFailure);
+ log.get()
+ .log(
+ Level.SEVERE,
+ "SafeAtomicHelper is broken!",
+ thrownAtomicReferenceFieldUpdaterFailure);
}
}
@@ -864,14 +866,16 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
// since all we are doing is unpacking a completed future which should be fast.
try {
future.addListener(valueToSet, DirectExecutor.INSTANCE);
- } catch (RuntimeException | Error t) {
+ } catch (Throwable t) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
+ //
// addListener has thrown an exception! SetFuture.run can't throw any exceptions so this
// must have been caused by addListener itself. The most likely explanation is a
// misconfigured mock. Try to switch to Failure.
Failure failure;
try {
failure = new Failure(t);
- } catch (RuntimeException | Error oomMostLikely) {
+ } catch (Exception | Error oomMostLikely) { // sneaky checked exception
failure = Failure.FALLBACK_INSTANCE;
}
// Note: The only way this CAS could fail is if cancel() has raced with us. That is ok.
@@ -966,7 +970,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
cancellation));
}
return new Cancellation(false, cancellation);
- } catch (RuntimeException | Error t) {
+ } catch (Exception | Error t) { // sneaky checked exception
return new Failure(t);
}
}
@@ -1190,6 +1194,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
return null;
}
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private void addPendingString(StringBuilder builder) {
// Capture current builder length so it can be truncated if this future ends up completing while
// the toString is being calculated
@@ -1206,7 +1211,9 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
String pendingDescription;
try {
pendingDescription = Strings.emptyToNull(pendingToString());
- } catch (RuntimeException | StackOverflowError e) {
+ } catch (Exception | StackOverflowError e) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
+ //
// Don't call getMessage or toString() on the exception, in case the exception thrown by the
// subclass is implemented with bugs similar to the subclass.
pendingDescription = "Exception thrown from implementation: " + e.getClass();
@@ -1225,6 +1232,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
}
}
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private void addDoneString(StringBuilder builder) {
try {
V value = getUninterruptibly(this);
@@ -1235,7 +1243,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
builder.append("FAILURE, cause=[").append(e.getCause()).append("]");
} catch (CancellationException e) {
builder.append("CANCELLED"); // shouldn't be reachable
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
builder.append("UNKNOWN, cause=[").append(e.getClass()).append(" thrown from get()]");
}
}
@@ -1259,6 +1267,7 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
}
/** Helper for printing user supplied objects into our toString method. */
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private void appendUserObject(StringBuilder builder, @CheckForNull Object o) {
// This is some basic recursion detection for when people create cycles via set/setFuture or
// when deep chains of futures exist resulting in a StackOverflowException. We could detect
@@ -1270,7 +1279,9 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
} else {
builder.append(o);
}
- } catch (RuntimeException | StackOverflowError e) {
+ } catch (Exception | StackOverflowError e) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
+ //
// Don't call getMessage or toString() on the exception, in case the exception thrown by the
// user object is implemented with bugs similar to the user object.
builder.append("Exception thrown from implementation: ").append(e.getClass());
@@ -1281,17 +1292,22 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
* Submits the given runnable to the given {@link Executor} catching and logging all {@linkplain
* RuntimeException runtime exceptions} thrown by the executor.
*/
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private static void executeListener(Runnable runnable, Executor executor) {
try {
executor.execute(runnable);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// Log it and keep going -- bad runnable and/or executor. Don't punish the other runnables if
// we're given a bad one. We only catch RuntimeException because we want Errors to propagate
// up.
- log.log(
- Level.SEVERE,
- "RuntimeException while executing runnable " + runnable + " with executor " + executor,
- e);
+ log.get()
+ .log(
+ Level.SEVERE,
+ "RuntimeException while executing runnable "
+ + runnable
+ + " with executor "
+ + executor,
+ e);
}
}
@@ -1371,8 +1387,6 @@ public abstract class AbstractFuture<V extends @Nullable Object> extends Interna
UNSAFE = unsafe;
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
- } catch (RuntimeException e) {
- throw e;
}
}
diff --git a/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java b/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java
index 164a6dbb4..2529d4749 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractScheduledService.java
@@ -40,7 +40,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -105,7 +104,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
@J2ktIncompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractScheduledService implements Service {
- private static final Logger logger = Logger.getLogger(AbstractScheduledService.class.getName());
+ private static final LazyLogger logger = new LazyLogger(AbstractScheduledService.class);
/**
* A scheduler defines the policy for how the {@link AbstractScheduledService} should run its
@@ -239,10 +238,12 @@ public abstract class AbstractScheduledService implements Service {
shutDown();
} catch (Exception ignored) {
restoreInterruptIfIsInterruptedException(ignored);
- logger.log(
- Level.WARNING,
- "Error while attempting to shut down the service after failure.",
- ignored);
+ logger
+ .get()
+ .log(
+ Level.WARNING,
+ "Error while attempting to shut down the service after failure.",
+ ignored);
}
notifyFailed(t);
// requireNonNull is safe now, just as it was above.
@@ -606,7 +607,9 @@ public abstract class AbstractScheduledService implements Service {
lock.lock();
try {
toReturn = initializeOrUpdateCancellationDelegate(schedule);
- } catch (RuntimeException | Error e) {
+ } catch (Throwable e) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
+ //
// If an exception is thrown by the subclass then we need to make sure that the service
// notices and transitions to the FAILED state. We do it by calling notifyFailed directly
// because the service does not monitor the state of the future so if the exception is not
diff --git a/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java b/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
index 5581b5fae..3c5f30b63 100644
--- a/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
+++ b/guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
@@ -66,6 +66,7 @@ abstract class AbstractTransformFuture<
}
@Override
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public final void run() {
ListenableFuture<? extends I> localInputFuture = inputFuture;
F localFunction = function;
@@ -104,7 +105,7 @@ abstract class AbstractTransformFuture<
// Set the cause of the exception as this future's exception.
setException(e.getCause());
return;
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// Bug in inputFuture.get(). Propagate to the output Future so that its consumers don't hang.
setException(e);
return;
diff --git a/guava/src/com/google/common/util/concurrent/AggregateFuture.java b/guava/src/com/google/common/util/concurrent/AggregateFuture.java
index ec96cbb89..353477416 100644
--- a/guava/src/com/google/common/util/concurrent/AggregateFuture.java
+++ b/guava/src/com/google/common/util/concurrent/AggregateFuture.java
@@ -30,7 +30,6 @@ import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -44,7 +43,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
@ElementTypesAreNonnullByDefault
abstract class AggregateFuture<InputT extends @Nullable Object, OutputT extends @Nullable Object>
extends AggregateFutureState<OutputT> {
- private static final Logger logger = Logger.getLogger(AggregateFuture.class.getName());
+ private static final LazyLogger logger = new LazyLogger(AggregateFuture.class);
/**
* The input futures. After {@link #init}, this field is read only by {@link #afterDone()} (to
@@ -230,7 +229,7 @@ abstract class AggregateFuture<InputT extends @Nullable Object, OutputT extends
(throwable instanceof Error)
? "Input Future failed with Error"
: "Got more than one input Future failure. Logging failures after the first";
- logger.log(SEVERE, message, throwable);
+ logger.get().log(SEVERE, message, throwable);
}
@Override
@@ -268,7 +267,7 @@ abstract class AggregateFuture<InputT extends @Nullable Object, OutputT extends
collectOneValue(index, getDone(future));
} catch (ExecutionException e) {
handleException(e.getCause());
- } catch (RuntimeException | Error t) {
+ } catch (Throwable t) { // sneaky checked exception
handleException(t);
}
}
diff --git a/guava/src/com/google/common/util/concurrent/AggregateFutureState.java b/guava/src/com/google/common/util/concurrent/AggregateFutureState.java
index 7bdec0135..5816abf05 100644
--- a/guava/src/com/google/common/util/concurrent/AggregateFutureState.java
+++ b/guava/src/com/google/common/util/concurrent/AggregateFutureState.java
@@ -25,7 +25,6 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -51,7 +50,7 @@ abstract class AggregateFutureState<OutputT extends @Nullable Object>
private static final AtomicHelper ATOMIC_HELPER;
- private static final Logger log = Logger.getLogger(AggregateFutureState.class.getName());
+ private static final LazyLogger log = new LazyLogger(AggregateFutureState.class);
static {
AtomicHelper helper;
@@ -61,7 +60,7 @@ abstract class AggregateFutureState<OutputT extends @Nullable Object>
new SafeAtomicHelper(
newUpdater(AggregateFutureState.class, Set.class, "seenExceptions"),
newUpdater(AggregateFutureState.class, "remaining"));
- } catch (RuntimeException | Error reflectionFailure) {
+ } catch (Throwable reflectionFailure) { // sneaky checked exception
// Some Android 5.0.x Samsung devices have bugs in JDK reflection APIs that cause
// getDeclaredField to throw a NoSuchFieldException when the field is definitely there.
// For these users fallback to a suboptimal implementation, based on synchronized. This will
@@ -73,7 +72,7 @@ abstract class AggregateFutureState<OutputT extends @Nullable Object>
// Log after all static init is finished; if an installed logger uses any Futures methods, it
// shouldn't break in cases where reflection is missing/broken.
if (thrownReflectionFailure != null) {
- log.log(Level.SEVERE, "SafeAtomicHelper is broken!", thrownReflectionFailure);
+ log.get().log(Level.SEVERE, "SafeAtomicHelper is broken!", thrownReflectionFailure);
}
}
@@ -159,7 +158,7 @@ abstract class AggregateFutureState<OutputT extends @Nullable Object>
}
private static final class SafeAtomicHelper extends AtomicHelper {
- final AtomicReferenceFieldUpdater<AggregateFutureState<?>, Set<Throwable>>
+ final AtomicReferenceFieldUpdater<AggregateFutureState<?>, @Nullable Set<Throwable>>
seenExceptionsUpdater;
final AtomicIntegerFieldUpdater<AggregateFutureState<?>> remainingCountUpdater;
@@ -169,7 +168,7 @@ abstract class AggregateFutureState<OutputT extends @Nullable Object>
AtomicReferenceFieldUpdater seenExceptionsUpdater,
AtomicIntegerFieldUpdater remainingCountUpdater) {
this.seenExceptionsUpdater =
- (AtomicReferenceFieldUpdater<AggregateFutureState<?>, Set<Throwable>>)
+ (AtomicReferenceFieldUpdater<AggregateFutureState<?>, @Nullable Set<Throwable>>)
seenExceptionsUpdater;
this.remainingCountUpdater =
(AtomicIntegerFieldUpdater<AggregateFutureState<?>>) remainingCountUpdater;
diff --git a/guava/src/com/google/common/util/concurrent/AtomicLongMap.java b/guava/src/com/google/common/util/concurrent/AtomicLongMap.java
index 28481cca5..4ede5d606 100644
--- a/guava/src/com/google/common/util/concurrent/AtomicLongMap.java
+++ b/guava/src/com/google/common/util/concurrent/AtomicLongMap.java
@@ -17,6 +17,7 @@
package com.google.common.util.concurrent;
import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.Objects.requireNonNull;
import com.google.common.annotations.GwtCompatible;
import com.google.common.annotations.J2ktIncompatible;
@@ -147,8 +148,11 @@ public final class AtomicLongMap<K> implements Serializable {
@CanIgnoreReturnValue
public long updateAndGet(K key, LongUnaryOperator updaterFunction) {
checkNotNull(updaterFunction);
- return map.compute(
- key, (k, value) -> updaterFunction.applyAsLong((value == null) ? 0L : value.longValue()));
+ Long result =
+ map.compute(
+ key,
+ (k, value) -> updaterFunction.applyAsLong((value == null) ? 0L : value.longValue()));
+ return requireNonNull(result);
}
/**
@@ -329,7 +333,7 @@ public final class AtomicLongMap<K> implements Serializable {
return oldValue;
}
});
- return noValue.get() ? 0L : result.longValue();
+ return noValue.get() ? 0L : requireNonNull(result).longValue();
}
/**
diff --git a/guava/src/com/google/common/util/concurrent/ClosingFuture.java b/guava/src/com/google/common/util/concurrent/ClosingFuture.java
index 79aa0aa0e..efdf56d8a 100644
--- a/guava/src/com/google/common/util/concurrent/ClosingFuture.java
+++ b/guava/src/com/google/common/util/concurrent/ClosingFuture.java
@@ -58,7 +58,6 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -196,7 +195,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
// TODO(dpb): GWT compatibility.
public final class ClosingFuture<V extends @Nullable Object> {
- private static final Logger logger = Logger.getLogger(ClosingFuture.class.getName());
+ private static final LazyLogger logger = new LazyLogger(ClosingFuture.class);
/**
* An object that can capture objects to be closed later, when a {@link ClosingFuture} pipeline is
@@ -681,7 +680,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
*
* <p>After calling this method, you may not call {@link #finishToFuture()}, {@link
* #finishToValueAndCloser(ValueAndCloserConsumer, Executor)}, or any other derivation method on
- * this {@code ClosingFuture}.
+ * the original {@code ClosingFuture} instance.
*
* @param function transforms the value of this step to the value of the derived step
* @param executor executor to run the function in
@@ -774,7 +773,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
*
* <p>After calling this method, you may not call {@link #finishToFuture()}, {@link
* #finishToValueAndCloser(ValueAndCloserConsumer, Executor)}, or any other derivation method on
- * this {@code ClosingFuture}.
+ * the original {@code ClosingFuture} instance.
*
* @param function transforms the value of this step to a {@code ClosingFuture} with the value of
* the derived step
@@ -865,7 +864,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
*
* <p>After calling this method, you may not call {@link #finishToFuture()}, {@link
* #finishToValueAndCloser(ValueAndCloserConsumer, Executor)}, or any other derivation method on
- * this {@code ClosingFuture}.
+ * the original {@code ClosingFuture} instance.
*
* @param exceptionType the exception type that triggers use of {@code fallback}. The exception
* type is matched against this step's exception. "This step's exception" means the cause of
@@ -958,7 +957,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
*
* <p>After calling this method, you may not call {@link #finishToFuture()}, {@link
* #finishToValueAndCloser(ValueAndCloserConsumer, Executor)}, or any other derivation method on
- * this {@code ClosingFuture}.
+ * the original {@code ClosingFuture} instance.
*
* @param exceptionType the exception type that triggers use of {@code fallback}. The exception
* type is matched against this step's exception. "This step's exception" means the cause of
@@ -1015,13 +1014,13 @@ public final class ClosingFuture<V extends @Nullable Object> {
*
* <p>After calling this method, you may not call {@link
* #finishToValueAndCloser(ValueAndCloserConsumer, Executor)}, this method, or any other
- * derivation method on this {@code ClosingFuture}.
+ * derivation method on the original {@code ClosingFuture} instance.
*
* @return a {@link Future} that represents the final value or exception of the pipeline
*/
public FluentFuture<V> finishToFuture() {
if (compareAndUpdateState(OPEN, WILL_CLOSE)) {
- logger.log(FINER, "will close {0}", this);
+ logger.get().log(FINER, "will close {0}", this);
future.addListener(
new Runnable() {
@Override
@@ -1060,7 +1059,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
* receiver can store the {@link ValueAndCloser} outside the receiver for later synchronous use.
*
* <p>After calling this method, you may not call {@link #finishToFuture()}, this method again, or
- * any other derivation method on this {@code ClosingFuture}.
+ * any other derivation method on the original {@code ClosingFuture} instance.
*
* @param consumer a callback whose method will be called (using {@code executor}) when this
* operation is done
@@ -1121,7 +1120,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
*/
@CanIgnoreReturnValue
public boolean cancel(boolean mayInterruptIfRunning) {
- logger.log(FINER, "cancelling {0}", this);
+ logger.get().log(FINER, "cancelling {0}", this);
boolean cancelled = future.cancel(mayInterruptIfRunning);
if (cancelled) {
close();
@@ -1130,7 +1129,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
}
private void close() {
- logger.log(FINER, "closing {0}", this);
+ logger.get().log(FINER, "closing {0}", this);
closeables.close();
}
@@ -2144,7 +2143,7 @@ public final class ClosingFuture<V extends @Nullable Object> {
@Override
protected void finalize() {
if (state.get().equals(OPEN)) {
- logger.log(SEVERE, "Uh oh! An open ClosingFuture has leaked and will close: {0}", this);
+ logger.get().log(SEVERE, "Uh oh! An open ClosingFuture has leaked and will close: {0}", this);
FluentFuture<V> unused = finishToFuture();
}
}
@@ -2159,14 +2158,26 @@ public final class ClosingFuture<V extends @Nullable Object> {
try {
closeable.close();
} catch (Exception e) {
+ /*
+ * In guava-jre, any kind of Exception may be thrown because `closeable` has type
+ * `AutoCloseable`.
+ *
+ * In guava-android, the only kinds of Exception that may be thrown are
+ * RuntimeException and IOException because `closeable` has type `Closeable`—except
+ * that we have to account for sneaky checked exception.
+ */
restoreInterruptIfIsInterruptedException(e);
- logger.log(WARNING, "thrown by close()", e);
+ logger.get().log(WARNING, "thrown by close()", e);
}
});
} catch (RejectedExecutionException e) {
- if (logger.isLoggable(WARNING)) {
- logger.log(
- WARNING, String.format("while submitting close to %s; will close inline", executor), e);
+ if (logger.get().isLoggable(WARNING)) {
+ logger
+ .get()
+ .log(
+ WARNING,
+ String.format("while submitting close to %s; will close inline", executor),
+ e);
}
closeQuietly(closeable, directExecutor());
}
diff --git a/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java b/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java
index 0ec799cc4..6e2ae47a3 100644
--- a/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java
+++ b/guava/src/com/google/common/util/concurrent/CycleDetectingLockFactory.java
@@ -41,7 +41,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
/**
@@ -211,7 +210,7 @@ public class CycleDetectingLockFactory {
WARN {
@Override
public void handlePotentialDeadlock(PotentialDeadlockException e) {
- logger.log(Level.SEVERE, "Detected potential deadlock", e);
+ logger.get().log(Level.SEVERE, "Detected potential deadlock", e);
}
},
@@ -447,7 +446,7 @@ public class CycleDetectingLockFactory {
//////// Implementation /////////
- private static final Logger logger = Logger.getLogger(CycleDetectingLockFactory.class.getName());
+ private static final LazyLogger logger = new LazyLogger(CycleDetectingLockFactory.class);
final Policy policy;
@@ -711,7 +710,8 @@ public class CycleDetectingLockFactory {
*/
private void aboutToAcquire(CycleDetectingLock lock) {
if (!lock.isAcquiredByCurrentThread()) {
- ArrayList<LockGraphNode> acquiredLockList = acquiredLocks.get();
+ // requireNonNull accommodates Android's @RecentlyNullable annotation on ThreadLocal.get
+ ArrayList<LockGraphNode> acquiredLockList = requireNonNull(acquiredLocks.get());
LockGraphNode node = lock.getLockGraphNode();
node.checkAcquiredLocks(policy, acquiredLockList);
acquiredLockList.add(node);
@@ -725,7 +725,8 @@ public class CycleDetectingLockFactory {
*/
private static void lockStateChanged(CycleDetectingLock lock) {
if (!lock.isAcquiredByCurrentThread()) {
- ArrayList<LockGraphNode> acquiredLockList = acquiredLocks.get();
+ // requireNonNull accommodates Android's @RecentlyNullable annotation on ThreadLocal.get
+ ArrayList<LockGraphNode> acquiredLockList = requireNonNull(acquiredLocks.get());
LockGraphNode node = lock.getLockGraphNode();
// Iterate in reverse because locks are usually locked/unlocked in a
// LIFO order.
diff --git a/guava/src/com/google/common/util/concurrent/ExecutionList.java b/guava/src/com/google/common/util/concurrent/ExecutionList.java
index 645817c4a..10b933aa1 100644
--- a/guava/src/com/google/common/util/concurrent/ExecutionList.java
+++ b/guava/src/com/google/common/util/concurrent/ExecutionList.java
@@ -21,7 +21,6 @@ import com.google.common.annotations.J2ktIncompatible;
import com.google.errorprone.annotations.concurrent.GuardedBy;
import java.util.concurrent.Executor;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
/**
@@ -45,7 +44,7 @@ import javax.annotation.CheckForNull;
@ElementTypesAreNonnullByDefault
public final class ExecutionList {
/** Logger to log exceptions caught when running runnables. */
- private static final Logger log = Logger.getLogger(ExecutionList.class.getName());
+ private static final LazyLogger log = new LazyLogger(ExecutionList.class);
/**
* The runnable, executor pairs to execute. This acts as a stack threaded through the {@link
@@ -140,17 +139,22 @@ public final class ExecutionList {
* Submits the given runnable to the given {@link Executor} catching and logging all {@linkplain
* RuntimeException runtime exceptions} thrown by the executor.
*/
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private static void executeListener(Runnable runnable, Executor executor) {
try {
executor.execute(runnable);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// Log it and keep going -- bad runnable and/or executor. Don't punish the other runnables if
// we're given a bad one. We only catch RuntimeException because we want Errors to propagate
// up.
- log.log(
- Level.SEVERE,
- "RuntimeException while executing runnable " + runnable + " with executor " + executor,
- e);
+ log.get()
+ .log(
+ Level.SEVERE,
+ "RuntimeException while executing runnable "
+ + runnable
+ + " with executor "
+ + executor,
+ e);
}
}
diff --git a/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java b/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
index 1c16cfb14..0f8a17894 100644
--- a/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
+++ b/guava/src/com/google/common/util/concurrent/FakeTimeLimiter.java
@@ -77,12 +77,13 @@ public final class FakeTimeLimiter implements TimeLimiter {
}
@Override
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public void runWithTimeout(Runnable runnable, long timeoutDuration, TimeUnit timeoutUnit) {
checkNotNull(runnable);
checkNotNull(timeoutUnit);
try {
runnable.run();
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
throw new UncheckedExecutionException(e);
} catch (Error e) {
throw new ExecutionError(e);
diff --git a/guava/src/com/google/common/util/concurrent/Futures.java b/guava/src/com/google/common/util/concurrent/Futures.java
index 31889609a..6e8d20193 100644
--- a/guava/src/com/google/common/util/concurrent/Futures.java
+++ b/guava/src/com/google/common/util/concurrent/Futures.java
@@ -545,7 +545,8 @@ public final class Futures extends GwtFuturesCatchingSpecialization {
private O applyTransformation(I input) throws ExecutionException {
try {
return function.apply(input);
- } catch (RuntimeException | Error t) {
+ } catch (Throwable t) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
throw new ExecutionException(t);
}
}
@@ -1126,7 +1127,8 @@ public final class Futures extends GwtFuturesCatchingSpecialization {
} catch (ExecutionException e) {
callback.onFailure(e.getCause());
return;
- } catch (RuntimeException | Error e) {
+ } catch (Throwable e) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
callback.onFailure(e);
return;
}
@@ -1202,10 +1204,10 @@ public final class Futures extends GwtFuturesCatchingSpecialization {
*
* <p>Instances of {@code exceptionClass} are created by choosing an arbitrary public constructor
* that accepts zero or more arguments, all of type {@code String} or {@code Throwable}
- * (preferring constructors with at least one {@code String}) and calling the constructor via
- * reflection. If the exception did not already have a cause, one is set by calling {@link
- * Throwable#initCause(Throwable)} on it. If no such constructor exists, an {@code
- * IllegalArgumentException} is thrown.
+ * (preferring constructors with at least one {@code String}, then preferring constructors with at
+ * least one {@code Throwable}) and calling the constructor via reflection. If the exception did
+ * not already have a cause, one is set by calling {@link Throwable#initCause(Throwable)} on it.
+ * If no such constructor exists, an {@code IllegalArgumentException} is thrown.
*
* @throws X if {@code get} throws any checked exception except for an {@code ExecutionException}
* whose cause is not itself a checked exception
@@ -1254,10 +1256,10 @@ public final class Futures extends GwtFuturesCatchingSpecialization {
*
* <p>Instances of {@code exceptionClass} are created by choosing an arbitrary public constructor
* that accepts zero or more arguments, all of type {@code String} or {@code Throwable}
- * (preferring constructors with at least one {@code String}) and calling the constructor via
- * reflection. If the exception did not already have a cause, one is set by calling {@link
- * Throwable#initCause(Throwable)} on it. If no such constructor exists, an {@code
- * IllegalArgumentException} is thrown.
+ * (preferring constructors with at least one {@code String}, then preferring constructors with at
+ * least one {@code Throwable}) and calling the constructor via reflection. If the exception did
+ * not already have a cause, one is set by calling {@link Throwable#initCause(Throwable)} on it.
+ * If no such constructor exists, an {@code IllegalArgumentException} is thrown.
*
* @throws X if {@code get} throws any checked exception except for an {@code ExecutionException}
* whose cause is not itself a checked exception
diff --git a/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java b/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java
index c512d82ee..17e0675b6 100644
--- a/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java
+++ b/guava/src/com/google/common/util/concurrent/FuturesGetChecked.java
@@ -21,7 +21,6 @@ import static java.util.Arrays.asList;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
import com.google.common.collect.Ordering;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.j2objc.annotations.J2ObjCIncompatible;
@@ -225,7 +224,7 @@ final class FuturesGetChecked {
try {
Exception unused = newWithCause(exceptionClass, new Exception());
return true;
- } catch (RuntimeException | Error e) {
+ } catch (Throwable t) { // sneaky checked exception
return false;
}
}
@@ -234,7 +233,7 @@ final class FuturesGetChecked {
// getConstructors() guarantees this as long as we don't modify the array.
@SuppressWarnings({"unchecked", "rawtypes"})
List<Constructor<X>> constructors = (List) Arrays.asList(exceptionClass.getConstructors());
- for (Constructor<X> constructor : preferringStrings(constructors)) {
+ for (Constructor<X> constructor : preferringStringsThenThrowables(constructors)) {
X instance = newFromConstructor(constructor, cause);
if (instance != null) {
if (instance.getCause() == null) {
@@ -250,17 +249,22 @@ final class FuturesGetChecked {
cause);
}
- private static <X extends Exception> List<Constructor<X>> preferringStrings(
+ private static <X extends Exception> List<Constructor<X>> preferringStringsThenThrowables(
List<Constructor<X>> constructors) {
- return WITH_STRING_PARAM_FIRST.sortedCopy(constructors);
+ return WITH_STRING_PARAM_THEN_WITH_THROWABLE_PARAM.sortedCopy(constructors);
}
- private static final Ordering<Constructor<?>> WITH_STRING_PARAM_FIRST =
+ // TODO: b/296487962 - Consider defining a total order over constructors.
+ private static final Ordering<List<Class<?>>> ORDERING_BY_CONSTRUCTOR_PARAMETER_LIST =
Ordering.natural()
- .onResultOf(
- (Function<Constructor<?>, Boolean>)
- input -> asList(input.getParameterTypes()).contains(String.class))
+ .onResultOf((List<Class<?>> params) -> params.contains(String.class))
+ .compound(
+ Ordering.natural()
+ .onResultOf((List<Class<?>> params) -> params.contains(Throwable.class)))
.reverse();
+ private static final Ordering<Constructor<?>> WITH_STRING_PARAM_THEN_WITH_THROWABLE_PARAM =
+ ORDERING_BY_CONSTRUCTOR_PARAMETER_LIST.onResultOf(
+ constructor -> asList(constructor.getParameterTypes()));
@CheckForNull
private static <X> X newFromConstructor(Constructor<X> constructor, Throwable cause) {
diff --git a/guava/src/com/google/common/util/concurrent/ImmediateFuture.java b/guava/src/com/google/common/util/concurrent/ImmediateFuture.java
index f09816c4e..62ae63eaa 100644
--- a/guava/src/com/google/common/util/concurrent/ImmediateFuture.java
+++ b/guava/src/com/google/common/util/concurrent/ImmediateFuture.java
@@ -22,7 +22,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -33,7 +32,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
class ImmediateFuture<V extends @Nullable Object> implements ListenableFuture<V> {
static final ListenableFuture<?> NULL = new ImmediateFuture<@Nullable Object>(null);
- private static final Logger log = Logger.getLogger(ImmediateFuture.class.getName());
+ private static final LazyLogger log = new LazyLogger(ImmediateFuture.class);
@ParametricNullness private final V value;
@@ -42,18 +41,23 @@ class ImmediateFuture<V extends @Nullable Object> implements ListenableFuture<V>
}
@Override
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public void addListener(Runnable listener, Executor executor) {
checkNotNull(listener, "Runnable was null.");
checkNotNull(executor, "Executor was null.");
try {
executor.execute(listener);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// ListenableFuture's contract is that it will not throw unchecked exceptions, so log the bad
// runnable and/or executor and swallow it.
- log.log(
- Level.SEVERE,
- "RuntimeException while executing runnable " + listener + " with executor " + executor,
- e);
+ log.get()
+ .log(
+ Level.SEVERE,
+ "RuntimeException while executing runnable "
+ + listener
+ + " with executor "
+ + executor,
+ e);
}
}
diff --git a/guava/src/com/google/common/util/concurrent/InterruptibleTask.java b/guava/src/com/google/common/util/concurrent/InterruptibleTask.java
index 6f33c5032..effa8ef59 100644
--- a/guava/src/com/google/common/util/concurrent/InterruptibleTask.java
+++ b/guava/src/com/google/common/util/concurrent/InterruptibleTask.java
@@ -23,6 +23,7 @@ import com.google.j2objc.annotations.ReflectionSupport;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.AbstractOwnableSynchronizer;
import java.util.concurrent.locks.LockSupport;
+import javax.annotation.CheckForNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@GwtCompatible(emulated = true)
@@ -234,6 +235,7 @@ abstract class InterruptibleTask<T extends @Nullable Object>
}
@VisibleForTesting
+ @CheckForNull
Thread getOwner() {
return super.getExclusiveOwnerThread();
}
diff --git a/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java b/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java
index 33403c978..eb3a24707 100644
--- a/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java
+++ b/guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java
@@ -19,7 +19,6 @@ import static com.google.common.util.concurrent.Uninterruptibles.getUninterrupti
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -162,10 +161,11 @@ public final class JdkFutureAdapters {
* to return a proper ListenableFuture instead of using listenInPoolThread.
*/
getUninterruptibly(delegate);
- } catch (ExecutionException | RuntimeException | Error e) {
- // (including CancellationException)
+ } catch (Throwable t) {
+ // (including CancellationException and sneaky checked exception)
// The task is presumably done, run the listeners.
- // TODO(cpovirk): Do *something* in case of Error (and maybe RuntimeException)?
+ // TODO(cpovirk): Do *something* in case of Error (and maybe
+ // non-CancellationException, non-ExecutionException exceptions)?
}
executionList.execute();
});
diff --git a/guava/src/com/google/common/util/concurrent/LazyLogger.java b/guava/src/com/google/common/util/concurrent/LazyLogger.java
new file mode 100644
index 000000000..9ae0f784e
--- /dev/null
+++ b/guava/src/com/google/common/util/concurrent/LazyLogger.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2023 The Guava Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.common.util.concurrent;
+
+import com.google.common.annotations.GwtCompatible;
+import java.util.logging.Logger;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/** A holder for a {@link Logger} that is initialized only when requested. */
+@GwtCompatible
+@ElementTypesAreNonnullByDefault
+final class LazyLogger {
+ private final String loggerName;
+ private volatile @Nullable Logger logger;
+
+ LazyLogger(Class<?> ownerOfLogger) {
+ this.loggerName = ownerOfLogger.getName();
+ }
+
+ Logger get() {
+ /*
+ * We use double-checked locking. We could the try racy single-check idiom, but that would
+ * depend on Logger not contain mutable state.
+ *
+ * We could use Suppliers.memoizingSupplier here, but I micro-optimized to this implementation
+ * to avoid the extra class for the lambda (and maybe more for memoizingSupplier itself) and the
+ * indirection.
+ *
+ * One thing to *avoid* is a change to make each Logger user use memoizingSupplier directly:
+ * That may introduce an extra class for each lambda (currently a dozen).
+ */
+ Logger local = logger;
+ if (local != null) {
+ return local;
+ }
+ synchronized (this) {
+ local = logger;
+ if (local != null) {
+ return local;
+ }
+ return logger = Logger.getLogger(loggerName);
+ }
+ }
+}
diff --git a/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java b/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
index 4ef7ed36c..e6284e1c7 100644
--- a/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
+++ b/guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
@@ -27,7 +27,6 @@ import java.util.List;
import java.util.Queue;
import java.util.concurrent.Executor;
import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* A list of listeners for implementing a concurrency friendly observable object.
@@ -58,7 +57,7 @@ import java.util.logging.Logger;
@ElementTypesAreNonnullByDefault
final class ListenerCallQueue<L> {
// TODO(cpovirk): consider using the logger associated with listener.getClass().
- private static final Logger logger = Logger.getLogger(ListenerCallQueue.class.getName());
+ private static final LazyLogger logger = new LazyLogger(ListenerCallQueue.class);
// TODO(chrisn): promote AppendOnlyCollection for use here.
private final List<PerListenerQueue<L>> listeners =
@@ -159,6 +158,7 @@ final class ListenerCallQueue<L> {
* Dispatches all listeners {@linkplain #enqueue enqueued} prior to this call, serially and in
* order.
*/
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
void dispatch() {
boolean scheduleEventRunner = false;
synchronized (this) {
@@ -170,22 +170,25 @@ final class ListenerCallQueue<L> {
if (scheduleEventRunner) {
try {
executor.execute(this);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// reset state in case of an error so that later dispatch calls will actually do something
synchronized (this) {
isThreadScheduled = false;
}
// Log it and keep going.
- logger.log(
- Level.SEVERE,
- "Exception while running callbacks for " + listener + " on " + executor,
- e);
+ logger
+ .get()
+ .log(
+ Level.SEVERE,
+ "Exception while running callbacks for " + listener + " on " + executor,
+ e);
throw e;
}
}
}
@Override
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
public void run() {
boolean stillRunning = true;
try {
@@ -206,12 +209,14 @@ final class ListenerCallQueue<L> {
// Always run while _not_ holding the lock, to avoid deadlocks.
try {
nextToRun.call(listener);
- } catch (RuntimeException e) {
+ } catch (Exception e) { // sneaky checked exception
// Log it and keep going.
- logger.log(
- Level.SEVERE,
- "Exception while executing callback: " + listener + " " + nextLabel,
- e);
+ logger
+ .get()
+ .log(
+ Level.SEVERE,
+ "Exception while executing callback: " + listener + " " + nextLabel,
+ e);
}
}
} finally {
diff --git a/guava/src/com/google/common/util/concurrent/Monitor.java b/guava/src/com/google/common/util/concurrent/Monitor.java
index 2ed31eda4..1abbc6405 100644
--- a/guava/src/com/google/common/util/concurrent/Monitor.java
+++ b/guava/src/com/google/common/util/concurrent/Monitor.java
@@ -1123,7 +1123,8 @@ public final class Monitor {
private boolean isSatisfied(Guard guard) {
try {
return guard.isSatisfied();
- } catch (RuntimeException | Error throwable) {
+ } catch (Throwable throwable) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
signalAllWaiters();
throw throwable;
}
diff --git a/guava/src/com/google/common/util/concurrent/MoreExecutors.java b/guava/src/com/google/common/util/concurrent/MoreExecutors.java
index ea3536957..46536fbe7 100644
--- a/guava/src/com/google/common/util/concurrent/MoreExecutors.java
+++ b/guava/src/com/google/common/util/concurrent/MoreExecutors.java
@@ -739,7 +739,8 @@ public final class MoreExecutors {
public void run() {
try {
delegate.run();
- } catch (RuntimeException | Error t) {
+ } catch (Throwable t) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
setException(t);
throw t;
}
@@ -784,7 +785,10 @@ public final class MoreExecutors {
* An implementation of {@link ExecutorService#invokeAny} for {@link ListeningExecutorService}
* implementations.
*/
- @SuppressWarnings("GoodTime") // should accept a java.time.Duration
+ @SuppressWarnings({
+ "GoodTime", // should accept a java.time.Duration
+ "CatchingUnchecked", // sneaky checked exception
+ })
@J2ktIncompatible
@GwtIncompatible
@ParametricNullness
@@ -847,7 +851,9 @@ public final class MoreExecutors {
return f.get();
} catch (ExecutionException eex) {
ee = eex;
- } catch (RuntimeException rex) {
+ } catch (InterruptedException iex) {
+ throw iex;
+ } catch (Exception rex) { // sneaky checked exception
ee = new ExecutionException(rex);
}
}
diff --git a/guava/src/com/google/common/util/concurrent/SequentialExecutor.java b/guava/src/com/google/common/util/concurrent/SequentialExecutor.java
index c842d7e07..ebc33178d 100644
--- a/guava/src/com/google/common/util/concurrent/SequentialExecutor.java
+++ b/guava/src/com/google/common/util/concurrent/SequentialExecutor.java
@@ -31,7 +31,6 @@ import java.util.Deque;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.CheckForNull;
/**
@@ -52,7 +51,7 @@ import javax.annotation.CheckForNull;
@GwtIncompatible
@ElementTypesAreNonnullByDefault
final class SequentialExecutor implements Executor {
- private static final Logger log = Logger.getLogger(SequentialExecutor.class.getName());
+ private static final LazyLogger log = new LazyLogger(SequentialExecutor.class);
enum WorkerRunningState {
/** Runnable is not running and not queued for execution */
@@ -136,7 +135,8 @@ final class SequentialExecutor implements Executor {
try {
executor.execute(worker);
- } catch (RuntimeException | Error t) {
+ } catch (Throwable t) {
+ // Any Exception is either a RuntimeException or sneaky checked exception.
synchronized (queue) {
boolean removed =
(workerRunningState == IDLE || workerRunningState == QUEUING)
@@ -202,6 +202,7 @@ final class SequentialExecutor implements Executor {
* will still be present. If the composed Executor is an ExecutorService, it can respond to
* shutdown() by returning tasks queued on that Thread after {@link #worker} drains the queue.
*/
+ @SuppressWarnings("CatchingUnchecked") // sneaky checked exception
private void workOnQueue() {
boolean interruptedDuringTask = false;
boolean hasSetRunning = false;
@@ -235,8 +236,8 @@ final class SequentialExecutor implements Executor {
interruptedDuringTask |= Thread.interrupted();
try {
task.run();
- } catch (RuntimeException e) {
- log.log(Level.SEVERE, "Exception while executing runnable " + task, e);
+ } catch (Exception e) { // sneaky checked exception
+ log.get().log(Level.SEVERE, "Exception while executing runnable " + task, e);
} finally {
task = null;
}
diff --git a/guava/src/com/google/common/util/concurrent/ServiceManager.java b/guava/src/com/google/common/util/concurrent/ServiceManager.java
index 42652c967..0bda0afec 100644
--- a/guava/src/com/google/common/util/concurrent/ServiceManager.java
+++ b/guava/src/com/google/common/util/concurrent/ServiceManager.java
@@ -65,7 +65,6 @@ import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* A manager for monitoring and controlling a set of {@linkplain Service services}. This class
@@ -125,7 +124,7 @@ import java.util.logging.Logger;
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ServiceManager implements ServiceManagerBridge {
- private static final Logger logger = Logger.getLogger(ServiceManager.class.getName());
+ private static final LazyLogger logger = new LazyLogger(ServiceManager.class);
private static final ListenerCallQueue.Event<Listener> HEALTHY_EVENT =
new ListenerCallQueue.Event<Listener>() {
@Override
@@ -208,10 +207,13 @@ public final class ServiceManager implements ServiceManagerBridge {
if (copy.isEmpty()) {
// Having no services causes the manager to behave strangely. Notably, listeners are never
// fired. To avoid this we substitute a placeholder service.
- logger.log(
- Level.WARNING,
- "ServiceManager configured with no services. Is your application configured properly?",
- new EmptyServiceManagerWarning());
+ logger
+ .get()
+ .log(
+ Level.WARNING,
+ "ServiceManager configured with no services. Is your application configured"
+ + " properly?",
+ new EmptyServiceManagerWarning());
copy = ImmutableList.<Service>of(new NoOpService());
}
this.state = new ServiceManagerState(copy);
@@ -278,7 +280,7 @@ public final class ServiceManager implements ServiceManagerBridge {
// service or listener). Our contract says it is safe to call this method if
// all services were NEW when it was called, and this has already been verified above, so we
// don't propagate the exception.
- logger.log(Level.WARNING, "Unable to start Service " + service, e);
+ logger.get().log(Level.WARNING, "Unable to start Service " + service, e);
}
}
return this;
@@ -706,7 +708,7 @@ public final class ServiceManager implements ServiceManagerBridge {
// N.B. if we miss the STARTING event then we may never record a startup time.
stopwatch.stop();
if (!(service instanceof NoOpService)) {
- logger.log(Level.FINE, "Started {0} in {1}.", new Object[] {service, stopwatch});
+ logger.get().log(Level.FINE, "Started {0} in {1}.", new Object[] {service, stopwatch});
}
}
// Queue our listeners
@@ -798,7 +800,7 @@ public final class ServiceManager implements ServiceManagerBridge {
if (state != null) {
state.transitionService(service, NEW, STARTING);
if (!(service instanceof NoOpService)) {
- logger.log(Level.FINE, "Starting {0}.", service);
+ logger.get().log(Level.FINE, "Starting {0}.", service);
}
}
}
@@ -824,10 +826,12 @@ public final class ServiceManager implements ServiceManagerBridge {
ServiceManagerState state = this.state.get();
if (state != null) {
if (!(service instanceof NoOpService)) {
- logger.log(
- Level.FINE,
- "Service {0} has terminated. Previous state was: {1}",
- new Object[] {service, from});
+ logger
+ .get()
+ .log(
+ Level.FINE,
+ "Service {0} has terminated. Previous state was: {1}",
+ new Object[] {service, from});
}
state.transitionService(service, from, TERMINATED);
}
@@ -846,10 +850,12 @@ public final class ServiceManager implements ServiceManagerBridge {
*/
log &= from != State.STARTING;
if (log) {
- logger.log(
- Level.SEVERE,
- "Service " + service + " has failed in the " + from + " state.",
- failure);
+ logger
+ .get()
+ .log(
+ Level.SEVERE,
+ "Service " + service + " has failed in the " + from + " state.",
+ failure);
}
state.transitionService(service, from, FAILED);
}
diff --git a/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java b/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java
index 1dc1094d4..9890c89d6 100644
--- a/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java
+++ b/guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java
@@ -21,7 +21,6 @@ import com.google.common.annotations.J2ktIncompatible;
import com.google.common.annotations.VisibleForTesting;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.Locale;
-import java.util.logging.Logger;
/**
* Factories for {@link UncaughtExceptionHandler} instances.
@@ -57,7 +56,7 @@ public final class UncaughtExceptionHandlers {
@VisibleForTesting
static final class Exiter implements UncaughtExceptionHandler {
- private static final Logger logger = Logger.getLogger(Exiter.class.getName());
+ private static final LazyLogger logger = new LazyLogger(Exiter.class);
private final Runtime runtime;
@@ -68,9 +67,13 @@ public final class UncaughtExceptionHandlers {
@Override
public void uncaughtException(Thread t, Throwable e) {
try {
- logger.log(
- SEVERE, String.format(Locale.ROOT, "Caught an exception in %s. Shutting down.", t), e);
- } catch (RuntimeException | Error errorInLogging) {
+ logger
+ .get()
+ .log(
+ SEVERE,
+ String.format(Locale.ROOT, "Caught an exception in %s. Shutting down.", t),
+ e);
+ } catch (Throwable errorInLogging) { // sneaky checked exception
// If logging fails, e.g. due to missing memory, at least try to log the
// message and the cause for the failed logging.
System.err.println(e.getMessage());
diff --git a/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java b/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java
index e728822a8..fd176780e 100644
--- a/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java
+++ b/guava/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.java
@@ -42,13 +42,13 @@ public final class PublicSuffixPatterns {
/** If a hostname is contained as a key in this map, it is a public suffix. */
public static final ImmutableMap<String, PublicSuffixType> EXACT =
TrieParser.parseTrie(
- "a&0&0trk9--nx?27qjf--nx?e9ebgn--nx?nbb0c7abgm--nx??1&2oa08--nx?apg6qpcbgm--nx?hbbgm--nx?rdceqa08--nx??2&8ugbgm--nx?eyh3la2ckx--nx?qbd9--nx??3&2wqq1--nx?60a0y8--nx??4x1d77xrck--nx?6&1f4a3abgm--nx?2yqyn--nx?5b06t--nx?axq--nx?ec7q--nx?lbgw--nx??883xnn--nx?9d2c24--nx?a&a?it??b!.&gro?lim?moc?sr,t&en?opsgolb,?ude?vog??abila?c?ihsot?m?n??c!.&b&a?m?n??c&b?g?q??ep?fn?k&s?y??ln?no?oc,p&i-on,ohsdaerpsym,?sn?t&n?opsgolb,?un?ysrab,?i&ma?r&emarp?fa??sroc??naiva?s??d&ats?n&eit?oh??om?sa?tl??eg?f&c?ob??g!emo?naripi?oy??hskihs?i&dem!.remarf,?hs?k!on??sa!.snduolc,??jnin?k&aso?dov?ede?usto??l!.&c,gro?moc?ofni?r&ep?nb,?t&en?ni??ude?vog??irgnahs?le&nisiuc?rbmuder???m!.&ca?gro?oc?sserp?ten?vog??ahokoy?e00sf7vqn--nx?m??n!.&ac?cc?eman?gro?ibom?loohcs?moc?ni?o&c?fni?rp??r&d?o??s&u?w??vt?xm??av?is?olecrab?tea??p!.&bog?ca?d&em?ls??g&ni?ro??mo&c?n??oba?ten?ude??c?g7hyabgm--nx?ra!.&461e?6pi?iru?nru?rdda-ni?siri???s??q!.&eman?gro?hcs?lim?moc?t&en?opsgolb,?ude?vog???r&az?emac?f4a3abgm--nx?n!d5uhf8le58r4w--nx??u&kas?tan???s!.&bup?dem?gro?hcs?moc?ten?ude?vog??ac!.uban.iu,?iv??t&ad?elhta?led?oyot??u!.&a&cinniv?emirc?i&hzhziropaz?stynniv??s&edo?sedo??tlay?vatlop??bs?cc,d&argovorik?o!roghzu??tl,?e&hzhziropaz?i,nvir?t??f&i?ni,?g&l?ro??hk?i&stvinrehc?ykstyn&lemhk?vypork???k&c?m?s&nagul?t&enod?ul??v&iknarf-onavi?orteporp&end?ind?????l&iponret?opotsa&bes?ves??p??m&k?oc?s?yrk??n&c?d?i?osrehk?v?ylov??o&c,nvor??p&d?p,z??r&c?imotihz?k?ymotyhz??sk?t&en?l?z??ude?v:c?e&alokin?ik??i&alokym?hinrehc?krahk?vl?yk??k?l?o&g!inrehc??krahk??r?,xc,y&ikstinlemhk?mus?s&akrehc?sakrehc?tvonrehc???z&ib,u????v!aj?bb?et?iv??waniko?x&a?iacal??yogan?z&.&bew?c&a?i&n?rga???gro?l&im?oohcs??m&on?t??o&c!.topsgolb,?gn??radnorg?sin?t&en?la??ude?vog?wal??zip!.korgn,???b&00ave5a9iabgm--nx?1&25qhx--nx?68quv--nx?e2kc1--nx??2xtbgm--nx?3&b2kcc--nx?jca1d--nx??4&6&1rfz--nx?qif--nx??96rzc--nx??88uvor--nx?a&0dc4xbgm--nx?c?her?n?ra?t??b!.&erots?gro?moc?o&c?fni??ten?ude?v&og?t??zib??a??c&j?s??d&hesa08--nx?mi??g?l!.&gro?moc?ten?ude?vog??m??s!.&gro?moc?ten?ude?vog???tc-retarebsnegmrev--nx?u&lc!.&elej,snduolc,ysrab,?smas??p!.ysrab,??wp-gnutarebsnegmrev--nx??c&1&1q54--nx?hbgw--nx??2e9c2czf--nx?4&4ub1km--nx?a1e--nx?byj9q--nx?erd5a9b1kcb--nx??8&4xx2g--nx?c9jrb2h--nx??9jr&b&2h--nx?54--nx?9s--nx??c&eg--nx?h3--nx?s2--nx???a!.&gro?lim?moc?rrd,ten?ude?vog??3a09--nx!.&ca1o--nx?gva1c--nx?h&ca1o--nx?za09--nx??ta1d--nx?ua08--nx????b&a?b?ci?f76a0c7ylqbgm--nx?sh??c!.&eugaelysatnaf,gnipparcs,liamwt,nwaps.secnatsni,revres-emag,s&nduolc,otohpym,seccaptf,?xsc,?0atf7b45--nx?a1l--nx??e!.&21k?bog?dem?esab,gro?l&aiciffo,im??moc?nif?o&fni?rp??ten?ude?vog??beuq?n?smoc??fdh?i&l&buperananab?ohtac??n&agro?ilc?osanap??sum?tic??l!.&gro?moc?oc?ten?ude?vog?yo,?l??m!.&mt?ossa??p1akcq--nx??n!.&mon?ossa??i?p??relcel?s!.&gro?moc?ten?ude?vog???t!.&e&m,w,?hc,?s?w??v!.&e0,gro?lim?moc?ten?ude?v&g:.d,,og????wp?yn??d&2urzc--nx?3&1wrpk--nx?c&4b11--nx?9jrcpf--nx???5xq55--nx?697uto--nx?75yrpk--nx?9ctdvkce--nx?a!.mon?d?er?olnwod??b2babgm--nx?c!.vog?g9a2g2b0ae0chclc--nx??e&m!bulc??r!k??sopxe?timil?w??fc?g!.&ude?vog???h&d3tbgm--nx?p?t??i!.&ased?bew?ca?etrof,hcs?lim?o&c!.topsgolb,?g??palf,ro?sepnop?ten?ym?zib??b?ordna?p?rdam??l&iub?og?row??m!.&ed,ot,pj,t&a,opsgolb,???n&a&b?l!.citats:.&setis,ved,?,raas???ob?uf??o&of?rp??r&a&c&tiderc?yalcrab??ugnav??ef506w4b--nx?k!.&oc,ude,?jh3a1habgm--nx??of??s!.&dem?gro?moc?ofni?ten?ude?v&og?t???m!kcrem???t!.topsgolb,excwkcc--nx?l??uolc!.&a&bura-vnej.&1ti,abura.rue.1ti,?tcepsrep,xo:.&ku,nt,?,?b&dnevar,ewilek:.sc,,?citsalej.piv,drayknil,elej,gnitsohdnert.&ed,hc,?letemirp:.ku,,m&edaid,ialcer.&ac,ku,su,??n&evueluk,woru,?r&epolroov,o&pav,tnemele,??tenraxa.1-se,ululetoj,wcs.&gnilebaltrams,koobelacs,latemerab.&1-&rap-rf,sma-ln,?2-rap-rf,?rap-rf.&3s,cnf:.snoitcnuf,,etisbew-3s,mhw,s8k:.sedon,,?s&8k,ecnatsni.&bup,virp,?ma-ln.&3s,etisbew-3s,mhw,s8k:.sedon,,??waw-lp.&3s,etisbew-3s,s8k:.sedon,,??xelpciffart,yawocne.ue,??za5cbgn--nx??e&1&53wlf--nx?7a1hbbgm--nx?ta3kg--nx??2a6a1b6b1i--nx?3ma0e1cvr--nx?418txh--nx?707b0e3--nx?a!.&ca?gro?hcs?lim?oc?t&en?opsgolb,?vog??09--nx??b!.&ca?etisbew321,gnitsohbew,nevueluk.yxorpze,pohsdaerpsym,snoitulostsohretni.duolc,topsgolb,?ortal?ut!uoy???c&0krbd4--nx!.&a2qbd8--nx?b8adbeh--nx?c6ytdgbd4--nx?d8lhbd5--nx???a&lp!.oc,?ps!.&lla4sx,rebu,tsafym,?artxe??sla??i!ffo??n&a&d?iler?nif?rusni!efil?srelevart???eics!.oby,??rofria??d!.&1sndnyd,42pi-nyd,7erauqs,amil4,b&ow-nrefeilgitsng--nx,rb-ni,vz-nelletsebgitsng--nx,?decalpb,e&daregtmueart,luhcsvresi,mohsnd,nihcamyek,tiesbew321,?hcierebsnoissuksid,keegnietsi,lsd-ni,m&oc,rofttalpluhcs,?n&-i-g-o-l,aw-ym,e&lletsebgitsnüg,sgnutiel,?i&emtsi,lreb-n&i,yd,??norblieh-sh.ti.segap,oitatsksid-ygolonys,pv&-n&i,yd,?nyd,?refeilgitsnüg,?orp-ytinummoc,p&h21,iog:ol,,ohsdaerpsym,?r&e&ntrapdeeps.remotsuc,su&-lautriv,lautriv,?t&adpusnd,tub-ni,uor-ym,?vres&-e&bucl,mohym,?bew-emoh:.nyd,,luhcs,??ogiv-&niem,ym,??s&d-&onys,ygolonys,?nd&-&dd,nufiat,sehcsimanyd,tenretni,yard,?isoc.nyd,ps,yard,?oper-&nvs,tig,?sndd:.&nyd,sndnyd,?,?topsgolb,vresi-&niem,tset,?xi2,y&awetag-&llawerif,ym,?srab,tic-amil,?zten&mitbel,sadtretteuf,??art!.oby,?i&sdoow?ug??on--nx??e!.&bil?dem?eif?gro?irp?kiir?moc!.topsgolb,?pia?ude?vog??ei?ffoc?gg?r&f?ged???f&a&c?s??il??g!.&gro?lim?moc?t&en?vp??ude?vog??a&f?gtrom?p!.&3xlh,detalsnart,grebedoc,kselp,sndp,tengam,xlh,y&cvrp,kcor,???rots?yov??elloc?na&hcxe?ro!.hcet,??roeg?ug??i!.&pohsdaerpsym,topsgolb,vog??tilop?v&bba?om???j!.&fo,gro?oc?ten???k!.&c&a?s??e&m?n??ibom?o&c!.topsgolb,?fni?g??ro??i&b?l?n???l&a&dmrif?s!rof???b&a?i&b?dua???c&aro?ric??dnik?g!oog??i&bom?ms??l&asal?erauqa??ppa?uhcs?yts!efil???m!.&4&32i,p&ct,v,??66c,ailisarb,b&dnevar,g-raegelif,?ca?duolcsd,e&d-raegelif,i&-raegelif,lpad:.tsohlacol,,?pcm,?g&ro?s-raegelif,?hctilg,kcatsegde,noitatsksid,o&bmoy,c?t&nigol,poh,??p&i&on,snart.etis,?j-raegelif,ohbew,?r&aegelif,idcm,ofsnd,?s&dym,ndd,ti?umhol,?t&en?s&acdnuos,ohon,??u&a-raegelif,de??v&irp?og??y&golonys,olpedew,srab,??a&g?n!.&reh.togrof,sih.togrof,???em?i&rp?twohs??orhc?w??n!goloc?i&lno!.&egats-oree,oree,ysrab,??w??o!.&derno:.gnigats,,ecivres,knilemoh,?hp?latipac?ts&der?e&gdirb?rif???z!.&66duolc,amil,sh,???ruoblem??om?p!.&bog?gro?lim?mo&c?n??t&en?opsgolb,?ude??irg?yks??r!.&mo&c?n??ossa?topsgolb,?a&c!htlaeh??pmoc?wtfos??bc?eh?if?ots!.&e&rawpohs,saberots,?yflles,??taeht?u&ces?sni?t&inruf?necca??za???s!.&a!bap.us,disnim321,?b!ibnal?rofmok??c!a??d!b?n&arb?ubroflanummok???e?f!noc,?g!ro??h!f??i!trap??k!shf??l?m!oc,t??n!mygskurbrutan??o?p!ohsdaerpsym,p??r!owebdluocti,?s!serp?yspoi,?t!opsgolb,?u?vhf?w?x!uvmok??y?z??a&c?el?hc??i&er?urc??nesemoh?roh?uoh??t&a&d?ts&e!laer??lla???is!.&e&lej,nilnigol,r&etnim,ocevon,?winmo,?k&rowtenoilof,wnf,?laicosnepo,n&eyb,oyc,?spvtsaf,thrs,xulel,ysrab,?bew!.remarf,??ov?ra?t&ioled?ol??utitsni??u&lb?qi&nilc?tuob???v!.&21e?b&ew?ib?og??ce&r?t??erots?gro?lim?m&o&c?n??rif??o&c?fni??rar?stra?t&en?ni??ude?vog??as?e3gerb2h--nx?i&l!.xlh,?rd?ssergorp??ol??w&kct--nx?r??xul?y!.&gro?lim?moc?ten?ude?vog????f&0f3rkcg--nx?198xim--nx?280xim--nx?7vqn--nx?a!.&gro?moc?ten?ude?vog???b!.vog?wa9bgm--nx??c!.topsgolb,a1p--nx!.&a14--nx,b8lea1j--nx,c&avc0aaa08--nx,ma09--nx,?f&a1a09--nx,ea1j--nx,?gva1c--nx,nha1h--nx,pda1j--nx,zila1h--nx,??ns??ea1j--nx?g?iam?l&a1d--nx?og??n!.&bew?cer?erots?m&oc?rif??ofni?re&hto?p??stra?ten???orp?p!.&gro?moc?ude???rus?t!.hcs,w??vd7ckaabgm--nx?w!.&hcs,zib,???g&2&4wq55--nx?8zrf6--nx??3&44sd3--nx?91w6j--nx!.&a5wqmg--nx?d&22svcw--nx?5xq55--nx??gla0do--nx?m1qtxm--nx?vta0cu--nx????455ses--nx?5mzt5--nx?69vqhr--nx?7&8a4d5a4prebgm--nx?rb2c--nx??a!.&gro?mo&c?n??oc?ten??vd??b!.&0?1?2?3?4?5?6?7?8?9?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t!opsgolb,?u?v?w?x?y!srab,?z???c!b?za9a0cbgm--nx??e!.&eman?gro?ics?lim?moc!.topsgolb,?nue?ten?ude?vog??a??g!.&ayc,gro?lenap:.nomead,,oc?saak,ten???i&a?v??k!.&g&olb,ro??ku,lim?moc?oi,pj,su,ten?ude?v&og?t,???m!.&drp?gro?lim?m&o&c?n??t??oc?ude?vog??pk??n!.&dtl,eman?gro?hcs?i!bom??l&im?oc,?m&oc!.topsgolb,?rif,?neg,ogn,ten?ude?vog??aw?i!b!mulp??car?d&art?dew??h&sif?tolc??k&iv?oo&b?c???ls?n&aelc?iart??p!pohs??re&enigne?tac??t&ad?ekram?hgil?lusnoc?neg?ov?soh!.tfarcnepo,??vi&g?l???o!s??u&rehcisrev?smas?tarebsnegömrev???o&d?lb?og!.&duolc,etalsnart,???r&2n084qlj--nx?ebmoolb?o!.&77ndc.c:sr,,a&remacytirucesym,t&neimip,sivretla,?z,?bew-llams,d&ab-yrev-si,e&sufnocsim,vas-si,?nuof-si,oog-yrev-si,uolc&arfniarodef,mw,??e&a,cin-yrev-si,grof&loot,peh,?l&as-4-ffuts,poeparodef,?m&-morf,agevres,ohruoyslles,?n&ozdop,uma.elet,?r&ehwongniogyldlob,iwym,uces-77ndc.nigiro.lss,?t&adidnac-a-si,is&-ybboh,golb,???fehc-a-si,golbymdaer,k&eeg-a&-si,si,?h,nut,?l&i&amwt,ve-yrev-si,?lawerif&-ym,ym,?sd-ni,?m&acssecca,edom-elbac,?n&af&blm,cfu,egelloc,lfn,s&citlec-a-si,niurb-a-si,tap-a-si,?xos-a-si,?ibptth,o&itatsksid,rviop,?p&j,v-ni,??o&jodsnd,tp&az,oh,??p&i&-on,fles,?o&hbew,tksedeerf,?tf&e&moh,vres,?ym,??r&e&gatop,ppepteews,su-xunil-a-si,?gmtrec,vdmac,?s&a&ila&nyd,snd,?nymsd,?b&alfmw,bevres,?d&ikcet.3s,ylimaf,?eirfotatophcuoc,j,koob-daer,ltbup,nd&-won,deerf,emoh,golb,kcud,mood,nyd:.&emoh,og,?,ps,rvd,tog,uolc,?s&a-skcik,ndd,?tnemhcattaomb,u,?t&ce&jorparodef.&duolc,gts.so.ppa,so.ppa,?riderbew,?e&ews-yrev-si,nretni&ehtfodne,fodne,??hgink-a-si,oi-allizom,s&ixetn&od,seod,?o&h-emag,l-si,?rifyam,??ue:.&a&-q,c,?cm,dc,e&b,d,e,i,m,s,?g&b,n,?hc,i&f,s,?k&d,m,s,u,?l&a,i,n,p,?n&c,i,?o&n,r,ssa,?pj,r&f,g,h,k,t,?s&e,i:rap,,u,?t&a,en,i,l,m,ni,p,?u&a,de,h,l,r,?vl,y&c,m,?z&c,n,??,vresnyd,x&inuemoh,unilemoh,?y&limafxut,srab,???ub&mah?oj???s!.&delacsne,gro?moc?rep?t&en?opsgolb,?ude?vog??gb639j43us5--nx??t?u!.&c&a?s??en?gro?moc?o&c?g??ro?topsgolb,??v!.ta,a1c--nx??wsa08--nx??h&0ee5a3ld2ckx--nx?4wc3o--nx!.&a&2xyc3o--nx?3j0hc3m--nx?ve4b3c0oc21--nx??id1kzuc3h--nx?l8bxi8ifc21--nx?rb0ef1c21--nx???8&8yvfe--nx?a7maabgm--nx??b!.&gro?moc?ten?ude?vog??mg??c!.&7erauqs,amil4,duolc-drayknil,etisbew321,gniksnd,p&h21,ohsdaerpsym,?sndtog,topsgolb,wolf.e&a.1pla,nigneppa,?xi2,ytic-amil,?aoc?et?ir!euz??r&aes?uhc??sob?taw!s???d0sbgp--nx?f&2lpbgm--nx?k??g!.&gro?lim?moc?ude?vog???m!a1j--nx??ocir?p!.&gro?i?lim?moc?ogn?ten?ude?vog???s!.&g&nabhsah,ro??l&im?xv,?m&oc?roftalp.&cb,su,tne,ue,??pib,ten",
- "?vog?won,yolpedew,?a&c?nom??i&d?f?ri???t!.&ca?enilno,im?ni?o&c?g??pohs,ro?ten??iaf!.oby,?laeh!.arh,?orxer?rae??vo!.lopdren,?zb??i&3tupk--nx?7a0oi--nx?a!.&ffo?gro?moc?ten?uwu,?1p--nx?bud?dnuyh?tnihc??b!.&gro?moc?oc?ro?ude??ahduba?o!m!.&duolcsd,ysrab,???s??c!.&ayb-tropora--nx?ca?d&e?m??esserp?gro?ln,moc?nif,o&c?g?ssa??ro?t&en?ni?roporéa??ude?vuog??cug?t??d&dk?ua??e&bhf--nx?piat??f!.&aw5-nenikkh--nx,dnala?i&ki,spak,?mroftalpduolc.if,nenikkäh,pohsdaerpsym,retnecatad.&omed,saap,?topsgolb,uvisitok321,yd,?onas??g!.&d&om?tl??gro?moc?ude?vog???h&c&atih?ra??s&abodoy?ibustim???juohs?k!.&gro?moc?ofni?ten?ude?vog?zib??b4gc--nx?iw!.remarf,?nisleh?s?uzus??l!.&aac,topsgolb,?drahcir?iamsi??maim?n!.&b&ew?og??ca?gro?lim?mo&c?n??ni?o&c?fni??pp?t&en?ni??ude?zib??airpic?i&hgrobmal?m??re??om?rarref?s!.&egaptig,ppatig,topsgolb,?ed??t&i&c?nifni??rahb??ut?v!.&21k?gro?moc?oc?ten???wik?xa&rp?t??yf??j&6pqgza9iabgm--nx?8da1tabbgl--nx?b!.&acirfa?eto?gro?m&oc?siruot??o&c!e??fni?noce?rga?tser??russa?s&etcetihcra?risiol?tacova??t&en?naruatser?opsgolb,?ude?vinu?yenom???d?f!.&ca?eman?gro?lim?moc?o&fni?rp??ten?vog?zib???nj?s?t!.&bew?c&a?in??eman?gro?lim?moc?o&c?g??t&en?ni?set??ude?vog?zib???yqx94qit--nx??k&8uxp3--nx?924tcf--nx?arfel?c&a&bdeef?lb??ebdnul?ilc?reme??d!.&e&disemmejh321,rots,?ger,mrif,oc,pohsdaerpsym,topsgolb,zib,?t??e&es?samet??h!.&a&4ya0cu--nx?5wqmg--nx??b3qa0do--nx?cni,d&2&2svcw--nx?3rvcl--nx??5xq55--nx?tl,?g&a0nt--nx?la0do--nx?ro??i&050qmg--nx?7a0oi--nx?xa0km--nx??m&1qtxm--nx?oc??npqic--nx?saaces,t&en?opsgolb,?ude?v&di?og?ta0cu--nx??xva0fz--nx?人&个?個?箇??司公?府政?絡&網?网??織&組?组??织&組?组??络&網?网??育&敎?教???n??i&tsob?vdnas??l!.&bew?c&a?os??dtl?gro?hcs?letoh?moc?nssa?ogn?prg?t&en?ni??ude?vog??at?cd?is??m!.&eman?fni?gro?moc?t&en?opsgolb,?ude?vog???n&ab!cfdh?etats?mmoc?t&en?fos??u??i!l!.&noyc,pepym,??p???oob?p!.&b&ew?og??gro?kog?m&af?oc??nog?ofni?pog?sog?ten?ude?vog?zib???row!ten!.&htumiza,nolt,o&c,vra,????s!.topsgolb,?t?u!.&c&a?lp??dtl?e&cilop?m??gro!.&gul:g,,sgul,yr&ettoly&lkeew,tiniffa,?tneelffar,???lenap-tnednepedni,n&noc,oissimmoc-&layor,tnednepedni,??o&c!.&bunsorter.tsuc,en&ilnoysrab,ozgniebllew,?krametyb.&hd,mv,?omida,p&i-on,ohsdaerpsym,?t&fihsreyal.j,opsgolb,?vres-hn,ysrab,??rpoc,?psoh,shn?t&en?nmyp,seuqni-tnednepedni,?vog!.&eci&ffoemoh,vres,?ipa,ngiapmac,??weiver-tnednepedni,y&riuqni-&cilbup,tnednepedni,?srab,????l&04sr4w--nx?a!.&gro?lim?moc?t&en?opsgolb,?ude?vog??bolg?c?ed?g!el??i&c&nanif!.oc,lpl??os??romem?tnedurp??n&if?oitanretni??t&i&gid!.sppaduolc:.nodnol,,?p&ac?soh???ned?ot??utum!nretsewhtron???c!.&bog?lim?oc?topsgolb,vog???dil?e&datic?n&ahc?nahc!rehtaew???t!ria?tam??vart??f&8f&pbgo--nx?tbgm--nx??a?n??g!.&gro?moc?oc?ten?ude?xx,zib,??h&d?op??i!.&21k?ca?fdi?gro?inum?oc!.&egapvar,redrotibat,t&ibatym,opsgolb,???ten?vog??a&f?m&e?g?toh???m?r??l&a&b&esab?t&eksab!.&sua,zn,??oof???c?mt??e&d?hs??ihmailliw?j??m!.&esserp?gro?moc?ten?ude?v&og?uog????n!.&etisbew321,no&med,rtsic,?oc,pohsdaerpsym,retsulc-gnitsoh,topsgolb,vog,yalphk,?o??o&a?btuf?l!.gmo,?o&c!.&ed,rotnemele,??hcs??rit?u??p!.&a&cin&diws?gel??d&g,ortso?urawon??i&dem?mraw?nydg,?k&elo&guld?rtso??slopolam?tsu?ytsyrut??l&ip?o&kzs?w&-awolats?oksnok????n&erapohs,img?zcel,?rog&-ai&bab?nelej??j?z??syn?tsaim?w&a&l&eib?i?o??zsraw??o&namil?tainop,??z&eiwolaib?mol???c&e&iw&alselob?o&nsos?rtso???le&im?zrogz???orw,p??d&em,ia?ragrats?uolc&inu,sds,??e&c&i&lrog?w&ilg,o&hc&arats?orp??klop?tak????yzreibok??i&csjuoniws?ksromop?saldop??l&ahdop?opo??napokaz,t&atselaer?iselpmis,?z&romop?swozam???g&alble?ezrbo&lok?nrat??ro??hcyzrblaw?i&csomohcurein?grat?klawus??k&e&rut?walcolw??in&byr?diws,sark,?le?o&nas?tsylaib??rob&el?lam??s&als?jazel?nadg,puls?rowezrp???l&colw?e&r?vart??i&am?m???m&o&c?dar?n?tyb??s&g?iruot??t!a???n&a&gaz?nzop,?i&bul?cezczs?lbul,molow?nok?zd&eb?obeiws???uleiw?y&tzslo?z&rtek?seic????o&c,fni?k&celo?zdolk??lkan?n&leim?pek?t&uk?yzczs??z&copo?eing?rowaj???rga?tua?w&ejarg?ogarm???p&e&eb,lks!emoh,??klwwortso?ohs!-ecremmoce,daerpsym,??romophcaz?sos?t&aiwop?en?opos,ra,sezc??ude?v&irp?og!.&a&io?p?s!w???bni&p?w??ci?dtiw?e&ko?ss&p?w???fiw?g&imu?u??hiiw?m&igu?rio?u!o???nds!ipz??o&ks?p!pu??s?wtsorats??p&a?sp!mk?pk?wk??u&m?p??wk?z??r&hcso?ksw?p?s??s&i?oiw?u?zu??talusnok?w&gzr?i&p?rg?w??m?o&o?pu??u!imzw???z&kw?ouw?????w&a&l&corw?sizdow??w??o&golg?k&ark,ul?zsurp??r&az?gew??t&rabul,sugua??z&coks?sezr????xes?y&buzsak?d&azczseib?ikseb??hcyt?n&jes?lod-zreimizak??pal?r&ogt?uzam??walup?zutrak??z&am-awar?c&aprak?iwol?zsogdyb??dalezc?ib?s&i&lak?p??uklo????l??r&as?f?s??s!.&gro?moc?ten?ude?vog???t!.vog??ubnatsi?x3b689qq6--nx?yc5rb54--nx??m&00tsb3--nx?1qtxm--nx?981rvj--nx?a!.&aayn,enummoc?gro?moc?o&c?idar,ken,?t&en?opsgolb,??c!bew??dretsma?e&rts?t!.&citsalej,esruocsid,???fma?xq--nx??b!.&gro?moc?ten?ude?vog??i??c!.&moc?oc?ten?vog???d!.&gro?moc?ten?ude?vog???f!.&gro?moc?oidar,ten?ude??i??g!vu96d8syzf--nx??h?i!.&ca?gro?moc?o&c!.&clp?dtl???r,?t&en?t??vt??k?rbg4--nx??k!.&drp?e&rianiretev?sserp??gro?lim?m&o&c?n??t??nicedem?ossa?pooc?s&eriaton?neicamrahp?sa??ude?v&og?uog????l&if?ohkcots??o!.&dem?gro?m&oc?uesum??o&c?rp??ten?ude?vog??b?c!.&0x,2aq,3pmevres,5sndd,a&c&-morf,ir&bafno,fa,??g&-morf,oy-sehcaet,?i-morf,m&-morf,all&-a-si,amai,??p&-morf,c-a-si,?r&emacytirucesym,odih,?s,tadtsudgniht,v-morf,w-morf,z,?b&ew&-sndnyd,arukas,draiw.segap,ottad,?ildts.ipa,?c&amytirucesemoh,d-morf,esyrcs,itsalej.omed,n&-morf,vym,?p&kroweht,ytirucesemoh,?q,rievres,s-morf,?d&aerotffuts,e&calpb,ifitrec-&si,ton-si,?llortnocduolc,rewopenignepw:.sj,,tsohecapsppa,?i&-morf,rgevissam.saap,?m-morf,n&-morf,abeht-htiw-si,?s-morf,uolc&-noitatsyalp,hr,iafaw.&d&ej,yr,?nol,?meaeboda,nevia,panqym:-&ahpla,ved,?,smetsystuo,tekcilc,ved&j,pw,??vreser,wetomer,?e&butuoyhtiw,ciffo-sndnyd,d:-morf,o&celgoog,n&il.srebmem,neve.&1-&su,ue,?2-&su,ue,?3-&su,ue,?4-&su,ue,????,erf&-sndnyd,sndd,?filflahevres,g&de-yltsaf,nahcxeevres,?i&hcet-a-si,p-sekil,?k&auqevres,irtsretnuocevres,?l&bitpa-no,googhtiw,?m&agevres,ina-otni-si,oh-&sndnyd,ta-sndnyd,??n&-morf,ilno&-evreser,ysrab,?og-si,?r&alfduolcyrt,ehwynanohtyp:.ue,,ihcec,?srun-a-si,t&i&nuarepo,s&-ybboh,aloy,elpmis,tipohs,xiw,??omer-sndnyd,upmocsma,ysgolb,?v&als-elcibuc-a-si,i&lsndd,tavresnoc-a-si,??z&amkcar,eelg,iig,??fehc-a-si,g&ni&gats-&raeghtua,swennwot,?ksndd,robsikrow,tsoh-bt.etis,?o&fgp,lb&-sndnyd,sihtsetirw,???h&n-morf,o-morf,?i&fiwehtno,h-morf,kiw-sndnyd,m-morf,p&aerocne,detsoh,?r-morf,w-morf,z&ihcppa,nilppa,??jn-morf,k&a&-morf,erfocsic,?cils-si,eeg&-a&-si,si,?sndd,?h,latsnaebcitsale:.&1-&htuos-pa,lartnec-&ac,ue,?ts&ae&-&as,su,?ht&ron-pa,uos-pa,??ew-&su,ue,vog-su,???2-ts&ae&-su,ht&ron-pa,uos-pa,??ew-&su,ue,??3-ts&aehtron-pa,ew-ue,??,o-morf,r&adhtiwtliub,ow&-&sndnyd,ta-sndnyd,?ten-orehkcats,??sedal,u,?l&a&-morf,colottad,rebil-a-si,?f-morf,i&-morf,am&-sndnyd,detsohpw,??l&ecelffaw,uf-ytnuob:.a&hpla,teb,?,?ppmswa,ru-&elpmis,taen,?ssukoreh,xegap,?m&n-morf,pml.ppa,rofe&pyt.orp,rerac-htlaeh,?sacrasevres,uirarret-yltsaf,?n&a&cilbuper-a-si,f&-sllub-a-si,racsan-a-si,?i&cisum-a-si,ratrebil-a-si,?tarukas,?c,dc&hsums,umpw,xirtrepmi,?eerg-a-si,i&-morf,jod,?m-morf,o&ehtnaptog,isam-al-a-tse,r&italik,tap-el-tse,?s&iam-al-a-tse,replausunu,??pj,t-morf,?o&bordym,c,hce-namtsop,jodsnd,m&-morf,ed-baltlow,?n:iloxip,,ttadym,?p&2pevres,aelutym,i&-sndnyd,fles,ogol,ruoy&esol,hctid,?ym&eerf,teg,??ohsdaerpsym,pa&-rettalp,anis:piv,,esaberif,k1,lortnocduolc,oifilauq,r&aegyks,oetem:.ue,,?t&ilmaerts,norfegap,?ukoreh,?t&fevres,thevres,??r&081,a:-morf,tskcor-a-si,,b,e&d&iv&erp-yb-detsoh.saap,orpnwo,?ner&.ppa,no,??e&bevres,nigne-na-si,?ggolb-a-si,h&caet-a-si,pargotohp-a-si,?krow-drah-a-si,n&gised-a-si,ia&rtlanosrep-a-si,tretne-na-si,??p&acsdnal-a-si,eekkoob-a-si,?retac-a-si,subq,tn&ecysrab,iap-a-si,uh-a-si,?vres&-&ki.&cpj-rev-duolcj,duolcj,?s&ndnyd,pvtsaf,??inim,nmad,sak,?y&alp-a-si,wal-a-si,?zilibomdeepsegap,?g,ituob,k,mgrp.nex,o&-morf,sivdalaicnanif-a-si,t&areleccalabolgswa,c&a-na-si,od-a-si,?susaym,??p-morf,u&as-o-nyd,e&tsoh.&duolc-gar,hc-duolc-gar,?ugolb-nom-tse,?omuhevres,??s&a&apod,ila&nyd,snd,?nymsd,vnacremarf,?bbevres,ci&p&-sndnyd,evres,?tcatytiruces,?dylimaf,e&cived-anelab,itilitu3,lahw-eht-sevas,mag-otni-si,t&i&iis,sro,?yskciuq,??fpi-&eralfduolc,fc,?i&ht2tniop,pa&elgoog,tneltneg,??jfac,k&-morf,aerf-ten,colb&egrof,pohsym,??m&-morf,cxolb,?n&d&-pmet,dyard,golb,htiwssem,mood,tog,?kselp,nyd,ootrac-otni-si,?o&-xobeerf,xobeerf,?ppa&-avnac,raeghtua,t&ikria,neg,??r&ac-otni-si,e&ntrap-paelut,tsohmaerd,??s&e&l-rof-slles,rtca-na-si,?ibodym,?tsaeb-cihtym.&a&llicno,zno,?ilay,lacarac,re&gitnef,motsuc,?sv,toleco,x:n&ihps,yl,?,?u,wanozama.&1-&ht&ron-ue.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??uos-&em.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??fa.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??pa&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,??ue.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,????la&nretxe-3s,rtnec-&ac&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,??ue&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,????ts&ae&-&as&-&3s,etisbew-3s,?.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??kcatslaud.3s,??pa.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??su:-etisbew-3s,.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??kcatslaud.3s,yawetag-scitylana,?,?ht&ron-pa&-&3s,etisbew-3s,?.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??kcatslaud.3s,yawetag-scitylana,??uos-pa&-&3s,etisbew-3s,?.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??kcatslaud.3s,????ew-&su&-&3s,etisbew-3s,?.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,???ue&-&3s,etisbew-3s,?.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??kcatslaud.3s,yawetag-scitylana,??vog-su-&3s,spif-3s,????2-ts&ae&-su&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,yawetag-scitylana,??ht&ron-pa&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,??uos-pa&-&3s,etisbew-3s,?.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??kcatslaud.3s,????ew-&su&-&3s,etisbew-3s,?.&9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??yawetag-scitylana,??ue&-3",
- "s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,????3&-ts&aehtron-pa.9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??ew-ue&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??etisbew-3s,kcatslaud.3s,???s,??yasdrocsid,?t&arcomed-a-si,c&-morf,etedatad.&ecnatsni,omed,??eel&-si,rebu-si,?hgilfhtiwletoh,i:batym,,m-morf,n&atnuocca-na-si,e&duts-a-si,r-ot-ecaps,tnocresu&buhtig,e&capsppa,donil.pi,lbavresbo.citats,?pl,???ops&edoc,golb,ppa,?s&i&hcrana-&a-si,na-si,?laicos-a-si,pareht-a-si,tra-na-si,xetn&od,seod,??oh&piym,sfn,??u&-morf,nyekcoh-asi,?v-morf,?u&-rof-slles,4,a-sppatikria,e,h,oynahtretramssi,r:ug-a-si,,?v&n-morf,rdlf,w-morf,?w&o&lpwons-yrt,zok,?ww100,?x&bsbf.sppa,em,i&nuemoh,rtrepmi,?obaniateb,t-morf,unilemoh,?y&a&bnx:.&2u,lacol-2u,?,l&erottad,pezam,?wetag-llawerif,?dnacsekil,fipohsym,k&-morf,niksisnd,?rot&ceridevitcaym,sitk,?u:goo,,w-morf,x&alagkeeg,orp&hsilbup,mapson.duolc,???zesdrocsid,?inu??m?or?tsla??p!.&eman,nwo,??raf!.jrots,etats??s?t!.&gro?lim?mo&c?n??oc?ten?ude?vog???u&esum?rof??z!.&ca?gro?hcs?lim?moc?o&c?fni??ten?ude?vog?zib????n&315rmi--nx?a&brud?cilbuper?f?grompj?hkaga?idraug?m?ol?ssin?u&hix?qna??varac?yalo??b!.&gro?moc?oc,ten?ude?vog??c??c!.&ah?bh?c&a?s??d&5xq55--nx?g?s?uolctnatsni,?eh?g&la0do--nx?ro??h&a?q?s??i&7a0oi--nx?h??j&b?f?t?x?z??kh?l&h?im?j??m&n?oc!.swanozama.&1-htron-nc.3s,be.1-&htron-nc,tsewhtron-nc,????n&h?l?s?y??om?qc?s&g?j?ppa-avnac,?t&cennockciuq.tcerid,en??ude?vog?wt?x&g?j?n?s??z&g?x??司公?絡網?络网??b??d&g!.ypnc,?ka??e&drag?erg?fuak?gawsklov?hctik?i&libommi?w??m?po?r!ednaalv??sier?ves??g!.&ca?gro?moc?ten?ude?vog??is&ed!.ssb,?irev???h!.&bog?cc,gro?lim?moc?ten?ude???i!.&ac?bew,c&a?in??dni?e&m?sabapus,?g&5?6?p?ro??i&a?hled??ku?l&evart?im??m&a?oc?rif??n&c?eg??o&c?fni?i?rp??p&ooc?u??r&ahib?d?e??s&c?er?nduolc,senisub?u??t&arajug?en!retni??ni?opsgolb,sop??ude?v&og?t??ysrab,zib??elknivlac?griv?ks?lreb?p?v?w?x??k!.&gro?ten?ude?vog???l&eok?ocnil??m!.&cyn,gro?ude?vog???o&dnol?i&hsaf?n&o?utiderc??siv!orue??t&a&cude!.oc,?dnuof?tsyalp??c&etorp?u&a?rtsnoc?????kin?las?mrom?nac?p&q?uoc??s&iam?pe?scire??t&ron?sob??zama??p!.&gro?oc?ten?ude?vog??k??r&e&c?yab??op!.eidni,??s!.&gro?moc?osrep?t&opsgolb,ra??ude?v&inu?uog????t!.&d&ni?uolcegnaro,?gro?ltni?m&oc!nim??siruot??nif?o&fni?srep??sne?t&an?en??vog??m??u&f?r!.&bdnevar,lper,retropno,s&h,revres,?tnempoleved,??stad?xamay?y??v!.&a&lnos?ohhnah&k?t???c&a?ouhphnib?uhphniv??di?e&man?rtneb?uhneihtauht??g&n&a&boac?ig&ah?cab?n&a?ei&k?t???uah??nad?rtcos?uqneyut??o&dmal?hpiah?lhniv?nkad?ud&hnib?iah????ro??h&ni&b&aoh?gnauq?hnin?iaht??d&hnib?man??mihcohohphnaht?n&cab?gnauq?yat??tah?vart??tlaeh??i&a!bney?coal?gngnauq?laig?ngnod??onah?rtgnauq??kalkad?m&an&ah?gnauq??oc?utnok??n&a&ehgn?gnol?kcab?uhthni&b?n???e&ibneid?y&gnuh?u&gniaht?hp????osgnal??o&fni?ht&nac?uhp??i?rp??pahtgnod?t&en?ni?opsgolb,?u&a&hcial?mac?tgnuv-airab??de?eilcab??vog?zib???wo&rc?t!epac????o&76i4orfy--nx?a!.&bp?de?go?oc?ti?vg??boat??b!.&a&ci&sum?tilop??i&c&arcomed?neic??golo&ce?ncet??m&edaca?onoce??rt&ap?sudni??vilob??n&egidni?icidem??serpme?tsiver?vitarepooc??b&ew?og??dulas?e&rbmon?tr&a?op&ed?snart????g&olb?ro??ikiw?l&a&noi&canirulp?seforp??rutan??im??moc?o&fni?lbeup?rga?tneimivom??saiciton?t&askt?en?ni??ude?vt??h?iew?olg??c!.&bew?cer?dr&c,rac,?esabapus,gro?ipym,l&im?per:.di,,?m&o&c!.topsgolb,?n??rif??ofni?s&egap&dael,l,?tra??t&4n,en?ilperdellawerif:.di,,ni??ude?vog??a?e?in?mara?s&edarb?ic???d!.&b&ew?og??dls?gro?lim?moc?t&en?ra??ude?vog??agoba?if?zd7acbgm--nx??e&c?d&iv?or???f!ni!.&e&g&delwonk-fo-l&errab,lerrab,?ellocevoli,?ht-skorg,rom-rof-ereh,tadpusn:d,,?llatiswonk,macrvd,ofni-v,p&i&-on,fles,?ohbew,?ruo-rof,s&iht-skorg,nd&-cimanyd,nyd,uolc,??tsrifyam,ysrab,zmurof,???g&el?n!am?ib???hwsohw?i!.&35nyd,8302,a&minifed,tad-b,?b&altig,uhtig,?czh,d&in,raobelgaeb,u&olc&iaznab.ppa,ropav,?rd,??e&c&apsinu.1rf-duolc,ivedniser,?donppad.sndnyd,egipa,lej,nilnigol,sufxob,t&i&beulb,snoehtnap,?newtu,ybeeb.saap,??gni&gatsniser.secived,tsohytsoh,?ilpu,k&coregrof.di,orgn:.&as,ni,p&a,j,?su,u&a,e,??,ramytefasresworb,?moc?n&aicisum,mtsp:.kcom,,yded,?ot&oq,pyrctfihs,?p&opilol,pa&-arusah,e&nalpkcab,tybeeb.1dkes,???r&e&tsneum-hf,vres&cisab,lautriv,??ial.sppa,?s&codehtdaer,gnihtbew,nemeis-om,pparevelc,t&acdnas,ekcit,??t&e&kcubtib,notorp,?i&belet,detfihs,gude,kecaps,?raedon.egats,s&ohg,udgniht.&cersid.&dvreser,tsuc,?dorp.tsuc,gnitset.&dvreser,tsuc,?ved.&dvreser,tsuc,????vgib.0ku,whs,x&bslprbv.g,cq,rotide,?y&olpedew,srab,??b?d&ar?u&a?ts???j?r?syhp??j!.&eman?gro?hcs?lim?moc?ten?ude?vog???ll&ag?o??m!.&gro?moc?ten?ude?vog??g?il?mi?orp??n!.&a&0&b-ekhgnark--nx?c-iehsrgev--nx?g-lksedlig--nx?k-negnanvk--nx??1&p-nedragy--nx?q-&asierrs--nx?grebsnt--nx?lado-rs--nx?n&egnidl--nx?orf-rs--nx??regnayh--nx?ssofenh--nx??r-datsgrt--nx?s-ladrjts--nx?v-y&senner--nx?vrejks--nx???3g-datsobegh--nx?4&5-&dnaleprj--nx?goksnerl--nx?tednalyh--nx??6-neladnjm--nx?s-&antouvachb--nx?impouvtalm--nx??y-&agrjnevvad--nx?ikhvlaraeb--nx???7k-antouvacchb--nx?8&k-rekie-erv--nx?l-ladrua-rs--nx?m-darehsdrk--nx??a!.sg??bct-eimeuvejsemn--nx?d&do?iisevvad?lov?narts?uas??f&1-&l--nx?s--nx??2-h--nx??g&10aq0-ineve--nx?av?ev?lot?r&ajn&evvad?u??ájn&evvad?u????h?iz-lf--nx?j&ddadab?sel??k&el?hoj&sarak?šárák??iiv&ag&na&el?g??ŋ&ael?ág???ran???l&f?lahrevo?o&ms?s??sennev?t-&ilm--nx?tom--nx??u&-edr--nx?s??øms??muar?n&0-tsr--nx?2-dob--nx?5-&asir--nx?tals--nx??a&r!-i-om?f?t??t??douvsatvid?kiv?m&os?øs??n&od?ød??ra?sen?t&aouvatheig?ouv&a&c&ch&ab?áb??h&ab?áb???n??i&ag?ág??sa&mo?ttvid??án???z-rey--nx?ær&f?t???o&p-&ladr--nx?sens--nx??q-nagv--nx?r-asns--nx?s-kjks--nx?v-murb--nx?w-&anr&f--nx?t--nx??ublk--nx???ppol?q&0-t&baol--nx?soum--nx?veib--nx??x-&ipphl--nx?r&embh--nx?imph--nx???y-tinks--nx??r&f-atsr--nx?g-&an&ms--nx?nd--nx??e&drf--nx?ngs--nx??murs--nx?netl--nx?olmb--nx?sorr--nx??h-&a&lms--nx?yrf--nx??emjt--nx??i&-&lboh--nx?rsir--nx?y&d&ar--nx?na--nx??ksa--nx?lem--nx?r&ul--nx?yd--nx????stu??j-&drav--nx?rolf--nx?sdav--nx??kua?l-&drojf--nx?lares--nx??m-tlohr--nx?n-esans--nx?olf?p-sdnil--nx?s-ladrl--nx?tih?v-rvsyt--nx??s&a&ns?ons??i&ar?er&dron?r&os?øs???ár??la&g?h??mor!t??sir?uf?åns??t&koulo&nka?ŋká??la?p-raddjb--nx?r-agrjnu--nx?s&aefr&ammah?ámmáh??orf?r&o?ø???u-vreiks--nx??u&h-dnusel--nx?i-&drojfk--nx?vleslm--nx??j-ekerom--nx?k-rekrem--nx?u-&dnalr--nx?goksr--nx?sensk--nx??v-nekyr--nx?w-&k&abrd--nx?ivjg--nx??oryso--nx??y-y&dnas--nx?mrak--nx?n&art--nx?nif--nx??reva--nx??z-smort--nx??v!.sg?ledatskork?reiks??wh-antouvn--nx?x&9-dlofts--nx.aoq-relv--nx?d-nmaherk--nx?f-dnalnks--nx?h-neltloh--nx?i-drgeppo--nx?j-gve&gnal--nx?lreb--nx??m-negnilr--nx?n-drojfvk--nx??y&7-ujdaehal--nx?8-antouvig--nx?b-&dlofrs--nx?goksmr--nx?kivryr--nx?retslj--nx??e-nejsom--nx?f-y&krajb--nx?re&dni--nx?tso--nx??stivk--nx??g-regark--nx?orf?ørf??z9-drojfstb--nx??b&25-akiivagael--nx?53ay7-olousech--nx?a&iy-gv--nx?le-tl&b--nx?s--nx??n0-ydr--nx??c&0-dnal-erdns--nx?z-netot-erts--nx??g&g-regnarav-rs--nx?o-nejssendnas--nx??ju-erdils-ertsy--nx?nj-dnalh-goksrua--nx?q&q-ladsmor-go-erm--nx.&ari-yreh--nx?ednas??s-neslahsladrjts--nx???ca&4s-atsaefrmmh--nx?8m-dnusynnrb--nx?il-tl--nx?le-slg--nx?n5-rdib--nx?op-drgl--nx?uw-ynnrb--nx??d&a&qx-tggrv--nx?reh!nnivk?sd&ork?ørk??uas??ts&e&bi?kkar?llyh?nnan??g&ort?ørt??k&alf?irderf??levev?mirg?obeg&ah?æh??r&ah?ejg????barm-jdddb--nx?ie!rah?s&etivk?ladman???lof&r&os?øs??ts&ev.ednas?o.relav?ø.relåv???n&a&l&-erd&n&os?øs??ron??adroh.so?dron.&a&g5-b--nx?ri-yreh--nx??ob?y&oreh?øreh??øb??e&m!lejh??pr&oj?øj??vi??gyb?n&aks?åks??o&h-goksrua?rf??r&o?ua?ø??tros?øh-goksrua??rts!e&devt?lab?mloh???s&ellil?naitsirk?rof???u&l!os??s!d&im?lejt??e&guah?l&a?å???kkoh?lavk?naitsirk?r&af?eg&e?ie???tef?y&onnorb?ønnørb?????r&a&blavs!.sg??g&eppo?la???o&j&f&a!dniv?k?vk??die?e&dnas?kkelf??llins?r&iel?ots??s&lab?t&ab?åb??yt??å!k??ævk??les??ts??åg&eppo?lå???ureksub.sen??e&ayb-yrettn--nx?d&ar?isemmejh321,lom?r&of?øf??år??g&gyr?nats??i&meuv&ejsem&aan?åån??sekaal??rjea??j&d&ef?oks??les??k&er&aom?åom??hgna&ark?årk??iregnir?kot!s??s&ig?uaf???l&bmab?kyb?l&av?ehtats??oh??m&it?ojt?øjt??n&arg?g&os?øs??meh?reil?te?ummok?yrb??r&dils-erts&ev?y&o?ø???ua?vod??sa&ans?åns??t&robraa?spaav??urg??f&62ats-ugsrop--nx?a&10-ujvrekkhr--nx?7k-tajjrv-attm--nx??o!.sg?h??s!.sg??v!.sg???g&5aly-yr&n--nx?v--nx??a&llor?ve&gnal?lreb???n&av!snellu??org??oks&die?m&or?ør??ner&ol?øl??r&o?ø???r&eb!adnar?edyps?s&die?elf?gnok?n&ot?øt????obspras??uahatsla?åve&gnal?lreb???h&0alu-ysm--nx?7&4ay8-akiivagg--nx?5ay7-atkoulok--nx??a!.sg???i&e&hsr&agev?ågev??rf??k&h&avlaraeb?ávlaraeb??s??lm&a?å??mpouvtal&am?ám??pph&al?ál??rrounaddleid?ssaneve?ššáneve??j&0aoq-ysgv--nx?94bawh-akhojrk--nx??k&a&b&ord?ørd??jks?lleis??iv!aklejps?l&am?evs?u??mag?nel?ojg?r&a&l?n??epok?iel?y&or?ør???s&ah?kel?om??øjg??kabene?ojsarak?ram&deh.&aoq-relv--nx?rel&av?åv??so??e&let.&ag5-b--nx?ob?øb??ra???åjks??l&a!d&anrus?d&numurb?ron??e&gnard?nte?s&meh?sin??ttin??g&is?nyl??kro?l&em?l&ejfttah?of??u&ag-ertdim?s???n&am?era?gos?i&b?nroh?r??kos?nus?oj??o-&dron?r&os?øs???ppo?r&a!l?nram??e&gne?l?v??is?o&jts?ts??u&a-&dron?r&os?øs???h??å?æl?øjts??s&e&jg?nivk?ryf??kav?mor-go-er&om.&ednas?yoreh??øm.&ednas?yøreh???uag??t&las?rajh?suan??v&l&a?e-rots??u-go-eron??yt??ksedlig?res&a?å???bib&eklof?seklyf??es!dah??h!.sg??i&m?syrt??l&ejf?ov&etsua?gnit?ksa?sdie???n!.sg??o!.sg?boh?g?h??r!.sg??å!ksedlig??øboh??m&a&rah?vk??f!.sg??h!.sg??i&e&h&dnort?rtsua?ssej??rkrejb??ksa??ol?t!.sg??u&dom?esum?r&ab?drejg?evle?os?uh?æb?øs??ttals???n&a&g&av?okssman?åv??jlis?or?r&g?rev???e&d&do&sen?ton??lah?r&agy&o?ø??ojfsam???g&iets?n&a&l&as?lab??n&avk?ævk??t&arg?ddosen??v&al?essov???i&d&ol?øl??l&ar?ær???yl??reb??iks?k&srot?y&or?ør???l&a&d&gnos?n&er?ojm?øjm??om??tloh??ug?åtloh??mmard?ojs&om?sendnas??ppolg?s&lahsladr&ojts?øjts??o??t&o&l?t-erts&ev?o?ø???roh?øl??vly&kkys?nav??yam-naj!.sg??øjs&om?sendnas???g&orf?ujb??i&dnaort?vnarg??kob?ladendua?maherk&a?å??n&it?urgsrop??orf-&dron?r&os?øs???r&aieb?evats??sfev?uaks?yrts??o&6axi-ygvtsev--nx?c,d&ob?rav??ievs?kssouf?l&m&ob?øb??ous&adna?ech&ac?áč???so!.sg???msdeks?niekotuak?r&egark?olf?y&oso?øso???s&dav?mort???p&ed?ohsdaerpsym,p&akdron?elk???r&a&d&dj&ab?áb??iab??jtif?luag?mah?vsyt??",
- "e&gn&a&k&iel?ro??merb?n&at?mas??rav-r&os?øs??srop?talf?v&ats?el??y&oh?øh???ivsgnok??il?jkniets?k&a&nvej?rem?s&gnir?nellu???ie-er&den?v&o?ø???ram?sa?årem??la&jf?vh??m&b&ah?áh??mahellil??nnul?ts&l&oj?øj??ul??y&o?ø???imp&ah?áh??m!.sg??osir?t!.sg??ádiáb?ævsyt?øsir??s&adnil?en&dnas?e&dga?k&ri&b?k??som??ve??me&h?jg??nroh-go-ejve?s&a?ednil?k&o?ø??of?yt?å??tsev??gv?hf?igaval?o&r&or?ør??sman??so&fen&oh?øh??m?v??uh&lem?sreka.sen??å!dnil???t&a&baol?g&aov?grav??jjr&av-attam?áv-attám??l&a&b?s??ás??soum?ts?v&eib?our???e&dnaly&oh?øh??f?s&nyt?rokomsdeks?sen??vtpiks??in&aks?áks??loh&ar?år??n!.sg??o&m&a?å??psgolb,?s!.sg?efremmah?or?ør??terdi?á&baol?ggráv?lá&b?s??soum?veib???u&b!.sg?alk?e&dna?gnir?nner??les?ælk??dra&b?eb??g&nasrop?vi?ŋásrop??j&daehal&a?á??jedub?v&arekkhar?árekkhár???ksiouf?n&diaegadvoug?taed???v&irp?lesl&am?åm???y&b&essen?nart?sebel?tsev??o&d&ar?na!s??or??gavtsev?k&rajb?sa??lem?mrak?n&art?n&if?orb???r&a&mah?n?v??e&dni?t&so?ton??va??ul?yd??s&am?enner?gav?lrak?tivk??vrejks??ø&d&ar?na!s??ør??gåvtsev?k&rajb?sa??lem?mrak?n&art?n&if?ørb???r&e&dni?t&so?tøn??va??ul?yd?æ&n?v???s&enner?gåv?tivk?åm??vrejks???á&slág?tlá?vreiks??å&gåv?h?jddådåb?lf??ø&d&ob?rav??r&egark?olf??s&dav?mort????aki?i&sac?tal??u??o&b?f?g?hay?o?ttat??r!.&cer?erots?gro?m&o&c?n??rif?t??o&c,fni??pohs,stra?t&n?opsgolb,?www?ysrab,?e&a!.&a&ac?cgd?idem??bulc!orea??ci&ffartria?taborea??e&cn&a&l&lievrus-ria?ubma??netniam?rusni??erefnoc??gnahcxe?mordorea?ni&gne?lria?zagam??rawtfos??gni&d&art?ilg!arap?gnah???l&dnahdnuorg?ledom??noollab?retac?sael?t&lusnoc?uhcarap??vidyks??hcraeser?l&anruoj?euf?icnuoc?ortnoc!-ciffart-ria???n&gised?oi&nu?t&a&cifitrec?ercer?gi&tsevni-tnedicca?van??i&cossa!-regnessap??valivic??redef??cudorp?neverp-tnedicca????ograc?p&ihsnoipmahc?uorg!gnikrow???r&e&dart?enigne?korb?niart?trahc??o&htua?tacude???s&citsigol?e&civres?r??krow?serp!xe??tnega??t&farcr&ia?otor??hgil&f?orcim??liubemoh?n&atlusnoc?e&duts?m&esuma?n&iatretne?revog??piuqe????olip?ropria?si&lanruoj?tneics???w&erc?ohs??y&cnegreme?dobper?tefas????rref?z??p!.&a&aa?ca?pc??dem?ecartsnd.icb,gne?r&ab?uj??snduolc,t&acova?cca?hcer??wal?ysrab,???s!.&em?gro?hcs,moc?ten?ude?vog???t!.&0x,116,ayo,gro?lim?moc?nayn,sulpnpv,t&cennockciuq.tcerid,en??ude?v&dr,og???o&hp?m?v?yk??tol?ua??v&iv?lov??xas?ykot??p&a&ehc?g?m?s??eej?g!.&gro?ibom?moc?ossa?ppa,ten?ude???i&r!.nalc,?v?z??j!.&0o0o,a&3&5xq6f--nx?xqi0ostn--nx??5wtb6--nx?85uwuu--nx?9xtlk--nx?ad,b&ats,ihc!.&a&bihciakoy?don?ma&him?ye&ragan?tat???r&a&bom?gan?hihci??u&agedos?kas?ustak???s&os?ufomihs??t&amihcay?iran??w&a&g&im&anah?o??omak??kihci?zustum??ihsak??y&agamak?imonihci???e&akas?nagot??i&azni?esohc?h&asa?s&abanuf?ohc???ka&to?zok??musi?orihs?r&akihabihsokoy?o&dim?tak??ukujuk??usihs??nano&hc?yk??o&d&iakustoy?ustam??hsonhot?k&a&rihs?t??iba??nihsaran?sobimanim?tas&arihsimao?imot??uhc?yihcay??u&kujno?s&ayaru?t&imik?tuf???zarasik?????c&cah,ed,?g&as!.&a&gas?m&a&tamah?yik??ihsak??rat?t&a&gatik?hatik??ira!ihsin????e&kaira?nimimak??i&akneg?g&aruyk?o??h&c&amo?uo??siorihs??kaznak?modukuf?ra&gonihsoy?mi???nezih?u&k&at?ohuok??s&ot?tarak?????ihs!.&a&kok?m&a&hagan?yirom??ihsakat??rabiam?wagoton??e&miharot?nokih??houyr?i&azaihsin?esok?kustakat?moihsagih??na&mihcahimo?nok??o&hsia?mag?t&asoyot?ok?tir???us&ay?t&asuk?o??????k&aso!.&a&d&awihsik?eki??k&a&noyot?s&akaayahihc?oihsagih???oadat?uziak??m&ayas!akaso??odak??r&a&bustam?wihsak??ediijuf??t&akarih?i&k?us???wag&ayen?odoyihsagih???e&son?tawanojihs??honim?i&akas?h&cugirom?s&ayabadnot?i&a&kat?t??n??oyimusihsagih???k&a&rabi?sim??ustakat??muzi?r&ijat?otamuk???nan&ak?n&ah?es???o&ay?n&a&ganihcawak?simuzi?tak??eba?ikibah?oyot??t&anim?iad?omamihs??uhc??ust&oimuzi?tes????ou&kuf!.&a&d&amay?eos??g&no?ok?usak??hiku?k&awayim?uzii??ma&kan?y&asih?im???rawak?t&a&gon?ka&h?num?t???umo??wa&g&a&kan?nay?t??ias??ko!rih???y&ihsa?usak???e&m&ay?uruk??taruk?us??i&a&nohs?raihcat??goruk?h&cukuf?s&a&gih?hukuy??in???k&a&gako?muzim??iust?o?ustani??m&anim?otihsoynihs?u??r&ogo?ugasas??usu??ne&siek?zu&b?kihc???o&gukihc?h&ak?ot?ukihc??j&ono?ukihc??kayim?nihsukihc?to?uhc??u&fiazad?gnihs?stoyot????zihs!.&a&bmetog?d&amihs?eijuf?ihsoy?omihs??kouzihs?mihsim?ra&biah?honikam??tawi?wa&g&ekak?ukik??kijuf??yimonijuf??i&a&ra?sok??hcamirom?juf?kaz&eamo?ustam??ma&nnak?ta??nukonuzi?orukuf??nohenawak?o&nosus?ti??u&stamamah?z&a&mun?wak??i!ay?i&hs&agih?in??manim??mihs????????m&a&tias!.&a&d&ihsoy?ot?usah??k&a&dih?sa??o&arihs?s???m&a&tias?y&as?o&rom?tah??ustamihsagih???i&hsagurust?jawak??uri??ni?wa&g&e&ko?man??ikot?o??k&ara?i&hsoy?mak???ru?zorokot??y&a&g&amuk?ihsok?otah??kuf??imo??ziin??e&bakusak?ogawak?sogo?ttas?zokoy??i&baraw?h&cugawak?s&oyim?ubustam???iroy?k&ato?ihs?u&k?stawi???m&akoyr?i&hsoy?juf??uziimak???naznar?o&dakas?ihsay?jnoh?n&a&go?nim??imijuf?nah?oy??r&ihsayim?otagan??t&asim!ak??igus?omatik??zak??u&bihcihc!ihsagih??sonuok?ynah????y&ak&aw!.&a&d&ira?notimak??kadih?ma&h&arihs?im??y&a&kaw?tik??oduk???ru&ustakihcan?y??sauy?wa&g&a&dira?zok??orih??konik??yok?zok??e&banat?dawi??i&garustak?jiat?mani??naniak?o&bog?nimik?t&asim?omihs&ah?uk????ugnihs???o!.&a&jos?koasak?m&ay&ako?ust??ihsayah??r&abi?ukawaihsin??wi&aka?nam???e&gakay?kaw??i&gan?h&cu&kasa?otes??sahakat??k&asim?ihsaruk??miin??n&anemuk?ezib??o&hsotas?jnihs?n&amat?imagak??ohs?uhcibik?????ot!.&a&damay?got?koakat?may&etat?ot??nahoj?riat?waki&inakan?reman???eb&ayo?oruk??i&h&asa?ciimak?sahanuf??kuzanu?m&an&i?ot??ih???nezuyn?otnan?u&hcuf?stimukuf?z&imi?ou???????ihs&o&gak!.&a&m&ayuok?ihsogak??si?yonak??e&banawak?n&at&akan?imanim??uka??tomoonihsin??i&adnesamustas?k&azarukam?oih??m&ama?uzi??usuy??nesi?o&knik?os?tomustam??uzimurat???rih!.&a&ka&n?s??m&ayukuf?i&hsorihihsagih?j&ate?imakikaso????r&a&bohs?h&ekat?im???es??tiak?wiad??e&kato?ruk??i&h&ci&akustah?mono?nihs??s&inares?oyim???manimasa?uk??negokikesnij?o&gnoh?namuk??uhcuf????uk&ot!.&a&bihci?mi&hsu&kot?stamok??m??wagakan??egihsustam?i&gum?h&coganas?soyim??kijaw?m&anim?uzia??ukihsihs??nan&a?iak??o&nati?turan????uf!.&a&batuf?m&a&to?y&enak?irok???ihs&im?ukuf??os?uko??r&aboihsatik?uganat??ta&katik?mawak?rih??w&a&g&akus?emas?uy??k&a&mat?rihs?sa??ihsi??nah??ohs???e&gnabuzia?iman?ta&d?tii???i&adnab?enet?hs&agih?iimagak??k&a&wi?zimuzi??ubay??minuk?r&ook?ustamay???nihsiat?o&g&etomo?ihsin?nan?omihs??no!duruf?rih??rihsawani?ta&may?simuzia???u&rahim?stamakawuzia?zia&ihsin?nay???????nug!.&a&bawak?doyihc?k&anna?oi&hsoy?juf?mot???m&ayakat?ustagaihsagih??n&ihsatak?nak??r&ahonagan?nak?o?u&kati?mamat???t&amun?inomihs?o??w&akubihs?iem?ohs???i&hsa&beam?yabetat??kas&akat?esi??m&akanim?uzio??ogamust?rodim??o&jonakan?n&eu?oyikust??tnihs??u&komnan?stasuk?yrik????rep,?n&ibmab,nog,ob,?ppacihc,ra&n!.&a&bihsak?d&akatotamay?u!o???guraki?m&ay&atik&imak?omihs??irokotamay??oki??ra&hihsak?n??wa&geson?knet???e&kayim?ozamay?sog?ustim??i&a&rukas?wak??garustak?h&ciomihs?sinawak??jo?ka&mnak?toruk??makawak?nos?r&net?otakat?ugeh???o&d&na?oyo??gnas?jnihs?nihsoy!ihsagih??tomarawat?yrok????rikik,?t&ag&amay!.&a&dihsio?k&atarihs?ourust??may&a&kan?rum??enak?onimak??rukho?ta&ga&may?nuf??hakat?kas??wa&g&ekas?orumam??ki&hsin?m??z&anabo?enoy?ot???zuy??e&agas?bonamay?dii?nihsagih?o??i&a&gan?nohs??h&asa?sinawak??nugo??o&dnet?jnihs?ynan??ukohak???iin!.&a&ga?k&ium?oagan??munou!imanim??t&a&bihs?giin??ioy??w&a&gioti?kikes?zuy??irak??yijo??e&kustim?mabust??i&aniat?hcamakot?kaz&awihsak?omuzi??m&a&gat?karum??o???n&anust?esog??o&das?ihcot?jnas?k&ihay?oym??mak?naga?ries??u&ories?steoj?????i&k&a!.&a&go?k&asok?oimak??t&ago!rihcah??ika!atik???w&aki?oyk???e&mojog?natim?suranihsagih?t&ado?okoy???i&hsoyirom?magatak?naokimak??nesiad?o&hakin?jnoh!iruy??nuzak?rihson?tasi&juf?m??yjnoh??u&kobmes?oppah????in,?o!.&a&dakatognub?m&asah?ihsemih??su?t&ekat?i&h?o????e&onokok?ustimak??i&jih?k&asinuk?ias?usu??mukust??onoognub?u&fuy?juk?ppeb?suk?????nayn,?wa&ga&k!.&a&mihsoan?rihotok?waga&kihsagih?ya???emaguram?i&j&nonak?ustnez??kunas?monihcu??o&hsonot?nnam?yotim??u&st&amakat?odat??zatu????nak!.&a&dustam?kus&okoy?tarih??maz?nibe?r&a&gihsaimanim?h&esi?imagas??wa&do?guy???u&im?kamak???tikamay?wa&k&ia?oyik?umas??sijuf??yimonin??e&nokah?saya??i&akan?esiak?gusta?hsuz?kasagihc?o?ukust??o&nadah?sio?tamay?????kihsi!.&a&danihcu?gak?kihs?mijaw?t&abust?ikawak??wazanak??i&gurust?hcionon?mon?ukah??nasukah?o&anan?ton!akan???u&kohak?stamok?z&imana?us?????niko!.&a&han?m&arat?ijemuk?uru??n&e&dak?zi??no??ra&hihsin?rih??wa&kihsi?niko??yehi?zonig??e&osaru?seay??i&hsagih?jomihs?k&a&gihsi?not??ihsakot??m&a&ginuk?kihsug?maz??igo?otekat??nuga!noy???n&a&moti?timoy?wonig??i&jikan?k???o&gan?jnan?tiad&atik?imanim???u&botom?kusug&akan!atik??imot??rab&anoy?eah??????yp,zomim,?bus,c&204ugv--nx?462a0t7--nx?678z7vq5d--nx?94ptr5--nx?a?mpopilol,?d&-2,17sql1--nx?3thr--nx?5&20xbz--nx?40sj5--nx??7&87tlk--nx?ptlk--nx??861ti4--nx?a?e!tfarcdnah,?n&eirf&lrig,yob,?om,?ooftac,?e&16thr--nx?5&1a4m2--nx?9ny7k--nx??damydaer,eweep,garotsarukas.&10ksi.3s,20ksi.3s,?i&bmoz,m!.&a&bot?k&asustam?uzus??m&a&him?y&emak?im???ihs??nawuk?wi&em?k???e&bani?ogawak?si!imanim???i&arataw?gusim?h&asa?ciakkoy??k&a&mat?sosik?t??iat??raban??o&dat?hik?n&amuk?ihseru?o&du?mok????ust????kilbew,lasrepus,mihe!.&a&m&a&h&ataway?iin??yustam??ij&awu?imak???taki!man???ebot?i&anoh?kasam?rabami??n&ania?egokamuk?oot??o&jias?kihcu?nustam?uhcukokihs?yi!es???u&kohik?zo????n!.&arukas,lapo,n&erukom,riheg,?omomus,stnim,teniesa.resu,xob-liam,yrovi,zapot,?amihs!.&a&d&amah?ho?usam??kustay?m&a?ihsoni&hsin?ko???wakih??e&namihs?ustam??i&g&aka?usay??konikak?mikih??nannu?o&mu&kay?zi!ihsagih?uko???nawust?tasim??u&stog?yamat????nep,?rotsnoihsaf,srev,t&awi!.&a&bahay?d&amay?on??koirom?t&a&honat?katnezukir??imus??w&as&ijuf?uzim??ihs???e&hon&i&hci?n??uk??tawi??i&a&duf?murak?wak??h&custo?si&amak?ukuzihs???j&oboj?uk??k&a&m&anah?uzuk??sagenak??esonihci??m&akatik?uzia&rih?wi????o&kayim?no&rih?t??tanufo??uhso???isarap,saman,tococ,?ulbybab,?g&3zsiu--nx?71qstn--nx?l?olblooc,?h&03pv23--nx?13ynr--nx?22tsiu--nx?61qqle--nx?o-hu,sulb,?i&54urkm--nx?azosbew,ced,g&ayim!.&a&dukak?m&a&goihs?kihs??ihsustam!ihsagih??unawi??r&awago?iho??ta&bihs?rum??w&a&gano?kuruf??iat??y&imot?ukaw???e&mot?nimes??i&hsiorihs?ka&monihsi?s&awak?o???mak?r&ataw?o&muram?tan????o&az?jagat?t&asim?",
- "omamay???u&fir?k&irnasimanim?uhsakihcihs?????ihcot!.&a&g&a&h?kihsa??ust??kom?m&ay&o?usarak??unak??r&a&boihsusan?watho??iho?ukas??t&akihsin?iay??wa&konimak?zenakat??y&imonustu?oihs???e&iiju?kustomihs?nufawi??i&akihci?g&etom?ihcot?on???o&k&ihsam?kin??nas?sioruk?tab??u&bim?san?????h&c&ia!.&a&dnah?m&a!h&akat?im??yuni??ihs&ibot?ust???r&a&hat?tihs??ik?u&ihsagih?kawi???t&ihc?o&k?yot???wa&koyot?zani??yi&monihci?rak???e&inak?k&aoyot?usa??manokot?noyot??i&a&gusak?kot?sia??eot?h&asairawo?cugo?s&ahoyot?oyim???k&a&mok?zako??ihssi??motay?rogamag??n&an&ikeh?ok??ihssin??o&got?ihsin?jna?rihsnihs?suf?tes??u&bo?raho?s&oyik?takihs??yrihc?zah????ok!.&a&dusay?kadih?mayotom?r&ah&im?usuy??umakan??sot!ihsin??wa&g&atik?odoyin??k&as?o????i&esieg?hco!k??jamu?k&a!sus??usto??ma&gak?k??rahan??o&mukus?n&i?ust!ihsagih???torum?yot!o???u&koknan?zimihsasot????ugamay!.&a&m&ayukot?ihso??toyot??e&bu?subat??i&gah?kesonomihs?nukawi?rakih??nanuhs?otagan?u&ba?foh?otim?stamaduk?uy?????s&anamay!.&a&dihsoyijuf?mayabat?r&ahoneu?ustakihsin??w&a&k&ayah?ijuf??suran??ohs???egusok?i&ak?h&cimakan?s&anamay?od???k&asarin?u&feuf?sto????o&k&akanamay?ihcugawakijuf??nihso?t&asimawakihci?ukoh??uhc??spla-imanim?u&b&nan?onim??fok?hsok?rust????ubon,??ix,ka&rabi!.&a&bukust?gok?kan!ihcatih??m&a&sak?timo?wi??ihsak?ustomihs??ni?r&a&hihcu?way??u&agimusak?ihcust???t&ag&amay?eman??oihcatih??w&ag&arukas?o??os??yi&moihcatih?rom???e&bomot?dirot?not?tadomihs??i&a&k&as?ot??rao??esukihc?gahakat?h&asa?catih??k&a&rabi?saguyr??ihsani?uy??ma?rukustamat??o&dnab?giad?him?kati?rihsijuf?soj?t&asorihs?im??yihcay??u&fius?kihsu?simak????sagan!.&a&m&abo?ihsust??natawak?r&abamihs?u&mo?ustam???wijihc?yahasi??i&akias?hies?k&asagan?i??masah??neznu?o&besas?darih?t&eso?og!imaknihs????ust&igot?onihcuk?uf????zayim!.&a&biihs?guyh?k&oebon?ustorom??mihsuk?r&emihsin?uatik??ta&katik?mim??wag&atik?odak??ya??e&banakat?sakog??i&hsayabok?kaza&kat?yim??m&animawak?ot&inuk?nihs????nanihcin?o&j&ik?onokayim??n&ibe?ust??tias??urahakat????ro&cep,moa!.&a&dawot?turust?wasim??e&hon&ihc&ah?ihs??nas?og?ukor??sario??i&anarih?ganayati?hsioruk?jehon?kasorih?makihsah?nawo?r&amodakan?omoa???o&gnihs?kkat??u&ragust?stum????ttot!.&a&r&ahawak?uotok??sa&kaw?sim???egok?irottot?nanihcin?o&ganoy?nih?tanimiakas??u&bnan?z&ay?ihc??????ukuf!.&a&deki?gurust?ma&bo?h&akat?im??yustak??sakaw??eabas?i&akas?ho?jiehie?ukuf??nezihce!imanim??ono????k&26rtl8--nx?4&3qtr5--nx?ytjd--nx??522tin--nx?797ti4--nx?ci&gid,ht,sevol,?ee,limybab,n&at,upatilol,??l&33ussp--nx?e&ccabew.&resu,sr,?llarap,?lik,oof,rigetuc,?m&11tqqq--nx?41s3c--nx?ef,sioge,?n&30sql1--nx?65zqhe--nx?a&ebyllej,i&lognom,viv,??iam,n7p7qrt0--nx?o&o&las,mflah,?ruk,staw,??o&131rot--nx?7qrbk--nx?aic,c?d&iakkoh!.&a&deki?gakihset?hcebihs?k&adih?u&fib?narihs???m&ayiruk?hot?ihs&orihatik?ukuf??oras?usta??r&ib&a!ka??o?uruf??ozo?u&gakihsagih?oyot???sakim?ta&gikust?mun??w&a&ga&k&an?uf??nus!imak???k&aru?i&h&asa?sagih??kat?mak??omihs?um??zimawi??ine?oyk??yot??e&a&mustam?nan??b&a&kihs?yak??o&noroh?to???ian?k&ihsam?ufoto??nakami?ppoko!ihsin??sotihc?tad!okah??uonikat??i&a&bib?mokamot?n&a&k&kaw?oroh??wi??eomak?ihsatu?okik?usta&moruk?sakan????eib?h&c&ioy?u&bmek?irihs???s&ase?ekka?oknar?uesom???jufirihsir?k&amamihs?i&at?n???m&atik?otoyot??oa&kihs?rihs??r&a&hs?kihsi?mot??ihs&aba?ir??otarib???n&a&hctuk?rorum?se?tokahs??uber??o&kayot?m&ire?ukay??naruf!ima&k?nim???orih?r&ih&ibo?suk??o&bah?h&i&b?hsimak??sa??pnan?yan??umen??t&asoyik?eko?ukoh???u&bassa?kotnihs?m&assaw?uo??pp&akiin?en&ioto?nuk??ip??rato?s&akat?t&eb&e?i&a?hs!a??robon??m&e?o&m?takan???no&h?tamah??o&mik?s?t??u&kir?ppihc?st???onihsnihs?ufuras??uaru??yru!koh??zimihs!ok?????nu,?g!iti,oyh!.&a&bmat?dnas?gusak?k&at?o&oyot?y??uzarakat??m&ayasas?irah??wa&g&ani?okak??k&i&hci?mak??oy???yi&hsa?monihsin???i&asak?hs&aka?i&at?nawak???j&awa!imanim??emih??k&a&goa?s&agama?ukuf??wihsin??i&hsog?m???mati?oia?rogimak??n&annas?esnonihs??o&gasa!kat??ka?n&ikat?o?ustat??rihsay?sihs?tomus?yas??u&bay?gnihs?????hih,konip,l&bs,ik,?mol,nagan!.&a&bukah?d&a&w?yim??e&ki?u??ii??k&a&s&ay?uki??zus??ihsoo?ousay??m&ay&akat?ii??i&hsukufosik?jii??ukihc??n&i!hsetat??uzii??r&ah?ugot??saim?t&agamay?oyim??w&a&g&a&kan?n??o??kustam?ziurak??onim!imanim??u&koo?s!omihs????ya&ko?rih???e&akas?nagamok?subo??i&gakat?h&asa?c&a!mo!nanihs???uonamay??sukagot??k&a&kas?mimanim?to??ia&atik?imanim??oa?uzihcom??m&akawak?ijuf?o!t???r&ato?ijoihs?omakat???n&ana?esnoawazon??o&hukas?n&a&gan?kan??i&hc?muza??ustat??romok?si&gan?k??tomustam??u&k&as?ohukihc??stamega????o&b,m,pac,?to&mamuk!.&a&gamay?rahihsin?sukama!imak??tamanim??enufim?i&hcukik?k&ihsam?u??nugo!imanim??romakat??o&ara?rihsustay?sa?t&amay?om&amuk?us??u!koyg???yohc??u&sagan?zo????yk!.&a&bmatoyk?k&ies?oemak?uzaw??mayi&h&cukuf?sagih??muk??nihsamay?rawatiju?t&away?ik???e&ba&nat!oyk??ya??di?ni??i&ju?kazamayo?manim??natnan?o&gnatoyk?kum?mak?rihsamayimanim?y&gakan?ka&koagan?s??oj???u&ruziam?z&ayim?ik??????wtc1--nx?ykot!.&a&d&i&hcam?mus??oyihc??k&atim?ihsustak??m&a&t!uko??yarumihsa&gih?sum???i&hs&agoa?ika?o!t??uzuok??ren???r&a&honih?wasago??iadok?umah??ssuf?t&ik?o??wa&g&anihs?ode??k&ara?ihcat???y&agates?ubihs???e&amok?donih?m&o?urukihsagih??soyik??i&enagok?gani?h&ca&da?tinuk??sabati??j&nubukok?oihcah??manigus??o&huzim?jihcah?n&akan?ih!sasum??urika??rugem?t&a&mayihsagih?nim??iat?ok??uhc?yknub??u&fohc?hcuf?kujnihs?????p&a&ehc,rc,?o&hs&eht,iiawak,yub,?lf,p&evol,ydnac,?rd&kcab,niar,???r&2xro6--nx?atselttil,e&d&nu,wohc,?h,ilf,pp&ep,irts,u,?t&aerg,tib,??g!r,?ks,o!on,?ufekaf,?s&9nvfe--nx?dom,p&ihc,oo,?remagten,sikhcnerf,u&bloohcs,ruci,srev,?xvp4--nx??t&a&cyssup,obgip,?e&rces,vlev,?hginyad,netnocresu,opsgolb,sidas,u&b,ollihc,??u&4rvp8--nx?fig!.&a&d&eki?ih??kimot?m&ayakat?ihsah??ne?raha&gi&kes?makak??sak??taga&may?tik??wa&g&ibi?ustakan??karihs!ihsagih????e&katim?uawak??i&gohakas?hc&apna?uonaw??k&ago?es?ot??m&anuzim?ijat??nak?urat??nanig?o&dog?jug?makonim?nim?roy?sihcih??u&fig?s&otom?t&amasak?oay??????hc,pup,stoknot,ynup,?wonsetihw,x&5ytlk--nx?irtam,?y&adynnus,dr,knarc,l&oh,rig,?moolg,ob,pp&ih,olf,?rgn&a,uh,?u6d27srjd--nx?vaeh,?z&72thr--nx?e&ej,lur,??井福?京東?分大?取鳥?口山?城&宮?茨??媛愛?山&富?岡?歌和??岡&福?静??島&児鹿?広?徳?福??崎&宮?長??川&奈神?石?香??庫兵?形山?手岩?木栃?本熊?根島?梨山?森青?潟新?玉埼?田秋?知&愛?高??縄沖?良奈?葉千?賀&佐?滋??道海北?都京?重三?野長?阜岐?阪大?馬群???k!.&art?gro?moc?per?ude?vog???l&eh?l??m!.uj,ac?j??nd?o&g?h&pih?s!.&esab,xilpoh,ysrab,???lnud?oc?t!.&lldtn,snd-won,???pa!.&0mroftalp,a&rusah,ted,?bew:erif,,e&erf-korgn,gatskrelc,kalfwons:.kniletavirp,,niln&igol,okoob,?tupmocegde,virdhsalfno,?ilressem,k&orgn,relc,?le&crev,napysae,?maerdepyt,n&aecolatigidno,ur:.a,,?poon,r&cne,emarf,?t&i&belet,lmaerts,?xenw,?yfilten,??ra&a?hs??u&ekam?llag?org!.esruocsid,cts?kouk?nayalo???vsr?xece4ibgm--nx??q&a!3a9y--nx??g?i!.&gro?lim?moc?ten?ude?vog???m?se??r&a!.&a&cisum?sanes??bog?gro?l&autum?im??moc!.topsgolb,?pooc?rut?t&e&b?n??ni??ude?vog??4d5a4prebgm--nx?b?c?eydoog?los?t&at?s!uen???ugaj??b!.&21g?a&b&a&coros?iuc??itiruc??cnogoas?dicerapa?gniram?i&naiog?ramatnas??n&erom?irdnol??op?p&acam?irolf?ma&j?s???rief?tsivaob??b!aj?ib?mi?sb??c&ba?e&r?t??js?sp?t!e???d&em?mb?n&f?i??rt??e&dnarganipmac?ficer?ht?llivnioj?rdnaotnas??f&dj?ed?gg?n&e?i???g&e&l!.&a&b,m,p,?bp,c&a,s,?e&c,p,s,?fd,gm,ip,jr,la,ma,nr,o&g,r,t,?p&a,s,?r&p,r,?s&e,m,r,?tm,??s??l&s?z??n&c?e?o??ol!b?f?v??pp?ro??hvp?i&du?kiw?nana?oretin?r&c?eurab??sp?te?xat??l&at&an?rof??el?im?sq??m&a?da?e&gatnoc?leb??f?ic?oc!.&duolclautriv.elacs.sresu,etiselpmis,topsgolb,???nce?o&ariebir?c&e?narboir?saso??d&o?ranreboas??e&g?t??i&b?dar?ecam?r??rp?t&a?erpoir???p&er?m!e?t??ooc?pa?se??qra?r&af?ga?o&davlas?j??tn?ut??s&a&ixac?mlap?nipmac??ed?u&anam?j?m???t&am?e&d?n?v??nc?o&f?n??ra?sf??u&caug9?de?ja?rg??v&da?ed?og!.&a&b?m?p??bp?c&a?s??e&c?p?s??fd?gm?ip?jr?la?ma?nr?o&g?r?t??p&a?s??r&p?r??s&e?m?r??tm???rs?t??xiv?z&hb?ls?o&c?f?????c!.&as?ca?de?if?o&c?g??ro???e&bew?ccos?dnik?e&b?n&igne?oip??rac??gni&arg?rheob??h&cor?sok?t&aew?orb???itnorf?k&col?o&p?rb???l&aed?ffeahcs??mal?nes?pinuj?t&a&eht?rebsnegömrev??law?nec?s&acnal?nom?ubkcolb??upmoc??v&o&csid?rdnal??resbo??wulksretlow?ywal?zifp??f!.&aterg?bew&-no,etis321,?drp?e&c&itsuj-reissiuh?narf-ne-setsitned-sneigrurihc,?lipuog,rianiretev??hny,i&cc?rgabmahc??m&o&c?n??t??n&eicamrahp?icedem??ossa?pohsdaerpsym,s&e&lbatpmoc-strepxe?riaton?tsitned-sneigrurihc?uova??o&-x&bf,obeerf,?x&bf,obeerf,???t&acova?o&or-ne,psgolb,?r&epxe-ertemoeg?op!orea????vuog?xobided,?avc7ylqbgm--nx?s??g!.&etiselpmis,gro?moc?t&en?opsgolb,?ude?vog???h!.&e&erf,man??mo&c?rf??topsgolb,zi??ur??i!.&a&61f4a3abgm--nx?rf4a3abgm--nx??ca?di?gro?hcs?oc?ten?vog?نار&يا?یا???a&h?per??ew?lf??k!.&c&a?s??e&n?p?r??gk?iggnoeyg?kub&gn&oeyg?uhc??noej??l&im?uoes??man&gn&oeyg?uhc??noej??n&as&lu?ub??o&e&hcni?jead??wgnag???o&c?g??ro?s&e?h?m??topsgolb,u&gead?j&ej?gnawg????cilf??l!.&gro?moc?ten?ude?vog???m!.&topsgolb,vog???n!.&gro?moc?ofni?ten?ude?vog?zib???o&htua?odtnorf?t&c&a?od??laer???p!.&alsi?ca?eman?forp?gro?moc?o&fni?rp??t&en?se??ude?vog?zib???s?t!.&21k?bew?cn!.vog??eman?gro?kst?l&e&b?t??im?op??moc!.topsgolb,?neg?ofni?pek?rd?sbb?ten?ude?v&a?og?t??zib??f?m??ubad?vd??s&8sqif--nx?9zqif--nx?a!.vog?birappnb?gev?lliv?mtsirhc?s??b!.&ew,gro?moc?ten?ude?vog??c?oj?s?u??c&i&hparg?p?t&sigolyrrek?ylana???od??d&a?d?ik?l?n&iwriaf?omaid??oogemoh?rac??e!.&b&ewim321,og??gro?mo&c!.topsgolb,?n??pohsdaerpsym,ude??civres!.enilnigol,?d&d2bgm--nx?oc??h&ctaw?guh??i&lppus?rtsudni?treporp!yrrek???jaiv?l&aw?cycrotom?gnis?pats??m&ag?oh?reh??nut?ohs?picer?r&it?ut&cip!.7331,?nev???s&i&rpretne?urc??ruoc??taicossa?vig??g!nidloh??h5c822qif--nx?i!.&ekacpuc,gro?moc?t&en?ni?opsgolb,?ude?vog??a09--nx?nnet?rap?targ??k&c&or!.&ecapsbew,snddym,ytic-amil,??us??hxda08--nx?row??l!.&c&a?s??ed,gro?o&c?fni??ten?ude?vog?zib??a&ed?tner??e&ssurb?toh!yrrek???lahsram?m?oot??m!.&bal,etisinim,gro?moc?ten?ude?vog??b?etsys!.tniopthgink,?ialc??n&a&f?gorf?ol??i&a&grab?mod??giro??o&it&acav?cudorp?ulos??puoc???o&dnoc?geuj?ppaz?t&ohp!.remarf,?ua???p!.&ces?gro?moc?olp?ten?ude?vog??i&hsralohcs?lihp?t??u??r!.&au,ca?gro?ni?oc?topsgolb,ude?vog?xo,yldnerb.pohs,?a&c?p?tiug??c?e&dliub!.etisduolc,?erac?gor?levart?mraf?n&niw?trap??wolf??ot&cartnoc?omatat??pj?uot??s!.&em?gro?hcs?moc?ten?ude?vog?zib??alg?e&n&isub",
- "!.oc,?tif??rp!xe!nacirema???xnal??iws??t&a&e&b?ytic??ob??ek&cit?ram??fig?h&cay?gilf??n&atnuocca?e&mt&rapa?sevni??ve!.&nibook,oc,????rap??u!.&a&c!.&21k?bil?cc???g!.&21k?bil?cc???i!.&21k?bil?cc???l!.&21k?bil?cc???m!.&21k!.&hcorap?rthc?tvp???bil?cc???p!.&21k?bil?cc???si?v!.&21k?bil?cc???w!.&21k?bil?cc????c&d!.&21k?bil?cc???n!.&21k?bil?cc???s!.&21k?bil?cc????d&e&f?lacsne.xhp,?i!.&21k?bil?cc???m!.&21k?bil?cc???n!.&bil?cc???s!.&bil?cc???u&olcrim,rd,??e&d!.&21k?bil,cc???las-4-&dnal,ffuts,?m!.&21k?bil?cc???n!.&21k?bil?cc????h&n!.&21k?bil?cc???o!.&21k?bil?cc????i&h!.&bil?cc???m!.&21k?bil?c&c?et??goc?n&eg?otae??robra-nna?sum?tsd?wanethsaw???nd?r!.&bil?cc???v!.&21k?bil?cc???w!.&21k?bil?cc????jn!.&21k?bil?cc???k&a!.&21k?bil?cc???o!.&21k?bil?cc????l&a!.&21k?bil?cc???f!.&21k?bil?cc???i!.&21k?bil?cc????mn!.&21k?bil?cc???n&afflog,i!.&21k?bil?cc???m!.&21k?bil?cc???sn?t!.&21k?bil?cc????o&c!.&21k?bil?cc???m!.&21k?bil?cc???ttniop,?p&ion,rettalp,?r&a!.&21k?bil?cc???o!.&21k?bil?cc???p!.&21k?bil?cc????s&a!.&21k?bil?cc???dik?k!.&21k?bil?cc???m!.&21k?bil?cc???nd&deerf,uolc,??t&c!.&21k?bil?cc???m!.&21k?bil?cc???u!.&21k?bil?cc???v!.&21k?bil?cc????ug!.&21k?bil?cc???v&n!.&21k?bil?cc???w!.cc???x&ohparg,t!.&21k?bil?cc????y&b-si,k!.&21k?bil?cc???n!.&21k?bil?cc???w!.&21k?bil?cc????za!.&21k?bil?cc????ah!uab??bria?col?e!.ytrap.resu,?ineserf?lp?xe&l?n???vt?w!.&66duolc,gro?moc?s&ndnyd,tepym,?ten?ude?vog??a?e&iver?n!.elbaeciton,??odniw??y&alcrab?ot???t&0srzc--nx?a!.&amil4,ca!.hts??etiesbew321,gni&liamerutuf,tsoherutuf,?o&c!.topsgolb,?fni,?p&h21,ohsdaerpsym,?r&euefknuf.neiw,o??v&g?irp,?xi2,ytic-amil,zib,?c?e!s??hc?l!asite??mami?rcomed??b!.&gro?moc?ten?ude?vog??b?gl??c&atnoc?e&les?rid!txen????dimhcs?e!.&eman?gro?moc?ofni?ten?ude?vog?zib??b?em?grat?id?k&circ?ram??n!.&0rab,1rab,2rab,5inu,6vnyd,7&7ndc.r,erauqs,?a&l&-morf,moob,?minifed,remacytirucesym,tadsyawla,z,?b&boi,g,lyltsaf:.pam,,?c&i&nagro-gnitae,tats-oieboda,?paidemym,?d&e&calpb,ziamaka,?hiamaka,irgevissam.saap.&1-&gs,nol,rf,yn,?2-&nol,yn,??nab-eht-ni,uolc&meaeboda,nievas.c&di-etsedron,itsalej,?xednay:.e&garots,tisbew,?,??e&c&narusnihtlaehezitavirp,rofelacs.j,?gd&eiamaka,irbtib,?ht-no-eciffo,l&acs&liat.ateb,noom,?ibom-eruza,?m&ecnuob,itnuroieboda,ohtanyd,tcerider,?n&ilno-evreser,ozdop,?rehurht,s:abapus,,ti&s-repparcs,usegde,?zam&aym,kcar,??f&aeletis,crs.&cos,resu,?ehc-a-si,?g&ni&gats-&d&eziamaka,hiamaka,?e&gdeiamaka,tiusegde,?iamaka,nigiroiamaka,yekegde,?reesnes,sirkcilc,tsohnnylf,?olbevres,?iamaka,k&catsvano,eeg-a&-si,si,?u,?l&acolottad,iamwt,meteh,s&d-ni,s-77ndc,??m&ac&asac,ih,?urofniem,?n&a&f&agp,lhn,?i&bed,llerk,??dcduabkcalb,i:giroiamaka,,pv-ni,?o&c-morf,duppa,jodsnd,rp-ytinummoc,ttadym,?p&i&-&etsef,on,?emoh,fles,nwo,?j,mac-dnab-ta,o&-oidar-mah,h&bew,sdaerpsym,??pa&duolc,egde,?tfe&moh,vres,?usnd,?r&e&tsulcyduolc,vres-xnk,?vdslennahc:.u,,?s&a&ila&nyd,snd,?nymsd,?bbevres,dylimaf,e&gde-ndc,rauqs,suohsyub,t&isbeweruza,ys,??k&catstsaf,ekokohcs,?n&d&-won,aka,d,golb,npv,?oitcnufduolc,?ppacitatseruza:.&1,2:suts&ae,ew,?,3,aisatsae,eporuetsew,sulartnec,?,s&a-skcik,ecca&-citats,duolc,??t,?t&adies,ce&ffeym,jorprot:.segap,,lespohs,?e&nretnifodne,smem,?farcenimevres,i-&ekorb,s&eod,lles,teg,??n&essidym,orfduolc,?r0p3l3t,s&ixetnod,oh&-spv:.citsalej.&cir,lta,sjn,?,gnik,???u&h,nyd,r:eakust.citsalej,,?ved-naissalta.dorp.ndc,x&inuemoh,spym,tsale.&1ots-slj,2ots-slj,3ots-slj,?unilemoh,?y&awetag-llawerif,ekegde,ffijduolc:.&ed-1arf,su-1tsew,?,ltsaf.&dorp.&a,labolg,?lss.&a,b,labolg,?pam,slteerf,?n&-morf,ofipi,?srab,?z&a-morf,tirfym,???p?tcip?v??f&ig?osorcim??g!.&bog?dni?ed,g&olb,ro??lim?moc?ot,ten?ude???h!.&dem?gro?l&er?op??m&oc?rif??o&fni?rp?s&rep?sa???po&hs?oc??t&en?luda?ra??ude?vuog???i!.&a&2n-loritds--nx?7e-etsoaellav--nx?8&c-aneseclrof--nx?i-lrofanesec--nx??at?b?c!cul??dv?i&blo&-oipmet?oipmet??cserb?drabmol?g&gof?urep??l&gup?i&cis?me&-oigger?oigger???uig&-&aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf???aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf????n&a&brev?cul?pmac?tac??idras?obrac&-saiselgi?saiselgi??resi??otsip?r&b&alac!-oigger?oigger??mu??dna&-&attelrab-inart?inart-attelrab??attelrabinart?inartattelrab?ssela??epmi?ugil??tnelav&-obiv?obiv??vap?z&e&nev?ps&-al?al???irog???l&iuqa!l??leib??m&or?rap??n!acsot?e&dom?is?sec&-&ilrof?ìlrof??ilrof?ìlrof???g&amor&-ailime?ailime??edras?olob??i&ssem?tal??ne!var??o&cna?merc?rev?vas???oneg?p?r!a&csep?rr&ac&-assam?assam??ef??von??etam?tsailgo!-lled?lled???s!ip?sam&-ararrac?ararrac??u&caris?gar???t!a&cilisab?recam??resac?soa!-&d&-&ellav?lav??ellav?lav??ellav??d&-&ellav?lav??ellav?lav??ellav??te&lrab&-&airdna-inart?inart-airdna??airdnainart?inartairdna??ssinatlac???udap?v!o&dap?neg?tnam???zn&airb&-a&lled-e-aznom?znom??a&lledeaznom?znom??eaznom??e&c&aip?iv??soc?top??om???b&-&23,46,61,?3c-lorit-ds-onitnert--nx?be-etsoa&-ellav--nx?dellav--nx??c!f-anesec-lrof--nx?m-lrof-anesec--nx??he-etsoa-d-ellav--nx?m!u??o2-loritds-nezob--nx?sn-loritds&-nasl&ab--nx?ub--nx??nitnert--nx??v!6-lorit-dsnitnert--nx?7-loritds&-nitnert--nx?onitnert--nx???z&r-lorit-ds&-nitnert--nx?onitnert--nx??s-loritds-onitnert--nx???c&f?is?l?m?p?r?v??d&p?u!olcnys,??e&c!cel?inev?nerolf??f?g!apemoh321,ida&-&a&-onitnert?onitnert??otla!-onitnert?onitnert???a&-onitnert?onitnert??otla!-on&azlob?itnert??onitnert????hcram?l?m!or??n&idu?o&n&edrop?isorf??torc???p?r?s&erav?ilom??t!nomeip?s&eirt?oa!-&d-e&ellav?éllav??e&ellav?éllav???de&ellav?éllav??e&ellav?éllav?????v?znerif??g&a?b?f?il?o?p?r?up?vf??hc?i&b?c?dol?f?l!lecrev?opan?rof&-anesec?anesec???m?n&a&part?rt&-attelrab-airdna?attelrabairdna???imir?ret??p?r!a&b?ilgac?ssas???s!idnirb??t&ei&hc?r??sa??v??l&a!c??b?c?o&m?rit&-&d&eus&-&nitnert?onitnert??nitnert?onitnert??us&-&nitnert?onitnert??nitnert?onitnert??üs&-&nitnert?onitnert??nitnert?onitnert???s&-onitnert?onitnert???d&eus!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??us&-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??üs!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert???s&-onitnert?onitnert?????m&ac?f?i!t.nepo.citsalej.duolc,?ol?r??n&a!lim?sl&ab?ub???b?c?e!en.cj,v?zob??irut?m!p??p?r?t??o&a!v??b!retiv??c!cel??enuc?g!ivor??i&dem&-onadipmac?onadipmac??pmet&-aiblo?aiblo??rdnos?zal??l?m!a&greb?ret??oc?re&f?lap???n!a&dipmac&-oidem?oidem??lim?tsiro?zlob??ecip&-ilocsa?ilocsa??i&bru&-orasep?orasep??lleva?rot?tnert??r&elas?ovil??ulleb??p?r!a&sep&-onibru?onibru??znatac??oun??s!ivert?sabopmac??t!arp?e&nev?ssorg??n&arat?e&girga?rt?veneb????zz&era?urba???p&a?ohsdaerpsym,s?t??qa?r&a!m?s??b!a??c?f?g?k?me?o?p?s?t?v??s&a&b?iselgi&-ainobrac?ainobrac???b?c?elpan?i?m?o&t?x&bi,obdaili,??s?t?v??t&a?b?c?l?m?nomdeip?o!psgolb,?p?v??u&de?l?n?p??v&a?og?p?s?t?v??y&drabmol?ellav&-atsoa?atsoa??licis?nacsut??z&al?b?c?p??ìlrof&-anesec?anesec???derc?er?f?m?utni??je3a3abgm--nx?kh?l!.&topsgolb,vog??uda??m!.&gro?moc!.topsgolb,?ten?ude???n&a&morockivdnas?ruatser?tnuocca??e&g?m&eganam!.retuor,?piuqe??r??i!.ue?m?opdlog??opud?uocsid??o&b?cs!.&ude,vog:.ecivres,,??d?g?h?j?oferab?p&edemoh?s???p!.&bewanigap321,emon?gro?lbup?moc?t&en?ni?opsgolb,?ude?vog???r&a!m&law?s???epxe?op&er?pus!.ysrab,?s???s!.&a&daxiabme?rarik,?e&motoas?picnirp?rots??gro?lim?moc?o&c?dalusnoc?hon,?ten?ude??a&cmoc?f??e&b?r?uq??i!rolf?tned??o&h!.&duolc&p,rim,?e&lej,tiseerf,?flah,l&enapysae,rupmet,?s&pvtsaf,seccaduolc,?tsafym,vedumpw,??p!sua???urt??t!.&eman?gro?ibom?levart?m&oc?uesum??o&c?fni?r&ea?p???pooc?sboj?t&en?ni??ude?vog?zib??ayh?n?o!bba?irram???uognah?xen?y!.gro,?ztej??u&2&5te9--nx?yssp--nx??a!.&a&s?w??civ?d&i?lq??fnoc?gro?moc!.&pohsdaerpsym,stelduolc.lem,topsgolb,??nsa?ofni?sat?t&ca?en?n??ude!.&a&s?w??ci&lohtac?v??dlq?sat?t&ca?n??wsn!.sloohcs????vog!.&a&s?w??civ?dlq?sat???wsn?zo??ti??c!.&fni?gro?moc?ten?ude?vog??i??d&e!.tir.segap-tig,?iab??e!.&dcym,enozgniebllew,noitatsksid,odagod.citsalej,s&nd&ps,uolc,?ppatikria,?ysrab,??g!.&bew?gro?m&aug?oc??ofni?ten?ude?vog???h!.&0002?a&citore?idem?kitore??edszot?gro?ilus?letoh?m&alker?lif?t?urof??naltagni?o&c?ediv?fni?levynok?nisac??pohs?rarga?s&a&kal?zatu??emag?wen??t&lob?opsgolb,rops??virp?xe&s?zs??ytic?zsagoj??os?sut??l!.&etisbew321,topsgolb,??m!.&ca?gro?moc?oc?ro?ten?vog???n!.&duolcesirpretne,eni&esrem,m,?tenkcahs,?em!.ysrab,??o&ggnaw?y!c???r!.&3kl,a&i&kymlak,rikhsab,vodrom,?yegyda,?bps,ca,duolcrim,e&niram,rpcm,?g&bc,nitsohurger.citsalej,ro,?ianatsuk,k&ihclan,s&m,rogitayp,??li&amdlc.bh,m,?moc,natsegad,onijym,pp,ri&b,d&cm:.spv,,orue,?midalv,?s&ar,itym,?t&en,ias321,ni,opsgolb,set,?u&4an,de,?vo&g,n,?ynzorg,zakvakidalv,?myc?p?ug??s!.&a&d&golov,nagarak,?gulak,i&groeg,kymlak,lerak,nemra,rikhsab,ssakahk,vodrom,zahkba,?lut,rahkub,vut,yegyda,znep,?bps,da&baghsa,rgonilest,?gunel,i&anatsuk,hcos,ovan,ttailgot,?k&alhsygnam,ihclan,s&legnahkra,m,n&a&mrum,yrb,?i&buytka,nbo,??tiort,vorkop,??l&ocarak,ybmaj,?na&gruk,jiabreza,ts&egad,hkazak-&htron,tsae,???ovonavi,r&adonsark,imidalv,?t&enxe,nek&hsat,mihc,??vo&hsalab,n,?ynzorg,z&akvakidalv,emret,??t&amok?i&juf?masih????v!.&em,g&olb,ro??moc?nc,ten?ude?ved,??ykuyr??v&b?c!.&emon?gro?moc?t&ni?opsgolb,?ude???ed!.&2r,ated,e&docotua,erf-korgn,nilnigol,?gnigats-oned,hcetaidem,korgn,lecrev,o&ned,tpyrctfihs,?ppa-rettalp,s&egap,rekrow,?vr&esi,uc,?weiverpbuhtig,ylf,??ih?l!.&di?fnoc?gro?lim?moc?nsa?ten?ude?vog???m!.&eman?gro?lim?m&oc?uesum??o&fni?r&ea?p???pooc?t&en?ni??ude?vog?zib???o&g?m??rt?s!.&bog?der?gro?moc?ude???t!.&arukas,bew-eht-no,morf,naht-&esrow,retteb,?sndnyd,?d?i?won??uqhv--nx??w&a!.moc?hs?l??b!.&gro?oc???c!.&gro?moc?ten?ude??cp??e&iver!.oby,?n?s??g?k!.&bme?dni?gro?moc?ten?ude?vog???m!.&ca?gro?m&oc?uesum??oc?pooc?t&en?ni??ude?vog?zib??b??o&csom?h!s??n?w??p!.&344x,de?en?o&c?g??ro?snduolc,ualeb???r!.&ca?gro?lim?oc?pooc?ten?vog??n??t!.&a46oa0fz--nx?b&82wrzc--nx?ulc??emag?gro?l&im?ru,?moc!.reliamym,?t&en?opsgolb,?ude?v&di?og?ta0cu--nx??zibe?業商?織組?路網???z!.&ca?gro?lim?oc?vog????x&a!.&cm,eb,gg,s&e,u,?tac,ue,yx,?t??c!.&hta,ofni,vog???e&d&ef?nay??ma!nab??rof?s??ilften?jt?m!.&bog?gro?moc?t&en?opsgolb,?ude??g?ma2ibgy--nx??o&b!x??f?rex??rbgn--nx?s!.vog??x&am&jt?kt??x???y&4punu--nx?7rr03--nx?a&d!i&loh?rfkcalb??ot!.emyfilauqerp,??g?lp?p!ila??rot?ssin?wdaorb??b!.&duolcym,fo?hcetai",
- "dem,lim?moc!.topsgolb,?vog??ab?gur??c!.&ca?dtl?gro?lim?m&oc!.&ecrofelacs.j,topsgolb,??t??orp?s&egolke?serp??ten?vog?zib??amrahp?nega??d&dadog?uts??e&kcoh?ltneb?n&dys?om?rotta??snikcm??g!.&eb,gro?moc?oc?ten?ude?vog??olonhcet!.oc,?rene??hpargotohp?id?k!.&gro?moc?ten?ude??s??l!.&clp?d&em?i??gro?hcs?moc?ten?ude?vog??f?imaf!nacirema??l&a?il??ppus??m!.&eman?gro?lim?moc?t&en?opsgolb,?ude?vog?zib??edaca!.laiciffo,?ra??n&a&ffit?pmoc??os??o&j?s??p!.&gro?lim?moc?pooc?ten?ude?vog???r&e&corg?grus?llag?viled??lewej?otcerid?tnuoc?uxul??s!.&gro?lim?moc?ten?ude?vog??pil??t&efas?i&c?ledif?n&ifx?ummoc!.&bdnevar,gon,murofym,???r&ahc?uces??srevinu??laer?r&ap!.oby,?eporp??uaeb??u!.&bug?gro?lim?moc!.topsgolb,?ten?ude??b!tseb???van!dlo??xes??z&a!.&eman?gro?lim?moc?o&fni?rp??pp?t&en?ni??ude?vog?zib???b!.&az,gro?jsg,moc?ten?ude?vog???c!.&4e,inum.duolc.&rsu,tlf,?m&laer,urtnecatem.motsuc,?oc,topsgolb,??d!.&cos?gro?lop?m&oc?t??ossa?t&en?ra??ude?vog???ib!.&duolcsd,e&ht-rof,mos-rof,rom-rof,?izoj,liartevitca,nafamm,p&i&-on,fles,?ohbew,tfym,?retteb-rof,snd&nyd,uolc,?xro,?g??k!.&duolcj,gro?lim?moc?t&en?ropeletzak.saapu,?ude?vog???m!.&ca?gro?lim?oc?ten?ude?v&da?og????n!.&asq-irom--nx?ca?gro?htlaeh?i&r&c?o&am?ām???wi!k???keeg?l&im?oohcs??neg?oc!.topsgolb,?t&en?nemailrap?vog???a!niflla???rawhcs?s!.&ca?gro?oc???t!.&c&a?s??e&m?n??ibom?l&etoh?im??o&c?fni?g??ro?vt???u!.&gro?moc?oc?ten??rwon??yx!.&e&nozlacol,tisgolb,?gnitfarc,otpaz,??zub??λε?υε?авксом?брс!.&гро?до?ка?р&бо?п!у?????г&б?ро??дкм?зақ?итед?килотак?леб?мок?н&йално?ом??рку?сур!.&арамас,бпс,гро,зиб,ичос,ксм,м&ок,ырк,?рим,я,??тйас?фр?юе?յահ?לארשי!.&בושי?הימדקא?ל&הצ?שממ????םוק?اي&روس?سيلم?ناتيروم??بر&ع?غملا??ة&كبش?ي&دوعسلا?روس??یدوعسلا??ت&ا&راما?لاصتا??را&ب?ڀ?ھب???ر&ئازجلا?ازاب?صم?طق??سنوت?عقوم?قارع?ك&تيب?يلوثاك??موك?ن&ا&تس&كاپ?کاپ??دوس?ر&يا?یا??مع?يلعلا??درالا?ميلا?ي&رحبلا?طسلف???ه&ارمه?يدوعسلا??وكمارا?يبظوبا?ۃیدوعسلا?टेन?त&राभ?ोराभ??नठगंस?मॉक?्मतराभ?ত&রাভ?ৰাভ??ালংাব?ਤਰਾਭ?તરાભ?ତରାଭ?ாயித்நஇ?ைக்ஙலஇ?்ரூப்பக்ஙிச?్తరాభ?ತರಾಭ?ംതരാഭ?ාකංල?มอค?ยทไ!.&จิกรุธ?ต็นเ?ร&ก์คงอ?าหท??ลาบฐัร?าษกึศ???ວາລ?ეგ?なんみ?アトス?トンイポ?ドウラク?ムコ?ル&グーグ?ーセ??ン&ゾマア?ョシッァフ??业企?东广?乐娱?你爱我?信中?务政?动移?博微?卦八?厅餐?司公?品食?善慈?团集?国中?國中?址网?坡加新?城商?尚时?山佛?店&商?网?酒大里嘉??府政?康健?息信?戏游?拉里格香?拿大?教主天?机手?构机!织组??标商?歌谷?浦利飞?港香!.&人個?司公?府政?絡網?織組?育教???湾台?灣&台?臺??物购?界世?益公?看点?科盈訊電?站网?籍書?线在?络网?网文中?聘招?販通?逊马亚?通联?里嘉?锡马淡?門澳?门澳?闻新?電家?국한?넷닷?성삼?컴닷??");
+ "a&0&0trk9--nx?27qjf--nx?e9ebgn--nx?nbb0c7abgm--nx??1&2oa08--nx?apg6qpcbgm--nx?hbbgm--nx?rdceqa08--nx??2&8ugbgm--nx?eyh3la2ckx--nx?qbd9--nx??3&2wqq1--nx?60a0y8--nx??4x1d77xrck--nx?6&1f4a3abgm--nx?2yqyn--nx?5b06t--nx?axq--nx?ec7q--nx?lbgw--nx??883xnn--nx?9d2c24--nx?a&a?it??b!.&gro?lim?moc?sr,t&en?opsgolb,?ude?vog??abila?c?ihsot?m?n??c!.&b&a?m?n??c&b?g?q??ep?fn?k&s?y??ln?no?oc,p&i-on,ohsdaerpsym,?sn?t&n?opsgolb,?un?ysrab,?i&ma?r&emarp?fa??sroc??naiva?s??d&ats?n&eit?oh??om?sa?tl??eg?f&c?ob??g!emo?naripi?oy??hskihs?i&dem!.remarf,?hs?k!on??sa!.snduolc,??jnin?k&aso?dov?ede?usto??l!.&c,gro?moc?ofni?r&ep?nb,?t&en?ni??ude?vog??irgnahs?le&nisiuc?rbmuder???m!.&ca?gro?oc?sserp?ten?vog??ahokoy?e00sf7vqn--nx?m??n!.&ac?cc?eman?gro?ibom?loohcs?moc?ni?o&c?fni?rp??r&d?o??s&u?w??vt?xm??av?is?olecrab?tea??p!.&bog?ca?d&em?ls??g&ni?ro??mo&c?n??oba?ten?ude??c?g7hyabgm--nx?ra!.&461e?6pi?iru?nru?rdda-ni?siri???s??q!.&eman?gro?hcs?lim?moc?t&en?opsgolb,?ude?vog???r&az?emac?f4a3abgm--nx?n!d5uhf8le58r4w--nx??u&kas?tan???s!.&bup?dem?gro?hcs?moc?ten?ude?vog??ac!.uban.iu,?iv??t&ad?elhta?led?oyot??u!.&a&cinniv?emirc?i&hzhziropaz?stynniv?ttaprakaz??s&edo?sedo??tlay?vatlop??bs?cc,d&argovorik?o!ro&ghzu?hhzu???tl,?e&hzhziropaz?i,nvir?t??f&i?ni,?g&l?ro??hk?i&stvinrehc?ykstyn&lemhk?vypork???k&c?m?s&na&gul?hul??t&enod?ul??v&iknarf-onavi?orteporp&end?ind?????l&iponret?opotsa&bes?ves??p??m&k?oc?s?yrk??n&c?d?i?osrehk?v?ylov??o&c,nvor??p&d?p,z??r&c?imotihz?k?ymotyhz??sk?t&en?l?z??ude?v:c?e&alokin?ik??i&alokym?hinrehc?krahk?vl?yk??k?l?o&g!inrehc??krahk??r?,xc,y&ikstinlemhk?mus?s&akrehc?sakrehc?tvonrehc???z&ib,u????v!aj?bb?et?iv??waniko?x&a?iacal??yogan?z&.&bew?c&a?i&n?rga???gro?l&im?oohcs??m&on?t??o&c!.topsgolb,?gn??radnorg?sin?t&en?la??ude?vog?wal??zip!.korgn,???b&00ave5a9iabgm--nx?1&25qhx--nx?68quv--nx?e2kc1--nx??2xtbgm--nx?3&b2kcc--nx?jca1d--nx??4&6&1rfz--nx?qif--nx??96rzc--nx??88uvor--nx?a&0dc4xbgm--nx?c?her?n?ra?t??b!.&erots?gro?moc?o&c?fni??ten?ude?v&og?t??zib??a??c&j?s??d&hesa08--nx?mi??g?l!.&gro?moc?ten?ude?vog??m??s!.&gro?moc?ten?ude?vog???tc-retarebsnegmrev--nx?u&lc!.&elej,snduolc,ysrab,?smas??p!.ysrab,??wp-gnutarebsnegmrev--nx??c&1&1q54--nx?hbgw--nx??2e9c2czf--nx?4&4ub1km--nx?a1e--nx?byj9q--nx?erd5a9b1kcb--nx??8&4xx2g--nx?c9jrb2h--nx??9jr&b&2h--nx?54--nx?9s--nx??c&eg--nx?h3--nx?s2--nx???a!.&gro?lim?moc?rrd,ten?ude?vog??3a09--nx!.&ca1o--nx?gva1c--nx?h&ca1o--nx?za09--nx??ta1d--nx?ua08--nx????b&a?b?ci?f76a0c7ylqbgm--nx?sh??c!.&eugaelysatnaf,gnipparcs,liamwt,nwaps.secnatsni,revres-emag,s&nduolc,otohpym,seccaptf,?xsc,?0atf7b45--nx?a1l--nx??e!.&21k?bog?dem?esab,gro?l&aiciffo,im??moc?nif?o&fni?rp??ten?ude?vog??beuq?n?smoc??fdh?i&l&buperananab?ohtac??n&agro?ilc?osanap??sum?tic??l!.&gro?moc?oc?ten?ude?vog?yo,?l??m!.&mt?ossa??p1akcq--nx??n!.&mon?ossa??i?p??relcel?s!.&gro?moc?ten?ude?vog???t!.&e&m,w,?hc,?s?w??v!.&e0,gro?lim?moc?ten?ude?v&g:.d,,og????wp?yn??d&2urzc--nx?3&1wrpk--nx?c&4b11--nx?9jrcpf--nx???5xq55--nx?697uto--nx?75yrpk--nx?9ctdvkce--nx?a!.mon?d?er?olnwod??b2babgm--nx?c!.vog?g9a2g2b0ae0chclc--nx??e&m!bulc??r!k??sopxe?timil?w??fc?g!.&ude?vog???h&d3tbgm--nx?p?t??i!.&ased?bew?ca?etrof,hcs?lim?o&c!.topsgolb,?g??palf,ro?sepnop?ten?ym?zib??b?ordna?p?rdam??l&iub?og?row??m!.&ed,ot,pj,t&a,opsgolb,???n&a&b?l!.citats:.&setis,ved,?,raas???ob?uf??o&of?rp??r&a&c&tiderc?yalcrab??ugnav??ef506w4b--nx?k!.&oc,ude,?jh3a1habgm--nx??of??s!.&dem?gro?moc?ofni?ten?ude?v&og?t???m!kcrem???t!.topsgolb,excwkcc--nx?l??uolc!.&a&bura-vnej.&1ti,abura.rue.1ti,?tcepsrep,xo:.&ku,nt,?,?b&dnevar,ewilek:.sc,,?citsalej.piv,drayknil,elej,gnitsohdnert.&ed,hc,?letemirp:.ku,,m&edaid,ialcer.&ac,ku,su,??n&evueluk,woru,?r&epolroov,o&pav,tnemele,??tenraxa.1-se,ululetoj,wcs.&gnilebaltrams,koobelacs,latemerab.&1-&rap-rf,sma-ln,?2-rap-rf,?rap-rf.&3s,cnf:.snoitcnuf,,etisbew-3s,mhw,s8k:.sedon,,?s&8k,ecnatsni.&bup,virp,?ma-ln.&3s,etisbew-3s,mhw,s8k:.sedon,,??waw-lp.&3s,etisbew-3s,s8k:.sedon,,??xelpciffart,yawocne.ue,??za5cbgn--nx??e&1&53wlf--nx?7a1hbbgm--nx?ta3kg--nx??2a6a1b6b1i--nx?3ma0e1cvr--nx?418txh--nx?707b0e3--nx?a!.&ca?gro?hcs?lim?oc?t&en?opsgolb,?vog??09--nx??b!.&ca?etisbew321,gnitsohbew,nevueluk.yxorpze,pohsdaerpsym,snoitulostsohretni.duolc,topsgolb,?ortal?ut!uoy???c&0krbd4--nx!.&a2qbd8--nx?b8adbeh--nx?c6ytdgbd4--nx?d8lhbd5--nx???a&lp!.oc,?ps!.&lla4sx,rebu,tsafym,?artxe??sla??i!ffo??n&a&d?iler?nif?rusni!efil?srelevart???eics!.oby,??rofria??d!.&1sndnyd,42pi-nyd,7erauqs,amil4,b&ow-nrefeilgitsng--nx,rb-ni,vz-nelletsebgitsng--nx,?decalpb,e&daregtmueart,luhcsvresi,mohsnd,nihcamyek,tiesbew321,?hcierebsnoissuksid,keegnietsi,lsd-ni,m&oc,rofttalpluhcs,?n&-i-g-o-l,aw-ym,e&lletsebgitsnüg,sgnutiel,?i&emtsi,lreb-n&i,yd,??norblieh-sh.ti.segap,oitatsksid-ygolonys,pv&-n&i,yd,?nyd,?refeilgitsnüg,?orp-ytinummoc,p&h21,iog:ol,,ohsdaerpsym,?r&e&ntrapdeeps.remotsuc,su&-lautriv,lautriv,?t&adpusnd,tub-ni,uor-ym,?vres&-e&bucl,mohym,?bew-emoh:.nyd,,luhcs,??ogiv-&niem,ym,??s&d-&onys,ygolonys,?nd&-&dd,nufiat,sehcsimanyd,tenretni,yard,?isoc.nyd,ps,yard,?oper-&nvs,tig,?sndd:.&nyd,sndnyd,?,?topsgolb,vresi-&niem,tset,?xi2,y&awetag-&llawerif,ym,?srab,tic-amil,?zten&mitbel,sadtretteuf,??art!.oby,?i&sdoow?ug??on--nx??e!.&bil?dem?eif?gro?irp?kiir?moc!.topsgolb,?pia?ude?vog??ei?ffoc?gg?r&f?ged???f&a&c?s??il??g!.&gro?lim?moc?t&en?vp??ude?vog??a&f?gtrom?p!.&3xlh,detalsnart,grebedoc,kselp,sndp,tengam,xlh,y&cvrp,kcor,???rots?yov??elloc?na&hcxe?ro!.hcet,??roeg?ug??i!.&pohsdaerpsym,topsgolb,vog??tilop?v&bba?om???j!.&fo,gro?oc?ten???k!.&c&a?s??e&m?n??ibom?o&c!.topsgolb,?fni?g??ro??i&b?l?n???l&a&dmrif?s!rof???b&a?i&b?dua???c&aro?ric??dnik?g!oog??i&bom?ms??l&asal?erauqa??ppa?uhcs?yts!efil???m!.&4&32i,p&ct,v,??66c,ailisarb,b&dnevar,g-raegelif,?ca?duolcsd,e&d-raegelif,i&-raegelif,lpad:.tsohlacol,,?pcm,?g&ro?s-raegelif,?hctilg,kcatsegde,noitatsksid,o&bmoy,c?t&nigol,poh,??p&i&on,snart.etis,?j-raegelif,ohbew,?r&aegelif,idcm,ofsnd,?s&dym,ndd,ti?umhol,?t&en?s&acdnuos,ohon,??u&a-raegelif,de??v&irp?og??y&golonys,olpedew,srab,??a&g?n!.&reh.togrof,sih.togrof,???em?irp?orhc?w??n!goloc?i&lno!.&egats-oree,oree,ysrab,??w??o!.&derno:.gnigats,,ecivres,knilemoh,?hp?latipac?ts&der?e&gdirb?rif???z!.&66duolc,amil,sh,???ruoblem??om?p!.&bog?gro?lim?mo&c?n??t&en?opsgolb,?ude??irg?yks??r!.&mo&c?n??ossa?topsgolb,?a&c!htlaeh??pmoc?wtfos??bc?eh?if?ots!.&e&rawpohs,saberots,?yflles,??taeht?u&ces?sni?t&inruf?necca??za???s!.&a!bap.us,disnim321,?b!ibnal?rofmok??c!a??d!b?n&arb?ubroflanummok???e?f!noc,?g!ro??h!f??i!trap??k!shf??l?m!oc,t??n!mygskurbrutan??o?p!ohsdaerpsym,p??r!owebdluocti,?s!serp?yspoi,?t!opsgolb,?u?vhf?w?x!uvmok??y?z??a&c?el?hc??i&er?urc??nesemoh?roh?uoh??t&a&d?ts&e!laer??lla???is!.&e&lej,nilnigol,r&etnim,ocevon,?winmo,?k&rowtenoilof,wnf,?laicosnepo,n&eyb,oyc,?spvtsaf,thrs,xulel,ysrab,?bew!.remarf,??ov?ra?t&ioled?ol??utitsni??u&lb?qi&nilc?tuob???v!.&21e?b&ew?ib?og??ce&r?t??erots?gro?lim?m&o&c?n??rif??o&c?fni??rar?stra?t&en?ni??ude?vog??as?e3gerb2h--nx?i&l!.xlh,?rd?ssergorp??ol??w&kct--nx?r??xul?y!.&gro?lim?moc?ten?ude?vog????f&0f3rkcg--nx?198xim--nx?280xim--nx?7vqn--nx?a!.&gro?moc?ten?ude?vog???b!.vog?wa9bgm--nx??c!.topsgolb,a1p--nx!.&a14--nx,b8lea1j--nx,c&avc0aaa08--nx,ma09--nx,?f&a1a09--nx,ea1j--nx,?gva1c--nx,nha1h--nx,pda1j--nx,zila1h--nx,??ns??ea1j--nx?g?iam?l&a1d--nx?og??n!.&bew?cer?erots?m&oc?rif??ofni?re&hto?p??stra?ten???orp?p!.&gro?moc?ude???rus?t!.hcs,w??vd7ckaabgm--nx?w!.&hcs,zib,???g&2&4wq55--nx?8zrf6--nx??3&44sd3--nx?91w6j--nx!.&a5wqmg--nx?d&22svcw--nx?5xq55--nx??gla0do--nx?m1qtxm--nx?vta0cu--nx????455ses--nx?5mzt5--nx?69vqhr--nx?7&8a4d5a4prebgm--nx?rb2c--nx??a!.&gro?mo&c?n??oc?ten??vd??b!.&0?1?2?3?4?5?6?7?8?9?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t!opsgolb,?u?v?w?x?y!srab,?z???c!b?za9a0cbgm--nx??e!.&eman?gro?ics?lim?moc!.topsgolb,?nue?ten?ude?vog??a??g!.&ayc,gro?lenap:.nomead,,oc?saak,ten???i&a?v??k!.&g&olb,ro??ku,lim?moc?oi,pj,su,ten?ude?v&og?t,???m!.&drp?gro?lim?m&o&c?n??t??oc?ude?vog??pk??n!.&dtl,eman?gro?hcs?i!bom??l&im?oc,?m&oc!.topsgolb,?rif,?neg,ogn,ten?ude?vog??aw?i!b!mulp??car?d&art?dew??h&sif?tolc??k&iv?oo&b?c???ls?n&aelc?iart??p!pohs??re&enigne?tac??t&ad?ekram?hgil?lusnoc?neg?ov?soh!.tfarcnepo,??vi&g?l???o!s??u&rehcisrev?smas?tarebsnegömrev???o&d?lb?og!.&duolc,etalsnart,???r&2n084qlj--nx?ebmoolb?o!.&77ndc.c:sr,,a&remacytirucesym,t&neimip,sivretla,?z,?bew-llams,d&ab-yrev-si,e&sufnocsim,vas-si,?nuof-si,oog-yrev-si,uolc&arfniarodef,mw,??e&a,cin-yrev-si,grof&loot,peh,?l&as-4-ffuts,poeparodef,?m&-morf,agevres,ohruoyslles,?n&ozdop,uma.elet,?r&ehwongniogyldlob,iwym,uces-77ndc.nigiro.lss,?t&adidnac-a-si,is&-ybboh,golb,???fehc-a-si,golbymdaer,k&eeg-a&-si,si,?h,nut,?l&i&amwt,ve-yrev-si,?lawerif&-ym,ym,?sd-ni,?m&acssecca,edom-elbac,?n&af&blm,cfu,egelloc,lfn,s&citlec-a-si,niurb-a-si,tap-a-si,?xos-a-si,?ibptth,o&itatsksid,rviop,?p&j,v-ni,??o&jodsnd,tp&az,oh,??p&i&-on,fles,?o&hbew,tksedeerf,?tf&e&moh,vres,?ym,??r&e&gatop,ppepteews,su-xunil-a-si,?gmtrec,vdmac,?s&a&ila&nyd,snd,?nymsd,?b&alfmw,bevres,?d&ikcet.3s,ylimaf,?eirfotatophcuoc,j,koob-daer,ltbup,nd&-won,deerf,emoh,golb,kcud,mood,nyd:.&emoh,og,?,ps,rvd,tog,uolc,?s&a-skcik,ndd,?tnemhcattaomb,u,?t&ce&jorparodef.&duolc,gts.so.ppa,so.ppa,?riderbew,?e&ews-yrev-si,nretni&ehtfodne,fodne,??hgink-a-si,oi-allizom,s&ixetn&od,seod,?o&h-emag,l-si,?rifyam,??ue:.&a&-q,c,?cm,dc,e&b,d,e,i,m,s,?g&b,n,?hc,i&f,s,?k&d,m,s,u,?l&a,i,n,p,?n&c,i,?o&n,r,ssa,?pj,r&f,g,h,k,t,?s&e,i:rap,,u,?t&a,en,i,l,m,ni,p,?u&a,de,h,l,r,?vl,y&c,m,?z&c,n,??,vresnyd,x&inuemoh,unilemoh,?y&limafxut,srab,???ub&mah?oj???s!.&delacsne,gro?moc?rep?t&en?opsgolb,?ude?vog??gb639j43us5--nx??t?u!.&c&a?s??en?gro?moc?o&c?g??ro?topsgolb,??v!.ta,a1c--nx??wsa08--nx??h&0ee5a3ld2ckx--nx?4wc3o--nx!.&a&2xyc3o--nx?3j0hc3m--nx?ve4b3c0oc21--nx??id1kzuc3h--nx?l8bxi8ifc21--nx?rb0ef1c21--nx???8&8yvfe--nx?a7maabgm--nx??b!.&gro?moc?ten?ude?vog??mg??c!.&7erauqs,amil4,duolc-drayknil,etisbew321,gniksnd,p&h21,ohsdaerpsym,?sndtog,topsgolb,wolf.e&a.1pla,nigneppa,?xi2,ytic-amil,?aoc?et?ir!euz??r&aes?uhc??sob?taw!s???d0sbgp--nx?f&2lpbgm--nx?k??g!.&gro?lim?moc?ude?vog???m!a1j--nx??ocir?p!.&gro?i?lim?moc?ogn?ten?ude?vog???s!.&g&nabhsah,ro??l&im?xv,?m&oc?roftalp.&cb,su,t",
+ "ne,ue,??pib,ten?vog?won,yolpedew,?a&c?nom??i&d?f?ri???t!.&ca?enilno,im?ni?o&c?g??pohs,ro?ten??iaf!.oby,?laeh!.arh,?orxer?rae??vo!.lopdren,?zb??i&3tupk--nx?7a0oi--nx?a!.&ffo?gro?moc?ten?uwu,?1p--nx?bud?dnuyh?tnihc??b!.&gro?moc?oc?ro?ude??ahduba?o!m!.&duolcsd,ysrab,???s??c!.&ayb-tropora--nx?ca?d&e?m??esserp?gro?ln,moc?nif,o&c?g?ssa??ro?t&en?ni?roporéa??ude?vuog??cug?t??d&dk?ua??e&bhf--nx?piat??f!.&aw5-nenikkh--nx,dnala?i&ki,spak,?mroftalpduolc.if,nenikkäh,pohsdaerpsym,retnecatad.&omed,saap,?topsgolb,uvisitok321,yd,?onas??g!.&d&om?tl??gro?moc?ude?vog???h&c&atih?ra??s&abodoy?ibustim???juohs?k!.&gro?moc?ofni?ten?ude?vog?zib??b4gc--nx?iw!.remarf,?nisleh?s?uzus??l!.&aac,topsgolb,?drahcir?iamsi??maim?n!.&b&ew?og??ca?gro?lim?mo&c?n??ni?o&c?fni??pp?t&en?ni??ude?zib??airpic?i&hgrobmal?m??re??om?rarref?s!.&egaptig,ppatig,topsgolb,?ed??t&i&c?nifni??rahb??ut?v!.&21k?gro?moc?oc?ten???wik?xa&rp?t??yf??j&6pqgza9iabgm--nx?8da1tabbgl--nx?b!.&acirfa?eto?gro?m&oc?siruot??o&c!e??fni?noce?rga?tser??russa?s&etcetihcra?risiol?tacova??t&en?naruatser?opsgolb,?ude?vinu?yenom???d?f!.&ca?eman?gro?lim?moc?o&fni?rp??ten?vog?zib???nj?s?t!.&bew?c&a?in??eman?gro?lim?moc?o&c?g??t&en?ni?set??ude?vog?zib???yqx94qit--nx??k&8uxp3--nx?924tcf--nx?arfel?c&a&bdeef?lb??ebdnul?ilc?reme??d!.&e&disemmejh321,rots,?ger,mrif,oc,pohsdaerpsym,topsgolb,zib,?t??e&es?samet??h!.&a&4ya0cu--nx?5wqmg--nx??b3qa0do--nx?cni,d&2&2svcw--nx?3rvcl--nx??5xq55--nx?tl,?g&a0nt--nx?la0do--nx?ro??i&050qmg--nx?7a0oi--nx?xa0km--nx??m&1qtxm--nx?oc??npqic--nx?saaces,t&en?opsgolb,?ude?v&di?og?ta0cu--nx??xva0fz--nx?人&个?個?箇??司公?府政?絡&網?网??織&組?组??织&組?组??络&網?网??育&敎?教???n??i&tsob?vdnas??l!.&bew?c&a?os??dtl?gro?hcs?letoh?moc?nssa?ogn?prg?t&en?ni??ude?vog??at?cd?is??m!.&eman?fni?gro?moc?t&en?opsgolb,?ude?vog???n&ab!cfdh?etats?mmoc?t&en?fos??u??i!l!.&noyc,pepym,??p???oob?p!.&b&ew?og??gro?kog?m&af?oc??nog?ofni?pog?sog?ten?ude?vog?zib???row!ten!.&htumiza,nolt,o&c,vra,????s!.topsgolb,?t?u!.&c&a?lp??dtl?e&cilop?m??gro!.&gul:g,,sgul,yr&ettoly&lkeew,tiniffa,?tneelffar,???lenap-tnednepedni,n&noc,oissimmoc-&layor,tnednepedni,??o&c!.&bunsorter.tsuc,en&ilnoysrab,ozgniebllew,?krametyb.&hd,mv,?omida,p&i-on,ohsdaerpsym,?t&fihsreyal.j,opsgolb,?vres-hn,ysrab,??rpoc,?psoh,shn?t&en?nmyp,seuqni-tnednepedni,?vog!.&eci&ffoemoh,vres,?ipa,ngiapmac,??weiver-tnednepedni,y&riuqni-&cilbup,tnednepedni,?srab,????l&04sr4w--nx?a!.&gro?lim?moc?t&en?opsgolb,?ude?vog??bolg?c?ed?g!el??i&c&nanif!.oc,lpl??os??romem?tnedurp??n&if?oitanretni??t&i&gid!.sppaduolc:.nodnol,,?p&ac?soh???ned?ot???c!.&bog?lim?oc?topsgolb,vog???dil?e&datic?n&ahc?nahc!rehtaew???t!ria?tam??vart??f&8f&pbgo--nx?tbgm--nx??a?n??g!.&gro?moc?oc?ten?ude?xx,zib,??h&d?op??i!.&21k?ca?fdi?gro?inum?oc!.&egapvar,redrotibat,t&ibatym,opsgolb,???ten?vog??a&f?m&e?g?toh???m?r??l&a&b&esab?t&eksab!.&sua,zn,??oof???c?mt??e&d?hs??ihmailliw?j??m!.&esserp?gro?moc?ten?ude?v&og?uog????n!.&etisbew321,no&med,rtsic,?oc,pohsdaerpsym,retsulc-gnitsoh,topsgolb,vog,yalphk,?o??o&a?btuf?l!.gmo,?o&c!.&ed,rotnemele,??hcs??rit?u??p!.&a&cin&diws?gel??d&g,ortso?urawon??i&dem?mraw?nydg,?k&elo&guld?rtso??slopolam?tsu?ytsyrut??l&ip?o&kzs?w&-awolats?oksnok????n&erapohs,img?zcel,?rog&-ai&bab?nelej??j?z??syn?tsaim?w&a&l&eib?i?o??zsraw??o&namil?tainop,??z&eiwolaib?mol???c&e&iw&alselob?o&nsos?rtso???le&im?zrogz???orw,p??d&em,ia?ragrats?uolc&inu,sds,??e&c&i&lrog?w&ilg,o&hc&arats?orp??klop?tak????yzreibok??i&csjuoniws?ksromop?saldop??l&ahdop?opo??napokaz,t&atselaer?iselpmis,?z&romop?swozam???g&alble?ezrbo&lok?nrat??ro??hcyzrblaw?i&csomohcurein?grat?klawus??k&e&rut?walcolw??in&byr?diws,sark,?le?o&nas?tsylaib??rob&el?lam??s&als?jazel?nadg,puls?rowezrp???l&colw?e&r?vart??i&am?m???m&o&c?dar?n?tyb??s&g?iruot??t!a???n&a&gaz?nzop,?i&bul?cezczs?lbul,molow?nok?zd&eb?obeiws???u&leiw?rot,?y&tzslo?z&rtek?seic????o&c,fni?k&celo?zdolk??lkan?n&leim?pek?t&uk?yzczs??z&copo?eing?rowaj???rga?tua?w&ejarg?ogarm???p&e&eb,lks!emoh,??klwwortso?ohs!-ecremmoce,daerpsym,??romophcaz?sos?t&aiwop?en?opos,ra,sezc??ude?v&irp?og!.&a&io?p?s!w???bni&p?w??ci?dtiw?e&ko?ss&p?w???fiw?g&imu?u??hiiw?m&igu?rio?u!o???nds!ipz??o&ks?p!pu??s?wtsorats??p&a?sp!mk?pk?wk??u&m?p??wk?z??r&hcso?ksw?p?s??s&i?oiw?u?zu??talusnok?w&gzr?i&p?rg?w??m?o&o?pu??u!imzw???z&kw?ouw?????w&a&l&corw?sizdow??w??o&golg?k&ark,ul?zsurp??r&az?gew??t&rabul,sugua??z&coks?sezr????xes?y&buzsak?d&azczseib?ikseb??hcyt?n&jes?lod-zreimizak??pal?r&ogt?uzam??walup?zutrak??z&am-awar?c&aprak?iwol?zsogdyb??dalezc?ib?s&i&lak?p??uklo????l??r&as?f?s??s!.&gro?moc?ten?ude?vog???t!.vog??ubnatsi?x3b689qq6--nx?yc5rb54--nx??m&00tsb3--nx?1qtxm--nx?981rvj--nx?a!.&aayn,enummoc?gro?moc?o&c?idar,ken,?t&en?opsgolb,??c!bew??dretsma?e&rts?t!.&citsalej,esruocsid,???fma?xq--nx??b!.&gro?moc?ten?ude?vog??i??c!.&moc?oc?ten?vog???d!.&gro?moc?ten?ude?vog???f!.&gro?moc?oidar,ten?ude??i??g!vu96d8syzf--nx??h?i!.&ca?gro?moc?o&c!.&clp?dtl???r,?t&en?t??vt??k?rbg4--nx??k!.&drp?e&rianiretev?sserp??gro?lim?m&o&c?n??t??nicedem?ossa?pooc?s&eriaton?neicamrahp?sa??ude?v&og?uog????l&if?ohkcots??o!.&dem?gro?m&oc?uesum??o&c?rp??ten?ude?vog??b?c!.&0x,2aq,3pmevres,5sndd,a&c&-morf,ir&bafno,fa,??g&-morf,oy-sehcaet,?i-morf,m&-morf,all&-a-si,amai,??p&-morf,c-a-si,?remacytirucesym,s,tadtsudgniht,v-morf,w-morf,z,?b&ew&-sndnyd,arukas,draiw.segap,ottad,?ildts.ipa,?c&amytirucesemoh,d-morf,esyrcs,itsalej.omed,n&-morf,vym,?p&kroweht,ytirucesemoh,?q,rievres,s-morf,?d&aerotffuts,e&calpb,ifitrec-&si,ton-si,?llortnocduolc,rewopenignepw:.sj,,tsohecapsppa,?i&-morf,rgevissam.saap,?m-morf,n&-morf,abeht-htiw-si,?s-morf,uolc&-noitatsyalp,hr,iafaw.&d&ej,yr,?nol,?meaeboda,nevia,panqym:-&ahpla,ved,?,smetsystuo,ved&j,pw,??vreser,wetomer,?e&butuoyhtiw,ciffo-sndnyd,d:-morf,o&celgoog,n&il.srebmem,neve.&1-&su,ue,?2-&su,ue,?3-&su,ue,?4-&su,ue,????,erf&-sndnyd,sndd,?filflahevres,g&de-yltsaf,nahcxeevres,?i&hcet-a-si,p-sekil,?k&auqevres,irtsretnuocevres,?l&bitpa-no,googhtiw,?m&agevres,ina-otni-si,oh-&sndnyd,ta-sndnyd,??n&-morf,ilno&-evreser,ysrab,?og-si,?r&alfduolcyrt,ehwynanohtyp:.ue,,ihcec,?srun-a-si,t&i&nuarepo,s&-ybboh,aloy,elpmis,tipohs,xiw,??omer-sndnyd,upmocsma,ysgolb,?v&als-elcibuc-a-si,i&lsndd,tavresnoc-a-si,??z&amkcar,eelg,iig,??fehc-a-si,g&ni&gats-&raeghtua,swennwot,?ksndd,robsikrow,tsoh-bt.etis,?o&fgp,lb&-sndnyd,sihtsetirw,???h&n-morf,o-morf,?i&fiwehtno,h-morf,kiw-sndnyd,m-morf,p&aerocne,detsoh,?r-morf,w-morf,z&ihcppa,nilppa,??jn-morf,k&a&-morf,erfocsic,?cils-si,eeg&-a&-si,si,?sndd,?h,latsnaebcitsale:.&1-&ht&ron-ue,uos-&em,fa,pa,ue,??lartnec-&ac,li,ue,?ts&ae&-&as,pa,su,vog-su,?ht&ron-pa,uos-pa,??ew-&su,ue,vog-su,???2-ts&ae&-su,ht&ron-pa,uos-pa,??ew-&su,ue,??3-ts&aeht&ron-pa,uos-pa,?ew-ue,??,o-morf,r&adhtiwtliub,ow&-&sndnyd,ta-sndnyd,?ten-orehkcats,??sedal,u,?l&a&-morf,colottad,rebil-a-si,?f-morf,i&-morf,am&-sndnyd,detsohpw,??l&ecelffaw,uf-ytnuob:.a&hpla,teb,?,?ppmswa,ru-&elpmis,taen,?ssukoreh,xegap,?m&n-morf,pml.ppa,rofe&pyt.orp,rerac-htlaeh,?sacrasevres,uirarret-yltsaf,?n&a&cilbuper-a-si,f&-sllub-a-si,racsan-a-si,?i&cisum-a-si,ratrebil-a-si,?tarukas,?c,dc&hsums,umpw,xirtrepmi,?eerg-a-si,i&-morf,jod,?m-morf,o&ehtnaptog,isam-al-a-tse,r&italik,tap-el-tse,?s&iam-al-a-tse,replausunu,??pj,t-morf,?o&bordym,c,hce-namtsop,jodsnd,m&-morf,ed-baltlow,?n:iloxip,,t&ingocnozama.&1-&ht&ron-ue.htua,uos-&em.htua,fa.htua,pa.htua,ue.htua,??lartnec-&ac.htua,li.htua,ue.htua,?ts&ae&-&as.htua,su.&htua,spif-htua,??ht&ron-pa.htua,uos-pa.htua,??ew-&su.&htua,spif-htua,?ue.htua,vog-su.spif-htua,???2-ts&ae&-su.&htua,spif-htua,?ht&ron-pa.htua,uos-pa.htua,??ew-&su.&htua,spif-htua,?ue.htua,??3-ts&aeht&ron-pa.htua,uos-pa.htua,?ew-ue.htua,??tadym,??p&2pevres,aelutym,i&-sndnyd,fles,ogol,ruoy&esol,hctid,?ym&eerf,teg,??ohsdaerpsym,pa&-rettalp,anis:piv,,esaberif,k1,lortnocduolc,oifilauq,r&aegyks,oetem:.ue,,?t&ilmaerts,norfegap,?ukoreh,?t&fevres,thevres,??r&081,a:-morf,tskcor-a-si,,b,e&d&iv&erp-yb-detsoh.saap,orpnwo,?ner&.ppa,no,??e&bevres,nigne-na-si,?ggolb-a-si,h&caet-a-si,pargotohp-a-si,?krow-drah-a-si,n&gised-a-si,ia&rtlanosrep-a-si,tretne-na-si,??p&acsdnal-a-si,eekkoob-a-si,?retac-a-si,subq,tn&ecysrab,iap-a-si,uh-a-si,?vres&-&ki.&cpj-rev-duolcj,duolcj,?s&ndnyd,pvtsaf,??inim,nmad,sak,?y&alp-a-si,wal-a-si,?zilibomdeepsegap,?g,ituob,k,mgrp.nex,o&-morf,sivdalaicnanif-a-si,t&areleccalabolgswa,c&a-na-si,od-a-si,?susaym,??p-morf,u&as-o-nyd,e&tsoh.&duolc-gar,hc-duolc-gar,?ugolb-nom-tse,?omuhevres,??s&a&apod,ila&nyd,snd,?nymsd,vnacremarf,?bbevres,ci&p&-sndnyd,evres,?tcatytiruces,?dylimaf,e&cived-anelab,itilitu3,lahw-eht-sevas,mag-otni-si,t&i&iis,sro,?yskciuq,??fpi-&eralfduolc,fc,?i&ht2tniop,pa&elgoog,tneltneg,??jfac,k&-morf,aerf-ten,colb&egrof,pohsym,??m&-morf,cxolb,?n&d&-pmet,dyard,golb,htiwssem,mood,tog,?kselp,nyd,ootrac-otni-si,?o&-xobeerf,xobeerf,?ppa&-avnac,raeghtua,t&ikria,neg,??r&ac-otni-si,e&ntrap-paelut,tsohmaerd,??s&e&l-rof-slles,rtca-na-si,?ibodym,?tsaeb-cihtym.&a&llicno,zno,?ilay,lacarac,re&gitnef,motsuc,?sv,toleco,x:n&ihps,yl,?,?u,wanozama.&1-&3s,ht&ron-ue&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,??uos-&em&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,??fa.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,?pa&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,??ue.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,???la&nretxe-3s,rtnec-&ac&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3",
+ "s,etisbew-3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,??em.&3s,adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,?li.&3s,adbmal-tcejbo-3s,etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,?ue&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,????ts&ae&-&as&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,??pa&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,??su:-etisbew-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,d&etacerped-3s,orp-&iupparme,oidutsrme,skoobetonrme,??etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,?,vog-su&-&3s,spif-3s,?.&3s,adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,???ht&ron-pa&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,??uos-pa&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,????ew-&su&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,??ue&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,d&etacerped-3s,orp-&iupparme,oidutsrme,skoobetonrme,??etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,??vog-su&-&3s,etisbew-3s,spif-3s,?.&3s,adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,?????2-&htuos-&pa.&3s,adbmal-tcejbo-3s,etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,?ue.&3s,adbmal-tcejbo-3s,etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,??lartnec-ue.&3s,adbmal-tcejbo-3s,etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,?ts&ae&-su&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,d&etacerped-3s,orp-&iupparme,oidutsrme,skoobetonrme,??etisbew-3s,ipa-etucexe,kcatslaud.&3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,??ht&ron-pa&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,??uos-pa&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,????ew-&su&-&3s,etisbew-3s,?.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,d&etacerped-3s,orp-&iupparme,oidutsrme,skoobetonrme,??etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,spif-&3s,tniopssecca-3s,?tniopssecca-3s,?spif-&3s,tniopssecca-3s,?tniopssecca-3s,yawetag-scitylana,??ue&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,?????3&-ts&aeht&ron-pa&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,??uos-pa.&3s,adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,??ew-ue&-3s,.&3s,9duolc&-swa.stessa-weivbew,.s&fv,tessa-weivbew,??adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,???s,?4-tsaehtuos-pa.&3s,adbmal-tcejbo-3s,etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,?labolg-3s.tniopssecca.parm,?yasdrocsid,?t&arcomed-a-si,c&-morf,etedatad.&ecnatsni,omed,??eel&-si,rebu-si,?hgilfhtiwletoh,i:batym,,m-morf,n&atnuocca-na-si,e&duts-a-si,r-ot-ecaps,tnocresu&buhtig,e&capsppa,donil.pi,lbavresbo.citats,?pl,???ops&edoc,golb,ppa,?s&i&hcrana-&a-si,na-si,?laicos-a-si,pareht-a-si,tra-na-si,xetn&od,seod,??oh&piym,sfn,??u&-morf,nyekcoh-asi,?v-morf,?u&-rof-slles,4,a-sppatikria,e,h,oynahtretramssi,r:ug-a-si,,?v&n-morf,rdlf,w-morf,?w&o&lpwons-yrt,zok,?ww100,?x&bsbf.sppa,em,i&nuemoh,rtrepmi,?obaniateb,t-morf,unilemoh,?y&a&bnx:.&2u,lacol-2u,?,l&erottad,pezam,?wetag-llawerif,?dnacsekil,fipohsym,k&-morf,niksisnd,?rot&ceridevitcaym,sitk,?u:goo,,w-morf,x&alagkeeg,orp&hsilbup,mapson.duolc,???zesdrocsid,?inu??m?or?tsla??p!.&eman,nwo,??raf!.jrots,etats??s?t!.&gro?lim?mo&c?n??oc?ten?ude?vog???u&esum?rof??z!.&ca?gro?hcs?lim?moc?o&c?fni??ten?ude?vog?zib????n&315rmi--nx?a&brud?cilbuper?f?grompj?hkaga?idraug?m?ol?ssin?u&hix?qna??varac?yalo??b!.&gro?moc?oc,ten?ude?vog??c??c!.&ah?bh?c&a?s??d&5xq55--nx?g?s?uolctnatsni,?eh?g&la0do--nx?ro??h&a?q?s??i&7a0oi--nx?h??j&b?f?t?x?z??kh?l&h?im?j??m&n?oc!.&rekamegas.1-&htron-nc.&koobeton,oiduts,?tsewhtron-nc.&koobeton,oiduts,??swanozama.&1-&htron-nc.&3s,adbmal-tcejbo-3s,d&etacerped-3s,orp-&iupparme,oidutsrme,skoobetonrme,??etisbew-3s,ipa-etucexe,kcatslaud.&3s,etisbew-3s,tniopssecca-3s,?tniopssecca-3s,?tsewhtron-nc.&3s,adbmal-tcejbo-3s,dorp-&iupparme,oidutsrme,skoobetonrme,?etisbew-3s,ipa-etucexe,kcatslaud.&3s,tniopssecca-3s,?tniopssecca-3s,??be.1-&htron-nc,tsewhtron-nc,?????n&h?l?s?y??om?qc?s&g?j?ppa-avnac,?t&cennockciuq.tcerid,en??ude?vog?wt?x&g?j?n?s??z&g?x??司公?絡網?络网??b??d&g!.ypnc,?ka??e&drag?erg?fuak?gawsklov?hctik?i&libommi?w??m?po?r!ednaalv??sier?ves??g!.&ca?gro?moc?ten?ude?vog??is&ed!.ssb,?irev???h!.&bog?cc,gro?lim?moc?ten?ude???i!.&ac?bew,c&a?in??dni?e&m?sabapus,?g&5?6?p?ro??i&a?hled??ku?l&evart?im??m&a?oc?rif??n&c?eg??o&c?fni?i?rp??p&ooc?u??r&ahib?d?e??s&c?er?nduolc,senisub?u??t&arajug?en!retni??ni?opsgolb,sop??ude?v&og?t??ysrab,zib??elknivlac?griv?ks?lreb?p?v?w?x??k!.&gro?ten?ude?vog???l&eok?ocnil??m!.&cyn,gro?ude?vog???o&dnol?i&hsaf?n&o?utiderc??siv!orue??t&a&cude!.oc,?dnuof?tsyalp??c&etorp?u&a?rtsnoc?????kin?las?mrom?nac?p&q?uoc??s&iam?pe?scire??t&ron?sob??zama??p!.&gro?oc?ten?ude?vog??k??r&e&c?yab??op!.eidni,??s!.&gro?moc?osrep?t&opsgolb,ra??ude?v&inu?uog????t!.&d&ni?uolcegnaro,?gro?ltni?m&oc!nim??siruot??nif?o&fni?srep??sne?t&an?en??vog??m??u&f?r!.&bdnevar,lper,retropno,s&h,revres,?tnempoleved,xiw,??stad?xamay?y??v!.&a&lnos?ohhnah&k?t???c&a?ouhphnib?uhphniv??di?e&man?rtneb?uhneihtauht??g&n&a&boac?ig&ah?cab?n&a?ei&k?t???uah??nad?rtcos?uqneyut??o&dmal?hpiah?lhniv?nkad?ud&hnib?iah????ro??h&ni&b&aoh?gnauq?hnin?iaht??d&hnib?man??mihcohohphnaht?n&cab?gnauq?yat??tah?vart??tlaeh??i&a!bney?coal?gngnauq?laig?ngnod??onah?rtgnauq??kalkad?m&an&ah?gnauq??oc?utnok??n&a&ehgn?gnol?kcab?uhthni&b?n???e&ibneid?y&gnuh?u&gniaht?hp????osgnal??o&fni?ht&nac?uhp??i?rp??pahtgnod?t&en?ni?opsgolb,?u&a&hcial?mac?tgnuv-airab??de?eilcab??vog?zib???wo&rc?t!epac????o&76i4orfy--nx?a!.&bp?de?go?oc?ti?vg??boat??b!.&a&ci&sum?tilop??i&c&arcomed?neic??golo&ce?ncet??m&edaca?onoce??rt&ap?sudni??vilob??n&egidni?icidem??serpme?tsiver?vitarepooc??b&ew?og??dulas?e&rbmon?tr&a?op&ed?snart????g&olb?ro??ikiw?l&a&noi&canirulp?seforp??rutan??im??moc?o&fni?lbeup?rga?tneimivom??saiciton?t&askt?en?ni??ude?vt??h?iew?olg??c!.&bew?cer?dr&c,rac,?esabapus,gro?ipym,l&im?per:.di,,?m&o&c!.topsgolb,?n??rif??ofni?s&egap&dael,l,?tra??t&4n,en?ilperdellawerif:.di,,ni??ude?vog??a?e?in?mara?s&edarb?ic???d!.&b&ew?og??dls?gro?lim?moc?t&en?ra??ude?vog??agoba?if?zd7acbgm--nx??e&c?d&iv?or???f!ni!.&e&g&delwonk-fo-l&errab,lerrab,?ellocevoli,?ht-skorg,rom-rof-ereh,tadpusn:d,,?llatiswonk,macrvd,ofni-v,p&i&-on,fles,?ohbew,?ruo-rof,s&iht-skorg,nd&-cimanyd,nyd,uolc,??tsrifyam,ysrab,zmurof,???g&el?n!am?ib???hwsohw?i!.&35nyd,8302,a&minifed,tad-b,?b&altig,uhtig,?czh,d&in,raobelgaeb,u&olc&iaznab.ppa,ropav,?rd,??e&c&apsinu.1rf-duolc,ivedniser,?donppad.sndnyd,egipa,lej,nilnigol,sufxob,t&i&beulb,snoehtnap,?newtu,ybeeb.saap,??gni&gatsniser.secived,tsohytsoh,?ilpu,k&coregrof.di,orgn:.&as,ni,p&a,j,?su,u&a,e,??,ramytefasresworb,?moc?n&aicisum,mtsp:.kcom,,yded,?o&idutsxiw,t&oq,pyrctfihs,??p&opilol,pa&-arusah,e&nalpkcab,tybeeb.1dkes,???r&e&tsneum-hf,vres&cisab,lautriv,??ial.sppa,?s&codehtdaer,gnihtbew,nemeis-om,pparevelc,t&acdnas,ekcit,??t&e&kcubtib,notorp,?i&belet,detfihs,gude,kecaps,?raedon.egats,s&ohg,udgniht.&cersid.&dvreser,tsuc,?dorp.tsuc,gnitset.&dvreser,tsuc,?ved.&dvreser,tsuc,????vgib.0ku,whs,x&bslprbv.g,cq,rotide,?y&olpedew,srab,??b?d&ar?u&a?ts???j?r?syhp??j!.&eman?gro?hcs?lim?moc?ten?ude?vog???ll&ag?o??m!.&gro?moc?ten?ude?vog??g?il?mi?orp??n!.&a&0&b-ekhgnark--nx?c-iehsrgev--nx?g-lksedlig--nx?k-negnanvk--nx??1&p-nedragy--nx?q-&asierrs--nx?grebsnt--nx?lado-rs--nx?n&egnidl--nx?orf-rs--nx??regnayh--nx?ssofenh--nx??r-datsgrt--nx?s-ladrjts--nx?v-y&senner--nx?vrejks--nx???3g-datsobegh--nx?4&5-&dnaleprj--nx?goksnerl--nx?tednalyh--nx??6-neladnjm--nx?s-&antouvachb--nx?impouvtalm--nx??y-&agrjnevvad--nx?ikhvlaraeb--nx???7k-antouvacchb--nx?8&k-rekie-erv--nx?l-ladrua-rs--nx?m-darehsdrk--nx??a!.sg??bct-eimeuvejsemn--nx?d&do?iisevvad?l",
+ "ov?narts?uas??f&1-&l--nx?s--nx??2-h--nx??g&10aq0-ineve--nx?av?ev?lot?r&ajn&evvad?u??ájn&evvad?u????h?iz-lf--nx?j&ddadab?sel??k&el?hoj&sarak?šárák??iiv&ag&na&el?g??ŋ&ael?ág???ran???l&f?lahrevo?o&ms?s??sennev?t-&ilm--nx?tom--nx??u&-edr--nx?s??øms??muar?n&0-tsr--nx?2-dob--nx?5-&asir--nx?tals--nx??a&r!-i-om?f?t??t??douvsatvid?kiv?m&os?øs??n&od?ød??ra?sen?t&aouvatheig?ouv&a&c&ch&ab?áb??h&ab?áb???n??i&ag?ág??sa&mo?ttvid??án???z-rey--nx?ær&f?t???o&p-&ladr--nx?sens--nx??q-nagv--nx?r-asns--nx?s-kjks--nx?v-murb--nx?w-&anr&f--nx?t--nx??ublk--nx???ppol?q&0-t&baol--nx?soum--nx?veib--nx??x-&ipphl--nx?r&embh--nx?imph--nx???y-tinks--nx??r&f-atsr--nx?g-&an&ms--nx?nd--nx??e&drf--nx?ngs--nx??murs--nx?netl--nx?olmb--nx?sorr--nx??h-&a&lms--nx?yrf--nx??emjt--nx??i&-&lboh--nx?rsir--nx?y&d&ar--nx?na--nx??ksa--nx?lem--nx?r&ul--nx?yd--nx????stu??j-&drav--nx?rolf--nx?sdav--nx??kua?l-&drojf--nx?lares--nx??m-tlohr--nx?n-esans--nx?olf?p-sdnil--nx?s-ladrl--nx?tih?v-rvsyt--nx??s&a&ns?ons??i&ar?er&dron?r&os?øs???ár??la&g?h??mor!t??sir?uf?åns??t&koulo&nka?ŋká??la?p-raddjb--nx?r-agrjnu--nx?s&aefr&ammah?ámmáh??orf?r&o?ø???u-vreiks--nx??u&h-dnusel--nx?i-&drojfk--nx?vleslm--nx??j-ekerom--nx?k-rekrem--nx?u-&dnalr--nx?goksr--nx?sensk--nx??v-nekyr--nx?w-&k&abrd--nx?ivjg--nx??oryso--nx??y-y&dnas--nx?mrak--nx?n&art--nx?nif--nx??reva--nx??z-smort--nx??v!.sg?ledatskork?reiks??wh-antouvn--nx?x&9-dlofts--nx.aoq-relv--nx?d-nmaherk--nx?f-dnalnks--nx?h-neltloh--nx?i-drgeppo--nx?j-gve&gnal--nx?lreb--nx??m-negnilr--nx?n-drojfvk--nx??y&7-ujdaehal--nx?8-antouvig--nx?b-&dlofrs--nx?goksmr--nx?kivryr--nx?retslj--nx??e-nejsom--nx?f-y&krajb--nx?re&dni--nx?tso--nx??stivk--nx??g-regark--nx?orf?ørf??z9-drojfstb--nx??b&25-akiivagael--nx?53ay7-olousech--nx?a&iy-gv--nx?le-tl&b--nx?s--nx??n0-ydr--nx??c&0-dnal-erdns--nx?z-netot-erts--nx??g&g-regnarav-rs--nx?o-nejssendnas--nx??ju-erdils-ertsy--nx?nj-dnalh-goksrua--nx?q&q-ladsmor-go-erm--nx.&ari-yreh--nx?ednas??s-neslahsladrjts--nx???ca&4s-atsaefrmmh--nx?8m-dnusynnrb--nx?il-tl--nx?le-slg--nx?n5-rdib--nx?op-drgl--nx?uw-ynnrb--nx??d&a&qx-tggrv--nx?reh!nnivk?sd&ork?ørk??uas??ts&e&bi?kkar?llyh?nnan??g&ort?ørt??k&alf?irderf??levev?mirg?obeg&ah?æh??r&ah?ejg????barm-jdddb--nx?ie!rah?s&etivk?ladman???lof&r&os?øs??ts&ev.ednas?o.relav?ø.relåv???n&a&l&-erd&n&os?øs??ron??adroh.so?dron.&a&g5-b--nx?ri-yreh--nx??ob?y&oreh?øreh??øb??e&m!lejh??pr&oj?øj??vi??gyb?n&aks?åks??o&h-goksrua?rf??r&o?ua?ø??tros?øh-goksrua??rts!e&devt?lab?mloh???s&ellil?naitsirk?rof???u&l!os??s!d&im?lejt??e&guah?l&a?å???kkoh?lavk?naitsirk?r&af?eg&e?ie???tef?y&onnorb?ønnørb?????r&a&blavs!.sg??g&eppo?la???o&j&f&a!dniv?k?vk??die?e&dnas?kkelf??llins?r&iel?ots??s&lab?t&ab?åb??yt??å!k??ævk??les??ts??åg&eppo?lå???ureksub.sen??e&ayb-yrettn--nx?d&ar?isemmejh321,lom?r&of?øf??år??g&gyr?nats??i&meuv&ejsem&aan?åån??sekaal??rjea??j&d&ef?oks??les??k&er&aom?åom??hgna&ark?årk??iregnir?kot!s??s&ig?uaf???l&bmab?kyb?l&av?ehtats??oh??m&it?ojt?øjt??n&arg?g&os?øs??meh?reil?te?ummok?yrb??r&dils-erts&ev?y&o?ø???ua?vod??sa&ans?åns??t&robraa?spaav??urg??f&62ats-ugsrop--nx?a&10-ujvrekkhr--nx?7k-tajjrv-attm--nx??o!.sg?h??s!.sg??v!.sg???g&5aly-yr&n--nx?v--nx??a&llor?ve&gnal?lreb???n&av!snellu??org??oks&die?m&or?ør??ner&ol?øl??r&o?ø???r&eb!adnar?edyps?s&die?elf?gnok?n&ot?øt????obspras??uahatsla?åve&gnal?lreb???h&0alu-ysm--nx?7&4ay8-akiivagg--nx?5ay7-atkoulok--nx??a!.sg???i&e&hsr&agev?ågev??rf??k&h&avlaraeb?ávlaraeb??s??lm&a?å??mpouvtal&am?ám??pph&al?ál??rrounaddleid?ssaneve?ššáneve??j&0aoq-ysgv--nx?94bawh-akhojrk--nx??k&a&b&ord?ørd??jks?lleis??iv!aklejps?l&am?evs?u??mag?nel?ojg?r&a&l?n??epok?iel?y&or?ør???s&ah?kel?om??øjg??kabene?ojsarak?ram&deh.&aoq-relv--nx?rel&av?åv??so??e&let.&ag5-b--nx?ob?øb??ra???åjks??l&a!d&anrus?d&numurb?ron??e&gnard?nte?s&meh?sin??ttin??g&is?nyl??kro?l&em?l&ejfttah?of??u&ag-ertdim?s???n&am?era?gos?i&b?nroh?r??kos?nus?oj??o-&dron?r&os?øs???ppo?r&a!l?nram??e&gne?l?v??is?o&jts?ts??u&a-&dron?r&os?øs???h??å?æl?øjts??s&e&jg?nivk?ryf??kav?mor-go-er&om.&ednas?yoreh??øm.&ednas?yøreh???uag??t&las?rajh?suan??v&l&a?e-rots??u-go-eron??yt??ksedlig?res&a?å???bib&eklof?seklyf??es!dah??h!.sg??i&m?syrt??l&ejf?ov&etsua?gnit?ksa?sdie???n!.sg??o!.sg?boh?g?h??r!.sg??å!ksedlig??øboh??m&a&rah?vk??f!.sg??h!.sg??i&e&h&dnort?rtsua?ssej??rkrejb??ksa??ol?t!.sg??u&dom?esum?r&ab?drejg?evle?os?uh?æb?øs??ttals???n&a&g&av?okssman?åv??jlis?or?r&g?rev???e&d&do&sen?ton??lah?r&agy&o?ø??ojfsam???g&iets?n&a&l&as?lab??n&avk?ævk??t&arg?ddosen??v&al?essov???i&d&ol?øl??l&ar?ær???yl??reb??iks?k&srot?y&or?ør???l&a&d&gnos?n&er?ojm?øjm??om??tloh??ug?åtloh??mmard?ojs&om?sendnas??ppolg?s&lahsladr&ojts?øjts??o??t&o&l?t-erts&ev?o?ø???roh?øl??vly&kkys?nav??yam-naj!.sg??øjs&om?sendnas???g&orf?ujb??i&dnaort?vnarg??kob?ladendua?maherk&a?å??n&it?urgsrop??orf-&dron?r&os?øs???r&aieb?evats??sfev?uaks?yrts??o&6axi-ygvtsev--nx?c,d&ob?rav??ievs?kssouf?l&m&ob?øb??ous&adna?ech&ac?áč???so!.sg???msdeks?niekotuak?r&egark?olf?y&oso?øso???s&dav?mort???p&ed?ohsdaerpsym,p&akdron?elk???r&a&d&dj&ab?áb??iab??jtif?luag?mah?vsyt??e&gn&a&k&iel?ro??merb?n&at?mas??rav-r&os?øs??srop?talf?v&ats?el??y&oh?øh???ivsgnok??il?jkniets?k&a&nvej?rem?s&gnir?nellu???ie-er&den?v&o?ø???ram?sa?årem??la&jf?vh??m&b&ah?áh??mahellil??nnul?ts&l&oj?øj??ul??y&o?ø???imp&ah?áh??m!.sg??osir?t!.sg??ádiáb?ævsyt?øsir??s&adnil?en&dnas?e&dga?k&ri&b?k??som??ve??me&h?jg??nroh-go-ejve?s&a?ednil?k&o?ø??of?yt?å??tsev??gv?hf?igaval?o&r&or?ør??sman??so&fen&oh?øh??m?v??uh&lem?sreka.sen??å!dnil???t&a&baol?g&aov?grav??jjr&av-attam?áv-attám??l&a&b?s??ás??soum?ts?v&eib?our???e&dnaly&oh?øh??f?s&nyt?rokomsdeks?sen??vtpiks??in&aks?áks??loh&ar?år??n!.sg??o&m&a?å??psgolb,?s!.sg?efremmah?or?ør??terdi?á&baol?ggráv?lá&b?s??soum?veib???u&b!.sg?alk?e&dna?gnir?nner??les?ælk??dra&b?eb??g&nasrop?vi?ŋásrop??j&daehal&a?á??jedub?v&arekkhar?árekkhár???ksiouf?n&diaegadvoug?taed???v&irp?lesl&am?åm???y&b&essen?nart?sebel?tsev??o&d&ar?na!s??or??gavtsev?k&rajb?sa??lem?mrak?n&art?n&if?orb???r&a&mah?n?v??e&dni?t&so?ton??va??ul?yd??s&am?enner?gav?lrak?tivk??vrejks??ø&d&ar?na!s??ør??gåvtsev?k&rajb?sa??lem?mrak?n&art?n&if?ørb???r&e&dni?t&so?tøn??va??ul?yd?æ&n?v???s&enner?gåv?tivk?åm??vrejks???á&slág?tlá?vreiks??å&gåv?h?jddådåb?lf??ø&d&ob?rav??r&egark?olf??s&dav?mort????aki?i&sac?tal??u??o&b?f?g?hay?o?ttat??r!.&cer?erots?gro?m&o&c?n??rif?t??o&c,fni??pohs,stra?t&n?opsgolb,?www?ysrab,?e&a!.&a&ac?cgd?idem??bulc!orea??ci&ffartria?taborea??e&cn&a&l&lievrus-ria?ubma??netniam?rusni??erefnoc??gnahcxe?mordorea?ni&gne?lria?zagam??rawtfos??gni&d&art?ilg!arap?gnah???l&dnahdnuorg?ledom??noollab?retac?sael?t&lusnoc?uhcarap??vidyks??hcraeser?l&anruoj?euf?icnuoc?ortnoc!-ciffart-ria???n&gised?oi&nu?t&a&cifitrec?ercer?gi&tsevni-tnedicca?van??i&cossa!-regnessap??valivic??redef??cudorp?neverp-tnedicca????ograc?p&ihsnoipmahc?uorg!gnikrow???r&e&dart?enigne?korb?niart?trahc??o&htua?tacude???s&citsigol?e&civres?r??krow?serp!xe??tnega??t&farcr&ia?otor??hgil&f?orcim??liubemoh?n&atlusnoc?e&duts?m&esuma?n&iatretne?revog??piuqe????olip?ropria?si&lanruoj?tneics???w&erc?ohs??y&cnegreme?dobper?tefas????rref?z??p!.&a&aa?ca?pc??dem?ecartsnd.icb,gne?r&ab?uj??snduolc,t&acova?cca?hcer??wal?ysrab,???s!.&em?gro?hcs,moc?ten?ude?vog???t!.&0x,116,ayo,gro?lim?moc?nayn,sulpnpv,t&cennockciuq.tcerid,en??ude?v&dr,og???o&hp?m?v?yk??tol?ua??v&iv?lov??xas?ykot??p&a&ehc?g?m?s??eej?g!.&gro?ibom?moc?ossa?ppa,ten?ude???i&r!.nalc,?v?z??j!.&0o0o,a&3&5xq6f--nx?xqi0ostn--nx??5wtb6--nx?85uwuu--nx?9xtlk--nx?ad,b&ats,ihc!.&a&bihciakoy?don?ma&him?ye&ragan?tat???r&a&bom?gan?hihci??u&agedos?kas?ustak???s&os?ufomihs??t&amihcay?iran??w&a&g&im&anah?o??omak??kihci?zustum??ihsak??y&agamak?imonihci???e&akas?nagot??i&azni?esohc?h&asa?s&abanuf?ohc???ka&to?zok??musi?orihs?r&akihabihsokoy?o&dim?tak??ukujuk??usihs??nano&hc?yk??o&d&iakustoy?ustam??hsonhot?k&a&rihs?t??iba??nihsaran?sobimanim?tas&arihsimao?imot??uhc?yihcay??u&kujno?s&ayaru?t&imik?tuf???zarasik?????c&cah,ed,?g&as!.&a&gas?m&a&tamah?yik??ihsak??rat?t&a&gatik?hatik??ira!ihsin????e&kaira?nimimak??i&akneg?g&aruyk?o??h&c&amo?uo??siorihs??kaznak?modukuf?ra&gonihsoy?mi???nezih?u&k&at?ohuok??s&ot?tarak?????ihs!.&a&kok?m&a&hagan?yirom??ihsakat??rabiam?wagoton??e&miharot?nokih??houyr?i&azaihsin?esok?kustakat?moihsagih??na&mihcahimo?nok??o&hsia?mag?t&asoyot?ok?tir???us&ay?t&asuk?o??????k&aso!.&a&d&awihsik?eki??k&a&noyot?s&akaayahihc?oihsagih???oadat?uziak??m&ayas!akaso??odak??r&a&bustam?wihsak??ediijuf??t&akarih?i&k?us???wag&ayen?odoyihsagih???e&son?tawanojihs??honim?i&akas?h&cugirom?s&ayabadnot?i&a&kat?t??n??oyimusihsagih???k&a&rabi?sim??ustakat??muzi?r&ijat?otamuk???nan&ak?n&ah?es???o&ay?n&a&ganihcawak?simuzi?tak??eba?ikibah?oyot??t&anim?iad?omamihs??uhc??ust&oimuzi?tes????ou&kuf!.&a&d&amay?eos??g&no?ok?usak??hiku?k&awayim?uzii??ma&kan?y&asih?im???rawak?t&a&gon?ka&h?num?t???umo??wa&g&a&kan?nay?t??ias??ko!rih???y&ihsa?usak???e&m&ay?uruk??taruk?us??i&a&nohs?raihcat??goruk?h&cukuf?s&a&gih?hukuy??in???k&a&gako?muzim??iust?o?ustani??m&anim?otihsoynihs?u??r&ogo?ugasas??usu??ne&siek?zu&b?kihc???o&gukihc?h&ak?ot?ukihc??j&ono?ukihc??kayim?nihsukihc?to?uhc??u&fiazad?gnihs?stoyot????zihs!.&a&bmetog?d&amihs?eijuf?ihsoy?omihs??kouzihs?mihsim?ra&biah?honikam??tawi?wa&g&ekak?ukik??kijuf??yimonijuf??i&a&ra?sok??hcamirom?juf?kaz&eamo?ustam??ma&nnak?ta??nukonuzi?orukuf??nohenawak?o&nosus?ti??u&stamamah?z&a&mun?wak??i!ay?i&hs&agih?in??manim??mihs????????m&a&tias!.&a&d&ihsoy?ot?usah??k&a&dih?sa??o&arihs?s???m&a&tias?y&as?o&rom?tah??ustamihsagih???i&hsagurust?jawak??uri??ni?wa&g&e&ko?man??ikot?o??k&ara?i&hsoy?mak???ru?zorokot??y&a&g&amuk?ihsok?otah??kuf??imo??ziin??e&bakusak?ogawak?sogo?ttas?zokoy??i&baraw?h&cugawak?s&oyim?ubustam???iroy?k&ato?ihs?u&k?stawi???m&akoyr?i&hsoy?juf??uziimak???naznar?o&dakas?ihsay?jnoh?n&a&go?nim??imijuf?nah?oy??r&ihsayim?otagan??t&asim!ak??igus?omatik??zak??u&bihcihc!ihsagih??sonuok?ynah????y&ak&aw!.&a&d&ira?notimak??kadih?ma&h&arihs?im??y&a&kaw?tik??oduk???ru&ustakihcan?y??sauy?wa&g&a&dira?zok??orih??konik??yok?zok??e&banat?dawi??i&garustak?jiat?mani??naniak?o&bog?nimik?t&asim?omihs&ah?uk????ugnihs???o!.&a&jos?koasak?m&ay&ako?ust??ih",
+ "sayah??r&abi?ukawaihsin??wi&aka?nam???e&gakay?kaw??i&gan?h&cu&kasa?otes??sahakat??k&asim?ihsaruk??miin??n&anemuk?ezib??o&hsotas?jnihs?n&amat?imagak??ohs?uhcibik?????ot!.&a&damay?got?koakat?may&etat?ot??nahoj?riat?waki&inakan?reman???eb&ayo?oruk??i&h&asa?ciimak?sahanuf??kuzanu?m&an&i?ot??ih???nezuyn?otnan?u&hcuf?stimukuf?z&imi?ou???????ihs&o&gak!.&a&m&ayuok?ihsogak??si?yonak??e&banawak?n&at&akan?imanim??uka??tomoonihsin??i&adnesamustas?k&azarukam?oih??m&ama?uzi??usuy??nesi?o&knik?os?tomustam??uzimurat???rih!.&a&ka&n?s??m&ayukuf?i&hsorihihsagih?j&ate?imakikaso????r&a&bohs?h&ekat?im???es??tiak?wiad??e&kato?ruk??i&h&ci&akustah?mono?nihs??s&inares?oyim???manimasa?uk??negokikesnij?o&gnoh?namuk??uhcuf????uk&ot!.&a&bihci?mi&hsu&kot?stamok??m??wagakan??egihsustam?i&gum?h&coganas?soyim??kijaw?m&anim?uzia??ukihsihs??nan&a?iak??o&nati?turan????uf!.&a&batuf?m&a&to?y&enak?irok???ihs&im?ukuf??os?uko??r&aboihsatik?uganat??ta&katik?mawak?rih??w&a&g&akus?emas?uy??k&a&mat?rihs?sa??ihsi??nah??ohs???e&gnabuzia?iman?ta&d?tii???i&adnab?enet?hs&agih?iimagak??k&a&wi?zimuzi??ubay??minuk?r&ook?ustamay???nihsiat?o&g&etomo?ihsin?nan?omihs??no!duruf?rih??rihsawani?ta&may?simuzia???u&rahim?stamakawuzia?zia&ihsin?nay???????nug!.&a&bawak?doyihc?k&anna?oi&hsoy?juf?mot???m&ayakat?ustagaihsagih??n&ihsatak?nak??r&ahonagan?nak?o?u&kati?mamat???t&amun?inomihs?o??w&akubihs?iem?ohs???i&hsa&beam?yabetat??kas&akat?esi??m&akanim?uzio??ogamust?rodim??o&jonakan?n&eu?oyikust??tnihs??u&komnan?stasuk?yrik????rep,?n&ibmab,nog,ob,?ppacihc,ra&n!.&a&bihsak?d&akatotamay?u!o???guraki?m&ay&atik&imak?omihs??irokotamay??oki??ra&hihsak?n??wa&geson?knet???e&kayim?ozamay?sog?ustim??i&a&rukas?wak??garustak?h&ciomihs?sinawak??jo?ka&mnak?toruk??makawak?nos?r&net?otakat?ugeh???o&d&na?oyo??gnas?jnihs?nihsoy!ihsagih??tomarawat?yrok????rikik,?t&ag&amay!.&a&dihsio?k&atarihs?ourust??may&a&kan?rum??enak?onimak??rukho?ta&ga&may?nuf??hakat?kas??wa&g&ekas?orumam??ki&hsin?m??z&anabo?enoy?ot???zuy??e&agas?bonamay?dii?nihsagih?o??i&a&gan?nohs??h&asa?sinawak??nugo??o&dnet?jnihs?ynan??ukohak???iin!.&a&ga?k&ium?oagan??munou!imanim??t&a&bihs?giin??ioy??w&a&gioti?kikes?zuy??irak??yijo??e&kustim?mabust??i&aniat?hcamakot?kaz&awihsak?omuzi??m&a&gat?karum??o???n&anust?esog??o&das?ihcot?jnas?k&ihay?oym??mak?naga?ries??u&ories?steoj?????i&k&a!.&a&go?k&asok?oimak??t&ago!rihcah??ika!atik???w&aki?oyk???e&mojog?natim?suranihsagih?t&ado?okoy???i&hsoyirom?magatak?naokimak??nesiad?o&hakin?jnoh!iruy??nuzak?rihson?tasi&juf?m??yjnoh??u&kobmes?oppah????in,?o!.&a&dakatognub?m&asah?ihsemih??su?t&ekat?i&h?o????e&onokok?ustimak??i&jih?k&asinuk?ias?usu??mukust??onoognub?u&fuy?juk?ppeb?suk?????nayn,?wa&ga&k!.&a&mihsoan?rihotok?waga&kihsagih?ya???emaguram?i&j&nonak?ustnez??kunas?monihcu??o&hsonot?nnam?yotim??u&st&amakat?odat??zatu????nak!.&a&dustam?kus&okoy?tarih??maz?nibe?r&a&gihsaimanim?h&esi?imagas??wa&do?guy???u&im?kamak???tikamay?wa&k&ia?oyik?umas??sijuf??yimonin??e&nokah?saya??i&akan?esiak?gusta?hsuz?kasagihc?o?ukust??o&nadah?sio?tamay?????kihsi!.&a&danihcu?gak?kihs?mijaw?t&abust?ikawak??wazanak??i&gurust?hcionon?mon?ukah??nasukah?o&anan?ton!akan???u&kohak?stamok?z&imana?us?????niko!.&a&han?m&arat?ijemuk?uru??n&e&dak?zi??no??ra&hihsin?rih??wa&kihsi?niko??yehi?zonig??e&osaru?seay??i&hsagih?jomihs?k&a&gihsi?not??ihsakot??m&a&ginuk?kihsug?maz??igo?otekat??nuga!noy???n&a&moti?timoy?wonig??i&jikan?k???o&gan?jnan?tiad&atik?imanim???u&botom?kusug&akan!atik??imot??rab&anoy?eah??????yp,zomim,?bus,c&204ugv--nx?462a0t7--nx?678z7vq5d--nx?94ptr5--nx?a?mpopilol,?d&-2,17sql1--nx?3thr--nx?5&20xbz--nx?40sj5--nx??7&87tlk--nx?ptlk--nx??861ti4--nx?a?e!tfarcdnah,?n&eirf&lrig,yob,?om,?ooftac,?e&16thr--nx?5&1a4m2--nx?9ny7k--nx??damydaer,eweep,garotsarukas.&10ksi.3s,20ksi.3s,?i&bmoz,m!.&a&bot?k&asustam?uzus??m&a&him?y&emak?im???ihs??nawuk?wi&em?k???e&bani?ogawak?si!imanim???i&arataw?gusim?h&asa?ciakkoy??k&a&mat?sosik?t??iat??raban??o&dat?hik?n&amuk?ihseru?o&du?mok????ust????kilbew,lasrepus,mihe!.&a&m&a&h&ataway?iin??yustam??ij&awu?imak???taki!man???ebot?i&anoh?kasam?rabami??n&ania?egokamuk?oot??o&jias?kihcu?nustam?uhcukokihs?yi!es???u&kohik?zo????n!.&arukas,lapo,n&erukom,riheg,?omomus,stnim,teniesa.resu,xob-liam,yrovi,zapot,?amihs!.&a&d&amah?ho?usam??kustay?m&a?ihsoni&hsin?ko???wakih??e&namihs?ustam??i&g&aka?usay??konikak?mikih??nannu?o&mu&kay?zi!ihsagih?uko???nawust?tasim??u&stog?yamat????nep,?rotsnoihsaf,srev,t&awi!.&a&bahay?d&amay?on??koirom?t&a&honat?katnezukir??imus??w&as&ijuf?uzim??ihs???e&hon&i&hci?n??uk??tawi??i&a&duf?murak?wak??h&custo?si&amak?ukuzihs???j&oboj?uk??k&a&m&anah?uzuk??sagenak??esonihci??m&akatik?uzia&rih?wi????o&kayim?no&rih?t??tanufo??uhso???isarap,saman,tococ,?ulbybab,?g&3zsiu--nx?71qstn--nx?l?olblooc,?h&03pv23--nx?13ynr--nx?22tsiu--nx?61qqle--nx?o-hu,sulb,?i&54urkm--nx?azosbew,ced,g&ayim!.&a&dukak?m&a&goihs?kihs??ihsustam!ihsagih??unawi??r&awago?iho??ta&bihs?rum??w&a&gano?kuruf??iat??y&imot?ukaw???e&mot?nimes??i&hsiorihs?ka&monihsi?s&awak?o???mak?r&ataw?o&muram?tan????o&az?jagat?t&asim?omamay???u&fir?k&irnasimanim?uhsakihcihs?????ihcot!.&a&g&a&h?kihsa??ust??kom?m&ay&o?usarak??unak??r&a&boihsusan?watho??iho?ukas??t&akihsin?iay??wa&konimak?zenakat??y&imonustu?oihs???e&iiju?kustomihs?nufawi??i&akihci?g&etom?ihcot?on???o&k&ihsam?kin??nas?sioruk?tab??u&bim?san?????h&c&ia!.&a&dnah?m&a!h&akat?im??yuni??ihs&ibot?ust???r&a&hat?tihs??ik?u&ihsagih?kawi???t&ihc?o&k?yot???wa&koyot?zani??yi&monihci?rak???e&inak?k&aoyot?usa??manokot?noyot??i&a&gusak?kot?sia??eot?h&asairawo?cugo?s&ahoyot?oyim???k&a&mok?zako??ihssi??motay?rogamag??n&an&ikeh?ok??ihssin??o&got?ihsin?jna?rihsnihs?suf?tes??u&bo?raho?s&oyik?takihs??yrihc?zah????ok!.&a&dusay?kadih?mayotom?r&ah&im?usuy??umakan??sot!ihsin??wa&g&atik?odoyin??k&as?o????i&esieg?hco!k??jamu?k&a!sus??usto??ma&gak?k??rahan??o&mukus?n&i?ust!ihsagih???torum?yot!o???u&koknan?zimihsasot????ugamay!.&a&m&ayukot?ihso??toyot??e&bu?subat??i&gah?kesonomihs?nukawi?rakih??nanuhs?otagan?u&ba?foh?otim?stamaduk?uy?????s&anamay!.&a&dihsoyijuf?mayabat?r&ahoneu?ustakihsin??w&a&k&ayah?ijuf??suran??ohs???egusok?i&ak?h&cimakan?s&anamay?od???k&asarin?u&feuf?sto????o&k&akanamay?ihcugawakijuf??nihso?t&asimawakihci?ukoh??uhc??spla-imanim?u&b&nan?onim??fok?hsok?rust????ubon,??ix,ka&rabi!.&a&bukust?gok?kan!ihcatih??m&a&sak?timo?wi??ihsak?ustomihs??ni?r&a&hihcu?way??u&agimusak?ihcust???t&ag&amay?eman??oihcatih??w&ag&arukas?o??os??yi&moihcatih?rom???e&bomot?dirot?not?tadomihs??i&a&k&as?ot??rao??esukihc?gahakat?h&asa?catih??k&a&rabi?saguyr??ihsani?uy??ma?rukustamat??o&dnab?giad?him?kati?rihsijuf?soj?t&asorihs?im??yihcay??u&fius?kihsu?simak????sagan!.&a&m&abo?ihsust??natawak?r&abamihs?u&mo?ustam???wijihc?yahasi??i&akias?hies?k&asagan?i??masah??neznu?o&besas?darih?t&eso?og!imaknihs????ust&igot?onihcuk?uf????zayim!.&a&biihs?guyh?k&oebon?ustorom??mihsuk?r&emihsin?uatik??ta&katik?mim??wag&atik?odak??ya??e&banakat?sakog??i&hsayabok?kaza&kat?yim??m&animawak?ot&inuk?nihs????nanihcin?o&j&ik?onokayim??n&ibe?ust??tias??urahakat????ro&cep,moa!.&a&dawot?turust?wasim??e&hon&ihc&ah?ihs??nas?og?ukor??sario??i&anarih?ganayati?hsioruk?jehon?kasorih?makihsah?nawo?r&amodakan?omoa???o&gnihs?kkat??u&ragust?stum????ttot!.&a&r&ahawak?uotok??sa&kaw?sim???egok?irottot?nanihcin?o&ganoy?nih?tanimiakas??u&bnan?z&ay?ihc??????ukuf!.&a&deki?gurust?ma&bo?h&akat?im??yustak??sakaw??eabas?i&akas?ho?jiehie?ukuf??nezihce!imanim??ono????k&26rtl8--nx?4&3qtr5--nx?ytjd--nx??522tin--nx?797ti4--nx?ci&gid,ht,sevol,?ee,limybab,n&at,upatilol,??l&33ussp--nx?e&ccabew.&resu,sr,?llarap,?lik,oof,rigetuc,?m&11tqqq--nx?41s3c--nx?ef,sioge,?n&30sql1--nx?65zqhe--nx?a&ebyllej,i&lognom,viv,??iam,n7p7qrt0--nx?o&o&las,mflah,?ruk,staw,??o&131rot--nx?7qrbk--nx?aic,c?d&iakkoh!.&a&deki?gakihset?hcebihs?k&adih?u&fib?narihs???m&ayiruk?hot?ihs&orihatik?ukuf??oras?usta??r&ib&a!ka??o?uruf??ozo?u&gakihsagih?oyot???sakim?ta&gikust?mun??w&a&ga&k&an?uf??nus!imak???k&aru?i&h&asa?sagih??kat?mak??omihs?um??zimawi??ine?oyk??yot??e&a&mustam?nan??b&a&kihs?yak??o&noroh?to???ian?k&ihsam?ufoto??nakami?ppoko!ihsin??sotihc?tad!okah??uonikat??i&a&bib?mokamot?n&a&k&kaw?oroh??wi??eomak?ihsatu?okik?usta&moruk?sakan????eib?h&c&ioy?u&bmek?irihs???s&ase?ekka?oknar?uesom???jufirihsir?k&amamihs?i&at?n???m&atik?otoyot??oa&kihs?rihs??r&a&hs?kihsi?mot??ihs&aba?ir??otarib???n&a&hctuk?rorum?se?tokahs??uber??o&kayot?m&ire?ukay??naruf!ima&k?nim???orih?r&ih&ibo?suk??o&bah?h&i&b?hsimak??sa??pnan?yan??umen??t&asoyik?eko?ukoh???u&bassa?kotnihs?m&assaw?uo??pp&akiin?en&ioto?nuk??ip??rato?s&akat?t&eb&e?i&a?hs!a??robon??m&e?o&m?takan???no&h?tamah??o&mik?s?t??u&kir?ppihc?st???onihsnihs?ufuras??uaru??yru!koh??zimihs!ok?????nu,?g!iti,oyh!.&a&bmat?dnas?gusak?k&at?o&oyot?y??uzarakat??m&ayasas?irah??wa&g&ani?okak??k&i&hci?mak??oy???yi&hsa?monihsin???i&asak?hs&aka?i&at?nawak???j&awa!imanim??emih??k&a&goa?s&agama?ukuf??wihsin??i&hsog?m???mati?oia?rogimak??n&annas?esnonihs??o&gasa!kat??ka?n&ikat?o?ustat??rihsay?sihs?tomus?yas??u&bay?gnihs?????hih,konip,l&bs,ik,?mol,nagan!.&a&bukah?d&a&w?yim??e&ki?u??ii??k&a&s&ay?uki??zus??ihsoo?ousay??m&ay&akat?ii??i&hsukufosik?jii??ukihc??n&i!hsetat??uzii??r&ah?ugot??saim?t&agamay?oyim??w&a&g&a&kan?n??o??kustam?ziurak??onim!imanim??u&koo?s!omihs????ya&ko?rih???e&akas?nagamok?subo??i&gakat?h&asa?c&a!mo!nanihs???uonamay??sukagot??k&a&kas?mimanim?to??ia&atik?imanim??oa?uzihcom??m&akawak?ijuf?o!t???r&ato?ijoihs?omakat???n&ana?esnoawazon??o&hukas?n&a&gan?kan??i&hc?muza??ustat??romok?si&gan?k??tomustam??u&k&as?ohukihc??stamega????o&b,m,pac,?to&mamuk!.&a&gamay?rahihsin?sukama!imak??tamanim??enufim?i&hcukik?k&ihsam?u??nugo!imanim??romakat??o&ara?rihsustay?sa?t&amay?om&amuk?us??u!koyg???yohc??u&sagan?zo????yk!.&a&bmatoyk?k&ies?oemak?uzaw??mayi&h&cukuf?sagih??muk??nihsamay?rawatiju?t&away?ik???e&ba&nat!oyk??ya??di?ni??i&ju?kazamayo?manim??natnan?o&gnatoyk?kum?mak?rihsamayimanim?y&gakan?ka&koagan?s??oj???u&ruziam?z&ayim?ik??????wtc1--nx?ykot!.&a&d&i&hcam?mus??oyihc??k&atim?ihsustak??m&a&t!uko??yarumihsa&gih?sum???i&hs&agoa?ika?o!t??uzuok??ren???r&a&honih?wasago??iadok?umah??ssuf?t&ik?o??wa&g&anihs?ode??k&ara",
+ "?ihcat???y&agates?ubihs???e&amok?donih?m&o?urukihsagih??soyik??i&enagok?gani?h&ca&da?tinuk??sabati??j&nubukok?oihcah??manigus??o&huzim?jihcah?n&akan?ih!sasum??urika??rugem?t&a&mayihsagih?nim??iat?ok??uhc?yknub??u&fohc?hcuf?kujnihs?????p&a&ehc,rc,?o&hs&eht,iiawak,yub,?lf,p&evol,ydnac,?rd&kcab,niar,???r&2xro6--nx?atselttil,e&d&nu,wohc,?h,ilf,pp&ep,irts,u,?t&aerg,tib,??g!r,?ks,o!on,?ufekaf,?s&9nvfe--nx?dom,p&ihc,oo,?remagten,sikhcnerf,u&bloohcs,ruci,srev,?xvp4--nx??t&a&cyssup,obgip,?e&rces,vlev,?hginyad,netnocresu,opsgolb,sidas,u&b,ollihc,??u&4rvp8--nx?fig!.&a&d&eki?ih??kimot?m&ayakat?ihsah??ne?raha&gi&kes?makak??sak??taga&may?tik??wa&g&ibi?ustakan??karihs!ihsagih????e&katim?uawak??i&gohakas?hc&apna?uonaw??k&ago?es?ot??m&anuzim?ijat??nak?urat??nanig?o&dog?jug?makonim?nim?roy?sihcih??u&fig?s&otom?t&amasak?oay??????hc,pup,stoknot,ynup,?wonsetihw,x&5ytlk--nx?irtam,?y&adynnus,dr,knarc,l&oh,rig,?moolg,ob,pp&ih,olf,?rgn&a,uh,?u6d27srjd--nx?vaeh,?z&72thr--nx?e&ej,lur,??井福?京東?分大?取鳥?口山?城&宮?茨??媛愛?山&富?岡?歌和??岡&福?静??島&児鹿?広?徳?福??崎&宮?長??川&奈神?石?香??庫兵?形山?手岩?木栃?本熊?根島?梨山?森青?潟新?玉埼?田秋?知&愛?高??縄沖?良奈?葉千?賀&佐?滋??道海北?都京?重三?野長?阜岐?阪大?馬群???k!.&art?gro?moc?per?ude?vog???l&eh?l??m!.uj,ac?j??nd?o&g?h&pih?s!.&esab,xilpoh,ysrab,???lnud?oc?t!.&lldtn,snd-won,???pa!.&0mroftalp,a&rusah,ted,?bew:erif,,e&erf-korgn,gatskrelc,kalfwons:.kniletavirp,,niln&igol,okoob,?tupmocegde,virdhsalfno,?ilressem,k&orgn,relc,?le&crev,napysae,?maerdepyt,n&aecolatigidno,ur:.a,,?poon,r&cne,emarf,?sserpirots,t&i&belet,lmaerts,?xenw,?yfilten,??ra&a?hs??u&ekam?llag?org!.esruocsid,cts?kouk?nayalo???vsr?xece4ibgm--nx??q&a!3a9y--nx??g?i!.&gro?lim?moc?ten?ude?vog???m?se??r&a!.&a&cisum?sanes??bog?gro?l&autum?im??moc!.topsgolb,?pooc?rut?t&e&b?n??ni??ude?vog??4d5a4prebgm--nx?b?c?eydoog?los?t&at?s!uen???ugaj??b!.&21g?a&b&a&coros?iuc??itiruc??cnogoas?dicerapa?gniram?i&naiog?ramatnas??n&erom?irdnol??op?p&acam?irolf?ma&j?s???rief?tsivaob??b!aj?ib?mi?sb??c&ba?e&r?t??js?sp?t!e???d&em?mb?n&f?i??rt??e&dnarganipmac?ficer?ht?llivnioj?rdnaotnas??f&dj?ed?gg?n&e?i???g&e&l!.&a&b,m,p,?bp,c&a,s,?e&c,p,s,?fd,gm,ip,jr,la,ma,nr,o&g,r,t,?p&a,s,?r&p,r,?s&e,m,r,?tm,??s??l&s?z??n&c?e?o??ol!b?f?v??pp?ro??hvp?i&du?kiw?nana?oretin?r&c?eurab??sp?te?xat??l&at&an?rof??el?im?sq??m&a?da?e&gatnoc?leb??f?ic?oc!.&etiselpmis,topsgolb,???nce?o&ariebir?c&e?narboir?saso??d&o?ranreboas??e&g?t??i&b?dar?ecam?r??rp?t&a?erpoir???p&er?m!e?t??ooc?pa?se??qra?r&af?ga?o&davlas?j??tn?ut??s&a&ixac?mlap?nipmac??ed?u&anam?j?m???t&am?e&d?n?v??nc?o&f?n??ra?sf??u&caug9?de?ja?rg??v&da?ed?og!.&a&b?m?p??bp?c&a?s??e&c?p?s??fd?gm?ip?jr?la?ma?nr?o&g?r?t??p&a?s??r&p?r??s&e?m?r??tm???rs?t??xiv?z&hb?ls?o&c?f?????c!.&as?ca?de?if?o&c?g??ro???e&bew?ccos?e&b?n&igne?oip??rac??gni&arg?rheob??h&sok?t&aew?orb???itnorf?k&col?o&p?rb???l&aed?ffeahcs??mal?nes?pinuj?t&a&eht?rebsnegömrev??law?nec?s&acnal?nom?ubkcolb??upmoc??v&o&csid?rdnal??resbo??wulksretlow?ywal?zifp??f!.&aterg?bew&-no,etis321,?drp?e&c&itsuj-reissiuh?narf-ne-setsitned-sneigrurihc,?lipuog,rianiretev,?hny,i&cc?rgabmahc,?m&o&c?n??t??n&eicamrahp,icedem,?ossa?pohsdaerpsym,s&e&lbatpmoc-strepxe,riaton,tsitned-sneigrurihc,uova??o&-x&bf,obeerf,?x&bf,obeerf,???t&acova,o&or-ne,psgolb,?rop:orea,,?vuog?xobided,?avc7ylqbgm--nx?s??g!.&etiselpmis,gro?moc?t&en?opsgolb,?ude?vog???h!.&e&erf,man??mo&c?rf??topsgolb,zi??ur??i!.&a&61f4a3abgm--nx?rf4a3abgm--nx??ca?di?gro?hcs?oc?ten?vog?نار&يا?یا???a&h?per??ew?lf??k!.&c&a?s??e&n?p?r??gk?iggnoeyg?kub&gn&oeyg?uhc??noej??l&im?uoes??man&gn&oeyg?uhc??noej??n&as&lu?ub??o&e&hcni?jead??wgnag???o&c?g??ro?s&e?h?m??topsgolb,u&gead?j&ej?gnawg????cilf??l!.&gro?moc?ten?ude?vog???m!.&topsgolb,vog???n!.&gro?moc?ofni?ten?ude?vog?zib???o&htua?t&c&a?od??laer???p!.&alsi?ca?eman?forp?gro?moc?o&fni?rp??t&en?se??ude?vog?zib???s?t!.&21k?bew?cn!.vog??eman?gro?kst?l&e&b?t??im?op??moc!.topsgolb,?neg?ofni?pek?rd?sbb?ten?ude?v&a?og?t??zib??f?m??ubad?vd??s&8sqif--nx?9zqif--nx?a!.vog?birappnb?gev?lliv?mtsirhc?s??b!.&ew,gro?moc?ten?ude?vog??oj?s?u??c&i&hparg?p?t&sigolyrrek?ylana???od??d&a?d?ik?l?n&iwriaf?omaid??oogemoh?rac??e!.&b&ewim321,og??gro?mo&c!.topsgolb,?n??pohsdaerpsym,ude??civres!.enilnigol,?d&d2bgm--nx?oc??h&ctaw?guh??i&lppus?rtsudni?treporp!yrrek???jaiv?l&aw?cycrotom?gnis?pats??m&ag?oh?reh??nut?ohs?picer?r&it?ut&cip!.7331,?nev???s&i&rpretne?urc??ruoc??taicossa?vig??g!nidloh??h5c822qif--nx?i!.&ekacpuc,gro?moc?t&en?ni?opsgolb,?ude?vog??a09--nx?nnet?rap?targ??k&c&or!.&ecapsbew,snddym,ytic-amil,??us??hxda08--nx?row??l!.&c&a?s??ed,gro?o&c?fni??ten?ude?vog?zib??a&ed?tner??e&ssurb?toh!yrrek???lahsram?m?oot??m!.&bal,etisinim,gro?moc?ten?ude?vog??b?etsys!.tniopthgink,?ialc??n&a&f?gorf?ol??i&a&grab?mod??giro??o&it&acav?cudorp?ulos??puoc???o&dnoc?geuj?ppaz?t&ohp!.remarf,?ua???p!.&ces?gro?moc?olp?ten?ude?vog??i&hsralohcs?lihp?t??u??r!.&au,ca?gro?ni?oc?topsgolb,ude?vog?xo,yldnerb.pohs,?a&c?p?tiug??c?e&dliub!.etisduolc,?erac?gor?levart?mraf?n&niw?trap??wolf??ot&cartnoc?omatat??pj?uot??s!.&em?gro?hcs?moc?ten?ude?vog?zib??alg?e&n&isub!.oc,?tif??rp!xe!nacirema???xnal??iws??t&a&eb?ob??ek&cit?ram??fig?h&cay?gilf??n&atnuocca?e&mt&rapa?sevni??ve!.&nibook,oc,????rap??u!.&a&c!.&21k?bil?cc???g!.&21k?bil?cc???i!.&21k?bil?cc???l!.&21k?bil?cc???m!.&21k!.&hcorap?rthc?tvp???bil?cc???p!.&21k?bil?cc???si?v!.&21k?bil?cc???w!.&21k?bil?cc????c&d!.&21k?bil?cc???n!.&21k?bil?cc???s!.&21k?bil?cc????d&e&f?lacsne.xhp,?i!.&21k?bil?cc???m!.&21k?bil?cc???n!.&bil?cc???s!.&bil?cc???u&olcrim,rd,??e&d!.&bil,cc???las-4-&dnal,ffuts,?m!.&21k?bil?cc???n!.&21k?bil?cc????h&n!.&21k?bil?cc???o!.&21k?bil?cc????i&h!.&bil?cc???m!.&21k?bil?c&c?et??goc?n&eg?otae??robra-nna?sum?tsd?wanethsaw???nd?r!.&bil?cc???v!.&21k?bil?cc???w!.&21k?bil?cc????jn!.&21k?bil?cc???k&a!.&21k?bil?cc???o!.&21k?bil?cc????l&a!.&21k?bil?cc???f!.&21k?bil?cc???i!.&21k?bil?cc????mn!.&21k?bil?cc???n&afflog,i!.&21k?bil?cc???m!.&21k?bil?cc???sn?t!.&21k?bil?cc????o&c!.&21k?bil?cc???m!.&21k?bil?cc???ttniop,?p&ion,rettalp,?r&a!.&21k?bil?cc???o!.&21k?bil?cc???p!.&21k?bil?cc????s&a!.&21k?bil?cc???dik?k!.&21k?bil?cc???m!.&21k?bil?cc???nd&deerf,uolc,??t&c!.&21k?bil?cc???m!.&21k?bil?cc???u!.&21k?bil?cc???v!.&21k?bil?cc????ug!.&21k?bil?cc???v&n!.&21k?bil?cc???w!.cc???x&ohparg,t!.&21k?bil?cc????y&b-si,k!.&21k?bil?cc???n!.&21k?bil?cc???w!.&21k?bil?cc????za!.&21k?bil?cc????ah!uab??bria?col?e!.ytrap.resu,?ineserf?lp?xe&l?n???vt?w!.&66duolc,gro?moc?s&ndnyd,tepym,?ten?ude?vog??a!.rekamegas.&1-&ht&ron-ue.&koobeton,oiduts,?uos-&em.&koobeton,oiduts,?fa.&koobeton,oiduts,?pa.&koobeton,oiduts,?ue.&koobeton,oiduts,???lartnec-&ac.&koobeton,oiduts,?em.&koobeton,oiduts,?li.&koobeton,oiduts,?ue.&koobeton,oiduts,??ts&ae&-&as.&koobeton,oiduts,?pa.&koobeton,oiduts,?su.&koobeton,oiduts,spif-koobeton,?vog-su.&koobeton,oiduts,spif-&koobeton,oiduts,???ht&ron-pa.&koobeton,oiduts,?uos-pa.&koobeton,oiduts,???ew-&su.&koobeton,oiduts,?ue.&koobeton,oiduts,?vog-su.&koobeton,oiduts,spif-&koobeton,oiduts,?????2-&htuos-&pa.koobeton,ue.koobeton,?lartnec-ue.koobeton,ts&ae&-su.&koobeton,oiduts,spif-koobeton,?ht&ron-pa.&koobeton,oiduts,?uos-pa.&koobeton,oiduts,???ew-&su.&koobeton,oiduts,spif-koobeton,?ue.&koobeton,oiduts,????3-ts&aeht&ron-pa.&koobeton,oiduts,?uos-pa.&koobeton,oiduts,??ew-ue.&koobeton,oiduts,??4-tsaehtuos-pa.koobeton,??e&iver?n!.elbaeciton,??odniw??y&alcrab?ot???t&0srzc--nx?a!.&amil4,ca!.hts??etiesbew321,gni&liamerutuf,tsoherutuf,?o&c!.topsgolb,?fni,?p&h21,ohsdaerpsym,?r&euefknuf.neiw,o??v&g?irp,?xi2,ytic-amil,zib,?c?e!s??hc?l!asite??mami?rcomed??b!.&gro?moc?ten?ude?vog??b?gl??c&atnoc?e&les?rid!txen????dimhcs?e!.&eman?gro?moc?ofni?ten?ude?vog?zib??b?em?grat?id?k&circ?ram??n!.&0rab,1rab,2rab,5inu,6vnyd,7&7ndc.r,erauqs,?a&l&-morf,moob,?minifed,remacytirucesym,tadsyawla,z,?b&boi,g,lyltsaf:.pam,,?c&i&nagro-gnitae,tats-oieboda,?paidemym,?d&e&calpb,ziamaka,?hiamaka,irgevissam.saap.&1-&gs,nol,rf,yn,?2-&nol,yn,??nab-eht-ni,uolc&meaeboda,nievas.c&di-etsedron,itsalej,?xednay:.e&garots,tisbew,?,??e&c&narusnihtlaehezitavirp,rofelacs.j,?gd&eiamaka,irbtib,?ht-no-eciffo,l&acs&liat.ateb,noom,?ibom-eruza,?m&ecnuob,itnuroieboda,ohtanyd,tcerider,?n&ilno-evreser,ozdop,?rehurht,s:abapus,,ti&s-repparcs,usegde,?zam&aym,kcar,??f&aeletis,crs.&cos,resu,?ehc-a-si,?g&ni&gats-&d&eziamaka,hiamaka,?e&gdeiamaka,tiusegde,?iamaka,nigiroiamaka,yekegde,?reesnes,sirkcilc,tsohnnylf,?olbevres,?iamaka,k&catsvano,eeg-a&-si,si,?u,?l&acolottad,iamwt,meteh,s&d-ni,s-77ndc,??m&ac&asac,ih,?urofniem,?n&a&f&agp,lhn,?i&bed,llerk,??dcduabkcalb,i:giroiamaka,,pv-ni,?o&c-morf,duppa,jodsnd,rp-ytinummoc,ttadym,?p&i&-&etsef,on,?emoh,fles,nwo,?j,mac-dnab-ta,o&-oidar-mah,h&bew,sdaerpsym,??pa&duolc,egde,?tfe&moh,vres,?usnd,?r&e&tsulcyduolc,vres-xnk,?vdslennahc:.u,,?s&a&ila&nyd,snd,?nymsd,?bbevres,dylimaf,e&gde-ndc,rauqs,suohsyub,t&isbeweruza,ys,??k&catstsaf,ekokohcs,?n&d&-won,aka,d,golb,npv,?oitcnufduolc,?ppacitatseruza:.&1,2:suts&ae,ew,?,3,4,5,6,7,aisatsae,eporuetsew,sulartnec,?,s&a-skcik,ecca&-citats,duolc,??t,?t&adies,ce&ffeym,jorprot:.segap,,lespohs,?e&nretnifodne,smem,?farcenimevres,i-&ekorb,s&eod,lles,teg,??n&essidym,orfduolc,?r0p3l3t,s&ixetnod,oh&-spv:.citsalej.&cir,lta,sjn,?,gnik,???u&h,nyd,r:eakust.citsalej,,?ved-naissalta.dorp.ndc,x&inuemoh,spym,tsale.&1ots-slj,2ots-slj,3ots-slj,?unilemoh,?y&awetag-llawerif,ekegde,ffijduolc:.&ed-1arf,su-1tsew,?,ltsaf.&dorp.&a,labolg,?lss.&a,b,labolg,?pam,slteerf,?n&-morf,ofipi,?srab,?z&a-morf,tirfym,???p?tcip?v??f&ig?osorcim??g!.&bog?dni?ed,g&olb,ro??lim?moc?ot,ten?ude???h!.&dem?gro?l&er?op??m&oc?rif??o&fni?rp?s&rep?sa???po&hs?oc??t&en?luda?ra??ude?vuog???i!.&a&2n-loritds--nx?7e-etsoaellav--nx?8&c-aneseclrof--nx?i-lrofanesec--nx??at?b?c!cul??dv?i&blo&-oipmet?oipmet??cserb?drabmol?g&gof?urep??l&gup?i&cis?me&-oigger?oigger???uig&-&aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf???aizenev&-iluirf?iluirf??ev&-iluirf?iluirf??v&-iluirf?iluirf????n&a&brev?cul?pmac?tac??idras?obrac&-saiselgi?saiselgi??resi??otsip?r&b&alac!-oigger?oigger??mu??dna&-&attelrab-inart?inart-attelrab??attelrabinart?inartattelrab?ssela??epmi?ugil??tnelav&-obiv?obiv??vap?z&e&nev?ps&-al?al???irog???l&iuqa!l??leib??m&or?rap??n!acsot?e&dom?is?sec&-",
+ "&ilrof?ìlrof??ilrof?ìlrof???g&amor&-ailime?ailime??edras?olob??i&ssem?tal??ne!var??o&cna?merc?rev?vas???oneg?p?r!a&csep?rr&ac&-assam?assam??ef??von??etam?tsailgo!-lled?lled???s!ip?sam&-ararrac?ararrac??u&caris?gar???t!a&cilisab?recam??resac?soa!-&d&-&ellav?lav??ellav?lav??ellav??d&-&ellav?lav??ellav?lav??ellav??te&lrab&-&airdna-inart?inart-airdna??airdnainart?inartairdna??ssinatlac???udap?v!o&dap?neg?tnam???zn&airb&-a&lled-e-aznom?znom??a&lledeaznom?znom??eaznom??e&c&aip?iv??soc?top??om???b&-&23,46,61,?3c-lorit-ds-onitnert--nx?be-etsoa&-ellav--nx?dellav--nx??c!f-anesec-lrof--nx?m-lrof-anesec--nx??he-etsoa-d-ellav--nx?m!u??o2-loritds-nezob--nx?sn-loritds&-nasl&ab--nx?ub--nx??nitnert--nx??v!6-lorit-dsnitnert--nx?7-loritds&-nitnert--nx?onitnert--nx???z&r-lorit-ds&-nitnert--nx?onitnert--nx??s-loritds-onitnert--nx???c&f?is?l?m?p?r?v??d&p?u!olcnys,??e&c!cel?inev?nerolf??f?g!apemoh321,ida&-&a&-onitnert?onitnert??otla!-onitnert?onitnert???a&-onitnert?onitnert??otla!-on&azlob?itnert??onitnert????hcram?l?m!or??n&idu?o&n&edrop?isorf??torc???p?r?s&erav?ilom??t!nomeip?s&eirt?oa!-&d-e&ellav?éllav??e&ellav?éllav???de&ellav?éllav??e&ellav?éllav?????v?znerif??g&a?b?f?il?o?p?r?up?vf??hc?i&b?c?dol?f?l!lecrev?opan?rof&-anesec?anesec???m?n&a&part?rt&-attelrab-airdna?attelrabairdna???imir?ret??p?r!a&b?ilgac?ssas???s!idnirb??t&ei&hc?r??sa??v??l&a!c??b?c?o&m?rit&-&d&eus&-&nitnert?onitnert??nitnert?onitnert??us&-&nitnert?onitnert??nitnert?onitnert??üs&-&nitnert?onitnert??nitnert?onitnert???s&-onitnert?onitnert???d&eus!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??us&-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert??üs!-&n&asl&ab?ub??ezob?itnert??onitnert??nitnert?onitnert???s&-onitnert?onitnert?????m&ac?f?i!t.nepo.citsalej.duolc,?ol?r??n&a!lim?sl&ab?ub???b?c?e!en.cj,v?zob??irut?m!p??p?r?t??o&a!v??b!retiv??c!cel??enuc?g!ivor??i&dem&-onadipmac?onadipmac??pmet&-aiblo?aiblo??rdnos?zal??l?m!a&greb?ret??oc?re&f?lap???n!a&dipmac&-oidem?oidem??lim?tsiro?zlob??ecip&-ilocsa?ilocsa??i&bru&-orasep?orasep??lleva?rot?tnert??r&elas?ovil??ulleb??p?r!a&sep&-onibru?onibru??znatac??oun??s!ivert?sabopmac??t!arp?e&nev?ssorg??n&arat?e&girga?rt?veneb????zz&era?urba???p&a?ohsdaerpsym,s?t??qa?r&a!m?s??b!a??c?f?g?k?me?o?p?s?t?v??s&a&b?iselgi&-ainobrac?ainobrac???b?c?elpan?i?m?o&t?x&bi,obdaili,??s?t?v??t&a?b?c?l?m?nomdeip?o!psgolb,?p?v??u&de?l?n?p??v&a?og?p?s?t?v??y&drabmol?ellav&-atsoa?atsoa??licis?nacsut??z&al?b?c?p??ìlrof&-anesec?anesec???derc?er?f?m?utni??je3a3abgm--nx?kh?l!.&topsgolb,vog??uda??m!.&gro?moc!.topsgolb,?ten?ude???n&a&morockivdnas?ruatser?tnuocca??e&g?m&eganam!.retuor,?piuqe??r??i!.ue?m?opdlog??opud?uocsid??o&b?cs!.&ude,vog:.ecivres,,??d?g?h?j?oferab?p&edemoh?s???p!.&bewanigap321,emon?gro?lbup?moc?t&en?ni?opsgolb,?ude?vog???r&a!m&law?s???epxe?op&er?pus!.ysrab,?s???s!.&a&daxiabme?rarik,?e&motoas?picnirp?rots??gro?lim?moc?o&c?dalusnoc?hon,?ten?ude??a&cmoc?f??e&b?r?uq??i!rolf?tned??o&h!.&duolc&p,rim,?e&lej,tiseerf,?flah,l&enapysae,rupmet,?s&pvtsaf,seccaduolc,?tsafym,vedumpw,??p!sua???urt??t!.&eman?gro?ibom?levart?m&oc?uesum??o&c?fni?r&ea?p???pooc?sboj?t&en?ni??ude?vog?zib??ayh?n?o!bba?irram???uognah?xen?y!.gro,?ztej??u&2&5te9--nx?yssp--nx??a!.&a&s?w??civ?d&i?lq??fnoc?gro?moc!.&pohsdaerpsym,stelduolc.lem,topsgolb,??nsa?ofni?sat?t&ca?en?n??ude!.&a&s?w??ci&lohtac?v??dlq?sat?t&ca?n??wsn!.sloohcs????vog!.&a&s?w??civ?dlq?sat???wsn?zo??ti??c!.&fni?gro?moc?ten?ude?vog??i??d&e!.tir.segap-tig,?iab??e!.&dcym,enozgniebllew,noitatsksid,odagod.citsalej,s&nd&ps,uolc,?ppatikria,?ysrab,??g!.&bew?gro?m&aug?oc??ofni?ten?ude?vog???h!.&0002?a&citore?idem?kitore??edszot?gro?ilus?letoh?m&alker?lif?t?urof??naltagni?o&c?ediv?fni?levynok?nisac??pohs?rarga?s&a&kal?zatu??emag?wen??t&lob?opsgolb,rops??virp?xe&s?zs??ytic?zsagoj??os?sut??l!.&etisbew321,topsgolb,??m!.&ca?gro?moc?oc?ro?ten?vog???n!.&duolcesirpretne,eni&esrem,m,?tenkcahs,?em!.ysrab,??o&ggnaw?y!c???r!.&3kl,a&i&kymlak,rikhsab,vodrom,?yegyda,?bps,ca,duolcrim,e&niram,rpcm,?g&bc,nitsohurger.citsalej,ro,?ianatsuk,k&ihclan,s&m,rogitayp,??li&amdlc.bh,m,?moc,natsegad,onijym,pp,ri&b,d&cm:.spv,,orue,?midalv,?s&ar,itym,?t&en,ias321,ni,opsgolb,set,?u&4an,de,?vo&g,n,?ynzorg,zakvakidalv,?myc?p?ug??s!.&a&d&golov,nagarak,?gulak,i&groeg,kymlak,lerak,nemra,rikhsab,ssakahk,vodrom,zahkba,?lut,rahkub,vut,yegyda,znep,?bps,da&baghsa,rgonilest,?gunel,i&anatsuk,hcos,ovan,ttailgot,?k&alhsygnam,ihclan,s&legnahkra,m,n&a&mrum,yrb,?i&buytka,nbo,??tiort,vorkop,??l&ocarak,ybmaj,?na&gruk,jiabreza,ts&egad,hkazak-&htron,tsae,???ovonavi,r&adonsark,imidalv,?t&enxe,nek&hsat,mihc,??vo&hsalab,n,?ynzorg,z&akvakidalv,emret,??t&amok?i&juf?masih????v!.&em,g&olb,ro??moc?nc,ten?ude?ved,??ykuyr??v&b?c!.&emon?gro?moc?t&ni?opsgolb,?ude???ed!.&2r,ated,e&docotua,erf-korgn,nilnigol,?gnigats-oned,hcetaidem,korgn,lecrev,o&ned,tpyrctfihs,?ppa-rettalp,s&egap,rekrow,?vr&esi,uc,?weiverpbuhtig,ylf,??ih?l!.&di?fnoc?gro?lim?moc?nsa?ten?ude?vog???m!.&eman?gro?lim?m&oc?uesum??o&fni?r&ea?p???pooc?t&en?ni??ude?vog?zib???o&g?m??rt?s!.&bog?der?gro?moc?ude???t!.&arukas,bew-eht-no,morf,naht-&esrow,retteb,?sndnyd,?d?i?won??uqhv--nx??w&a!.moc?hs?l??b!.&gro?oc???c!.&gro?moc?ten?ude??cp??e&iver!.oby,?n?s??g?k!.&bme?dni?gro?moc?ten?ude?vog???m!.&ca?gro?m&oc?uesum??oc?pooc?t&en?ni??ude?vog?zib??b??o&csom?h!s??n?w??p!.&344x,de?en?o&c?g??ro?snduolc,ualeb???r!.&ca?gro?lim?oc?pooc?ten?vog??n??t!.&a46oa0fz--nx?b&82wrzc--nx?ulc??emag?gro?l&im?ru,?moc!.reliamym,?t&en?opsgolb,?ude?v&di?og?ta0cu--nx??zibe?業商?織組?路網???z!.&ca?gro?lim?oc?vog????x&a!.&cm,eb,gg,s&e,u,?tac,ue,yx,?t??c!.&hta,ofni,vog???e&d&ef?nay??ma!nab??rof?s??ilften?jt?m!.&bog?gro?moc?t&en?opsgolb,?ude??g?ma2ibgy--nx??o&b!x??f?rex??rbgn--nx?s!.vog??x&am&jt?kt??x???y&4punu--nx?7rr03--nx?a&d!i&loh?rfkcalb??ot!.emyfilauqerp,??g?lp?p!ila??rot?ssin?wdaorb??b!.&duolcym,fo?hcetaidem,lim?moc!.topsgolb,?vog??ab?gur??c!.&ca?dtl?gro?lim?m&oc!.&ecrofelacs.j,topsgolb,??t??orp?s&egolke?serp??ten?vog?zib??amrahp?nega??d&dadog?uts??e&kcoh?ltneb?n&dys?om?rotta??snikcm??g!.&eb,gro?moc?oc?ten?ude?vog??olonhcet!.oc,?rene??hpargotohp?id?k!.&gro?moc?ten?ude??s??l!.&clp?d&em?i??gro?hcs?moc?ten?ude?vog??f?imaf!nacirema??l&a?il??ppus??m!.&eman?gro?lim?moc?t&en?opsgolb,?ude?vog?zib??edaca!.laiciffo,?ra??n&apmoc?os??o&j?s??p!.&gro?lim?moc?pooc?ten?ude?vog???r&e&corg?grus?llag?viled??lewej?otcerid?tnuoc?uxul??s!.&gro?lim?moc?ten?ude?vog??pil??t&efas?i&c?ledif?n&ifx?ummoc!.&bdnevar,gon,murofym,???r&ahc?uces??srevinu??laer?r&ap!.oby,?eporp??uaeb??u!.&bug?gro?lim?moc!.topsgolb,?ten?ude??b!tseb???van!dlo??xes??z&a!.&eman?gro?lim?moc?o&fni?rp??pp?t&en?ni??ude?vog?zib???b!.&az,gro?jsg,moc?ten?ude?vog???c!.&4e,inum.duolc.&rsu,tlf,?m&laer,urtnecatem.motsuc,?oc,topsgolb,??d!.&cos?gro?lop?m&oc?t??ossa?t&en?ra??ude?vog???ib!.&duolcsd,e&ht-rof,mos-rof,rom-rof,?izoj,liartevitca,nafamm,p&i&-on,fles,?ohbew,tfym,?retteb-rof,snd&nyd,uolc,?xro,?g??k!.&duolcj,gro?lim?moc?t&en?ropeletzak.saapu,?ude?vog???m!.&ca?gro?lim?oc?ten?ude?v&da?og????n!.&asq-irom--nx?ca?gro?htlaeh?i&r&c?o&am?ām???wi!k???keeg?l&im?oohcs??neg?oc!.topsgolb,?t&en?nemailrap?vog???a!niflla???rawhcs?s!.&ca?gro?oc???t!.&c&a?s??e&m?n??ibom?l&etoh?im??o&c?fni?g??ro?vt???u!.&gro?moc?oc?ten??rwon??yx!.&e&nozlacol,tisgolb,?gnitfarc,otpaz,??zub??λε?υε?авксом?брс!.&гро?до?ка?р&бо?п!у?????г&б?ро??дкм?зақ?итед?килотак?леб?мок?н&йално?ом??рку?сур!.&арамас,бпс,гро,зиб,ичос,ксм,м&ок,ырк,?рим,я,??тйас?фр?юе?յահ?לארשי!.&בושי?הימדקא?ל&הצ?שממ????םוק?اي&روس?سيلم?ناتيروم??بر&ع?غملا??ة&كبش?ي&دوعسلا?روس??یدوعسلا??ت&ا&راما?لاصتا??را&ب?ڀ?ھب???ر&ئازجلا?ازاب?صم?طق??سنوت?عقوم?قارع?ك&تيب?يلوثاك??موك?ن&ا&تس&كاپ?کاپ??دوس?ر&يا?یا??مع?يلعلا??درالا?ميلا?ي&رحبلا?طسلف???ه&ارمه?يدوعسلا??وكمارا?يبظوبا?ۃیدوعسلا?टेन?त&राभ?ोराभ??नठगंस?मॉक?्मतराभ?ত&রাভ?ৰাভ??ালংাব?ਤਰਾਭ?તરાભ?ତରାଭ?ாயித்நஇ?ைக்ஙலஇ?்ரூப்பக்ஙிச?్తరాభ?ತರಾಭ?ംതരാഭ?ාකංල?มอค?ยทไ!.&จิกรุธ?ต็นเ?ร&ก์คงอ?าหท??ลาบฐัร?าษกึศ???ວາລ?ეგ?なんみ?アトス?トンイポ?ドウラク?ムコ?ル&グーグ?ーセ??ン&ゾマア?ョシッァフ??业企?东广?乐娱?你爱我?信中?务政?动移?博微?卦八?厅餐?司公?品食?善慈?团集?国中?國中?址网?坡加新?城商?尚时?山佛?店&商?网?酒大里嘉??府政?康健?息信?戏游?拉里格香?拿大?教主天?机手?构机!织组??标商?歌谷?浦利飞?港香!.&人個?司公?府政?絡網?織組?育教???湾台?灣&台?臺??物购?界世?益公?看点?科盈訊電?站网?籍書?线在?络网?网文中?聘招?販通?逊马亚?通联?里嘉?锡马淡?門澳?门澳?闻新?電家?국한?넷닷?성삼?컴닷??");
/**
* If a hostname is not a key in the EXCLUDE map, and if removing its leftmost component results
@@ -56,7 +56,7 @@ public final class PublicSuffixPatterns {
*/
public static final ImmutableMap<String, PublicSuffixType> UNDER =
TrieParser.parseTrie(
- "ac.vedwa,d&b?i.ym.ssr,uolc.&etiso&isnes,tnegam,?iaznab,rehcnar-no,scitats,??e&b.lrusnart,d.&ecapsrebu,yksurf,?noz.notirt,t&atse.etupmoc,is.&areduolc,hsmroftalp,tst,???g&oog.tnetnocresu,p??h&c.tenerif:.cvs,,k?trae.sppad:.zzb,,?k&c?f?nil.bewd,rowten.secla,u.hcs??ln.lrusnart,m&f.resu,j?m?oc.&duolcmeaeboda.ved,edo&c.redliub:-&gts,ved,?,nil.recnalabedon,?ico-remotsuc:.&ico,pco,sco,?,lrihwyap,mme0,osseccandcved,s&ecapsnaecolatigid,t&cejbo&edonil,rtluv,?nemelepiuq,?wanozama.&1-etupmoc,ble,etupmoc,??t&neyoj.snc,opsppa.r,???n&c.moc.swanozama.&ble,etupmoc,?ur.&dliub,e&doc,sabatad,?noitargim,??o&c.pato,i.&duolciaznab.sdraykcab,elacsnoom,nroca-no,oir-no,reniatnoceruza,s&3k-no,olots,?xcq.sys,y5s,??p&j.&a&mahokoy?yogan??ebok?i&adnes?kasawak??oroppas?uhsuykatik??n?pa.&knalfhtron,repoleved,tegeb,??r&b.mon?e??s&edoc.owo,noitulos.rehid,w.rosivda,?t&a.&ofnistro.&nednuk,xe,?smcerutuf:.&ni,xe,?,?en.&cimonotpyrc,hvo.&gnitsoh,saapbew,???u&e.lrusnart,r.onijym.&gni&dnal,tsoh,?murtceps,spv,??ved.&e&gats&gts,lcl,?rahbew,?gts,lcl,treclacol.resu,yawetag,?z&c.murtnecatem.duolc,yx.tibelet,??");
+ "ac.vedwa,d&b?i.ym.ssr,uolc.&etiso&isnes,tnegam,?iaznab,rehcnar-no,scitats,??e&b.lrusnart,d.&ecapsrebu,yksurf,?noz.notirt,t&atse.etupmoc,is.&areduolc,hsmroftalp,tst,???g&oog.tnetnocresu,p??h&c.tenerif:.cvs,,k?trae.sppad:.zzb,,?k&c?f?nil.bewd,rowten.secla,u.hcs??ln.lrusnart,m&f.resu,j?m?oc.&duolcmeaeboda.ved,edo&c.redliub:-&gts,ved,?,nil.recnalabedon,?ico-remotsuc:.&ico,pco,sco,?,lrihwyap,mme0,osseccandcved,ppayfilpma,rennurppaswa,s&ecapsnaecolatigid,t&cejbo&edonil,rtluv,?nemelepiuq,?wanozama.&1-etupmoc,ble,etupmoc,wolfria.&1-&ht&ron-ue,uos-pa,?lartnec-&ac,ue,?ts&ae&-&as,su,?ht&ron-pa,uos-pa,??ew-ue,??2-ts&ae&-su,ht&ron-pa,uos-pa,??ew-&su,ue,??3-tsew-ue,???t&neyoj.snc,opsppa.r,???n&c.moc.swanozama.&ble,etupmoc,wolfria.1-&htron-nc,tsewhtron-nc,??ur.&dliub,e&doc,sabatad,?noitargim,??o&c.pato,i.&duolciaznab.sdraykcab,elacsnoom,nroca-no,oir-no,reniatnoceruza,s&3k-no,olots,?xcq.sys,y5s,??p&j.&a&mahokoy?yogan??ebok?i&adnes?kasawak??oroppas?uhsuykatik??n?pa.&knalfhtron,repoleved,tegeb,??r&b.mon?e??s&edoc.owo,noitulos.rehid,w.rosivda,?t&a.&ofnistro.&nednuk,xe,?smcerutuf:.&ni,xe,?,?en.&cimonotpyrc,hvo.&gnitsoh,saapbew,???u&e.lrusnart,r.onijym.&gni&dnal,tsoh,?murtceps,spv,??ved.&e&gats&gts,lcl,?rahbew,?gts,lcl,treclacol.resu,yawetag,?z&c.murtnecatem.duolc,yx.tibelet,??");
/**
* The elements in this map would pass the UNDER test, but are known not to be public suffixes and
diff --git a/integration-tests/gradle/build.gradle.kts b/integration-tests/gradle/build.gradle.kts
index 79db509a4..963b71873 100644
--- a/integration-tests/gradle/build.gradle.kts
+++ b/integration-tests/gradle/build.gradle.kts
@@ -7,19 +7,19 @@ val guavaVersionJre =
val expectedReducedRuntimeClasspathAndroidVersion =
setOf(
"guava-${guavaVersionJre.replace("jre", "android")}.jar",
- "failureaccess-1.0.1.jar",
+ "failureaccess-1.0.2.jar",
"jsr305-3.0.2.jar",
- "checker-qual-3.33.0.jar",
- "error_prone_annotations-2.18.0.jar",
+ "checker-qual-3.41.0.jar",
+ "error_prone_annotations-2.23.0.jar",
"listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar"
)
val expectedReducedRuntimeClasspathJreVersion =
setOf(
"guava-$guavaVersionJre.jar",
- "failureaccess-1.0.1.jar",
+ "failureaccess-1.0.2.jar",
"jsr305-3.0.2.jar",
- "checker-qual-3.33.0.jar",
- "error_prone_annotations-2.18.0.jar",
+ "checker-qual-3.41.0.jar",
+ "error_prone_annotations-2.23.0.jar",
"listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar"
)
val expectedCompileClasspathAndroidVersion =
@@ -27,10 +27,7 @@ val expectedCompileClasspathAndroidVersion =
val expectedCompileClasspathJreVersion =
expectedReducedRuntimeClasspathJreVersion + setOf("j2objc-annotations-2.8.jar")
-val extraLegacyDependencies =
- setOf(
- "google-collections-1.0.jar"
- )
+val extraLegacyDependencies = setOf("google-collections-1.0.jar")
buildscript {
val agpVersion = if (gradle.gradleVersion.startsWith("5.")) "3.6.4" else "7.0.4"
diff --git a/integration-tests/gradle/gradle/wrapper/gradle-wrapper.jar b/integration-tests/gradle/gradle/wrapper/gradle-wrapper.jar
index afba10928..7f93135c4 100644
--- a/integration-tests/gradle/gradle/wrapper/gradle-wrapper.jar
+++ b/integration-tests/gradle/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/integration-tests/gradle/gradle/wrapper/gradle-wrapper.properties b/integration-tests/gradle/gradle/wrapper/gradle-wrapper.properties
index 4e86b9270..3fa8f862f 100644
--- a/integration-tests/gradle/gradle/wrapper/gradle-wrapper.properties
+++ b/integration-tests/gradle/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/integration-tests/gradle/gradlew b/integration-tests/gradle/gradlew
index 65dcd68d6..1aa94a426 100755
--- a/integration-tests/gradle/gradlew
+++ b/integration-tests/gradle/gradlew
@@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
-APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
+ fi
fi
# Increase the maximum file descriptors if we can.
@@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
+ # shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
+ # shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi
-# Collect all arguments for the java command;
-# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
-# shell script including quotes and variable substitutions, so put them in
-# double quotes to make sure that they get re-expanded; and
-# * put everything else in single quotes, so that it's not re-expanded.
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
diff --git a/mvnw b/mvnw
new file mode 100755
index 000000000..8d937f4c1
--- /dev/null
+++ b/mvnw
@@ -0,0 +1,308 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Apache Maven Wrapper startup batch script, version 3.2.0
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+ if [ -f /usr/local/etc/mavenrc ] ; then
+ . /usr/local/etc/mavenrc
+ fi
+
+ if [ -f /etc/mavenrc ] ; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ] ; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "$(uname)" in
+ CYGWIN*) cygwin=true ;;
+ MINGW*) mingw=true;;
+ Darwin*) darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
+ else
+ JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
+ fi
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=$(java-config --jre-home)
+ fi
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+ [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
+ JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)"
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="$(which javac)"
+ if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=$(which readlink)
+ if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
+ if $darwin ; then
+ javaHome="$(dirname "\"$javaExecutable\"")"
+ javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
+ else
+ javaExecutable="$(readlink -f "\"$javaExecutable\"")"
+ fi
+ javaHome="$(dirname "\"$javaExecutable\"")"
+ javaHome=$(expr "$javaHome" : '\(.*\)/bin')
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+ if [ -z "$1" ]
+ then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ] ; do
+ if [ -d "$wdir"/.mvn ] ; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=$(cd "$wdir/.." || exit 1; pwd)
+ fi
+ # end of workaround
+ done
+ printf '%s' "$(cd "$basedir" || exit 1; pwd)"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ # Remove \r in case we run on Windows within Git Bash
+ # and check out the repository with auto CRLF management
+ # enabled. Otherwise, we may read lines that are delimited with
+ # \r\n and produce $'-Xarg\r' rather than -Xarg due to word
+ # splitting rules.
+ tr -s '\r\n' ' ' < "$1"
+ fi
+}
+
+log() {
+ if [ "$MVNW_VERBOSE" = true ]; then
+ printf '%s\n' "$1"
+ fi
+}
+
+BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
+if [ -z "$BASE_DIR" ]; then
+ exit 1;
+fi
+
+MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
+log "$MAVEN_PROJECTBASEDIR"
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
+if [ -r "$wrapperJarPath" ]; then
+ log "Found $wrapperJarPath"
+else
+ log "Couldn't find $wrapperJarPath, downloading it ..."
+
+ if [ -n "$MVNW_REPOURL" ]; then
+ wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
+ else
+ wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
+ fi
+ while IFS="=" read -r key value; do
+ # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
+ safeValue=$(echo "$value" | tr -d '\r')
+ case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
+ esac
+ done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
+ log "Downloading from: $wrapperUrl"
+
+ if $cygwin; then
+ wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
+ fi
+
+ if command -v wget > /dev/null; then
+ log "Found wget ... using wget"
+ [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+ else
+ wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
+ fi
+ elif command -v curl > /dev/null; then
+ log "Found curl ... using curl"
+ [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
+ if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
+ curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
+ else
+ curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
+ fi
+ else
+ log "Falling back to using Java to download"
+ javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
+ # For Cygwin, switch paths to Windows format before running javac
+ if $cygwin; then
+ javaSource=$(cygpath --path --windows "$javaSource")
+ javaClass=$(cygpath --path --windows "$javaClass")
+ fi
+ if [ -e "$javaSource" ]; then
+ if [ ! -e "$javaClass" ]; then
+ log " - Compiling MavenWrapperDownloader.java ..."
+ ("$JAVA_HOME/bin/javac" "$javaSource")
+ fi
+ if [ -e "$javaClass" ]; then
+ log " - Running MavenWrapperDownloader.java ..."
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
+ fi
+ fi
+ fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+# If specified, validate the SHA-256 sum of the Maven wrapper jar file
+wrapperSha256Sum=""
+while IFS="=" read -r key value; do
+ case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
+ esac
+done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
+if [ -n "$wrapperSha256Sum" ]; then
+ wrapperSha256Result=false
+ if command -v sha256sum > /dev/null; then
+ if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
+ wrapperSha256Result=true
+ fi
+ elif command -v shasum > /dev/null; then
+ if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
+ wrapperSha256Result=true
+ fi
+ else
+ echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
+ echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
+ exit 1
+ fi
+ if [ $wrapperSha256Result = false ]; then
+ echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
+ echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
+ echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
+ exit 1
+ fi
+fi
+
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
+ [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+ MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
+fi
+
+# Provide a "standardized" way to retrieve the CLI args that will
+# work with both Windows and non-Windows executions.
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
+export MAVEN_CMD_LINE_ARGS
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+# shellcheck disable=SC2086 # safe args
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ $MAVEN_DEBUG_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/mvnw.cmd b/mvnw.cmd
new file mode 100644
index 000000000..c4586b564
--- /dev/null
+++ b/mvnw.cmd
@@ -0,0 +1,205 @@
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. You may obtain a copy of the License at
+@REM
+@REM http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Apache Maven Wrapper startup batch script, version 3.2.0
+@REM
+@REM Required ENV vars:
+@REM JAVA_HOME - location of a JDK home dir
+@REM
+@REM Optional ENV vars
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
+@REM e.g. to debug Maven itself, use
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+@REM ----------------------------------------------------------------------------
+
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
+@echo off
+@REM set title of command window
+title %0
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
+if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
+
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Found %WRAPPER_JAR%
+ )
+) else (
+ if not "%MVNW_REPOURL%" == "" (
+ SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
+ )
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %WRAPPER_URL%
+ )
+
+ powershell -Command "&{"^
+ "$webclient = new-object System.Net.WebClient;"^
+ "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
+ "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
+ "}"^
+ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
+ "}"
+ if "%MVNW_VERBOSE%" == "true" (
+ echo Finished downloading %WRAPPER_JAR%
+ )
+)
+@REM End of extension
+
+@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
+SET WRAPPER_SHA_256_SUM=""
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
+ IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
+)
+IF NOT %WRAPPER_SHA_256_SUM%=="" (
+ powershell -Command "&{"^
+ "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
+ "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
+ " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
+ " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
+ " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
+ " exit 1;"^
+ "}"^
+ "}"
+ if ERRORLEVEL 1 goto error
+)
+
+@REM Provide a "standardized" way to retrieve the CLI args that will
+@REM work with both Windows and non-Windows executions.
+set MAVEN_CMD_LINE_ARGS=%*
+
+%MAVEN_JAVA_EXE% ^
+ %JVM_CONFIG_MAVEN_PROPS% ^
+ %MAVEN_OPTS% ^
+ %MAVEN_DEBUG_OPTS% ^
+ -classpath %WRAPPER_JAR% ^
+ "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
+ %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
+if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%"=="on" pause
+
+if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
+
+cmd /C exit /B %ERROR_CODE%
diff --git a/pom.xml b/pom.xml
index 38df75f49..d13d3fd52 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,12 +15,14 @@
<!-- Override this with -Dtest.include="**/SomeTest.java" on the CLI -->
<test.include>%regex[.*.class]</test.include>
<truth.version>1.1.3</truth.version>
- <maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version>
+ <jsr305.version>3.0.2</jsr305.version>
+ <checker.version>3.41.0</checker.version>
+ <errorprone.version>2.23.0</errorprone.version>
+ <j2objc.version>2.8</j2objc.version>
<javac.version>9+181-r4173-1</javac.version>
<!-- Empty for all JDKs but 9-12 -->
<maven-javadoc-plugin.additionalJOptions></maven-javadoc-plugin.additionalJOptions>
- <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
- <project.build.outputTimestamp>2023-07-31T21:01:01Z</project.build.outputTimestamp>
+ <project.build.outputTimestamp>2023-02-01T00:00:00Z</project.build.outputTimestamp>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<test.add.opens></test.add.opens>
<module.status>release</module.status>
@@ -95,7 +97,6 @@
</testResources>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
@@ -116,13 +117,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>${maven-javadoc-plugin.version}</version>
- <configuration>
- <source>${java.specification.version}</source>
- </configuration>
- </plugin>
</plugins>
<pluginManagement>
<plugins>
@@ -151,7 +145,7 @@
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
- <version>2.16</version>
+ <version>2.23.0</version>
</path>
</annotationProcessorPaths>
<!-- Fork:
@@ -169,12 +163,13 @@
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
- <version>${maven-source-plugin.version}</version>
+ <version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
- <phase>post-integration-test</phase>
- <goals><goal>jar</goal></goals>
+ <goals>
+ <goal>jar-no-fork</goal>
+ </goals>
</execution>
</executions>
</plugin>
@@ -203,7 +198,7 @@
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>${maven-javadoc-plugin.version}</version>
+ <version>3.5.0</version>
<configuration>
<quiet>true</quiet>
<notimestamp>true</notimestamp>
@@ -215,13 +210,12 @@
<additionalOption>-Xdoclint:-html</additionalOption>
</additionalOptions>
<linksource>true</linksource>
- <source>8</source>
+ <source>${java.specification.version}</source>
<additionalJOption>${maven-javadoc-plugin.additionalJOptions}</additionalJOption>
</configuration>
<executions>
<execution>
<id>attach-docs</id>
- <phase>post-integration-test</phase>
<goals><goal>jar</goal></goals>
</execution>
</executions>
@@ -258,7 +252,6 @@
</configuration>
</plugin>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
@@ -296,24 +289,28 @@
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
- <version>3.0.2</version>
+ <version>${jsr305.version}</version>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
- <version>3.33.0</version>
+ <version>${checker.version}</version>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
- <version>2.18.0</version>
+ <version>${errorprone.version}</version>
</dependency>
<dependency>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
- <version>2.8</version>
+ <version>${j2objc.version}</version>
</dependency>
- <!-- We avoid using dependencyManagement for test-only deps because of https://github.com/google/guava/issues/6654 -->
+ <!--
+ We moved away from using dependencyManagement for test-only deps because of https://github.com/google/guava/issues/6654.
+ We could probably have resumed it after https://github.com/google/guava/pull/6664.
+ But it's always weird that published poms reference test-only libraries at all, so I'm not in any rush to do so.
+ -->
</dependencies>
</dependencyManagement>
<profiles>
@@ -322,33 +319,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <version>${maven-source-plugin.version}</version>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar-no-fork</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>${maven-javadoc-plugin.version}</version>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<executions>
@@ -411,7 +381,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- Under JDK8, we continue to use errorprone's javac9 (even
@@ -454,7 +423,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs combine.children="append">
diff --git a/proguard/reflect.pro b/proguard/reflect.pro
deleted file mode 100644
index 620cbd314..000000000
--- a/proguard/reflect.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-# Warning: common.reflect (like reflection in general) is typically slow and
-# unreliable under Android. We do not recommend using it. This Proguard config
-# exists only to avoid breaking the builds of users who already have
-# common.reflect in their transitive dependencies.
-#
--dontwarn com.google.common.reflect.Invokable
--dontwarn com.google.common.reflect.Invokable$ConstructorInvokable
--dontwarn com.google.common.reflect.Invokable$MethodInvokable
--dontwarn com.google.common.reflect.Parameter
diff --git a/util/deploy_snapshot.sh b/util/deploy_snapshot.sh
index d021318fd..e84496439 100755
--- a/util/deploy_snapshot.sh
+++ b/util/deploy_snapshot.sh
@@ -5,7 +5,7 @@
set -e -u
function mvn_deploy() {
- mvn clean source:jar javadoc:jar deploy -DskipTests=true "$@"
+ ./mvnw clean deploy -DskipTests=true "$@"
}
echo "Publishing Maven snapshot..."
diff --git a/util/gradle_integration_tests.sh b/util/gradle_integration_tests.sh
index 9378e6717..3a8f921ac 100755
--- a/util/gradle_integration_tests.sh
+++ b/util/gradle_integration_tests.sh
@@ -2,8 +2,8 @@
set -eu
-mvn clean install --projects '!guava-testlib,!guava-tests,!guava-bom,!guava-gwt' -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
-mvn clean install --projects '!guava-testlib,!guava-tests,!guava-bom' -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -f android
+./mvnw clean install --projects '!guava-testlib,!guava-tests,!guava-bom,!guava-gwt' -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
+./mvnw clean install --projects '!guava-testlib,!guava-tests,!guava-bom' -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -f android
# Gradle Wrapper overwrites some files when it runs.
# To avoid modifying the Git client, we copy everything we need to another directory.