From 504978f1032ab9b6284ffadd1f94bdb7c870557a Mon Sep 17 00:00:00 2001 From: xingx Date: Wed, 30 Jan 2019 07:30:30 -0800 Subject: [PATCH 01/23] Add Report-To header. https://www.w3.org/TR/reporting/ RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=231590633 --- android/guava/src/com/google/common/net/HttpHeaders.java | 4 ++++ guava-gwt/src/com/google/common/base/Base.gwt.xml | 4 +--- guava-gwt/src/com/google/common/cache/Cache.gwt.xml | 4 +--- guava-gwt/src/com/google/common/collect/Collect.gwt.xml | 4 +--- .../src/com/google/common/util/concurrent/Concurrent.gwt.xml | 4 +--- guava-gwt/test/com/google/common/html/testModule.gwt.xml | 2 -- guava-gwt/test/com/google/common/testing/Testing.gwt.xml | 4 +--- guava/src/com/google/common/net/HttpHeaders.java | 4 ++++ 8 files changed, 13 insertions(+), 17 deletions(-) diff --git a/android/guava/src/com/google/common/net/HttpHeaders.java b/android/guava/src/com/google/common/net/HttpHeaders.java index f405eec9fa81..5864bbe67baa 100644 --- a/android/guava/src/com/google/common/net/HttpHeaders.java +++ b/android/guava/src/com/google/common/net/HttpHeaders.java @@ -270,6 +270,10 @@ private ReferrerPolicyValues() {} public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate"; /** The HTTP {@code Refresh} header field name. Non-standard header supported by most browsers. */ public static final String REFRESH = "Refresh"; + /** + * The HTTP {@code Report-To} header field name. + */ + public static final String REPORT_TO = "Report-To"; /** The HTTP {@code Retry-After} header field name. */ public static final String RETRY_AFTER = "Retry-After"; /** The HTTP {@code Server} header field name. */ diff --git a/guava-gwt/src/com/google/common/base/Base.gwt.xml b/guava-gwt/src/com/google/common/base/Base.gwt.xml index 4df8ad0a81b8..1fcbe108e2eb 100644 --- a/guava-gwt/src/com/google/common/base/Base.gwt.xml +++ b/guava-gwt/src/com/google/common/base/Base.gwt.xml @@ -17,9 +17,7 @@ - - - + diff --git a/guava-gwt/src/com/google/common/cache/Cache.gwt.xml b/guava-gwt/src/com/google/common/cache/Cache.gwt.xml index 7b21cfbe3e37..174b2fac127c 100644 --- a/guava-gwt/src/com/google/common/cache/Cache.gwt.xml +++ b/guava-gwt/src/com/google/common/cache/Cache.gwt.xml @@ -21,9 +21,7 @@ - - - + diff --git a/guava-gwt/src/com/google/common/collect/Collect.gwt.xml b/guava-gwt/src/com/google/common/collect/Collect.gwt.xml index 5c71637d869f..0439cf6bad01 100644 --- a/guava-gwt/src/com/google/common/collect/Collect.gwt.xml +++ b/guava-gwt/src/com/google/common/collect/Collect.gwt.xml @@ -23,9 +23,7 @@ - - - + diff --git a/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml b/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml index 4981b291ed05..aa59ee17793c 100644 --- a/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml +++ b/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml @@ -19,9 +19,7 @@ - - - + diff --git a/guava-gwt/test/com/google/common/html/testModule.gwt.xml b/guava-gwt/test/com/google/common/html/testModule.gwt.xml index 6e128468d132..0346ed12be98 100644 --- a/guava-gwt/test/com/google/common/html/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/html/testModule.gwt.xml @@ -6,8 +6,6 @@ - - diff --git a/guava-gwt/test/com/google/common/testing/Testing.gwt.xml b/guava-gwt/test/com/google/common/testing/Testing.gwt.xml index 9e815a494c8f..e65cd647beff 100644 --- a/guava-gwt/test/com/google/common/testing/Testing.gwt.xml +++ b/guava-gwt/test/com/google/common/testing/Testing.gwt.xml @@ -21,9 +21,7 @@ - - - + diff --git a/guava/src/com/google/common/net/HttpHeaders.java b/guava/src/com/google/common/net/HttpHeaders.java index f405eec9fa81..5864bbe67baa 100644 --- a/guava/src/com/google/common/net/HttpHeaders.java +++ b/guava/src/com/google/common/net/HttpHeaders.java @@ -270,6 +270,10 @@ private ReferrerPolicyValues() {} public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate"; /** The HTTP {@code Refresh} header field name. Non-standard header supported by most browsers. */ public static final String REFRESH = "Refresh"; + /** + * The HTTP {@code Report-To} header field name. + */ + public static final String REPORT_TO = "Report-To"; /** The HTTP {@code Retry-After} header field name. */ public static final String RETRY_AFTER = "Retry-After"; /** The HTTP {@code Server} header field name. */ From f0945a2ca741ead2a435cf52ddae2217763cc092 Mon Sep 17 00:00:00 2001 From: Oleksii Bondar Date: Wed, 30 Jan 2019 11:51:19 -0800 Subject: [PATCH 02/23] Remove unused imports and warnings. Fixes #3356 RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=231638663 --- .../src/com/google/common/collect/AbstractMapBasedMultimap.java | 2 -- .../guava/src/com/google/common/collect/EmptyContiguousSet.java | 2 +- android/guava/src/com/google/common/collect/EnumMultiset.java | 1 - .../guava/src/com/google/common/collect/LinkedHashMultiset.java | 1 - .../guava/src/com/google/common/collect/NaturalOrdering.java | 2 +- .../com/google/common/collect/RegularImmutableSortedSet.java | 2 +- .../src/com/google/common/collect/ReverseNaturalOrdering.java | 2 +- android/guava/src/com/google/common/io/ByteStreams.java | 1 - .../src/com/google/common/collect/AbstractMapBasedMultimap.java | 2 -- guava/src/com/google/common/collect/AbstractTable.java | 1 - guava/src/com/google/common/collect/EmptyContiguousSet.java | 2 +- guava/src/com/google/common/collect/EnumMultiset.java | 1 - guava/src/com/google/common/collect/LinkedHashMultiset.java | 1 - guava/src/com/google/common/collect/NaturalOrdering.java | 2 +- .../com/google/common/collect/RegularImmutableSortedSet.java | 2 +- guava/src/com/google/common/collect/ReverseNaturalOrdering.java | 2 +- guava/src/com/google/common/io/ByteStreams.java | 1 - guava/src/com/google/common/io/MoreFiles.java | 1 - 18 files changed, 8 insertions(+), 20 deletions(-) diff --git a/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java b/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java index fae1f032d394..d9f4ce1a386e 100644 --- a/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java +++ b/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java @@ -21,8 +21,6 @@ import static com.google.common.collect.CollectPreconditions.checkRemove; import com.google.common.annotations.GwtCompatible; -import com.google.common.collect.AbstractMultimap.Entries; -import com.google.common.collect.AbstractMultimap.EntrySet; import com.google.common.collect.Maps.ViewCachingAbstractMap; import com.google.j2objc.annotations.WeakOuter; import java.io.Serializable; diff --git a/android/guava/src/com/google/common/collect/EmptyContiguousSet.java b/android/guava/src/com/google/common/collect/EmptyContiguousSet.java index b86fda0e0321..e35611d40377 100644 --- a/android/guava/src/com/google/common/collect/EmptyContiguousSet.java +++ b/android/guava/src/com/google/common/collect/EmptyContiguousSet.java @@ -26,7 +26,7 @@ * @author Gregory Kick */ @GwtCompatible(emulated = true) -@SuppressWarnings("unchecked") // allow ungenerified Comparable types +@SuppressWarnings("rawtypes") // allow ungenerified Comparable types final class EmptyContiguousSet extends ContiguousSet { EmptyContiguousSet(DiscreteDomain domain) { super(domain); diff --git a/android/guava/src/com/google/common/collect/EnumMultiset.java b/android/guava/src/com/google/common/collect/EnumMultiset.java index 88026d2ad946..111de6eca6e9 100644 --- a/android/guava/src/com/google/common/collect/EnumMultiset.java +++ b/android/guava/src/com/google/common/collect/EnumMultiset.java @@ -106,7 +106,6 @@ private boolean isActuallyE(@NullableDecl Object o) { * Returns {@code element} cast to {@code E}, if it actually is a nonnull E. Otherwise, throws * either a NullPointerException or a ClassCastException as appropriate. */ - @SuppressWarnings("unchecked") void checkIsE(@NullableDecl Object element) { checkNotNull(element); if (!isActuallyE(element)) { diff --git a/android/guava/src/com/google/common/collect/LinkedHashMultiset.java b/android/guava/src/com/google/common/collect/LinkedHashMultiset.java index cb3a94998cbd..6f95d4d2dc4f 100644 --- a/android/guava/src/com/google/common/collect/LinkedHashMultiset.java +++ b/android/guava/src/com/google/common/collect/LinkedHashMultiset.java @@ -34,7 +34,6 @@ * @since 2.0 */ @GwtCompatible(serializable = true, emulated = true) -@SuppressWarnings("serial") // we're overriding default serialization public final class LinkedHashMultiset extends AbstractMapBasedMultiset { /** Creates a new, empty {@code LinkedHashMultiset} using the default initial capacity. */ diff --git a/android/guava/src/com/google/common/collect/NaturalOrdering.java b/android/guava/src/com/google/common/collect/NaturalOrdering.java index 2f5258641589..177cd76c1e61 100644 --- a/android/guava/src/com/google/common/collect/NaturalOrdering.java +++ b/android/guava/src/com/google/common/collect/NaturalOrdering.java @@ -24,7 +24,7 @@ /** An ordering that uses the natural order of the values. */ @GwtCompatible(serializable = true) -@SuppressWarnings("unchecked") // TODO(kevinb): the right way to explain this?? +@SuppressWarnings({"unchecked", "rawtypes"}) // TODO(kevinb): the right way to explain this?? final class NaturalOrdering extends Ordering implements Serializable { static final NaturalOrdering INSTANCE = new NaturalOrdering(); diff --git a/android/guava/src/com/google/common/collect/RegularImmutableSortedSet.java b/android/guava/src/com/google/common/collect/RegularImmutableSortedSet.java index e2dfd70bda0e..d70d8fb74c12 100644 --- a/android/guava/src/com/google/common/collect/RegularImmutableSortedSet.java +++ b/android/guava/src/com/google/common/collect/RegularImmutableSortedSet.java @@ -37,7 +37,7 @@ * @author Louis Wasserman */ @GwtCompatible(serializable = true, emulated = true) -@SuppressWarnings("serial") +@SuppressWarnings({"serial", "rawtypes"}) final class RegularImmutableSortedSet extends ImmutableSortedSet { static final RegularImmutableSortedSet NATURAL_EMPTY_SET = new RegularImmutableSortedSet<>(ImmutableList.of(), Ordering.natural()); diff --git a/android/guava/src/com/google/common/collect/ReverseNaturalOrdering.java b/android/guava/src/com/google/common/collect/ReverseNaturalOrdering.java index 93513e3c9ab3..612d846a7727 100644 --- a/android/guava/src/com/google/common/collect/ReverseNaturalOrdering.java +++ b/android/guava/src/com/google/common/collect/ReverseNaturalOrdering.java @@ -24,7 +24,7 @@ /** An ordering that uses the reverse of the natural order of the values. */ @GwtCompatible(serializable = true) -@SuppressWarnings("unchecked") // TODO(kevinb): the right way to explain this?? +@SuppressWarnings({"unchecked", "rawtypes"}) // TODO(kevinb): the right way to explain this?? final class ReverseNaturalOrdering extends Ordering implements Serializable { static final ReverseNaturalOrdering INSTANCE = new ReverseNaturalOrdering(); diff --git a/android/guava/src/com/google/common/io/ByteStreams.java b/android/guava/src/com/google/common/io/ByteStreams.java index 25111a77a54b..b2b017bd8267 100644 --- a/android/guava/src/com/google/common/io/ByteStreams.java +++ b/android/guava/src/com/google/common/io/ByteStreams.java @@ -488,7 +488,6 @@ public static ByteArrayDataOutput newDataOutput(ByteArrayOutputStream byteArrayO return new ByteArrayDataOutputStream(checkNotNull(byteArrayOutputSteam)); } - @SuppressWarnings("deprecation") // for writeBytes private static class ByteArrayDataOutputStream implements ByteArrayDataOutput { final DataOutput output; diff --git a/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java b/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java index 241a8b9a1c42..385befbf75a2 100644 --- a/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java +++ b/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java @@ -21,8 +21,6 @@ import static com.google.common.collect.CollectPreconditions.checkRemove; import com.google.common.annotations.GwtCompatible; -import com.google.common.collect.AbstractMultimap.Entries; -import com.google.common.collect.AbstractMultimap.EntrySet; import com.google.common.collect.Maps.ViewCachingAbstractMap; import com.google.j2objc.annotations.WeakOuter; import java.io.Serializable; diff --git a/guava/src/com/google/common/collect/AbstractTable.java b/guava/src/com/google/common/collect/AbstractTable.java index d3da69532cd3..d4111604f8c5 100644 --- a/guava/src/com/google/common/collect/AbstractTable.java +++ b/guava/src/com/google/common/collect/AbstractTable.java @@ -15,7 +15,6 @@ package com.google.common.collect; import com.google.common.annotations.GwtCompatible; -import com.google.common.collect.Table.Cell; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.j2objc.annotations.WeakOuter; import java.util.AbstractCollection; diff --git a/guava/src/com/google/common/collect/EmptyContiguousSet.java b/guava/src/com/google/common/collect/EmptyContiguousSet.java index 325566485fee..922de306f066 100644 --- a/guava/src/com/google/common/collect/EmptyContiguousSet.java +++ b/guava/src/com/google/common/collect/EmptyContiguousSet.java @@ -26,7 +26,7 @@ * @author Gregory Kick */ @GwtCompatible(emulated = true) -@SuppressWarnings("unchecked") // allow ungenerified Comparable types +@SuppressWarnings("rawtypes") // allow ungenerified Comparable types final class EmptyContiguousSet extends ContiguousSet { EmptyContiguousSet(DiscreteDomain domain) { super(domain); diff --git a/guava/src/com/google/common/collect/EnumMultiset.java b/guava/src/com/google/common/collect/EnumMultiset.java index bf1f3944d56e..76f007f4ccbf 100644 --- a/guava/src/com/google/common/collect/EnumMultiset.java +++ b/guava/src/com/google/common/collect/EnumMultiset.java @@ -107,7 +107,6 @@ private boolean isActuallyE(@Nullable Object o) { * Returns {@code element} cast to {@code E}, if it actually is a nonnull E. Otherwise, throws * either a NullPointerException or a ClassCastException as appropriate. */ - @SuppressWarnings("unchecked") void checkIsE(@Nullable Object element) { checkNotNull(element); if (!isActuallyE(element)) { diff --git a/guava/src/com/google/common/collect/LinkedHashMultiset.java b/guava/src/com/google/common/collect/LinkedHashMultiset.java index a584f7690221..87c2ad24a745 100644 --- a/guava/src/com/google/common/collect/LinkedHashMultiset.java +++ b/guava/src/com/google/common/collect/LinkedHashMultiset.java @@ -39,7 +39,6 @@ * @since 2.0 */ @GwtCompatible(serializable = true, emulated = true) -@SuppressWarnings("serial") // we're overriding default serialization public final class LinkedHashMultiset extends AbstractMapBasedMultiset { /** Creates a new, empty {@code LinkedHashMultiset} using the default initial capacity. */ diff --git a/guava/src/com/google/common/collect/NaturalOrdering.java b/guava/src/com/google/common/collect/NaturalOrdering.java index dcb09dafad1d..b80f5d660413 100644 --- a/guava/src/com/google/common/collect/NaturalOrdering.java +++ b/guava/src/com/google/common/collect/NaturalOrdering.java @@ -24,7 +24,7 @@ /** An ordering that uses the natural order of the values. */ @GwtCompatible(serializable = true) -@SuppressWarnings("unchecked") // TODO(kevinb): the right way to explain this?? +@SuppressWarnings({"unchecked", "rawtypes"}) // TODO(kevinb): the right way to explain this?? final class NaturalOrdering extends Ordering implements Serializable { static final NaturalOrdering INSTANCE = new NaturalOrdering(); diff --git a/guava/src/com/google/common/collect/RegularImmutableSortedSet.java b/guava/src/com/google/common/collect/RegularImmutableSortedSet.java index f8427c78f1bf..c659adad7410 100644 --- a/guava/src/com/google/common/collect/RegularImmutableSortedSet.java +++ b/guava/src/com/google/common/collect/RegularImmutableSortedSet.java @@ -38,7 +38,7 @@ * @author Louis Wasserman */ @GwtCompatible(serializable = true, emulated = true) -@SuppressWarnings("serial") +@SuppressWarnings({"serial", "rawtypes"}) final class RegularImmutableSortedSet extends ImmutableSortedSet { static final RegularImmutableSortedSet NATURAL_EMPTY_SET = new RegularImmutableSortedSet<>(ImmutableList.of(), Ordering.natural()); diff --git a/guava/src/com/google/common/collect/ReverseNaturalOrdering.java b/guava/src/com/google/common/collect/ReverseNaturalOrdering.java index 93513e3c9ab3..612d846a7727 100644 --- a/guava/src/com/google/common/collect/ReverseNaturalOrdering.java +++ b/guava/src/com/google/common/collect/ReverseNaturalOrdering.java @@ -24,7 +24,7 @@ /** An ordering that uses the reverse of the natural order of the values. */ @GwtCompatible(serializable = true) -@SuppressWarnings("unchecked") // TODO(kevinb): the right way to explain this?? +@SuppressWarnings({"unchecked", "rawtypes"}) // TODO(kevinb): the right way to explain this?? final class ReverseNaturalOrdering extends Ordering implements Serializable { static final ReverseNaturalOrdering INSTANCE = new ReverseNaturalOrdering(); diff --git a/guava/src/com/google/common/io/ByteStreams.java b/guava/src/com/google/common/io/ByteStreams.java index 25111a77a54b..b2b017bd8267 100644 --- a/guava/src/com/google/common/io/ByteStreams.java +++ b/guava/src/com/google/common/io/ByteStreams.java @@ -488,7 +488,6 @@ public static ByteArrayDataOutput newDataOutput(ByteArrayOutputStream byteArrayO return new ByteArrayDataOutputStream(checkNotNull(byteArrayOutputSteam)); } - @SuppressWarnings("deprecation") // for writeBytes private static class ByteArrayDataOutputStream implements ByteArrayDataOutput { final DataOutput output; diff --git a/guava/src/com/google/common/io/MoreFiles.java b/guava/src/com/google/common/io/MoreFiles.java index dedcb10251f0..364d5c651878 100644 --- a/guava/src/com/google/common/io/MoreFiles.java +++ b/guava/src/com/google/common/io/MoreFiles.java @@ -26,7 +26,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.graph.SuccessorsFunction; import com.google.common.graph.Traverser; -import com.google.common.io.ByteSource.AsCharSource; import com.google.j2objc.annotations.J2ObjCIncompatible; import java.io.IOException; import java.io.InputStream; From 7809097021927058b21523e7b4d24d1f7fdb91b8 Mon Sep 17 00:00:00 2001 From: cushon Date: Thu, 31 Jan 2019 17:50:36 -0800 Subject: [PATCH 03/23] Reformat with google-java-format RELNOTES=N/A ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=231889594 --- .../AbstractMultisetSetCountTester.java | 5 +- .../testers/CollectionAddAllTester.java | 5 +- .../testing/testers/CollectionAddTester.java | 5 +- .../src/com/google/common/base/Splitter.java | 1 + .../collect/AbstractMapBasedMultimap.java | 6 +- .../common/collect/BaseImmutableMultimap.java | 4 +- .../google/common/collect/CompactHashMap.java | 4 +- .../google/common/collect/CompactHashSet.java | 4 +- .../common/collect/CompactLinkedHashMap.java | 14 +- .../common/collect/CompactLinkedHashSet.java | 19 +- .../google/common/collect/HashMultiset.java | 13 - .../google/common/collect/ImmutableList.java | 3 +- .../google/common/collect/ImmutableSet.java | 3 +- .../common/collect/ImmutableSetMultimap.java | 2 +- .../common/collect/MultimapBuilder.java | 18 +- .../com/google/common/collect/Multimaps.java | 4 +- .../google/common/graph/AbstractNetwork.java | 4 +- .../common/graph/MutableValueGraph.java | 4 +- .../com/google/common/graph/Traverser.java | 5 +- .../google/common/hash/MacHashFunction.java | 2 + .../hash/MessageDigestHashFunction.java | 1 + .../src/com/google/common/io/ByteStreams.java | 6 +- .../com/google/common/math/PairedStats.java | 3 +- .../com/google/common/net/HttpHeaders.java | 3 +- .../com/google/common/net/InetAddresses.java | 2 +- .../primitives/ImmutableDoubleArray.java | 3 +- .../common/primitives/ImmutableIntArray.java | 3 +- .../common/primitives/ImmutableLongArray.java | 3 +- .../google/common/reflect/TypeResolver.java | 17 +- .../com/google/common/reflect/TypeToken.java | 39 +-- .../util/concurrent/AbstractService.java | 4 +- .../common/util/concurrent/ExecutionList.java | 3 +- .../util/concurrent/InterruptibleTask.java | 4 +- .../common/util/concurrent/Monitor.java | 3 +- .../common/util/concurrent/Striped.java | 18 +- .../common/collect/ImmutableCollection.java | 2 +- .../super/java/lang/InterruptedException.java | 6 +- .../concurrent/CancellationException.java | 4 +- .../util/concurrent/ConcurrentHashMap.java | 29 +- .../super/java/util/concurrent/Delayed.java | 6 +- .../util/concurrent/ExecutionException.java | 2 +- .../super/java/util/concurrent/Executor.java | 6 +- .../super/java/util/concurrent/Executors.java | 7 +- .../super/java/util/concurrent/Future.java | 12 +- .../RejectedExecutionException.java | 7 +- .../java/util/concurrent/RunnableFuture.java | 7 +- .../java/util/concurrent/ScheduledFuture.java | 3 +- .../super/java/util/concurrent/TimeUnit.java | 279 ++++++++++++++---- .../util/concurrent/TimeoutException.java | 4 +- .../util/concurrent/atomic/AtomicBoolean.java | 20 +- .../util/concurrent/atomic/AtomicInteger.java | 10 +- .../util/concurrent/atomic/AtomicLong.java | 10 +- .../AbstractMultisetSetCountTester.java | 5 +- .../testers/CollectionAddAllTester.java | 5 +- .../testing/testers/CollectionAddTester.java | 5 +- guava/src/com/google/common/base/Objects.java | 2 +- .../com/google/common/base/Preconditions.java | 6 +- guava/src/com/google/common/base/Strings.java | 2 +- guava/src/com/google/common/base/Verify.java | 4 +- .../com/google/common/cache/LocalCache.java | 6 +- .../collect/AbstractMapBasedMultimap.java | 6 +- .../common/collect/BaseImmutableMultimap.java | 4 +- .../google/common/collect/CompactHashMap.java | 8 +- .../google/common/collect/CompactHashSet.java | 4 +- .../common/collect/CompactLinkedHashMap.java | 18 +- .../common/collect/CompactLinkedHashSet.java | 25 +- .../google/common/collect/ImmutableList.java | 3 +- .../google/common/collect/ImmutableSet.java | 3 +- .../common/collect/ImmutableSetMultimap.java | 2 +- .../common/collect/MultimapBuilder.java | 18 +- .../com/google/common/collect/Multimaps.java | 4 +- .../google/common/graph/AbstractNetwork.java | 4 +- .../common/graph/MutableValueGraph.java | 4 +- .../com/google/common/graph/Traverser.java | 5 +- .../com/google/common/graph/ValueGraph.java | 4 +- .../google/common/hash/MacHashFunction.java | 2 + .../hash/MessageDigestHashFunction.java | 1 + .../src/com/google/common/io/ByteStreams.java | 6 +- .../com/google/common/math/PairedStats.java | 3 +- .../com/google/common/net/HttpHeaders.java | 3 +- .../com/google/common/net/InetAddresses.java | 2 +- .../primitives/ImmutableDoubleArray.java | 3 +- .../common/primitives/ImmutableIntArray.java | 3 +- .../common/primitives/ImmutableLongArray.java | 3 +- .../google/common/reflect/TypeResolver.java | 17 +- .../com/google/common/reflect/TypeToken.java | 39 +-- .../util/concurrent/AbstractService.java | 4 +- .../util/concurrent/InterruptibleTask.java | 4 +- .../common/util/concurrent/Striped.java | 18 +- 89 files changed, 507 insertions(+), 399 deletions(-) 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 68c270bde864..a72fd9fba5e8 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 @@ -315,9 +315,8 @@ public void testSetCount_removeNull_nullSupported() { } @CollectionFeature.Require( - value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, - absent = RESTRICTS_ELEMENTS - ) + value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, + absent = RESTRICTS_ELEMENTS) public void testSetCount_addNull_nullSupported() { assertSetCount(null, 1); } diff --git a/android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddAllTester.java b/android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddAllTester.java index 2b95dc99898c..5c21c9a93137 100644 --- a/android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddAllTester.java +++ b/android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddAllTester.java @@ -128,9 +128,8 @@ public void testAddAll_unsupportedAllPresent() { } @CollectionFeature.Require( - value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, - absent = RESTRICTS_ELEMENTS - ) + value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, + absent = RESTRICTS_ELEMENTS) public void testAddAll_nullSupported() { List containsNull = singletonList(null); assertTrue("addAll(containsNull) should return true", collection.addAll(containsNull)); diff --git a/android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddTester.java b/android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddTester.java index 7845e7d06354..bed257c97675 100644 --- a/android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddTester.java +++ b/android/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddTester.java @@ -72,9 +72,8 @@ public void testAdd_unsupportedPresent() { } @CollectionFeature.Require( - value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, - absent = RESTRICTS_ELEMENTS - ) + value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, + absent = RESTRICTS_ELEMENTS) public void testAdd_nullSupported() { assertTrue("add(null) should return true", collection.add(null)); expectAdded((E) null); diff --git a/android/guava/src/com/google/common/base/Splitter.java b/android/guava/src/com/google/common/base/Splitter.java index 6ee00988349e..d82b1de82ba0 100644 --- a/android/guava/src/com/google/common/base/Splitter.java +++ b/android/guava/src/com/google/common/base/Splitter.java @@ -452,6 +452,7 @@ public MapSplitter withKeyValueSeparator(char separator) { * does not change the behavior of the {@code keyValueSplitter}. * *

Example: + * *

{@code
    * String toSplit = " x -> y, z-> a ";
    * Splitter outerSplitter = Splitter.on(',').trimResults();
diff --git a/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java b/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
index d9f4ce1a386e..bd39a75587a6 100644
--- a/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
+++ b/android/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java
@@ -891,7 +891,7 @@ private class RandomAccessWrappedList extends WrappedList implements RandomAcces
   Set createKeySet() {
     return new KeySet(map);
   }
-  
+
   final Set createMaybeNavigableKeySet() {
     if (map instanceof NavigableMap) {
       return new NavigableKeySet((NavigableMap>) map);
@@ -1200,7 +1200,7 @@ Multiset createKeys() {
   public Collection> entries() {
     return super.entries();
   }
-  
+
   @Override
   Collection> createEntries() {
     if (this instanceof SetMultimap) {
@@ -1232,7 +1232,7 @@ Entry output(K key, V value) {
   Map> createAsMap() {
     return new AsMap(map);
   }
-  
+
   final Map> createMaybeNavigableAsMap() {
     if (map instanceof NavigableMap) {
       return new NavigableAsMap((NavigableMap>) map);
diff --git a/android/guava/src/com/google/common/collect/BaseImmutableMultimap.java b/android/guava/src/com/google/common/collect/BaseImmutableMultimap.java
index 456d06ae9a0d..6ebdf14f52fa 100644
--- a/android/guava/src/com/google/common/collect/BaseImmutableMultimap.java
+++ b/android/guava/src/com/google/common/collect/BaseImmutableMultimap.java
@@ -18,8 +18,8 @@
 import com.google.common.annotations.GwtCompatible;
 
 /**
- * A dummy superclass of {@link ImmutableMultimap} that can be instanceof'd without ProGuard retaining
- * additional implementation details of {@link ImmutableMultimap}.
+ * A dummy superclass of {@link ImmutableMultimap} that can be instanceof'd without ProGuard
+ * retaining additional implementation details of {@link ImmutableMultimap}.
  */
 @GwtCompatible
 abstract class BaseImmutableMultimap extends AbstractMultimap {}
diff --git a/android/guava/src/com/google/common/collect/CompactHashMap.java b/android/guava/src/com/google/common/collect/CompactHashMap.java
index 76384471cb95..1987470a316c 100644
--- a/android/guava/src/com/google/common/collect/CompactHashMap.java
+++ b/android/guava/src/com/google/common/collect/CompactHashMap.java
@@ -61,8 +61,8 @@
  *
  * 

This class should not be assumed to be universally superior to {@code java.util.HashMap}. * Generally speaking, this class reduces object allocation and memory consumption at the price of - * moderately increased constant factors of CPU. Only use this class when there is a specific - * reason to prioritize memory over CPU. + * moderately increased constant factors of CPU. Only use this class when there is a specific reason + * to prioritize memory over CPU. * * @author Louis Wasserman */ diff --git a/android/guava/src/com/google/common/collect/CompactHashSet.java b/android/guava/src/com/google/common/collect/CompactHashSet.java index 463b78d7e57d..a363e58e671c 100644 --- a/android/guava/src/com/google/common/collect/CompactHashSet.java +++ b/android/guava/src/com/google/common/collect/CompactHashSet.java @@ -58,8 +58,8 @@ * *

This class should not be assumed to be universally superior to {@code java.util.HashSet}. * Generally speaking, this class reduces object allocation and memory consumption at the price of - * moderately increased constant factors of CPU. Only use this class when there is a specific - * reason to prioritize memory over CPU. + * moderately increased constant factors of CPU. Only use this class when there is a specific reason + * to prioritize memory over CPU. * * @author Dimitris Andreou */ diff --git a/android/guava/src/com/google/common/collect/CompactLinkedHashMap.java b/android/guava/src/com/google/common/collect/CompactLinkedHashMap.java index 02ca3d44e7e8..c90c9df40413 100644 --- a/android/guava/src/com/google/common/collect/CompactLinkedHashMap.java +++ b/android/guava/src/com/google/common/collect/CompactLinkedHashMap.java @@ -44,20 +44,18 @@ class CompactLinkedHashMap extends CompactHashMap { // TODO(lowasser): implement removeEldestEntry so this can be used as a drop-in replacement - /** - * Creates an empty {@code CompactLinkedHashMap} instance. - */ + /** Creates an empty {@code CompactLinkedHashMap} instance. */ public static CompactLinkedHashMap create() { return new CompactLinkedHashMap<>(); } /** - * Creates a {@code CompactLinkedHashMap} instance, with a high enough "initial capacity" - * that it should hold {@code expectedSize} elements without growth. + * Creates a {@code CompactLinkedHashMap} instance, with a high enough "initial capacity" that it + * should hold {@code expectedSize} elements without growth. * * @param expectedSize the number of elements you expect to add to the returned set * @return a new, empty {@code CompactLinkedHashMap} with enough capacity to hold {@code - * expectedSize} elements without resizing + * expectedSize} elements without resizing * @throws IllegalArgumentException if {@code expectedSize} is negative */ public static CompactLinkedHashMap createWithExpectedSize(int expectedSize) { @@ -80,9 +78,7 @@ public static CompactLinkedHashMap createWithExpectedSize(int expec /** Pointer to the first node in the linked list, or {@code ENDPOINT} if there are no entries. */ private transient int firstEntry; - /** - * Pointer to the last node in the linked list, or {@code ENDPOINT} if there are no entries. - */ + /** Pointer to the last node in the linked list, or {@code ENDPOINT} if there are no entries. */ private transient int lastEntry; private final boolean accessOrder; diff --git a/android/guava/src/com/google/common/collect/CompactLinkedHashSet.java b/android/guava/src/com/google/common/collect/CompactLinkedHashSet.java index 30e861db120b..70ac3cc0cf94 100644 --- a/android/guava/src/com/google/common/collect/CompactLinkedHashSet.java +++ b/android/guava/src/com/google/common/collect/CompactLinkedHashSet.java @@ -46,16 +46,14 @@ @GwtIncompatible // not worth using in GWT for now class CompactLinkedHashSet extends CompactHashSet { - /** - * Creates an empty {@code CompactLinkedHashSet} instance. - */ + /** Creates an empty {@code CompactLinkedHashSet} instance. */ public static CompactLinkedHashSet create() { return new CompactLinkedHashSet(); } /** - * Creates a mutable {@code CompactLinkedHashSet} instance containing the elements - * of the given collection in the order returned by the collection's iterator. + * Creates a mutable {@code CompactLinkedHashSet} instance containing the elements of the + * given collection in the order returned by the collection's iterator. * * @param collection the elements that the set should contain * @return a new {@code CompactLinkedHashSet} containing those elements (minus duplicates) @@ -67,8 +65,8 @@ public static CompactLinkedHashSet create(Collection collect } /** - * Creates a {@code CompactLinkedHashSet} instance containing the given elements in - * unspecified order. + * Creates a {@code CompactLinkedHashSet} instance containing the given elements in unspecified + * order. * * @param elements the elements that the set should contain * @return a new {@code CompactLinkedHashSet} containing those elements (minus duplicates) @@ -80,13 +78,12 @@ public static CompactLinkedHashSet create(E... elements) { } /** - * Creates a {@code CompactLinkedHashSet} instance, with a high enough "initial capacity" - * that it should hold {@code expectedSize} elements without rebuilding internal - * data structures. + * Creates a {@code CompactLinkedHashSet} instance, with a high enough "initial capacity" that it + * should hold {@code expectedSize} elements without rebuilding internal data structures. * * @param expectedSize the number of elements you expect to add to the returned set * @return a new, empty {@code CompactLinkedHashSet} with enough capacity to hold {@code - * expectedSize} elements without resizing + * expectedSize} elements without resizing * @throws IllegalArgumentException if {@code expectedSize} is negative */ public static CompactLinkedHashSet createWithExpectedSize(int expectedSize) { diff --git a/android/guava/src/com/google/common/collect/HashMultiset.java b/android/guava/src/com/google/common/collect/HashMultiset.java index c5b8bcb4d543..a78c6915e26c 100644 --- a/android/guava/src/com/google/common/collect/HashMultiset.java +++ b/android/guava/src/com/google/common/collect/HashMultiset.java @@ -16,21 +16,8 @@ package com.google.common.collect; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.collect.CollectPreconditions.checkNonnegative; - import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; -import com.google.common.primitives.Ints; -import com.google.errorprone.annotations.CanIgnoreReturnValue; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.NoSuchElementException; -import org.checkerframework.checker.nullness.compatqual.NullableDecl; /** * Multiset implementation that uses hashing for key and entry access. diff --git a/android/guava/src/com/google/common/collect/ImmutableList.java b/android/guava/src/com/google/common/collect/ImmutableList.java index ddb53701d2a2..c61531f6e26a 100644 --- a/android/guava/src/com/google/common/collect/ImmutableList.java +++ b/android/guava/src/com/google/common/collect/ImmutableList.java @@ -185,8 +185,7 @@ public static ImmutableList of( public static ImmutableList of( E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11, E e12, E... others) { checkArgument( - others.length <= Integer.MAX_VALUE - 12, - "the total number of elements must fit in an int"); + others.length <= Integer.MAX_VALUE - 12, "the total number of elements must fit in an int"); Object[] array = new Object[12 + others.length]; array[0] = e1; array[1] = e2; diff --git a/android/guava/src/com/google/common/collect/ImmutableSet.java b/android/guava/src/com/google/common/collect/ImmutableSet.java index 9be1c36cdfdf..366223c49cd3 100644 --- a/android/guava/src/com/google/common/collect/ImmutableSet.java +++ b/android/guava/src/com/google/common/collect/ImmutableSet.java @@ -112,8 +112,7 @@ public static ImmutableSet of(E e1, E e2, E e3, E e4, E e5) { @SafeVarargs // For Eclipse. For internal javac we have disabled this pointless type of warning. public static ImmutableSet of(E e1, E e2, E e3, E e4, E e5, E e6, E... others) { checkArgument( - others.length <= Integer.MAX_VALUE - 6, - "the total number of elements must fit in an int"); + others.length <= Integer.MAX_VALUE - 6, "the total number of elements must fit in an int"); final int paramCount = 6; Object[] elements = new Object[paramCount + others.length]; elements[0] = e1; diff --git a/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java b/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java index 32a3459e1166..fc85c186ed87 100644 --- a/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java +++ b/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java @@ -491,7 +491,7 @@ Comparator valueComparator() { ? ((ImmutableSortedSet) emptySet).comparator() : null; } - + @GwtIncompatible // java serialization private static final class SetFieldSettersHolder { static final Serialization.FieldSetter EMPTY_SET_FIELD_SETTER = diff --git a/android/guava/src/com/google/common/collect/MultimapBuilder.java b/android/guava/src/com/google/common/collect/MultimapBuilder.java index 8d9521ef5b1e..482385e50a25 100644 --- a/android/guava/src/com/google/common/collect/MultimapBuilder.java +++ b/android/guava/src/com/google/common/collect/MultimapBuilder.java @@ -79,8 +79,8 @@ public static MultimapBuilderWithKeys hashKeys() { } /** - * Uses a hash table to map keys to value collections, initialized to expect the specified - * number of keys. + * Uses a hash table to map keys to value collections, initialized to expect the specified number + * of keys. * * @throws IllegalArgumentException if {@code expectedKeys < 0} */ @@ -107,8 +107,8 @@ public static MultimapBuilderWithKeys linkedHashKeys() { } /** - * Uses an hash table to map keys to value collections, initialized to expect the - * specified number of keys. + * Uses an hash table to map keys to value collections, initialized to expect the specified number + * of keys. * *

The collections returned by {@link Multimap#keySet()}, {@link Multimap#keys()}, and {@link * Multimap#asMap()} will iterate through the keys in the order that they were first added to the @@ -223,7 +223,7 @@ public Set get() { return Platform.newHashSetWithExpectedSize(expectedValuesPerKey); } } - + private static final class LinkedHashSetSupplier implements Supplier>, Serializable { private final int expectedValuesPerKey; @@ -319,8 +319,8 @@ public SetMultimapBuilder hashSetValues() { } /** - * Uses a hash-based {@code Set} to store value collections, initialized to expect the specified number - * of values per key. + * Uses a hash-based {@code Set} to store value collections, initialized to expect the specified + * number of values per key. * * @throws IllegalArgumentException if {@code expectedValuesPerKey < 0} */ @@ -342,8 +342,8 @@ public SetMultimapBuilder linkedHashSetValues() { } /** - * Uses an insertion-ordered hash-based {@code Set} to store value collections, initialized to expect the specified - * number of values per key. + * Uses an insertion-ordered hash-based {@code Set} to store value collections, initialized to + * expect the specified number of values per key. * * @throws IllegalArgumentException if {@code expectedValuesPerKey < 0} */ diff --git a/android/guava/src/com/google/common/collect/Multimaps.java b/android/guava/src/com/google/common/collect/Multimaps.java index 5c8e16c5e325..c0d921e4fba1 100644 --- a/android/guava/src/com/google/common/collect/Multimaps.java +++ b/android/guava/src/com/google/common/collect/Multimaps.java @@ -1100,7 +1100,7 @@ Collection createValues() { public Set> entries() { return map.entrySet(); } - + @Override Collection> createEntries() { throw new AssertionError("unreachable"); @@ -1374,7 +1374,7 @@ public void clear() { public boolean containsKey(Object key) { return fromMultimap.containsKey(key); } - + @Override Collection> createEntries() { return new Entries(); diff --git a/android/guava/src/com/google/common/graph/AbstractNetwork.java b/android/guava/src/com/google/common/graph/AbstractNetwork.java index 5b9b5d0a8996..a1c11ced8b59 100644 --- a/android/guava/src/com/google/common/graph/AbstractNetwork.java +++ b/android/guava/src/com/google/common/graph/AbstractNetwork.java @@ -222,8 +222,8 @@ public boolean hasEdgeConnecting(EndpointPair endpoints) { } /** - * Throws an IllegalArgumentException if the ordering of {@code endpoints} is not compatible - * with the directionality of this graph. + * Throws an IllegalArgumentException if the ordering of {@code endpoints} is not compatible with + * the directionality of this graph. */ protected final void validateEndpoints(EndpointPair endpoints) { checkNotNull(endpoints); diff --git a/android/guava/src/com/google/common/graph/MutableValueGraph.java b/android/guava/src/com/google/common/graph/MutableValueGraph.java index baa883ae18e8..f4d7376f4d94 100644 --- a/android/guava/src/com/google/common/graph/MutableValueGraph.java +++ b/android/guava/src/com/google/common/graph/MutableValueGraph.java @@ -42,8 +42,8 @@ public interface MutableValueGraph extends ValueGraph { boolean addNode(N node); /** - * Adds an edge connecting {@code nodeU} to {@code nodeV} if one is not already present, and - * sets a value for that edge to {@code value} (overwriting the existing value, if any). + * Adds an edge connecting {@code nodeU} to {@code nodeV} if one is not already present, and sets + * a value for that edge to {@code value} (overwriting the existing value, if any). * *

If the graph is directed, the resultant edge will be directed; otherwise, it will be * undirected. diff --git a/android/guava/src/com/google/common/graph/Traverser.java b/android/guava/src/com/google/common/graph/Traverser.java index 9db2431dacd3..713e54b05b5b 100644 --- a/android/guava/src/com/google/common/graph/Traverser.java +++ b/android/guava/src/com/google/common/graph/Traverser.java @@ -41,9 +41,8 @@ * based on your answers to the following questions: * *

    - *
  1. Is there only one path to any node that's reachable from any start node? (If so, the - * graph to be traversed is a tree or forest even if it is a subgraph of a graph which is - * neither.) + *
  2. Is there only one path to any node that's reachable from any start node? (If so, the graph + * to be traversed is a tree or forest even if it is a subgraph of a graph which is neither.) *
  3. Are the node objects' implementations of {@code equals()}/{@code hashCode()} recursive? *
diff --git a/android/guava/src/com/google/common/hash/MacHashFunction.java b/android/guava/src/com/google/common/hash/MacHashFunction.java index 2f6db2eda532..ed1841c36b18 100644 --- a/android/guava/src/com/google/common/hash/MacHashFunction.java +++ b/android/guava/src/com/google/common/hash/MacHashFunction.java @@ -34,8 +34,10 @@ final class MacHashFunction extends AbstractHashFunction { @SuppressWarnings("Immutable") // cloned before each use private final Mac prototype; + @SuppressWarnings("Immutable") // keys are immutable, but not provably so private final Key key; + private final String toString; private final int bits; private final boolean supportsClone; diff --git a/android/guava/src/com/google/common/hash/MessageDigestHashFunction.java b/android/guava/src/com/google/common/hash/MessageDigestHashFunction.java index 68d41d7ce629..5c48c7d7f3ab 100644 --- a/android/guava/src/com/google/common/hash/MessageDigestHashFunction.java +++ b/android/guava/src/com/google/common/hash/MessageDigestHashFunction.java @@ -36,6 +36,7 @@ final class MessageDigestHashFunction extends AbstractHashFunction implements Se @SuppressWarnings("Immutable") // cloned before each use private final MessageDigest prototype; + private final int bytes; private final boolean supportsClone; private final String toString; diff --git a/android/guava/src/com/google/common/io/ByteStreams.java b/android/guava/src/com/google/common/io/ByteStreams.java index b2b017bd8267..510947ef0e17 100644 --- a/android/guava/src/com/google/common/io/ByteStreams.java +++ b/android/guava/src/com/google/common/io/ByteStreams.java @@ -171,8 +171,8 @@ private static byte[] toByteArrayInternal(InputStream in, Deque bufs, in // in a deque so that there's no copying between buffers while reading and so all of the bytes // in each new allocated buffer are available for reading from the stream. for (int bufSize = BUFFER_SIZE; - totalLen < MAX_ARRAY_LEN; - bufSize = IntMath.saturatedMultiply(bufSize, 2)) { + totalLen < MAX_ARRAY_LEN; + bufSize = IntMath.saturatedMultiply(bufSize, 2)) { byte[] buf = new byte[Math.min(bufSize, MAX_ARRAY_LEN - totalLen)]; bufs.add(buf); int off = 0; @@ -255,7 +255,7 @@ static byte[] toByteArray(InputStream in, long expectedSize) throws IOException // the stream was longer, so read the rest normally Deque bufs = new ArrayDeque(TO_BYTE_ARRAY_DEQUE_SIZE + 2); bufs.add(bytes); - bufs.add(new byte[] { (byte) b }); + bufs.add(new byte[] {(byte) b}); return toByteArrayInternal(in, bufs, bytes.length + 1); } diff --git a/android/guava/src/com/google/common/math/PairedStats.java b/android/guava/src/com/google/common/math/PairedStats.java index 91bad4aa448a..a636e51d3160 100644 --- a/android/guava/src/com/google/common/math/PairedStats.java +++ b/android/guava/src/com/google/common/math/PairedStats.java @@ -223,8 +223,7 @@ public boolean equals(@NullableDecl Object obj) { PairedStats other = (PairedStats) obj; return xStats.equals(other.xStats) && yStats.equals(other.yStats) - && doubleToLongBits(sumOfProductsOfDeltas) - == doubleToLongBits(other.sumOfProductsOfDeltas); + && doubleToLongBits(sumOfProductsOfDeltas) == doubleToLongBits(other.sumOfProductsOfDeltas); } /** diff --git a/android/guava/src/com/google/common/net/HttpHeaders.java b/android/guava/src/com/google/common/net/HttpHeaders.java index 5864bbe67baa..ae18f189f458 100644 --- a/android/guava/src/com/google/common/net/HttpHeaders.java +++ b/android/guava/src/com/google/common/net/HttpHeaders.java @@ -374,8 +374,7 @@ private ReferrerPolicyValues() {} * * @since 24.1 */ - @Beta - public static final String X_DOWNLOAD_OPTIONS = "X-Download-Options"; + @Beta public static final String X_DOWNLOAD_OPTIONS = "X-Download-Options"; /** The HTTP {@code X-XSS-Protection} header field name. */ public static final String X_XSS_PROTECTION = "X-XSS-Protection"; /** diff --git a/android/guava/src/com/google/common/net/InetAddresses.java b/android/guava/src/com/google/common/net/InetAddresses.java index 06cc5bc96547..40f74747eb78 100644 --- a/android/guava/src/com/google/common/net/InetAddresses.java +++ b/android/guava/src/com/google/common/net/InetAddresses.java @@ -235,7 +235,7 @@ private static byte[] textToNumericFormatV6(String ipString) { if (parts.get(0).length() == 0 && --partsHi != 0) { return null; // ^: requires ^:: } - if (Iterables.getLast(parts).length() == 0 && --partsLo != 0) { + if (Iterables.getLast(parts).length() == 0 && --partsLo != 0) { return null; // :$ requires ::$ } } else { diff --git a/android/guava/src/com/google/common/primitives/ImmutableDoubleArray.java b/android/guava/src/com/google/common/primitives/ImmutableDoubleArray.java index 550382653d53..b3d1dbbf0281 100644 --- a/android/guava/src/com/google/common/primitives/ImmutableDoubleArray.java +++ b/android/guava/src/com/google/common/primitives/ImmutableDoubleArray.java @@ -130,8 +130,7 @@ public static ImmutableDoubleArray of( // is okay since we have to copy the just-created array anyway. public static ImmutableDoubleArray of(double first, double... rest) { checkArgument( - rest.length <= Integer.MAX_VALUE - 1, - "the total number of elements must fit in an int"); + rest.length <= Integer.MAX_VALUE - 1, "the total number of elements must fit in an int"); double[] array = new double[rest.length + 1]; array[0] = first; System.arraycopy(rest, 0, array, 1, rest.length); diff --git a/android/guava/src/com/google/common/primitives/ImmutableIntArray.java b/android/guava/src/com/google/common/primitives/ImmutableIntArray.java index 333973da3a31..9dfaf71221e3 100644 --- a/android/guava/src/com/google/common/primitives/ImmutableIntArray.java +++ b/android/guava/src/com/google/common/primitives/ImmutableIntArray.java @@ -129,8 +129,7 @@ public static ImmutableIntArray of(int e0, int e1, int e2, int e3, int e4, int e // okay since we have to copy the just-created array anyway. public static ImmutableIntArray of(int first, int... rest) { checkArgument( - rest.length <= Integer.MAX_VALUE - 1, - "the total number of elements must fit in an int"); + rest.length <= Integer.MAX_VALUE - 1, "the total number of elements must fit in an int"); int[] array = new int[rest.length + 1]; array[0] = first; System.arraycopy(rest, 0, array, 1, rest.length); diff --git a/android/guava/src/com/google/common/primitives/ImmutableLongArray.java b/android/guava/src/com/google/common/primitives/ImmutableLongArray.java index 3f0033c3e747..e43a7cb2cc26 100644 --- a/android/guava/src/com/google/common/primitives/ImmutableLongArray.java +++ b/android/guava/src/com/google/common/primitives/ImmutableLongArray.java @@ -129,8 +129,7 @@ public static ImmutableLongArray of(long e0, long e1, long e2, long e3, long e4, // okay since we have to copy the just-created array anyway. public static ImmutableLongArray of(long first, long... rest) { checkArgument( - rest.length <= Integer.MAX_VALUE - 1, - "the total number of elements must fit in an int"); + rest.length <= Integer.MAX_VALUE - 1, "the total number of elements must fit in an int"); long[] array = new long[rest.length + 1]; array[0] = first; System.arraycopy(rest, 0, array, 1, rest.length); diff --git a/android/guava/src/com/google/common/reflect/TypeResolver.java b/android/guava/src/com/google/common/reflect/TypeResolver.java index b5880f537533..0c18a1dbee07 100644 --- a/android/guava/src/com/google/common/reflect/TypeResolver.java +++ b/android/guava/src/com/google/common/reflect/TypeResolver.java @@ -66,10 +66,10 @@ private TypeResolver(TypeTable typeTable) { /** * Returns a resolver that resolves types "covariantly". - *

For example, when resolving {@code List} in the context of {@code ArrayList}, - * {@code } is covariantly resolved to {@code } such that return type of {@code List::get} - * is {@code }. * + *

For example, when resolving {@code List} in the context of {@code ArrayList}, {@code + * } is covariantly resolved to {@code } such that return type of {@code List::get} is + * {@code }. */ static TypeResolver covariantly(Type contextType) { return new TypeResolver().where(TypeMappingIntrospector.getTypeMappings(contextType)); @@ -78,14 +78,13 @@ static TypeResolver covariantly(Type contextType) { /** * Returns a resolver that resolves types "invariantly". * - *

For example, when resolving {@code List} in the context of {@code ArrayList}, - * {@code } cannot be invariantly resolved to {@code } because otherwise the parameter type - * of {@code List::set} will be {@code } and it'll falsely say any object can be passed into + *

For example, when resolving {@code List} in the context of {@code ArrayList}, {@code + * } cannot be invariantly resolved to {@code } because otherwise the parameter type of + * {@code List::set} will be {@code } and it'll falsely say any object can be passed into * {@code ArrayList::set}. * - *

Instead, {@code } will be resolved to a capture in the form of a type variable - * {@code }, effectively preventing {@code set} from accepting any - * type. + *

Instead, {@code } will be resolved to a capture in the form of a type variable {@code + * }, effectively preventing {@code set} from accepting any type. */ static TypeResolver invariantly(Type contextType) { Type invariantContext = WildcardCapturer.INSTANCE.capture(contextType); diff --git a/android/guava/src/com/google/common/reflect/TypeToken.java b/android/guava/src/com/google/common/reflect/TypeToken.java index 73bec0b5d3e7..664ab4af4593 100644 --- a/android/guava/src/com/google/common/reflect/TypeToken.java +++ b/android/guava/src/com/google/common/reflect/TypeToken.java @@ -947,26 +947,27 @@ private boolean isSupertypeOfArray(GenericArrayType subtype) { * {@code A.is(B)} is defined as {@code Foo.isSubtypeOf(Foo)}. * *

Specifically, returns true if any of the following conditions is met: + * *

    *
  1. 'this' and {@code formalType} are equal. *
  2. 'this' and {@code formalType} have equal canonical form. *
  3. {@code formalType} is {@code } and 'this' is a subtype of {@code Foo}. *
  4. {@code formalType} is {@code } and 'this' is a supertype of {@code Foo}. *
- * Note that condition 2 isn't technically accurate under the context of a recursively - * bounded type variables. For example, {@code Enum>} canonicalizes to - * {@code Enum} where {@code E} is the type variable declared on the {@code Enum} class - * declaration. It's technically not true that {@code Foo>>} is a - * subtype of {@code Foo>} according to JLS. See testRecursiveWildcardSubtypeBug() for - * a real example. + * + * Note that condition 2 isn't technically accurate under the context of a recursively bounded + * type variables. For example, {@code Enum>} canonicalizes to {@code Enum} + * where {@code E} is the type variable declared on the {@code Enum} class declaration. It's + * technically not true that {@code Foo>>} is a subtype of {@code + * Foo>} according to JLS. See testRecursiveWildcardSubtypeBug() for a real example. * *

It appears that properly handling recursive type bounds in the presence of implicit type * bounds is not easy. For now we punt, hoping that this defect should rarely cause issues in real * code. * * @param formalType is {@code Foo} a supertype of {@code Foo}? - * @param declaration The type variable in the context of a parameterized type. Used to infer - * type bound when {@code formalType} is a wildcard with implicit upper bound. + * @param declaration The type variable in the context of a parameterized type. Used to infer type + * bound when {@code formalType} is a wildcard with implicit upper bound. */ private boolean is(Type formalType, TypeVariable declaration) { if (runtimeType.equals(formalType)) { @@ -982,8 +983,7 @@ private boolean is(Type formalType, TypeVariable declaration) { return every(your.getUpperBounds()).isSupertypeOf(runtimeType) && every(your.getLowerBounds()).isSubtypeOf(runtimeType); } - return canonicalizeWildcardsInType(runtimeType) - .equals(canonicalizeWildcardsInType(formalType)); + return canonicalizeWildcardsInType(runtimeType).equals(canonicalizeWildcardsInType(formalType)); } /** @@ -991,16 +991,17 @@ private boolean is(Type formalType, TypeVariable declaration) { * is defined as {@code Foo}. Thus directly calling {@code .is(String.class)} * will return false. To mitigate, we canonicalize wildcards by enforcing the following * invariants: + * *

*/ private static Type canonicalizeTypeArg(TypeVariable declaration, Type typeArg) { diff --git a/android/guava/src/com/google/common/util/concurrent/AbstractService.java b/android/guava/src/com/google/common/util/concurrent/AbstractService.java index bc5bf9b1f73b..362a530a8251 100644 --- a/android/guava/src/com/google/common/util/concurrent/AbstractService.java +++ b/android/guava/src/com/google/common/util/concurrent/AbstractService.java @@ -230,8 +230,8 @@ protected AbstractService() {} * convenient. It is invoked exactly once on service shutdown, even when {@link #stopAsync} is * called multiple times. * - *

When this method is called {@link #state()} will return {@link State#STOPPING}, which - * is the external state observable by the caller of {@link #stopAsync}. + *

When this method is called {@link #state()} will return {@link State#STOPPING}, which is the + * external state observable by the caller of {@link #stopAsync}. * * @since 27.0 */ 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 30a0ca8a58da..153f42513794 100644 --- a/android/guava/src/com/google/common/util/concurrent/ExecutionList.java +++ b/android/guava/src/com/google/common/util/concurrent/ExecutionList.java @@ -49,7 +49,8 @@ public final class ExecutionList { * RunnableExecutorPair#next} field. */ @GuardedBy("this") - @NullableDecl private RunnableExecutorPair runnables; + @NullableDecl + private RunnableExecutorPair runnables; @GuardedBy("this") private boolean executed; 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 4ce50ec383e4..acebae4eb4a8 100644 --- a/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java +++ b/android/guava/src/com/google/common/util/concurrent/InterruptibleTask.java @@ -154,8 +154,8 @@ public final void run() { abstract void afterRanInterruptibly(@NullableDecl T result, @NullableDecl Throwable error); /** - * Interrupts the running task. Because this internally calls {@link Thread#interrupt()} which can in turn - * invoke arbitrary code it is not safe to call while holding a lock. + * Interrupts the running task. Because this internally calls {@link Thread#interrupt()} which can + * in turn invoke arbitrary code it is not safe to call while holding a lock. */ final void interruptTask() { // Since the Thread is replaced by DONE before run() invokes listeners or returns, if we succeed 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 2eafee08f9fc..20b2a88e581b 100644 --- a/android/guava/src/com/google/common/util/concurrent/Monitor.java +++ b/android/guava/src/com/google/common/util/concurrent/Monitor.java @@ -310,7 +310,8 @@ public abstract static class Guard { /** The next active guard */ @GuardedBy("monitor.lock") - @NullableDecl Guard next; + @NullableDecl + Guard next; protected Guard(Monitor monitor) { this.monitor = checkNotNull(monitor, "monitor"); diff --git a/android/guava/src/com/google/common/util/concurrent/Striped.java b/android/guava/src/com/google/common/util/concurrent/Striped.java index 1b6652fe0a6f..c9ba77235d5a 100644 --- a/android/guava/src/com/google/common/util/concurrent/Striped.java +++ b/android/guava/src/com/google/common/util/concurrent/Striped.java @@ -184,8 +184,8 @@ public Iterable bulkGet(Iterable keys) { // Static factories /** - * Creates a {@code Striped} with eagerly initialized, strongly referenced locks. Every lock - * is obtained from the passed supplier. + * Creates a {@code Striped} with eagerly initialized, strongly referenced locks. Every lock is + * obtained from the passed supplier. * * @param stripes the minimum number of stripes (locks) required * @param supplier a {@code Supplier} object to obtain locks from @@ -203,12 +203,14 @@ static Striped custom(int stripes, Supplier supplier) { * @return a new {@code Striped} */ public static Striped lock(int stripes) { - return custom(stripes, new Supplier() { - @Override - public Lock get() { - return new PaddedLock(); - } - }); + return custom( + stripes, + new Supplier() { + @Override + public Lock get() { + return new PaddedLock(); + } + }); } /** 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 001b914477f2..c5bdbfdc46c2 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 @@ -125,7 +125,7 @@ public abstract static class Builder { Builder() {} static int expandedCapacity(int oldCapacity, int minCapacity) { - if (minCapacity < 0) { + if (minCapacity < 0) { throw new AssertionError("cannot store more than MAX_VALUE elements"); } // careful of overflow! diff --git a/guava-gwt/src-super/java/lang/super/java/lang/InterruptedException.java b/guava-gwt/src-super/java/lang/super/java/lang/InterruptedException.java index 3592c600cad7..9bfcecec7642 100644 --- a/guava-gwt/src-super/java/lang/super/java/lang/InterruptedException.java +++ b/guava-gwt/src-super/java/lang/super/java/lang/InterruptedException.java @@ -17,9 +17,9 @@ package java.lang; /** - * Minimal emulation of {@link java.lang.InterruptedException}, that should - * only be used in method signatures. New GWT code should not reference this - * class at all. It is here only to ease the GWTification of common code. + * Minimal emulation of {@link java.lang.InterruptedException}, that should only be used in method + * signatures. New GWT code should not reference this class at all. It is here only to ease the + * GWTification of common code. * * @author Tom O'Neill */ diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/CancellationException.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/CancellationException.java index 2fff7131a1f3..29bd332e6bad 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/CancellationException.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/CancellationException.java @@ -16,9 +16,7 @@ package java.util.concurrent; -/** - * Emulation of CancellationException. - */ +/** Emulation of CancellationException. */ public class CancellationException extends IllegalStateException { public CancellationException() {} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/ConcurrentHashMap.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/ConcurrentHashMap.java index 058839ee79ec..7367f04c00a1 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/ConcurrentHashMap.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/ConcurrentHashMap.java @@ -24,16 +24,15 @@ import java.util.Set; /** - * Minimal emulation of {@link java.util.concurrent.ConcurrentHashMap}. - * Note that the javascript interpreter is - * single-threaded, it is essentially a {@link java.util.HashMap}, - * implementing the new methods introduced by {@link ConcurrentMap}. + * single-threaded, it is essentially a {@link java.util.HashMap}, implementing the new methods + * introduced by {@link ConcurrentMap}. * * @author Hayward Chan */ -public class ConcurrentHashMap - extends AbstractMap implements ConcurrentMap { +public class ConcurrentHashMap extends AbstractMap implements ConcurrentMap { private final Map backingMap; @@ -91,42 +90,48 @@ public V replace(K key, V value) { } } - @Override public boolean containsKey(Object key) { + @Override + public boolean containsKey(Object key) { if (key == null) { throw new NullPointerException(); } return backingMap.containsKey(key); } - @Override public V get(Object key) { + @Override + public V get(Object key) { if (key == null) { throw new NullPointerException(); } return backingMap.get(key); } - @Override public V put(K key, V value) { + @Override + public V put(K key, V value) { if (key == null || value == null) { throw new NullPointerException(); } return backingMap.put(key, value); } - @Override public boolean containsValue(Object value) { + @Override + public boolean containsValue(Object value) { if (value == null) { throw new NullPointerException(); } return backingMap.containsValue(value); } - @Override public V remove(Object key) { + @Override + public V remove(Object key) { if (key == null) { throw new NullPointerException(); } return backingMap.remove(key); } - @Override public Set> entrySet() { + @Override + public Set> entrySet() { return backingMap.entrySet(); } diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/Delayed.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/Delayed.java index f8d69a43b93a..4fa57f20280e 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/Delayed.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/Delayed.java @@ -10,9 +10,7 @@ package java.util.concurrent; -/** - * Emulation of Delayed. - */ +/** Emulation of Delayed. */ public interface Delayed extends Comparable { - long getDelay(TimeUnit unit); + long getDelay(TimeUnit unit); } diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/ExecutionException.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/ExecutionException.java index c1fc0f4fce2b..7484438d8943 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/ExecutionException.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/ExecutionException.java @@ -22,7 +22,7 @@ * @author Charles Fry */ public class ExecutionException extends Exception { - protected ExecutionException() { } + protected ExecutionException() {} protected ExecutionException(String message) { super(message); diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/Executor.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/Executor.java index 35fc2468acb3..d74ec076af7a 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/Executor.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/Executor.java @@ -16,9 +16,7 @@ package java.util.concurrent; -/** - * Emulation of Executor. - */ +/** Emulation of Executor. */ public interface Executor { void execute(Runnable command); -} \ No newline at end of file +} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/Executors.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/Executors.java index 09a3e8dc6ce0..afb41e2ea69c 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/Executors.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/Executors.java @@ -10,9 +10,7 @@ package java.util.concurrent; -/** - * Emulation of executors. - */ +/** Emulation of executors. */ public class Executors { public static Callable callable(Runnable task, T result) { @@ -45,6 +43,5 @@ public T call() { } } - private Executors() { - } + private Executors() {} } diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/Future.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/Future.java index f91734c4879f..f52ac619b33e 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/Future.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/Future.java @@ -25,18 +25,18 @@ * @param value type returned by the future. */ public interface Future { - boolean cancel(boolean mayInterruptIfRunning); + boolean cancel(boolean mayInterruptIfRunning); - boolean isCancelled(); + boolean isCancelled(); - boolean isDone(); + boolean isDone(); // Even though the 'get' methods below are blocking, they are the only built-in APIs to get the // result of the {@code Future}, hence they are not removed. The implementation must throw {@link // IllegalStateException} if the {@code Future} is not done yet (see the class javadoc). - V get() throws InterruptedException, ExecutionException; + V get() throws InterruptedException, ExecutionException; - V get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException; + V get(long timeout, TimeUnit unit) + throws InterruptedException, ExecutionException, TimeoutException; } diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/RejectedExecutionException.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/RejectedExecutionException.java index ec7c2da4293c..56a19f7f25f1 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/RejectedExecutionException.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/RejectedExecutionException.java @@ -16,12 +16,9 @@ package java.util.concurrent; -/** - * GWT emulation of RejectedExecutionException. - */ +/** GWT emulation of RejectedExecutionException. */ public class RejectedExecutionException extends RuntimeException { - public RejectedExecutionException() { - } + public RejectedExecutionException() {} public RejectedExecutionException(String message) { super(message); diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/RunnableFuture.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/RunnableFuture.java index 08e266091c34..c33168a491af 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/RunnableFuture.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/RunnableFuture.java @@ -16,8 +16,5 @@ package java.util.concurrent; -/** - * Emulation of RunnableFuture. - */ -public interface RunnableFuture extends Runnable, Future { -} +/** Emulation of RunnableFuture. */ +public interface RunnableFuture extends Runnable, Future {} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/ScheduledFuture.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/ScheduledFuture.java index 5220e0c26b99..5aab49fef93e 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/ScheduledFuture.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/ScheduledFuture.java @@ -15,5 +15,4 @@ * * @param value type returned by the future. */ -public interface ScheduledFuture extends Delayed, Future { -} +public interface ScheduledFuture extends Delayed, Future {} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeUnit.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeUnit.java index df4e1eaa6123..d2966f1a4576 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeUnit.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeUnit.java @@ -11,79 +11,240 @@ package java.util.concurrent; /** - * GWT emulation of TimeUnit, created by removing unsupported operations from - * Doug Lea's public domain version. + * GWT emulation of TimeUnit, created by removing unsupported operations from Doug Lea's public + * domain version. */ public enum TimeUnit { NANOSECONDS { - public long toNanos(long d) { return d; } - public long toMicros(long d) { return d / C1_C0; } - public long toMillis(long d) { return d / C2_C0; } - public long toSeconds(long d) { return d / C3_C0; } - public long toMinutes(long d) { return d / C4_C0; } - public long toHours(long d) { return d / C5_C0; } - public long toDays(long d) { return d / C6_C0; } - public long convert(long d, TimeUnit u) { return u.toNanos(d); } + public long toNanos(long d) { + return d; + } + + public long toMicros(long d) { + return d / C1_C0; + } + + public long toMillis(long d) { + return d / C2_C0; + } + + public long toSeconds(long d) { + return d / C3_C0; + } + + public long toMinutes(long d) { + return d / C4_C0; + } + + public long toHours(long d) { + return d / C5_C0; + } + + public long toDays(long d) { + return d / C6_C0; + } + + public long convert(long d, TimeUnit u) { + return u.toNanos(d); + } }, MICROSECONDS { - public long toNanos(long d) { return x(d, C1_C0, MAX_C1_C0); } - public long toMicros(long d) { return d; } - public long toMillis(long d) { return d / C2_C1; } - public long toSeconds(long d) { return d / C3_C1; } - public long toMinutes(long d) { return d / C4_C1; } - public long toHours(long d) { return d / C5_C1; } - public long toDays(long d) { return d / C6_C1; } - public long convert(long d, TimeUnit u) { return u.toMicros(d); } + public long toNanos(long d) { + return x(d, C1_C0, MAX_C1_C0); + } + + public long toMicros(long d) { + return d; + } + + public long toMillis(long d) { + return d / C2_C1; + } + + public long toSeconds(long d) { + return d / C3_C1; + } + + public long toMinutes(long d) { + return d / C4_C1; + } + + public long toHours(long d) { + return d / C5_C1; + } + + public long toDays(long d) { + return d / C6_C1; + } + + public long convert(long d, TimeUnit u) { + return u.toMicros(d); + } }, MILLISECONDS { - public long toNanos(long d) { return x(d, C2_C0, MAX_C2_C0); } - public long toMicros(long d) { return x(d, C2_C1, MAX_C2_C1); } - public long toMillis(long d) { return d; } - public long toSeconds(long d) { return d / C3_C2; } - public long toMinutes(long d) { return d / C4_C2; } - public long toHours(long d) { return d / C5_C2; } - public long toDays(long d) { return d / C6_C2; } - public long convert(long d, TimeUnit u) { return u.toMillis(d); } + public long toNanos(long d) { + return x(d, C2_C0, MAX_C2_C0); + } + + public long toMicros(long d) { + return x(d, C2_C1, MAX_C2_C1); + } + + public long toMillis(long d) { + return d; + } + + public long toSeconds(long d) { + return d / C3_C2; + } + + public long toMinutes(long d) { + return d / C4_C2; + } + + public long toHours(long d) { + return d / C5_C2; + } + + public long toDays(long d) { + return d / C6_C2; + } + + public long convert(long d, TimeUnit u) { + return u.toMillis(d); + } }, SECONDS { - public long toNanos(long d) { return x(d, C3_C0, MAX_C3_C0); } - public long toMicros(long d) { return x(d, C3_C1, MAX_C3_C1); } - public long toMillis(long d) { return x(d, C3_C2, MAX_C3_C2); } - public long toSeconds(long d) { return d; } - public long toMinutes(long d) { return d / C4_C3; } - public long toHours(long d) { return d / C5_C3; } - public long toDays(long d) { return d / C6_C3; } - public long convert(long d, TimeUnit u) { return u.toSeconds(d); } + public long toNanos(long d) { + return x(d, C3_C0, MAX_C3_C0); + } + + public long toMicros(long d) { + return x(d, C3_C1, MAX_C3_C1); + } + + public long toMillis(long d) { + return x(d, C3_C2, MAX_C3_C2); + } + + public long toSeconds(long d) { + return d; + } + + public long toMinutes(long d) { + return d / C4_C3; + } + + public long toHours(long d) { + return d / C5_C3; + } + + public long toDays(long d) { + return d / C6_C3; + } + + public long convert(long d, TimeUnit u) { + return u.toSeconds(d); + } }, MINUTES { - public long toNanos(long d) { return x(d, C4_C0, MAX_C4_C0); } - public long toMicros(long d) { return x(d, C4_C1, MAX_C4_C1); } - public long toMillis(long d) { return x(d, C4_C2, MAX_C4_C2); } - public long toSeconds(long d) { return x(d, C4_C3, MAX_C4_C3); } - public long toMinutes(long d) { return d; } - public long toHours(long d) { return d / C5_C4; } - public long toDays(long d) { return d / C6_C4; } - public long convert(long d, TimeUnit u) { return u.toMinutes(d); } + public long toNanos(long d) { + return x(d, C4_C0, MAX_C4_C0); + } + + public long toMicros(long d) { + return x(d, C4_C1, MAX_C4_C1); + } + + public long toMillis(long d) { + return x(d, C4_C2, MAX_C4_C2); + } + + public long toSeconds(long d) { + return x(d, C4_C3, MAX_C4_C3); + } + + public long toMinutes(long d) { + return d; + } + + public long toHours(long d) { + return d / C5_C4; + } + + public long toDays(long d) { + return d / C6_C4; + } + + public long convert(long d, TimeUnit u) { + return u.toMinutes(d); + } }, HOURS { - public long toNanos(long d) { return x(d, C5_C0, MAX_C5_C0); } - public long toMicros(long d) { return x(d, C5_C1, MAX_C5_C1); } - public long toMillis(long d) { return x(d, C5_C2, MAX_C5_C2); } - public long toSeconds(long d) { return x(d, C5_C3, MAX_C5_C3); } - public long toMinutes(long d) { return x(d, C5_C4, MAX_C5_C4); } - public long toHours(long d) { return d; } - public long toDays(long d) { return d / C6_C5; } - public long convert(long d, TimeUnit u) { return u.toHours(d); } + public long toNanos(long d) { + return x(d, C5_C0, MAX_C5_C0); + } + + public long toMicros(long d) { + return x(d, C5_C1, MAX_C5_C1); + } + + public long toMillis(long d) { + return x(d, C5_C2, MAX_C5_C2); + } + + public long toSeconds(long d) { + return x(d, C5_C3, MAX_C5_C3); + } + + public long toMinutes(long d) { + return x(d, C5_C4, MAX_C5_C4); + } + + public long toHours(long d) { + return d; + } + + public long toDays(long d) { + return d / C6_C5; + } + + public long convert(long d, TimeUnit u) { + return u.toHours(d); + } }, DAYS { - public long toNanos(long d) { return x(d, C6_C0, MAX_C6_C0); } - public long toMicros(long d) { return x(d, C6_C1, MAX_C6_C1); } - public long toMillis(long d) { return x(d, C6_C2, MAX_C6_C2); } - public long toSeconds(long d) { return x(d, C6_C3, MAX_C6_C3); } - public long toMinutes(long d) { return x(d, C6_C4, MAX_C6_C4); } - public long toHours(long d) { return x(d, C6_C5, MAX_C6_C5); } - public long toDays(long d) { return d; } - public long convert(long d, TimeUnit u) { return u.toDays(d); } + public long toNanos(long d) { + return x(d, C6_C0, MAX_C6_C0); + } + + public long toMicros(long d) { + return x(d, C6_C1, MAX_C6_C1); + } + + public long toMillis(long d) { + return x(d, C6_C2, MAX_C6_C2); + } + + public long toSeconds(long d) { + return x(d, C6_C3, MAX_C6_C3); + } + + public long toMinutes(long d) { + return x(d, C6_C4, MAX_C6_C4); + } + + public long toHours(long d) { + return x(d, C6_C5, MAX_C6_C5); + } + + public long toDays(long d) { + return d; + } + + public long convert(long d, TimeUnit u) { + return u.toDays(d); + } }; // Handy constants for conversion methods @@ -152,7 +313,7 @@ public enum TimeUnit { private static final long MAX_C1_C0 = MAX / C1_C0; static long x(long d, long m, long over) { - if (d > over) return Long.MAX_VALUE; + if (d > over) return Long.MAX_VALUE; if (d < -over) return Long.MIN_VALUE; return d * m; } diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeoutException.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeoutException.java index 63723f649ffb..4cbf128fafc4 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeoutException.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeoutException.java @@ -16,9 +16,7 @@ package java.util.concurrent; -/** - * Emulation of TimeoutException. - */ +/** Emulation of TimeoutException. */ public class TimeoutException extends Exception { public TimeoutException() {} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicBoolean.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicBoolean.java index a8712045b0fe..4be46d42bdd9 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicBoolean.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicBoolean.java @@ -12,24 +12,21 @@ * 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. - */ /** - * Atomically sets the value to the given updated value - * if the current value {@code ==} the expected value. + */ +/** + * Atomically sets the value to the given updated value if the current value {@code ==} the expected + * value. * - *

May fail spuriously - * and does not provide ordering guarantees, so is only rarely an - * appropriate alternative to {@code compareAndSet}. + *

May fail spuriously and does not provide ordering + * guarantees, so is only rarely an appropriate alternative to {@code compareAndSet}. * * @param expect the expected value * @param update the new value * @return true if successful. */ - package java.util.concurrent.atomic; -/** - * GWT emulation of AtomicBoolean. - */ +/** GWT emulation of AtomicBoolean. */ public class AtomicBoolean implements java.io.Serializable { private boolean value; @@ -37,8 +34,7 @@ public AtomicBoolean(boolean initialValue) { value = initialValue; } - public AtomicBoolean() { - } + public AtomicBoolean() {} public final boolean get() { return value; diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicInteger.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicInteger.java index d9c16a667388..0a680f3be550 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicInteger.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicInteger.java @@ -17,8 +17,8 @@ package java.util.concurrent.atomic; /** - * GWT emulated version of {@link AtomicInteger}. It's a thin wrapper - * around the primitive {@code int}. + * GWT emulated version of {@link AtomicInteger}. It's a thin wrapper around the primitive {@code + * int}. * * @author Hayward Chan */ @@ -30,8 +30,7 @@ public AtomicInteger(int initialValue) { value = initialValue; } - public AtomicInteger() { - } + public AtomicInteger() {} public final int get() { return value; @@ -87,7 +86,8 @@ public final int addAndGet(int delta) { return value; } - @Override public String toString() { + @Override + public String toString() { return Integer.toString(value); } diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicLong.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicLong.java index fdd1b34f9f97..af782b3a6bbe 100644 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicLong.java +++ b/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicLong.java @@ -17,8 +17,8 @@ package java.util.concurrent.atomic; /** - * GWT emulated version of {@link AtomicLong}. It's a thin wrapper - * around the primitive {@code long}. + * GWT emulated version of {@link AtomicLong}. It's a thin wrapper around the primitive {@code + * long}. * * @author Jige Yu */ @@ -30,8 +30,7 @@ public AtomicLong(long initialValue) { this.value = initialValue; } - public AtomicLong() { - } + public AtomicLong() {} public final long get() { return value; @@ -87,7 +86,8 @@ public final long addAndGet(long delta) { return value; } - @Override public String toString() { + @Override + public String toString() { return Long.toString(value); } 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 68c270bde864..a72fd9fba5e8 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 @@ -315,9 +315,8 @@ public void testSetCount_removeNull_nullSupported() { } @CollectionFeature.Require( - value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, - absent = RESTRICTS_ELEMENTS - ) + value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, + absent = RESTRICTS_ELEMENTS) public void testSetCount_addNull_nullSupported() { assertSetCount(null, 1); } diff --git a/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddAllTester.java b/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddAllTester.java index 2b95dc99898c..5c21c9a93137 100644 --- a/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddAllTester.java +++ b/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddAllTester.java @@ -128,9 +128,8 @@ public void testAddAll_unsupportedAllPresent() { } @CollectionFeature.Require( - value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, - absent = RESTRICTS_ELEMENTS - ) + value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, + absent = RESTRICTS_ELEMENTS) public void testAddAll_nullSupported() { List containsNull = singletonList(null); assertTrue("addAll(containsNull) should return true", collection.addAll(containsNull)); diff --git a/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddTester.java b/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddTester.java index 7845e7d06354..bed257c97675 100644 --- a/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddTester.java +++ b/guava-testlib/src/com/google/common/collect/testing/testers/CollectionAddTester.java @@ -72,9 +72,8 @@ public void testAdd_unsupportedPresent() { } @CollectionFeature.Require( - value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, - absent = RESTRICTS_ELEMENTS - ) + value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, + absent = RESTRICTS_ELEMENTS) public void testAdd_nullSupported() { assertTrue("add(null) should return true", collection.add(null)); expectAdded((E) null); diff --git a/guava/src/com/google/common/base/Objects.java b/guava/src/com/google/common/base/Objects.java index 924885843948..498550221d3b 100644 --- a/guava/src/com/google/common/base/Objects.java +++ b/guava/src/com/google/common/base/Objects.java @@ -73,7 +73,7 @@ public static boolean equal(@Nullable Object a, @Nullable Object b) { *

Note for Java 7 and later: This method should be treated as deprecated; use {@link * java.util.Objects#hash} instead. */ - public static int hashCode(Object @Nullable... objects) { + public static int hashCode(Object @Nullable ... objects) { return Arrays.hashCode(objects); } } diff --git a/guava/src/com/google/common/base/Preconditions.java b/guava/src/com/google/common/base/Preconditions.java index d8f3532d04dd..681294ed279b 100644 --- a/guava/src/com/google/common/base/Preconditions.java +++ b/guava/src/com/google/common/base/Preconditions.java @@ -158,7 +158,7 @@ public static void checkArgument(boolean expression, @Nullable Object errorMessa public static void checkArgument( boolean expression, @Nullable String errorMessageTemplate, - Object @Nullable... errorMessageArgs) { + Object @Nullable ... errorMessageArgs) { if (!expression) { throw new IllegalArgumentException(lenientFormat(errorMessageTemplate, errorMessageArgs)); } @@ -526,7 +526,7 @@ public static void checkState(boolean expression, @Nullable Object errorMessage) public static void checkState( boolean expression, @Nullable String errorMessageTemplate, - @Nullable Object @Nullable... errorMessageArgs) { + @Nullable Object @Nullable ... errorMessageArgs) { if (!expression) { throw new IllegalStateException(lenientFormat(errorMessageTemplate, errorMessageArgs)); } @@ -914,7 +914,7 @@ public static T checkNotNull(T reference, @Nullable Object errorMessage) { */ @CanIgnoreReturnValue public static T checkNotNull( - T reference, @Nullable String errorMessageTemplate, Object @Nullable... errorMessageArgs) { + T reference, @Nullable String errorMessageTemplate, Object @Nullable ... errorMessageArgs) { if (reference == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, errorMessageArgs)); } diff --git a/guava/src/com/google/common/base/Strings.java b/guava/src/com/google/common/base/Strings.java index 7a5ff7f60e2d..8f70f631b6b6 100644 --- a/guava/src/com/google/common/base/Strings.java +++ b/guava/src/com/google/common/base/Strings.java @@ -257,7 +257,7 @@ static boolean validSurrogatePairAt(CharSequence string, int index) { */ // TODO(diamondm) consider using Arrays.toString() for array parameters public static String lenientFormat( - @Nullable String template, @Nullable Object @Nullable... args) { + @Nullable String template, @Nullable Object @Nullable ... args) { template = String.valueOf(template); // null -> "null" if (args == null) { diff --git a/guava/src/com/google/common/base/Verify.java b/guava/src/com/google/common/base/Verify.java index 2f252340a87e..c2846de869a6 100644 --- a/guava/src/com/google/common/base/Verify.java +++ b/guava/src/com/google/common/base/Verify.java @@ -119,7 +119,7 @@ public static void verify(boolean expression) { public static void verify( boolean expression, @Nullable String errorMessageTemplate, - @Nullable Object @Nullable... errorMessageArgs) { + @Nullable Object @Nullable ... errorMessageArgs) { if (!expression) { throw new VerifyException(lenientFormat(errorMessageTemplate, errorMessageArgs)); } @@ -496,7 +496,7 @@ public static T verifyNotNull(@Nullable T reference) { public static T verifyNotNull( @Nullable T reference, @Nullable String errorMessageTemplate, - @Nullable Object @Nullable... errorMessageArgs) { + @Nullable Object @Nullable ... errorMessageArgs) { verify(reference != null, errorMessageTemplate, errorMessageArgs); return reference; } diff --git a/guava/src/com/google/common/cache/LocalCache.java b/guava/src/com/google/common/cache/LocalCache.java index 7f2881e5105a..46fc29388ec9 100644 --- a/guava/src/com/google/common/cache/LocalCache.java +++ b/guava/src/com/google/common/cache/LocalCache.java @@ -3564,10 +3564,10 @@ public V compute(K key, BiFunction function) } V newValue; try { - newValue = function.apply(key, previousValue); + newValue = function.apply(key, previousValue); } catch (Throwable th) { - this.setException(th); - throw th; + this.setException(th); + throw th; } this.set(newValue); return newValue; diff --git a/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java b/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java index 385befbf75a2..b63281aa4ef2 100644 --- a/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java +++ b/guava/src/com/google/common/collect/AbstractMapBasedMultimap.java @@ -897,7 +897,7 @@ private class RandomAccessWrappedList extends WrappedList implements RandomAcces Set createKeySet() { return new KeySet(map); } - + final Set createMaybeNavigableKeySet() { if (map instanceof NavigableMap) { return new NavigableKeySet((NavigableMap>) map); @@ -1217,7 +1217,7 @@ Multiset createKeys() { public Collection> entries() { return super.entries(); } - + @Override Collection> createEntries() { if (this instanceof SetMultimap) { @@ -1270,7 +1270,7 @@ public void forEach(BiConsumer action) { Map> createAsMap() { return new AsMap(map); } - + final Map> createMaybeNavigableAsMap() { if (map instanceof NavigableMap) { return new NavigableAsMap((NavigableMap>) map); diff --git a/guava/src/com/google/common/collect/BaseImmutableMultimap.java b/guava/src/com/google/common/collect/BaseImmutableMultimap.java index 456d06ae9a0d..6ebdf14f52fa 100644 --- a/guava/src/com/google/common/collect/BaseImmutableMultimap.java +++ b/guava/src/com/google/common/collect/BaseImmutableMultimap.java @@ -18,8 +18,8 @@ import com.google.common.annotations.GwtCompatible; /** - * A dummy superclass of {@link ImmutableMultimap} that can be instanceof'd without ProGuard retaining - * additional implementation details of {@link ImmutableMultimap}. + * A dummy superclass of {@link ImmutableMultimap} that can be instanceof'd without ProGuard + * retaining additional implementation details of {@link ImmutableMultimap}. */ @GwtCompatible abstract class BaseImmutableMultimap extends AbstractMultimap {} diff --git a/guava/src/com/google/common/collect/CompactHashMap.java b/guava/src/com/google/common/collect/CompactHashMap.java index befd1ad1233f..8fa34ed3fc9b 100644 --- a/guava/src/com/google/common/collect/CompactHashMap.java +++ b/guava/src/com/google/common/collect/CompactHashMap.java @@ -66,8 +66,8 @@ * *

This class should not be assumed to be universally superior to {@code java.util.HashMap}. * Generally speaking, this class reduces object allocation and memory consumption at the price of - * moderately increased constant factors of CPU. Only use this class when there is a specific - * reason to prioritize memory over CPU. + * moderately increased constant factors of CPU. Only use this class when there is a specific reason + * to prioritize memory over CPU. * * @author Louis Wasserman */ @@ -139,13 +139,13 @@ public static CompactHashMap createWithExpectedSize(int expectedSiz * The keys of the entries in the map, in the range of [0, size()). The keys in [size(), * keys.length) are all {@code null}. */ - @VisibleForTesting transient Object @MonotonicNonNull[] keys; + @VisibleForTesting transient Object @MonotonicNonNull [] keys; /** * The values of the entries in the map, in the range of [0, size()). The values in [size(), * values.length) are all {@code null}. */ - @VisibleForTesting transient Object @MonotonicNonNull[] values; + @VisibleForTesting transient Object @MonotonicNonNull [] values; /** The load factor. */ transient float loadFactor; diff --git a/guava/src/com/google/common/collect/CompactHashSet.java b/guava/src/com/google/common/collect/CompactHashSet.java index d4b6eaa791a5..5afc71cf9cd6 100644 --- a/guava/src/com/google/common/collect/CompactHashSet.java +++ b/guava/src/com/google/common/collect/CompactHashSet.java @@ -62,8 +62,8 @@ * *

This class should not be assumed to be universally superior to {@code java.util.HashSet}. * Generally speaking, this class reduces object allocation and memory consumption at the price of - * moderately increased constant factors of CPU. Only use this class when there is a specific - * reason to prioritize memory over CPU. + * moderately increased constant factors of CPU. Only use this class when there is a specific reason + * to prioritize memory over CPU. * * @author Dimitris Andreou */ diff --git a/guava/src/com/google/common/collect/CompactLinkedHashMap.java b/guava/src/com/google/common/collect/CompactLinkedHashMap.java index ba15c2604108..3f219f597e60 100644 --- a/guava/src/com/google/common/collect/CompactLinkedHashMap.java +++ b/guava/src/com/google/common/collect/CompactLinkedHashMap.java @@ -53,20 +53,18 @@ class CompactLinkedHashMap extends CompactHashMap { // TODO(lowasser): implement removeEldestEntry so this can be used as a drop-in replacement - /** - * Creates an empty {@code CompactLinkedHashMap} instance. - */ + /** Creates an empty {@code CompactLinkedHashMap} instance. */ public static CompactLinkedHashMap create() { return new CompactLinkedHashMap<>(); } /** - * Creates a {@code CompactLinkedHashMap} instance, with a high enough "initial capacity" - * that it should hold {@code expectedSize} elements without growth. + * Creates a {@code CompactLinkedHashMap} instance, with a high enough "initial capacity" that it + * should hold {@code expectedSize} elements without growth. * * @param expectedSize the number of elements you expect to add to the returned set * @return a new, empty {@code CompactLinkedHashMap} with enough capacity to hold {@code - * expectedSize} elements without resizing + * expectedSize} elements without resizing * @throws IllegalArgumentException if {@code expectedSize} is negative */ public static CompactLinkedHashMap createWithExpectedSize(int expectedSize) { @@ -86,14 +84,10 @@ public static CompactLinkedHashMap createWithExpectedSize(int expec */ @VisibleForTesting transient long @MonotonicNonNull [] links; - /** - * Pointer to the first node in the linked list, or {@code ENDPOINT} if there are no entries. - */ + /** Pointer to the first node in the linked list, or {@code ENDPOINT} if there are no entries. */ private transient int firstEntry; - /** - * Pointer to the last node in the linked list, or {@code ENDPOINT} if there are no entries. - */ + /** Pointer to the last node in the linked list, or {@code ENDPOINT} if there are no entries. */ private transient int lastEntry; private final boolean accessOrder; diff --git a/guava/src/com/google/common/collect/CompactLinkedHashSet.java b/guava/src/com/google/common/collect/CompactLinkedHashSet.java index 9c027dacf6e3..de31fcdd0e26 100644 --- a/guava/src/com/google/common/collect/CompactLinkedHashSet.java +++ b/guava/src/com/google/common/collect/CompactLinkedHashSet.java @@ -51,16 +51,14 @@ @GwtIncompatible // not worth using in GWT for now class CompactLinkedHashSet extends CompactHashSet { - /** - * Creates an empty {@code CompactLinkedHashSet} instance. - */ + /** Creates an empty {@code CompactLinkedHashSet} instance. */ public static CompactLinkedHashSet create() { return new CompactLinkedHashSet(); } /** - * Creates a mutable {@code CompactLinkedHashSet} instance containing the elements - * of the given collection in the order returned by the collection's iterator. + * Creates a mutable {@code CompactLinkedHashSet} instance containing the elements of the + * given collection in the order returned by the collection's iterator. * * @param collection the elements that the set should contain * @return a new {@code CompactLinkedHashSet} containing those elements (minus duplicates) @@ -72,8 +70,8 @@ public static CompactLinkedHashSet create(Collection collect } /** - * Creates a {@code CompactLinkedHashSet} instance containing the given elements in - * unspecified order. + * Creates a {@code CompactLinkedHashSet} instance containing the given elements in unspecified + * order. * * @param elements the elements that the set should contain * @return a new {@code CompactLinkedHashSet} containing those elements (minus duplicates) @@ -85,13 +83,12 @@ public static CompactLinkedHashSet create(E... elements) { } /** - * Creates a {@code CompactLinkedHashSet} instance, with a high enough "initial capacity" - * that it should hold {@code expectedSize} elements without rebuilding internal - * data structures. + * Creates a {@code CompactLinkedHashSet} instance, with a high enough "initial capacity" that it + * should hold {@code expectedSize} elements without rebuilding internal data structures. * * @param expectedSize the number of elements you expect to add to the returned set * @return a new, empty {@code CompactLinkedHashSet} with enough capacity to hold {@code - * expectedSize} elements without resizing + * expectedSize} elements without resizing * @throws IllegalArgumentException if {@code expectedSize} is negative */ public static CompactLinkedHashSet createWithExpectedSize(int expectedSize) { @@ -221,11 +218,13 @@ int getSuccessor(int entryIndex) { return successor[entryIndex]; } - @Override public Spliterator spliterator() { + @Override + public Spliterator spliterator() { return Spliterators.spliterator(this, Spliterator.ORDERED | Spliterator.DISTINCT); } - @Override public void forEach(Consumer action) { + @Override + public void forEach(Consumer action) { checkNotNull(action); for (int i = firstEntry; i != ENDPOINT; i = successor[i]) { action.accept((E) elements[i]); diff --git a/guava/src/com/google/common/collect/ImmutableList.java b/guava/src/com/google/common/collect/ImmutableList.java index 683dfad0a9b2..a2843538d973 100644 --- a/guava/src/com/google/common/collect/ImmutableList.java +++ b/guava/src/com/google/common/collect/ImmutableList.java @@ -201,8 +201,7 @@ public static ImmutableList of( public static ImmutableList of( E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11, E e12, E... others) { checkArgument( - others.length <= Integer.MAX_VALUE - 12, - "the total number of elements must fit in an int"); + others.length <= Integer.MAX_VALUE - 12, "the total number of elements must fit in an int"); Object[] array = new Object[12 + others.length]; array[0] = e1; array[1] = e2; diff --git a/guava/src/com/google/common/collect/ImmutableSet.java b/guava/src/com/google/common/collect/ImmutableSet.java index 56a78f95414c..63cb0b2e3edc 100644 --- a/guava/src/com/google/common/collect/ImmutableSet.java +++ b/guava/src/com/google/common/collect/ImmutableSet.java @@ -133,8 +133,7 @@ public static ImmutableSet of(E e1, E e2, E e3, E e4, E e5) { @SafeVarargs // For Eclipse. For internal javac we have disabled this pointless type of warning. public static ImmutableSet of(E e1, E e2, E e3, E e4, E e5, E e6, E... others) { checkArgument( - others.length <= Integer.MAX_VALUE - 6, - "the total number of elements must fit in an int"); + others.length <= Integer.MAX_VALUE - 6, "the total number of elements must fit in an int"); final int paramCount = 6; Object[] elements = new Object[paramCount + others.length]; elements[0] = e1; diff --git a/guava/src/com/google/common/collect/ImmutableSetMultimap.java b/guava/src/com/google/common/collect/ImmutableSetMultimap.java index 5c63beb9792f..bab39c90f0be 100644 --- a/guava/src/com/google/common/collect/ImmutableSetMultimap.java +++ b/guava/src/com/google/common/collect/ImmutableSetMultimap.java @@ -596,7 +596,7 @@ Comparator valueComparator() { ? ((ImmutableSortedSet) emptySet).comparator() : null; } - + @GwtIncompatible // java serialization private static final class SetFieldSettersHolder { static final Serialization.FieldSetter EMPTY_SET_FIELD_SETTER = diff --git a/guava/src/com/google/common/collect/MultimapBuilder.java b/guava/src/com/google/common/collect/MultimapBuilder.java index 8d9521ef5b1e..482385e50a25 100644 --- a/guava/src/com/google/common/collect/MultimapBuilder.java +++ b/guava/src/com/google/common/collect/MultimapBuilder.java @@ -79,8 +79,8 @@ public static MultimapBuilderWithKeys hashKeys() { } /** - * Uses a hash table to map keys to value collections, initialized to expect the specified - * number of keys. + * Uses a hash table to map keys to value collections, initialized to expect the specified number + * of keys. * * @throws IllegalArgumentException if {@code expectedKeys < 0} */ @@ -107,8 +107,8 @@ public static MultimapBuilderWithKeys linkedHashKeys() { } /** - * Uses an hash table to map keys to value collections, initialized to expect the - * specified number of keys. + * Uses an hash table to map keys to value collections, initialized to expect the specified number + * of keys. * *

The collections returned by {@link Multimap#keySet()}, {@link Multimap#keys()}, and {@link * Multimap#asMap()} will iterate through the keys in the order that they were first added to the @@ -223,7 +223,7 @@ public Set get() { return Platform.newHashSetWithExpectedSize(expectedValuesPerKey); } } - + private static final class LinkedHashSetSupplier implements Supplier>, Serializable { private final int expectedValuesPerKey; @@ -319,8 +319,8 @@ public SetMultimapBuilder hashSetValues() { } /** - * Uses a hash-based {@code Set} to store value collections, initialized to expect the specified number - * of values per key. + * Uses a hash-based {@code Set} to store value collections, initialized to expect the specified + * number of values per key. * * @throws IllegalArgumentException if {@code expectedValuesPerKey < 0} */ @@ -342,8 +342,8 @@ public SetMultimapBuilder linkedHashSetValues() { } /** - * Uses an insertion-ordered hash-based {@code Set} to store value collections, initialized to expect the specified - * number of values per key. + * Uses an insertion-ordered hash-based {@code Set} to store value collections, initialized to + * expect the specified number of values per key. * * @throws IllegalArgumentException if {@code expectedValuesPerKey < 0} */ diff --git a/guava/src/com/google/common/collect/Multimaps.java b/guava/src/com/google/common/collect/Multimaps.java index 9a4d2294f773..62534968ac19 100644 --- a/guava/src/com/google/common/collect/Multimaps.java +++ b/guava/src/com/google/common/collect/Multimaps.java @@ -1207,7 +1207,7 @@ Collection createValues() { public Set> entries() { return map.entrySet(); } - + @Override Collection> createEntries() { throw new AssertionError("unreachable"); @@ -1481,7 +1481,7 @@ public void clear() { public boolean containsKey(Object key) { return fromMultimap.containsKey(key); } - + @Override Collection> createEntries() { return new Entries(); diff --git a/guava/src/com/google/common/graph/AbstractNetwork.java b/guava/src/com/google/common/graph/AbstractNetwork.java index 9b1e748e08ec..904e2aa1c824 100644 --- a/guava/src/com/google/common/graph/AbstractNetwork.java +++ b/guava/src/com/google/common/graph/AbstractNetwork.java @@ -232,8 +232,8 @@ public boolean hasEdgeConnecting(EndpointPair endpoints) { } /** - * Throws an IllegalArgumentException if the ordering of {@code endpoints} is not compatible - * with the directionality of this graph. + * Throws an IllegalArgumentException if the ordering of {@code endpoints} is not compatible with + * the directionality of this graph. */ protected final void validateEndpoints(EndpointPair endpoints) { checkNotNull(endpoints); diff --git a/guava/src/com/google/common/graph/MutableValueGraph.java b/guava/src/com/google/common/graph/MutableValueGraph.java index baa883ae18e8..f4d7376f4d94 100644 --- a/guava/src/com/google/common/graph/MutableValueGraph.java +++ b/guava/src/com/google/common/graph/MutableValueGraph.java @@ -42,8 +42,8 @@ public interface MutableValueGraph extends ValueGraph { boolean addNode(N node); /** - * Adds an edge connecting {@code nodeU} to {@code nodeV} if one is not already present, and - * sets a value for that edge to {@code value} (overwriting the existing value, if any). + * Adds an edge connecting {@code nodeU} to {@code nodeV} if one is not already present, and sets + * a value for that edge to {@code value} (overwriting the existing value, if any). * *

If the graph is directed, the resultant edge will be directed; otherwise, it will be * undirected. diff --git a/guava/src/com/google/common/graph/Traverser.java b/guava/src/com/google/common/graph/Traverser.java index 745f72bbc744..1a53dc673dc3 100644 --- a/guava/src/com/google/common/graph/Traverser.java +++ b/guava/src/com/google/common/graph/Traverser.java @@ -41,9 +41,8 @@ * based on your answers to the following questions: * *

    - *
  1. Is there only one path to any node that's reachable from any start node? (If so, the - * graph to be traversed is a tree or forest even if it is a subgraph of a graph which is - * neither.) + *
  2. Is there only one path to any node that's reachable from any start node? (If so, the graph + * to be traversed is a tree or forest even if it is a subgraph of a graph which is neither.) *
  3. Are the node objects' implementations of {@code equals()}/{@code hashCode()} recursive? *
diff --git a/guava/src/com/google/common/graph/ValueGraph.java b/guava/src/com/google/common/graph/ValueGraph.java index 54ee20dd2466..c93a1daa0cdd 100644 --- a/guava/src/com/google/common/graph/ValueGraph.java +++ b/guava/src/com/google/common/graph/ValueGraph.java @@ -263,8 +263,8 @@ public interface ValueGraph extends BaseGraph { /** * Returns the value of the edge that connects {@code nodeU} to {@code nodeV} (in the order, if - * any, specified by {@code endpoints}), if one is present; - * otherwise, returns {@code Optional.empty()}. + * any, specified by {@code endpoints}), if one is present; otherwise, returns {@code + * Optional.empty()}. * * @throws IllegalArgumentException if {@code nodeU} or {@code nodeV} is not an element of this * graph diff --git a/guava/src/com/google/common/hash/MacHashFunction.java b/guava/src/com/google/common/hash/MacHashFunction.java index 2f6db2eda532..ed1841c36b18 100644 --- a/guava/src/com/google/common/hash/MacHashFunction.java +++ b/guava/src/com/google/common/hash/MacHashFunction.java @@ -34,8 +34,10 @@ final class MacHashFunction extends AbstractHashFunction { @SuppressWarnings("Immutable") // cloned before each use private final Mac prototype; + @SuppressWarnings("Immutable") // keys are immutable, but not provably so private final Key key; + private final String toString; private final int bits; private final boolean supportsClone; diff --git a/guava/src/com/google/common/hash/MessageDigestHashFunction.java b/guava/src/com/google/common/hash/MessageDigestHashFunction.java index 68d41d7ce629..5c48c7d7f3ab 100644 --- a/guava/src/com/google/common/hash/MessageDigestHashFunction.java +++ b/guava/src/com/google/common/hash/MessageDigestHashFunction.java @@ -36,6 +36,7 @@ final class MessageDigestHashFunction extends AbstractHashFunction implements Se @SuppressWarnings("Immutable") // cloned before each use private final MessageDigest prototype; + private final int bytes; private final boolean supportsClone; private final String toString; diff --git a/guava/src/com/google/common/io/ByteStreams.java b/guava/src/com/google/common/io/ByteStreams.java index b2b017bd8267..510947ef0e17 100644 --- a/guava/src/com/google/common/io/ByteStreams.java +++ b/guava/src/com/google/common/io/ByteStreams.java @@ -171,8 +171,8 @@ private static byte[] toByteArrayInternal(InputStream in, Deque bufs, in // in a deque so that there's no copying between buffers while reading and so all of the bytes // in each new allocated buffer are available for reading from the stream. for (int bufSize = BUFFER_SIZE; - totalLen < MAX_ARRAY_LEN; - bufSize = IntMath.saturatedMultiply(bufSize, 2)) { + totalLen < MAX_ARRAY_LEN; + bufSize = IntMath.saturatedMultiply(bufSize, 2)) { byte[] buf = new byte[Math.min(bufSize, MAX_ARRAY_LEN - totalLen)]; bufs.add(buf); int off = 0; @@ -255,7 +255,7 @@ static byte[] toByteArray(InputStream in, long expectedSize) throws IOException // the stream was longer, so read the rest normally Deque bufs = new ArrayDeque(TO_BYTE_ARRAY_DEQUE_SIZE + 2); bufs.add(bytes); - bufs.add(new byte[] { (byte) b }); + bufs.add(new byte[] {(byte) b}); return toByteArrayInternal(in, bufs, bytes.length + 1); } diff --git a/guava/src/com/google/common/math/PairedStats.java b/guava/src/com/google/common/math/PairedStats.java index 549100248c27..6b9c778d1d62 100644 --- a/guava/src/com/google/common/math/PairedStats.java +++ b/guava/src/com/google/common/math/PairedStats.java @@ -223,8 +223,7 @@ public boolean equals(@Nullable Object obj) { PairedStats other = (PairedStats) obj; return xStats.equals(other.xStats) && yStats.equals(other.yStats) - && doubleToLongBits(sumOfProductsOfDeltas) - == doubleToLongBits(other.sumOfProductsOfDeltas); + && doubleToLongBits(sumOfProductsOfDeltas) == doubleToLongBits(other.sumOfProductsOfDeltas); } /** diff --git a/guava/src/com/google/common/net/HttpHeaders.java b/guava/src/com/google/common/net/HttpHeaders.java index 5864bbe67baa..ae18f189f458 100644 --- a/guava/src/com/google/common/net/HttpHeaders.java +++ b/guava/src/com/google/common/net/HttpHeaders.java @@ -374,8 +374,7 @@ private ReferrerPolicyValues() {} * * @since 24.1 */ - @Beta - public static final String X_DOWNLOAD_OPTIONS = "X-Download-Options"; + @Beta public static final String X_DOWNLOAD_OPTIONS = "X-Download-Options"; /** The HTTP {@code X-XSS-Protection} header field name. */ public static final String X_XSS_PROTECTION = "X-XSS-Protection"; /** diff --git a/guava/src/com/google/common/net/InetAddresses.java b/guava/src/com/google/common/net/InetAddresses.java index 8f9f40e236d4..930e54da5db5 100644 --- a/guava/src/com/google/common/net/InetAddresses.java +++ b/guava/src/com/google/common/net/InetAddresses.java @@ -232,7 +232,7 @@ public static boolean isInetAddress(String ipString) { if (parts.get(0).length() == 0 && --partsHi != 0) { return null; // ^: requires ^:: } - if (Iterables.getLast(parts).length() == 0 && --partsLo != 0) { + if (Iterables.getLast(parts).length() == 0 && --partsLo != 0) { return null; // :$ requires ::$ } } else { diff --git a/guava/src/com/google/common/primitives/ImmutableDoubleArray.java b/guava/src/com/google/common/primitives/ImmutableDoubleArray.java index f8a56e03315f..46e0b0ad7cfb 100644 --- a/guava/src/com/google/common/primitives/ImmutableDoubleArray.java +++ b/guava/src/com/google/common/primitives/ImmutableDoubleArray.java @@ -138,8 +138,7 @@ public static ImmutableDoubleArray of( // is okay since we have to copy the just-created array anyway. public static ImmutableDoubleArray of(double first, double... rest) { checkArgument( - rest.length <= Integer.MAX_VALUE - 1, - "the total number of elements must fit in an int"); + rest.length <= Integer.MAX_VALUE - 1, "the total number of elements must fit in an int"); double[] array = new double[rest.length + 1]; array[0] = first; System.arraycopy(rest, 0, array, 1, rest.length); diff --git a/guava/src/com/google/common/primitives/ImmutableIntArray.java b/guava/src/com/google/common/primitives/ImmutableIntArray.java index 6480b58b3733..8eb35d360a51 100644 --- a/guava/src/com/google/common/primitives/ImmutableIntArray.java +++ b/guava/src/com/google/common/primitives/ImmutableIntArray.java @@ -137,8 +137,7 @@ public static ImmutableIntArray of(int e0, int e1, int e2, int e3, int e4, int e // okay since we have to copy the just-created array anyway. public static ImmutableIntArray of(int first, int... rest) { checkArgument( - rest.length <= Integer.MAX_VALUE - 1, - "the total number of elements must fit in an int"); + rest.length <= Integer.MAX_VALUE - 1, "the total number of elements must fit in an int"); int[] array = new int[rest.length + 1]; array[0] = first; System.arraycopy(rest, 0, array, 1, rest.length); diff --git a/guava/src/com/google/common/primitives/ImmutableLongArray.java b/guava/src/com/google/common/primitives/ImmutableLongArray.java index 399aa185349f..a4161b282890 100644 --- a/guava/src/com/google/common/primitives/ImmutableLongArray.java +++ b/guava/src/com/google/common/primitives/ImmutableLongArray.java @@ -137,8 +137,7 @@ public static ImmutableLongArray of(long e0, long e1, long e2, long e3, long e4, // okay since we have to copy the just-created array anyway. public static ImmutableLongArray of(long first, long... rest) { checkArgument( - rest.length <= Integer.MAX_VALUE - 1, - "the total number of elements must fit in an int"); + rest.length <= Integer.MAX_VALUE - 1, "the total number of elements must fit in an int"); long[] array = new long[rest.length + 1]; array[0] = first; System.arraycopy(rest, 0, array, 1, rest.length); diff --git a/guava/src/com/google/common/reflect/TypeResolver.java b/guava/src/com/google/common/reflect/TypeResolver.java index 4d0b41a9da70..339eb43b5850 100644 --- a/guava/src/com/google/common/reflect/TypeResolver.java +++ b/guava/src/com/google/common/reflect/TypeResolver.java @@ -66,10 +66,10 @@ private TypeResolver(TypeTable typeTable) { /** * Returns a resolver that resolves types "covariantly". - *

For example, when resolving {@code List} in the context of {@code ArrayList}, - * {@code } is covariantly resolved to {@code } such that return type of {@code List::get} - * is {@code }. * + *

For example, when resolving {@code List} in the context of {@code ArrayList}, {@code + * } is covariantly resolved to {@code } such that return type of {@code List::get} is + * {@code }. */ static TypeResolver covariantly(Type contextType) { return new TypeResolver().where(TypeMappingIntrospector.getTypeMappings(contextType)); @@ -78,14 +78,13 @@ static TypeResolver covariantly(Type contextType) { /** * Returns a resolver that resolves types "invariantly". * - *

For example, when resolving {@code List} in the context of {@code ArrayList}, - * {@code } cannot be invariantly resolved to {@code } because otherwise the parameter type - * of {@code List::set} will be {@code } and it'll falsely say any object can be passed into + *

For example, when resolving {@code List} in the context of {@code ArrayList}, {@code + * } cannot be invariantly resolved to {@code } because otherwise the parameter type of + * {@code List::set} will be {@code } and it'll falsely say any object can be passed into * {@code ArrayList::set}. * - *

Instead, {@code } will be resolved to a capture in the form of a type variable - * {@code }, effectively preventing {@code set} from accepting any - * type. + *

Instead, {@code } will be resolved to a capture in the form of a type variable {@code + * }, effectively preventing {@code set} from accepting any type. */ static TypeResolver invariantly(Type contextType) { Type invariantContext = WildcardCapturer.INSTANCE.capture(contextType); diff --git a/guava/src/com/google/common/reflect/TypeToken.java b/guava/src/com/google/common/reflect/TypeToken.java index 2a924650c090..c1dc5e2c565d 100644 --- a/guava/src/com/google/common/reflect/TypeToken.java +++ b/guava/src/com/google/common/reflect/TypeToken.java @@ -944,26 +944,27 @@ private boolean isSupertypeOfArray(GenericArrayType subtype) { * {@code A.is(B)} is defined as {@code Foo.isSubtypeOf(Foo)}. * *

Specifically, returns true if any of the following conditions is met: + * *

    *
  1. 'this' and {@code formalType} are equal. *
  2. 'this' and {@code formalType} have equal canonical form. *
  3. {@code formalType} is {@code } and 'this' is a subtype of {@code Foo}. *
  4. {@code formalType} is {@code } and 'this' is a supertype of {@code Foo}. *
- * Note that condition 2 isn't technically accurate under the context of a recursively - * bounded type variables. For example, {@code Enum>} canonicalizes to - * {@code Enum} where {@code E} is the type variable declared on the {@code Enum} class - * declaration. It's technically not true that {@code Foo>>} is a - * subtype of {@code Foo>} according to JLS. See testRecursiveWildcardSubtypeBug() for - * a real example. + * + * Note that condition 2 isn't technically accurate under the context of a recursively bounded + * type variables. For example, {@code Enum>} canonicalizes to {@code Enum} + * where {@code E} is the type variable declared on the {@code Enum} class declaration. It's + * technically not true that {@code Foo>>} is a subtype of {@code + * Foo>} according to JLS. See testRecursiveWildcardSubtypeBug() for a real example. * *

It appears that properly handling recursive type bounds in the presence of implicit type * bounds is not easy. For now we punt, hoping that this defect should rarely cause issues in real * code. * * @param formalType is {@code Foo} a supertype of {@code Foo}? - * @param declaration The type variable in the context of a parameterized type. Used to infer - * type bound when {@code formalType} is a wildcard with implicit upper bound. + * @param declaration The type variable in the context of a parameterized type. Used to infer type + * bound when {@code formalType} is a wildcard with implicit upper bound. */ private boolean is(Type formalType, TypeVariable declaration) { if (runtimeType.equals(formalType)) { @@ -979,8 +980,7 @@ private boolean is(Type formalType, TypeVariable declaration) { return every(your.getUpperBounds()).isSupertypeOf(runtimeType) && every(your.getLowerBounds()).isSubtypeOf(runtimeType); } - return canonicalizeWildcardsInType(runtimeType) - .equals(canonicalizeWildcardsInType(formalType)); + return canonicalizeWildcardsInType(runtimeType).equals(canonicalizeWildcardsInType(formalType)); } /** @@ -988,16 +988,17 @@ private boolean is(Type formalType, TypeVariable declaration) { * is defined as {@code Foo}. Thus directly calling {@code .is(String.class)} * will return false. To mitigate, we canonicalize wildcards by enforcing the following * invariants: + * *

*/ private static Type canonicalizeTypeArg(TypeVariable declaration, Type typeArg) { diff --git a/guava/src/com/google/common/util/concurrent/AbstractService.java b/guava/src/com/google/common/util/concurrent/AbstractService.java index dcfcb271c03a..3a15f2aec72a 100644 --- a/guava/src/com/google/common/util/concurrent/AbstractService.java +++ b/guava/src/com/google/common/util/concurrent/AbstractService.java @@ -230,8 +230,8 @@ protected AbstractService() {} * convenient. It is invoked exactly once on service shutdown, even when {@link #stopAsync} is * called multiple times. * - *

When this method is called {@link #state()} will return {@link State#STOPPING}, which - * is the external state observable by the caller of {@link #stopAsync}. + *

When this method is called {@link #state()} will return {@link State#STOPPING}, which is the + * external state observable by the caller of {@link #stopAsync}. * * @since 27.0 */ diff --git a/guava/src/com/google/common/util/concurrent/InterruptibleTask.java b/guava/src/com/google/common/util/concurrent/InterruptibleTask.java index 4accbff00515..76537764cd33 100644 --- a/guava/src/com/google/common/util/concurrent/InterruptibleTask.java +++ b/guava/src/com/google/common/util/concurrent/InterruptibleTask.java @@ -154,8 +154,8 @@ public final void run() { abstract void afterRanInterruptibly(@Nullable T result, @Nullable Throwable error); /** - * Interrupts the running task. Because this internally calls {@link Thread#interrupt()} which can in turn - * invoke arbitrary code it is not safe to call while holding a lock. + * Interrupts the running task. Because this internally calls {@link Thread#interrupt()} which can + * in turn invoke arbitrary code it is not safe to call while holding a lock. */ final void interruptTask() { // Since the Thread is replaced by DONE before run() invokes listeners or returns, if we succeed diff --git a/guava/src/com/google/common/util/concurrent/Striped.java b/guava/src/com/google/common/util/concurrent/Striped.java index 1b6652fe0a6f..c9ba77235d5a 100644 --- a/guava/src/com/google/common/util/concurrent/Striped.java +++ b/guava/src/com/google/common/util/concurrent/Striped.java @@ -184,8 +184,8 @@ public Iterable bulkGet(Iterable keys) { // Static factories /** - * Creates a {@code Striped} with eagerly initialized, strongly referenced locks. Every lock - * is obtained from the passed supplier. + * Creates a {@code Striped} with eagerly initialized, strongly referenced locks. Every lock is + * obtained from the passed supplier. * * @param stripes the minimum number of stripes (locks) required * @param supplier a {@code Supplier} object to obtain locks from @@ -203,12 +203,14 @@ static Striped custom(int stripes, Supplier supplier) { * @return a new {@code Striped} */ public static Striped lock(int stripes) { - return custom(stripes, new Supplier() { - @Override - public Lock get() { - return new PaddedLock(); - } - }); + return custom( + stripes, + new Supplier() { + @Override + public Lock get() { + return new PaddedLock(); + } + }); } /** From 8843b6ca39c8baddcf01991ea34ad91f87b30d82 Mon Sep 17 00:00:00 2001 From: cushon Date: Fri, 1 Feb 2019 11:14:51 -0800 Subject: [PATCH 04/23] Add missing @Override annotations RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=232004516 --- .../google/AbstractListMultimapTester.java | 2 + .../DerivedGoogleCollectionGenerators.java | 3 ++ .../google/common/testing/GcFinalization.java | 1 + .../com/google/common/cache/LongAdder.java | 9 ++++ .../com/google/common/cache/Striped64.java | 1 + .../common/collect/EmptyContiguousSet.java | 1 + .../common/collect/ImmutableSetMultimap.java | 3 +- .../google/common/collect/SortedMultiset.java | 1 + .../src/com/google/common/hash/Funnels.java | 6 +++ .../src/com/google/common/hash/LongAdder.java | 9 ++++ .../src/com/google/common/hash/Striped64.java | 1 + .../common/util/concurrent/AtomicDouble.java | 5 +++ .../util/concurrent/AtomicDoubleArray.java | 1 + .../concurrent/ForwardingExecutorService.java | 1 + .../google/AbstractListMultimapTester.java | 2 + .../DerivedGoogleCollectionGenerators.java | 3 ++ .../google/common/testing/GcFinalization.java | 1 + .../common/testing/GcFinalizationTest.java | 3 ++ .../base/FinalizableReferenceQueueTest.java | 1 + .../AbstractSequentialIteratorTest.java | 1 + .../collect/MapsTransformValuesTest.java | 1 + .../com/google/common/collect/QueuesTest.java | 1 + .../concurrent/AtomicDoubleArrayTest.java | 2 + .../util/concurrent/AtomicDoubleTest.java | 1 + .../util/concurrent/JSR166TestCase.java | 41 +++++++++++++++++++ .../com/google/common/base/CharMatcher.java | 1 + .../com/google/common/cache/LocalCache.java | 1 + .../com/google/common/cache/LongAdder.java | 9 ++++ .../com/google/common/cache/Striped64.java | 1 + .../common/collect/EmptyContiguousSet.java | 1 + .../common/collect/ImmutableSetMultimap.java | 3 +- .../google/common/collect/SortedMultiset.java | 1 + guava/src/com/google/common/hash/Funnels.java | 6 +++ .../src/com/google/common/hash/LongAdder.java | 9 ++++ .../src/com/google/common/hash/Striped64.java | 1 + .../com/google/common/reflect/Parameter.java | 3 ++ .../common/util/concurrent/AtomicDouble.java | 5 +++ .../util/concurrent/AtomicDoubleArray.java | 1 + .../concurrent/ForwardingExecutorService.java | 1 + 39 files changed, 140 insertions(+), 4 deletions(-) diff --git a/android/guava-testlib/src/com/google/common/collect/testing/google/AbstractListMultimapTester.java b/android/guava-testlib/src/com/google/common/collect/testing/google/AbstractListMultimapTester.java index 22404390a822..7bce8b012072 100644 --- a/android/guava-testlib/src/com/google/common/collect/testing/google/AbstractListMultimapTester.java +++ b/android/guava-testlib/src/com/google/common/collect/testing/google/AbstractListMultimapTester.java @@ -32,10 +32,12 @@ public class AbstractListMultimapTester extends AbstractMultimapTester> { + @Override protected void assertGet(K key, V... values) { assertGet(key, Arrays.asList(values)); } + @Override protected void assertGet(K key, Collection values) { assertEqualInOrder(values, multimap().get(key)); diff --git a/android/guava-testlib/src/com/google/common/collect/testing/google/DerivedGoogleCollectionGenerators.java b/android/guava-testlib/src/com/google/common/collect/testing/google/DerivedGoogleCollectionGenerators.java index dee61e121eee..bbeefd278e00 100644 --- a/android/guava-testlib/src/com/google/common/collect/testing/google/DerivedGoogleCollectionGenerators.java +++ b/android/guava-testlib/src/com/google/common/collect/testing/google/DerivedGoogleCollectionGenerators.java @@ -81,6 +81,7 @@ public V[] createValueArray(int length) { return (V[]) new Object[length]; } + @Override public TestSubjectGenerator getInnerGenerator() { return generator; } @@ -144,6 +145,7 @@ public K[] createValueArray(int length) { return (K[]) new Object[length]; } + @Override public TestSubjectGenerator getInnerGenerator() { return generator; } @@ -202,6 +204,7 @@ public Iterable order(List insertionOrder) { return insertionOrder; } + @Override public TestSubjectGenerator getInnerGenerator() { return mapGenerator; } diff --git a/android/guava-testlib/src/com/google/common/testing/GcFinalization.java b/android/guava-testlib/src/com/google/common/testing/GcFinalization.java index 08c03e8f3439..92394f17670a 100644 --- a/android/guava-testlib/src/com/google/common/testing/GcFinalization.java +++ b/android/guava-testlib/src/com/google/common/testing/GcFinalization.java @@ -264,6 +264,7 @@ public interface FinalizationPredicate { public static void awaitClear(final WeakReference ref) { awaitDone( new FinalizationPredicate() { + @Override public boolean isDone() { return ref.get() == null; } diff --git a/android/guava/src/com/google/common/cache/LongAdder.java b/android/guava/src/com/google/common/cache/LongAdder.java index 2e8553253012..f0c44ffbc697 100644 --- a/android/guava/src/com/google/common/cache/LongAdder.java +++ b/android/guava/src/com/google/common/cache/LongAdder.java @@ -44,6 +44,7 @@ final class LongAdder extends Striped64 implements Serializable, LongAddable { private static final long serialVersionUID = 7249069246863182397L; /** Version of plus for use in retryUpdate */ + @Override final long fn(long v, long x) { return v + x; } @@ -56,6 +57,7 @@ public LongAdder() {} * * @param x the value to add */ + @Override public void add(long x) { Cell[] as; long b, v; @@ -73,6 +75,7 @@ public void add(long x) { } /** Equivalent to {@code add(1)}. */ + @Override public void increment() { add(1L); } @@ -89,6 +92,7 @@ public void decrement() { * * @return the sum */ + @Override public long sum() { long sum = base; Cell[] as = cells; @@ -142,6 +146,7 @@ public long sumThenReset() { * * @return the String representation of the {@link #sum} */ + @Override public String toString() { return Long.toString(sum()); } @@ -151,21 +156,25 @@ public String toString() { * * @return the sum */ + @Override public long longValue() { return sum(); } /** Returns the {@link #sum} as an {@code int} after a narrowing primitive conversion. */ + @Override public int intValue() { return (int) sum(); } /** Returns the {@link #sum} as a {@code float} after a widening primitive conversion. */ + @Override public float floatValue() { return (float) sum(); } /** Returns the {@link #sum} as a {@code double} after a widening primitive conversion. */ + @Override public double doubleValue() { return (double) sum(); } diff --git a/android/guava/src/com/google/common/cache/Striped64.java b/android/guava/src/com/google/common/cache/Striped64.java index 14e28c7b889e..676e09aa6bc5 100644 --- a/android/guava/src/com/google/common/cache/Striped64.java +++ b/android/guava/src/com/google/common/cache/Striped64.java @@ -293,6 +293,7 @@ private static sun.misc.Unsafe getUnsafe() { try { return java.security.AccessController.doPrivileged( new java.security.PrivilegedExceptionAction() { + @Override public sun.misc.Unsafe run() throws Exception { Class k = sun.misc.Unsafe.class; for (java.lang.reflect.Field f : k.getDeclaredFields()) { diff --git a/android/guava/src/com/google/common/collect/EmptyContiguousSet.java b/android/guava/src/com/google/common/collect/EmptyContiguousSet.java index e35611d40377..8043ef7880da 100644 --- a/android/guava/src/com/google/common/collect/EmptyContiguousSet.java +++ b/android/guava/src/com/google/common/collect/EmptyContiguousSet.java @@ -162,6 +162,7 @@ Object writeReplace() { } @GwtIncompatible // NavigableSet + @Override ImmutableSortedSet createDescendingSet() { return ImmutableSortedSet.emptySet(Ordering.natural().reverse()); } diff --git a/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java b/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java index fc85c186ed87..9b2a579fdf83 100644 --- a/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java +++ b/android/guava/src/com/google/common/collect/ImmutableSetMultimap.java @@ -366,9 +366,8 @@ public ImmutableSet get(@NullableDecl K key) { *

Because an inverse of a set multimap cannot contain multiple pairs with the same key and * value, this method returns an {@code ImmutableSetMultimap} rather than the {@code * ImmutableMultimap} specified in the {@code ImmutableMultimap} class. - * - * @since 11.0 */ + @Override public ImmutableSetMultimap inverse() { ImmutableSetMultimap result = inverse; return (result == null) ? (inverse = invert()) : result; diff --git a/android/guava/src/com/google/common/collect/SortedMultiset.java b/android/guava/src/com/google/common/collect/SortedMultiset.java index 7da5528e8b47..849ea50d231f 100644 --- a/android/guava/src/com/google/common/collect/SortedMultiset.java +++ b/android/guava/src/com/google/common/collect/SortedMultiset.java @@ -47,6 +47,7 @@ public interface SortedMultiset extends SortedMultisetBridge, SortedIterab * Returns the comparator that orders this multiset, or {@link Ordering#natural()} if the natural * ordering of the elements is used. */ + @Override Comparator comparator(); /** diff --git a/android/guava/src/com/google/common/hash/Funnels.java b/android/guava/src/com/google/common/hash/Funnels.java index 9bb48337bc8b..afe60c176385 100644 --- a/android/guava/src/com/google/common/hash/Funnels.java +++ b/android/guava/src/com/google/common/hash/Funnels.java @@ -39,6 +39,7 @@ public static Funnel byteArrayFunnel() { private enum ByteArrayFunnel implements Funnel { INSTANCE; + @Override public void funnel(byte[] from, PrimitiveSink into) { into.putBytes(from); } @@ -63,6 +64,7 @@ public static Funnel unencodedCharsFunnel() { private enum UnencodedCharsFunnel implements Funnel { INSTANCE; + @Override public void funnel(CharSequence from, PrimitiveSink into) { into.putUnencodedChars(from); } @@ -90,6 +92,7 @@ private static class StringCharsetFunnel implements Funnel, Serial this.charset = Preconditions.checkNotNull(charset); } + @Override public void funnel(CharSequence from, PrimitiveSink into) { into.putString(from, charset); } @@ -144,6 +147,7 @@ public static Funnel integerFunnel() { private enum IntegerFunnel implements Funnel { INSTANCE; + @Override public void funnel(Integer from, PrimitiveSink into) { into.putInt(from); } @@ -171,6 +175,7 @@ private static class SequentialFunnel implements Funnel this.elementFunnel = Preconditions.checkNotNull(elementFunnel); } + @Override public void funnel(Iterable from, PrimitiveSink into) { for (E e : from) { elementFunnel.funnel(e, into); @@ -209,6 +214,7 @@ public static Funnel longFunnel() { private enum LongFunnel implements Funnel { INSTANCE; + @Override public void funnel(Long from, PrimitiveSink into) { into.putLong(from); } diff --git a/android/guava/src/com/google/common/hash/LongAdder.java b/android/guava/src/com/google/common/hash/LongAdder.java index 7ef21100ee7e..bd08428ff3a4 100644 --- a/android/guava/src/com/google/common/hash/LongAdder.java +++ b/android/guava/src/com/google/common/hash/LongAdder.java @@ -42,6 +42,7 @@ final class LongAdder extends Striped64 implements Serializable, LongAddable { private static final long serialVersionUID = 7249069246863182397L; /** Version of plus for use in retryUpdate */ + @Override final long fn(long v, long x) { return v + x; } @@ -54,6 +55,7 @@ public LongAdder() {} * * @param x the value to add */ + @Override public void add(long x) { Cell[] as; long b, v; @@ -71,6 +73,7 @@ public void add(long x) { } /** Equivalent to {@code add(1)}. */ + @Override public void increment() { add(1L); } @@ -87,6 +90,7 @@ public void decrement() { * * @return the sum */ + @Override public long sum() { long sum = base; Cell[] as = cells; @@ -140,6 +144,7 @@ public long sumThenReset() { * * @return the String representation of the {@link #sum} */ + @Override public String toString() { return Long.toString(sum()); } @@ -149,21 +154,25 @@ public String toString() { * * @return the sum */ + @Override public long longValue() { return sum(); } /** Returns the {@link #sum} as an {@code int} after a narrowing primitive conversion. */ + @Override public int intValue() { return (int) sum(); } /** Returns the {@link #sum} as a {@code float} after a widening primitive conversion. */ + @Override public float floatValue() { return (float) sum(); } /** Returns the {@link #sum} as a {@code double} after a widening primitive conversion. */ + @Override public double doubleValue() { return (double) sum(); } diff --git a/android/guava/src/com/google/common/hash/Striped64.java b/android/guava/src/com/google/common/hash/Striped64.java index a884dd0d41af..9542bef5a77c 100644 --- a/android/guava/src/com/google/common/hash/Striped64.java +++ b/android/guava/src/com/google/common/hash/Striped64.java @@ -293,6 +293,7 @@ private static sun.misc.Unsafe getUnsafe() { try { return java.security.AccessController.doPrivileged( new java.security.PrivilegedExceptionAction() { + @Override public sun.misc.Unsafe run() throws Exception { Class k = sun.misc.Unsafe.class; for (java.lang.reflect.Field f : k.getDeclaredFields()) { diff --git a/android/guava/src/com/google/common/util/concurrent/AtomicDouble.java b/android/guava/src/com/google/common/util/concurrent/AtomicDouble.java index a0e63c009b65..cfd0ec700a7d 100644 --- a/android/guava/src/com/google/common/util/concurrent/AtomicDouble.java +++ b/android/guava/src/com/google/common/util/concurrent/AtomicDouble.java @@ -184,6 +184,7 @@ public final double addAndGet(double delta) { * * @return the String representation of the current value */ + @Override public String toString() { return Double.toString(get()); } @@ -192,6 +193,7 @@ public String toString() { * Returns the value of this {@code AtomicDouble} as an {@code int} after a narrowing primitive * conversion. */ + @Override public int intValue() { return (int) get(); } @@ -200,6 +202,7 @@ public int intValue() { * Returns the value of this {@code AtomicDouble} as a {@code long} after a narrowing primitive * conversion. */ + @Override public long longValue() { return (long) get(); } @@ -208,11 +211,13 @@ public long longValue() { * Returns the value of this {@code AtomicDouble} as a {@code float} after a narrowing primitive * conversion. */ + @Override public float floatValue() { return (float) get(); } /** Returns the value of this {@code AtomicDouble} as a {@code double}. */ + @Override public double doubleValue() { return get(); } diff --git a/android/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java b/android/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java index a364502d2e4e..c58395782709 100644 --- a/android/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java +++ b/android/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java @@ -206,6 +206,7 @@ public double addAndGet(int i, double delta) { * * @return the String representation of the current values of array */ + @Override public String toString() { int iMax = length() - 1; if (iMax == -1) { diff --git a/android/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java b/android/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java index 4f44a74254f2..f9da1d495631 100644 --- a/android/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java +++ b/android/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java @@ -99,6 +99,7 @@ public void execute(Runnable command) { delegate().execute(command); } + @Override public Future submit(Callable task) { return delegate().submit(task); } diff --git a/guava-testlib/src/com/google/common/collect/testing/google/AbstractListMultimapTester.java b/guava-testlib/src/com/google/common/collect/testing/google/AbstractListMultimapTester.java index 22404390a822..7bce8b012072 100644 --- a/guava-testlib/src/com/google/common/collect/testing/google/AbstractListMultimapTester.java +++ b/guava-testlib/src/com/google/common/collect/testing/google/AbstractListMultimapTester.java @@ -32,10 +32,12 @@ public class AbstractListMultimapTester extends AbstractMultimapTester> { + @Override protected void assertGet(K key, V... values) { assertGet(key, Arrays.asList(values)); } + @Override protected void assertGet(K key, Collection values) { assertEqualInOrder(values, multimap().get(key)); diff --git a/guava-testlib/src/com/google/common/collect/testing/google/DerivedGoogleCollectionGenerators.java b/guava-testlib/src/com/google/common/collect/testing/google/DerivedGoogleCollectionGenerators.java index dee61e121eee..bbeefd278e00 100644 --- a/guava-testlib/src/com/google/common/collect/testing/google/DerivedGoogleCollectionGenerators.java +++ b/guava-testlib/src/com/google/common/collect/testing/google/DerivedGoogleCollectionGenerators.java @@ -81,6 +81,7 @@ public V[] createValueArray(int length) { return (V[]) new Object[length]; } + @Override public TestSubjectGenerator getInnerGenerator() { return generator; } @@ -144,6 +145,7 @@ public K[] createValueArray(int length) { return (K[]) new Object[length]; } + @Override public TestSubjectGenerator getInnerGenerator() { return generator; } @@ -202,6 +204,7 @@ public Iterable order(List insertionOrder) { return insertionOrder; } + @Override public TestSubjectGenerator getInnerGenerator() { return mapGenerator; } diff --git a/guava-testlib/src/com/google/common/testing/GcFinalization.java b/guava-testlib/src/com/google/common/testing/GcFinalization.java index 08c03e8f3439..92394f17670a 100644 --- a/guava-testlib/src/com/google/common/testing/GcFinalization.java +++ b/guava-testlib/src/com/google/common/testing/GcFinalization.java @@ -264,6 +264,7 @@ public interface FinalizationPredicate { public static void awaitClear(final WeakReference ref) { awaitDone( new FinalizationPredicate() { + @Override public boolean isDone() { return ref.get() == null; } diff --git a/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java b/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java index 164ac5a0c0a5..645eda01529f 100644 --- a/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java +++ b/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java @@ -94,6 +94,7 @@ public void testAwaitDone_FinalizationPredicate() { map.put(new Object(), Boolean.TRUE); GcFinalization.awaitDone( new FinalizationPredicate() { + @Override public boolean isDone() { return map.isEmpty(); } @@ -116,6 +117,7 @@ class Interruptenator extends Thread { Interruptenator(final Thread interruptee, final AtomicBoolean shutdown) { super( new Runnable() { + @Override public void run() { while (!shutdown.get()) { interruptee.interrupt(); @@ -194,6 +196,7 @@ public void testAwaitDone_FinalizationPredicate_Interrupted() { try { GcFinalization.awaitDone( new FinalizationPredicate() { + @Override public boolean isDone() { return false; } diff --git a/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java b/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java index 967870140f02..b8af39899f7f 100644 --- a/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java +++ b/guava-tests/test/com/google/common/base/FinalizableReferenceQueueTest.java @@ -45,6 +45,7 @@ public void testFinalizeReferentCalled() { GcFinalization.awaitDone( new GcFinalization.FinalizationPredicate() { + @Override public boolean isDone() { return reference.finalizeReferentCalled; } diff --git a/guava-tests/test/com/google/common/collect/AbstractSequentialIteratorTest.java b/guava-tests/test/com/google/common/collect/AbstractSequentialIteratorTest.java index c0b7d91c4cf4..f63f01ae3775 100644 --- a/guava-tests/test/com/google/common/collect/AbstractSequentialIteratorTest.java +++ b/guava-tests/test/com/google/common/collect/AbstractSequentialIteratorTest.java @@ -59,6 +59,7 @@ public void testSampleCode() { public Iterator iterator() { Iterator powersOfTwo = new AbstractSequentialIterator(1) { + @Override protected Integer computeNext(Integer previous) { return (previous == 1 << 30) ? null : previous * 2; } diff --git a/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java b/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java index eec27251e5ec..c20e166167b6 100644 --- a/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java +++ b/guava-tests/test/com/google/common/collect/MapsTransformValuesTest.java @@ -58,6 +58,7 @@ public MapsTransformValuesTest() { super(false, true, false, true, true); } + @Override protected Map makeEmptyMap() { return Maps.transformValues(Maps.newHashMap(), Functions.identity()); } diff --git a/guava-tests/test/com/google/common/collect/QueuesTest.java b/guava-tests/test/com/google/common/collect/QueuesTest.java index e85051b9ea89..4ee1f82c579f 100644 --- a/guava-tests/test/com/google/common/collect/QueuesTest.java +++ b/guava-tests/test/com/google/common/collect/QueuesTest.java @@ -222,6 +222,7 @@ private void testDrainUninterruptibly_doesNotThrow(final BlockingQueue q Future possiblyIgnoredError = threadPool.submit( new Callable() { + @Override public Void call() throws InterruptedException { new Producer(q, 50).call(); new Interrupter(mainThread).run(); 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 70c186d345da..038e2ec69bc0 100644 --- a/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java @@ -188,6 +188,7 @@ public void testCompareAndSetInMultipleThreads() throws InterruptedException { Thread t = newStartedThread( new CheckedRunnable() { + @Override public void realRun() { while (!a.compareAndSet(0, 2.0, 3.0)) { Thread.yield(); @@ -270,6 +271,7 @@ class Counter extends CheckedRunnable { aa = a; } + @Override public void realRun() { for (; ; ) { boolean done = true; diff --git a/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java b/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java index 468ee3811f9e..c892842f71f1 100644 --- a/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleTest.java @@ -102,6 +102,7 @@ public void testCompareAndSetInMultipleThreads() throws Exception { Thread t = newStartedThread( new CheckedRunnable() { + @Override public void realRun() { while (!at.compareAndSet(2.0, 3.0)) { Thread.yield(); diff --git a/guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java b/guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java index 0822ae14a8df..8df7ce955821 100644 --- a/guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java +++ b/guava-tests/test/com/google/common/util/concurrent/JSR166TestCase.java @@ -115,6 +115,7 @@ abstract class JSR166TestCase extends TestCase { */ private static final long profileThreshold = Long.getLong("jsr166.profileThreshold", 100); + @Override protected void runTest() throws Throwable { if (profileTests) runTestProfiled(); else super.runTest(); @@ -280,6 +281,7 @@ public void threadRecordFailure(Throwable t) { threadFailure.compareAndSet(null, t); } + @Override public void setUp() { setDelays(); } @@ -292,6 +294,7 @@ public void setUp() { * *

Triggers test case failure if interrupt status is set in the main thread. */ + @Override public void tearDown() throws Exception { Throwable t = threadFailure.getAndSet(null); if (t != null) { @@ -602,18 +605,22 @@ void clearPermissions() { perms = new Permissions(); } + @Override public PermissionCollection getPermissions(CodeSource cs) { return perms; } + @Override public PermissionCollection getPermissions(ProtectionDomain pd) { return perms; } + @Override public boolean implies(ProtectionDomain pd, Permission p) { return perms.implies(p); } + @Override public void refresh() {} } @@ -721,6 +728,7 @@ void awaitTermination(Thread t) { public abstract class CheckedRunnable implements Runnable { protected abstract void realRun() throws Throwable; + @Override public final void run() { try { realRun(); @@ -739,6 +747,7 @@ RunnableShouldThrow(Class exceptionClass) { this.exceptionClass = exceptionClass; } + @Override public final void run() { try { realRun(); @@ -758,6 +767,7 @@ ThreadShouldThrow(Class exceptionClass) { this.exceptionClass = exceptionClass; } + @Override public final void run() { try { realRun(); @@ -771,6 +781,7 @@ public final void run() { public abstract class CheckedInterruptedRunnable implements Runnable { protected abstract void realRun() throws Throwable; + @Override public final void run() { try { realRun(); @@ -786,6 +797,7 @@ public final void run() { public abstract class CheckedCallable implements Callable { protected abstract T realCall() throws Throwable; + @Override public final T call() { try { return realCall(); @@ -799,6 +811,7 @@ public final T call() { public abstract class CheckedInterruptedCallable implements Callable { protected abstract T realCall() throws Throwable; + @Override public final T call() { try { T result = realCall(); @@ -814,10 +827,12 @@ public final T call() { } public static class NoOpRunnable implements Runnable { + @Override public void run() {} } public static class NoOpCallable implements Callable { + @Override public Object call() { return Boolean.TRUE; } @@ -826,6 +841,7 @@ public Object call() { public static final String TEST_STRING = "a test string"; public static class StringTask implements Callable { + @Override public String call() { return TEST_STRING; } @@ -833,6 +849,7 @@ public String call() { public Callable latchAwaitingStringTask(final CountDownLatch latch) { return new CheckedCallable() { + @Override protected String realCall() { try { latch.await(); @@ -845,6 +862,7 @@ protected String realCall() { public Runnable awaiter(final CountDownLatch latch) { return new CheckedRunnable() { + @Override public void realRun() throws InterruptedException { await(latch); } @@ -887,36 +905,42 @@ public void await(Semaphore semaphore) { // } public static class NPETask implements Callable { + @Override public String call() { throw new NullPointerException(); } } public static class CallableOne implements Callable { + @Override public Integer call() { return one; } } public class ShortRunnable extends CheckedRunnable { + @Override protected void realRun() throws Throwable { delay(SHORT_DELAY_MS); } } public class ShortInterruptedRunnable extends CheckedInterruptedRunnable { + @Override protected void realRun() throws InterruptedException { delay(SHORT_DELAY_MS); } } public class SmallRunnable extends CheckedRunnable { + @Override protected void realRun() throws Throwable { delay(SMALL_DELAY_MS); } } public class SmallPossiblyInterruptedRunnable extends CheckedRunnable { + @Override protected void realRun() { try { delay(SMALL_DELAY_MS); @@ -926,6 +950,7 @@ protected void realRun() { } public class SmallCallable extends CheckedCallable { + @Override protected Object realCall() throws InterruptedException { delay(SMALL_DELAY_MS); return Boolean.TRUE; @@ -933,12 +958,14 @@ protected Object realCall() throws InterruptedException { } public class MediumRunnable extends CheckedRunnable { + @Override protected void realRun() throws Throwable { delay(MEDIUM_DELAY_MS); } } public class MediumInterruptedRunnable extends CheckedInterruptedRunnable { + @Override protected void realRun() throws InterruptedException { delay(MEDIUM_DELAY_MS); } @@ -946,6 +973,7 @@ protected void realRun() throws InterruptedException { public Runnable possiblyInterruptedRunnable(final long timeoutMillis) { return new CheckedRunnable() { + @Override protected void realRun() { try { delay(timeoutMillis); @@ -956,6 +984,7 @@ protected void realRun() { } public class MediumPossiblyInterruptedRunnable extends CheckedRunnable { + @Override protected void realRun() { try { delay(MEDIUM_DELAY_MS); @@ -965,6 +994,7 @@ protected void realRun() { } public class LongPossiblyInterruptedRunnable extends CheckedRunnable { + @Override protected void realRun() { try { delay(LONG_DELAY_MS); @@ -975,6 +1005,7 @@ protected void realRun() { /** For use as ThreadFactory in constructors */ public static class SimpleThreadFactory implements ThreadFactory { + @Override public Thread newThread(Runnable r) { return new Thread(r); } @@ -988,10 +1019,12 @@ public static TrackedRunnable trackedRunnable(final long timeoutMillis) { return new TrackedRunnable() { private volatile boolean done = false; + @Override public boolean isDone() { return done; } + @Override public void run() { try { delay(timeoutMillis); @@ -1005,6 +1038,7 @@ public void run() { public static class TrackedShortRunnable implements Runnable { public volatile boolean done = false; + @Override public void run() { try { delay(SHORT_DELAY_MS); @@ -1017,6 +1051,7 @@ public void run() { public static class TrackedSmallRunnable implements Runnable { public volatile boolean done = false; + @Override public void run() { try { delay(SMALL_DELAY_MS); @@ -1029,6 +1064,7 @@ public void run() { public static class TrackedMediumRunnable implements Runnable { public volatile boolean done = false; + @Override public void run() { try { delay(MEDIUM_DELAY_MS); @@ -1041,6 +1077,7 @@ public void run() { public static class TrackedLongRunnable implements Runnable { public volatile boolean done = false; + @Override public void run() { try { delay(LONG_DELAY_MS); @@ -1053,6 +1090,7 @@ public void run() { public static class TrackedNoOpRunnable implements Runnable { public volatile boolean done = false; + @Override public void run() { done = true; } @@ -1061,6 +1099,7 @@ public void run() { public static class TrackedCallable implements Callable { public volatile boolean done = false; + @Override public Object call() { try { delay(SMALL_DELAY_MS); @@ -1104,6 +1143,7 @@ public Object call() { /** For use as RejectedExecutionHandler in constructors */ public static class NoOpREHandler implements RejectedExecutionHandler { + @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {} } @@ -1116,6 +1156,7 @@ public CheckedBarrier(int parties) { super(parties); } + @Override public int await() { try { return super.await(2 * LONG_DELAY_MS, MILLISECONDS); diff --git a/guava/src/com/google/common/base/CharMatcher.java b/guava/src/com/google/common/base/CharMatcher.java index 6e150248e48f..89ebfe008f84 100644 --- a/guava/src/com/google/common/base/CharMatcher.java +++ b/guava/src/com/google/common/base/CharMatcher.java @@ -367,6 +367,7 @@ protected CharMatcher() {} /** Returns a matcher that matches any character not matched by this matcher. */ // @Override under Java 8 but not under Java 7 + @Override public CharMatcher negate() { return new Negated(this); } diff --git a/guava/src/com/google/common/cache/LocalCache.java b/guava/src/com/google/common/cache/LocalCache.java index 46fc29388ec9..f2b875d5390b 100644 --- a/guava/src/com/google/common/cache/LocalCache.java +++ b/guava/src/com/google/common/cache/LocalCache.java @@ -3966,6 +3966,7 @@ V get(K key, CacheLoader loader) throws ExecutionException { // Only becomes available in Java 8 when it's on the interface. // @Override + @Override public @Nullable V getOrDefault(@Nullable Object key, @Nullable V defaultValue) { V result = get(key); return (result != null) ? result : defaultValue; diff --git a/guava/src/com/google/common/cache/LongAdder.java b/guava/src/com/google/common/cache/LongAdder.java index 2e8553253012..f0c44ffbc697 100644 --- a/guava/src/com/google/common/cache/LongAdder.java +++ b/guava/src/com/google/common/cache/LongAdder.java @@ -44,6 +44,7 @@ final class LongAdder extends Striped64 implements Serializable, LongAddable { private static final long serialVersionUID = 7249069246863182397L; /** Version of plus for use in retryUpdate */ + @Override final long fn(long v, long x) { return v + x; } @@ -56,6 +57,7 @@ public LongAdder() {} * * @param x the value to add */ + @Override public void add(long x) { Cell[] as; long b, v; @@ -73,6 +75,7 @@ public void add(long x) { } /** Equivalent to {@code add(1)}. */ + @Override public void increment() { add(1L); } @@ -89,6 +92,7 @@ public void decrement() { * * @return the sum */ + @Override public long sum() { long sum = base; Cell[] as = cells; @@ -142,6 +146,7 @@ public long sumThenReset() { * * @return the String representation of the {@link #sum} */ + @Override public String toString() { return Long.toString(sum()); } @@ -151,21 +156,25 @@ public String toString() { * * @return the sum */ + @Override public long longValue() { return sum(); } /** Returns the {@link #sum} as an {@code int} after a narrowing primitive conversion. */ + @Override public int intValue() { return (int) sum(); } /** Returns the {@link #sum} as a {@code float} after a widening primitive conversion. */ + @Override public float floatValue() { return (float) sum(); } /** Returns the {@link #sum} as a {@code double} after a widening primitive conversion. */ + @Override public double doubleValue() { return (double) sum(); } diff --git a/guava/src/com/google/common/cache/Striped64.java b/guava/src/com/google/common/cache/Striped64.java index e2f1cbf1377c..8c53158eb1d3 100644 --- a/guava/src/com/google/common/cache/Striped64.java +++ b/guava/src/com/google/common/cache/Striped64.java @@ -293,6 +293,7 @@ private static sun.misc.Unsafe getUnsafe() { try { return java.security.AccessController.doPrivileged( new java.security.PrivilegedExceptionAction() { + @Override public sun.misc.Unsafe run() throws Exception { Class k = sun.misc.Unsafe.class; for (java.lang.reflect.Field f : k.getDeclaredFields()) { diff --git a/guava/src/com/google/common/collect/EmptyContiguousSet.java b/guava/src/com/google/common/collect/EmptyContiguousSet.java index 922de306f066..fd90124b59c3 100644 --- a/guava/src/com/google/common/collect/EmptyContiguousSet.java +++ b/guava/src/com/google/common/collect/EmptyContiguousSet.java @@ -162,6 +162,7 @@ Object writeReplace() { } @GwtIncompatible // NavigableSet + @Override ImmutableSortedSet createDescendingSet() { return ImmutableSortedSet.emptySet(Ordering.natural().reverse()); } diff --git a/guava/src/com/google/common/collect/ImmutableSetMultimap.java b/guava/src/com/google/common/collect/ImmutableSetMultimap.java index bab39c90f0be..7f59097b4379 100644 --- a/guava/src/com/google/common/collect/ImmutableSetMultimap.java +++ b/guava/src/com/google/common/collect/ImmutableSetMultimap.java @@ -471,9 +471,8 @@ public ImmutableSet get(@Nullable K key) { *

Because an inverse of a set multimap cannot contain multiple pairs with the same key and * value, this method returns an {@code ImmutableSetMultimap} rather than the {@code * ImmutableMultimap} specified in the {@code ImmutableMultimap} class. - * - * @since 11.0 */ + @Override public ImmutableSetMultimap inverse() { ImmutableSetMultimap result = inverse; return (result == null) ? (inverse = invert()) : result; diff --git a/guava/src/com/google/common/collect/SortedMultiset.java b/guava/src/com/google/common/collect/SortedMultiset.java index 7da5528e8b47..849ea50d231f 100644 --- a/guava/src/com/google/common/collect/SortedMultiset.java +++ b/guava/src/com/google/common/collect/SortedMultiset.java @@ -47,6 +47,7 @@ public interface SortedMultiset extends SortedMultisetBridge, SortedIterab * Returns the comparator that orders this multiset, or {@link Ordering#natural()} if the natural * ordering of the elements is used. */ + @Override Comparator comparator(); /** diff --git a/guava/src/com/google/common/hash/Funnels.java b/guava/src/com/google/common/hash/Funnels.java index a95769e91347..6051bfd7c3ec 100644 --- a/guava/src/com/google/common/hash/Funnels.java +++ b/guava/src/com/google/common/hash/Funnels.java @@ -39,6 +39,7 @@ public static Funnel byteArrayFunnel() { private enum ByteArrayFunnel implements Funnel { INSTANCE; + @Override public void funnel(byte[] from, PrimitiveSink into) { into.putBytes(from); } @@ -63,6 +64,7 @@ public static Funnel unencodedCharsFunnel() { private enum UnencodedCharsFunnel implements Funnel { INSTANCE; + @Override public void funnel(CharSequence from, PrimitiveSink into) { into.putUnencodedChars(from); } @@ -90,6 +92,7 @@ private static class StringCharsetFunnel implements Funnel, Serial this.charset = Preconditions.checkNotNull(charset); } + @Override public void funnel(CharSequence from, PrimitiveSink into) { into.putString(from, charset); } @@ -144,6 +147,7 @@ public static Funnel integerFunnel() { private enum IntegerFunnel implements Funnel { INSTANCE; + @Override public void funnel(Integer from, PrimitiveSink into) { into.putInt(from); } @@ -171,6 +175,7 @@ private static class SequentialFunnel implements Funnel this.elementFunnel = Preconditions.checkNotNull(elementFunnel); } + @Override public void funnel(Iterable from, PrimitiveSink into) { for (E e : from) { elementFunnel.funnel(e, into); @@ -209,6 +214,7 @@ public static Funnel longFunnel() { private enum LongFunnel implements Funnel { INSTANCE; + @Override public void funnel(Long from, PrimitiveSink into) { into.putLong(from); } diff --git a/guava/src/com/google/common/hash/LongAdder.java b/guava/src/com/google/common/hash/LongAdder.java index 7ef21100ee7e..bd08428ff3a4 100644 --- a/guava/src/com/google/common/hash/LongAdder.java +++ b/guava/src/com/google/common/hash/LongAdder.java @@ -42,6 +42,7 @@ final class LongAdder extends Striped64 implements Serializable, LongAddable { private static final long serialVersionUID = 7249069246863182397L; /** Version of plus for use in retryUpdate */ + @Override final long fn(long v, long x) { return v + x; } @@ -54,6 +55,7 @@ public LongAdder() {} * * @param x the value to add */ + @Override public void add(long x) { Cell[] as; long b, v; @@ -71,6 +73,7 @@ public void add(long x) { } /** Equivalent to {@code add(1)}. */ + @Override public void increment() { add(1L); } @@ -87,6 +90,7 @@ public void decrement() { * * @return the sum */ + @Override public long sum() { long sum = base; Cell[] as = cells; @@ -140,6 +144,7 @@ public long sumThenReset() { * * @return the String representation of the {@link #sum} */ + @Override public String toString() { return Long.toString(sum()); } @@ -149,21 +154,25 @@ public String toString() { * * @return the sum */ + @Override public long longValue() { return sum(); } /** Returns the {@link #sum} as an {@code int} after a narrowing primitive conversion. */ + @Override public int intValue() { return (int) sum(); } /** Returns the {@link #sum} as a {@code float} after a widening primitive conversion. */ + @Override public float floatValue() { return (float) sum(); } /** Returns the {@link #sum} as a {@code double} after a widening primitive conversion. */ + @Override public double doubleValue() { return (double) sum(); } diff --git a/guava/src/com/google/common/hash/Striped64.java b/guava/src/com/google/common/hash/Striped64.java index 8f6348a40eb3..3f6cf1b06be2 100644 --- a/guava/src/com/google/common/hash/Striped64.java +++ b/guava/src/com/google/common/hash/Striped64.java @@ -293,6 +293,7 @@ private static sun.misc.Unsafe getUnsafe() { try { return java.security.AccessController.doPrivileged( new java.security.PrivilegedExceptionAction() { + @Override public sun.misc.Unsafe run() throws Exception { Class k = sun.misc.Unsafe.class; for (java.lang.reflect.Field f : k.getDeclaredFields()) { diff --git a/guava/src/com/google/common/reflect/Parameter.java b/guava/src/com/google/common/reflect/Parameter.java index 4d0388ea6e47..d916310ba074 100644 --- a/guava/src/com/google/common/reflect/Parameter.java +++ b/guava/src/com/google/common/reflect/Parameter.java @@ -85,6 +85,7 @@ public Annotation[] getAnnotations() { /** @since 18.0 */ // @Override on JDK8 + @Override public A[] getAnnotationsByType(Class annotationType) { return getDeclaredAnnotationsByType(annotationType); } @@ -98,6 +99,7 @@ public Annotation[] getDeclaredAnnotations() { /** @since 18.0 */ // @Override on JDK8 + @Override public @Nullable A getDeclaredAnnotation(Class annotationType) { checkNotNull(annotationType); return FluentIterable.from(annotations).filter(annotationType).first().orNull(); @@ -105,6 +107,7 @@ public Annotation[] getDeclaredAnnotations() { /** @since 18.0 */ // @Override on JDK8 + @Override public A[] getDeclaredAnnotationsByType(Class annotationType) { return FluentIterable.from(annotations).filter(annotationType).toArray(annotationType); } diff --git a/guava/src/com/google/common/util/concurrent/AtomicDouble.java b/guava/src/com/google/common/util/concurrent/AtomicDouble.java index 4701084ac29e..42d6656150f8 100644 --- a/guava/src/com/google/common/util/concurrent/AtomicDouble.java +++ b/guava/src/com/google/common/util/concurrent/AtomicDouble.java @@ -191,6 +191,7 @@ public final double addAndGet(double delta) { * * @return the String representation of the current value */ + @Override public String toString() { return Double.toString(get()); } @@ -199,6 +200,7 @@ public String toString() { * Returns the value of this {@code AtomicDouble} as an {@code int} after a narrowing primitive * conversion. */ + @Override public int intValue() { return (int) get(); } @@ -207,6 +209,7 @@ public int intValue() { * Returns the value of this {@code AtomicDouble} as a {@code long} after a narrowing primitive * conversion. */ + @Override public long longValue() { return (long) get(); } @@ -215,11 +218,13 @@ public long longValue() { * Returns the value of this {@code AtomicDouble} as a {@code float} after a narrowing primitive * conversion. */ + @Override public float floatValue() { return (float) get(); } /** Returns the value of this {@code AtomicDouble} as a {@code double}. */ + @Override public double doubleValue() { return get(); } diff --git a/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java b/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java index a364502d2e4e..c58395782709 100644 --- a/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java +++ b/guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java @@ -206,6 +206,7 @@ public double addAndGet(int i, double delta) { * * @return the String representation of the current values of array */ + @Override public String toString() { int iMax = length() - 1; if (iMax == -1) { diff --git a/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java b/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java index 4f44a74254f2..f9da1d495631 100644 --- a/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java +++ b/guava/src/com/google/common/util/concurrent/ForwardingExecutorService.java @@ -99,6 +99,7 @@ public void execute(Runnable command) { delegate().execute(command); } + @Override public Future submit(Callable task) { return delegate().submit(task); } From f6287e1b85eb4daf5678d252aaaf215a82f4fd2d Mon Sep 17 00:00:00 2001 From: jdcormie Date: Fri, 1 Feb 2019 11:29:10 -0800 Subject: [PATCH 05/23] Document the retention of listeners added to Guava implementations of ListenableFuture. RELNOTES=Document the retention of listeners added to Guava implementations of `ListenableFuture`. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=232007326 --- .../com/google/common/util/concurrent/ListenableFuture.java | 3 +++ .../com/google/common/util/concurrent/ListenableFuture.java | 3 +++ .../com/google/common/util/concurrent/ListenableFuture.java | 3 +++ 3 files changed, 9 insertions(+) diff --git a/android/guava/src/com/google/common/util/concurrent/ListenableFuture.java b/android/guava/src/com/google/common/util/concurrent/ListenableFuture.java index 33b56d6a1bcd..862ff2aa7beb 100644 --- a/android/guava/src/com/google/common/util/concurrent/ListenableFuture.java +++ b/android/guava/src/com/google/common/util/concurrent/ListenableFuture.java @@ -135,6 +135,9 @@ public interface ListenableFuture extends Future { * href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.4.5"> * happen-before its execution begins, perhaps in another thread. * + *

Guava implementations of {@code ListenableFuture} promptly release references to listeners + * after executing them. + * * @param listener the listener to run when the computation is complete * @param executor the executor to run the listener in * @throws RejectedExecutionException if we tried to execute the listener immediately but the diff --git a/futures/listenablefuture1/src/com/google/common/util/concurrent/ListenableFuture.java b/futures/listenablefuture1/src/com/google/common/util/concurrent/ListenableFuture.java index 33b56d6a1bcd..862ff2aa7beb 100644 --- a/futures/listenablefuture1/src/com/google/common/util/concurrent/ListenableFuture.java +++ b/futures/listenablefuture1/src/com/google/common/util/concurrent/ListenableFuture.java @@ -135,6 +135,9 @@ public interface ListenableFuture extends Future { * href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.4.5"> * happen-before its execution begins, perhaps in another thread. * + *

Guava implementations of {@code ListenableFuture} promptly release references to listeners + * after executing them. + * * @param listener the listener to run when the computation is complete * @param executor the executor to run the listener in * @throws RejectedExecutionException if we tried to execute the listener immediately but the diff --git a/guava/src/com/google/common/util/concurrent/ListenableFuture.java b/guava/src/com/google/common/util/concurrent/ListenableFuture.java index 33b56d6a1bcd..862ff2aa7beb 100644 --- a/guava/src/com/google/common/util/concurrent/ListenableFuture.java +++ b/guava/src/com/google/common/util/concurrent/ListenableFuture.java @@ -135,6 +135,9 @@ public interface ListenableFuture extends Future { * href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.4.5"> * happen-before its execution begins, perhaps in another thread. * + *

Guava implementations of {@code ListenableFuture} promptly release references to listeners + * after executing them. + * * @param listener the listener to run when the computation is complete * @param executor the executor to run the listener in * @throws RejectedExecutionException if we tried to execute the listener immediately but the From 28cff42bc92b7685937c5771868167e0c03155d3 Mon Sep 17 00:00:00 2001 From: cushon Date: Mon, 4 Feb 2019 11:07:18 -0800 Subject: [PATCH 06/23] Reformat with google-java-format RELNOTES=N/A ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=232329476 --- .../collect/BinaryTreeTraverserBenchmark.java | 1 - .../com/google/common/base/StringsTest.java | 3 +- .../common/collect/CompactHashMapTest.java | 37 +++++----- .../common/collect/CompactHashSetTest.java | 71 +++++++++++-------- .../collect/CompactLinkedHashMapTest.java | 44 ++++++------ .../collect/CompactLinkedHashSetTest.java | 39 +++++----- .../common/collect/ForwardingMapTest.java | 12 ++-- .../common/graph/AbstractNetworkTest.java | 2 +- .../graph/ConfigurableDirectedGraphTest.java | 5 +- .../ConfigurableUndirectedGraphTest.java | 5 +- .../common/reflect/TypeTokenSubtypeTest.java | 52 +++++++------- .../concurrent/InterruptibleTaskTest.java | 4 +- .../common/util/concurrent/StripedTest.java | 28 ++++---- .../collect/BinaryTreeTraverserBenchmark.java | 1 - .../com/google/common/base/StringsTest.java | 3 +- .../cache/LocalCacheMapComputeTest.java | 14 +++- .../common/collect/CompactHashMapTest.java | 37 +++++----- .../common/collect/CompactHashSetTest.java | 71 +++++++++++-------- .../collect/CompactLinkedHashMapTest.java | 44 ++++++------ .../collect/CompactLinkedHashSetTest.java | 39 +++++----- .../common/collect/ForwardingMapTest.java | 12 ++-- .../common/collect/ImmutableBiMapTest.java | 6 +- .../common/graph/AbstractNetworkTest.java | 2 +- .../graph/ConfigurableDirectedGraphTest.java | 5 +- .../ConfigurableUndirectedGraphTest.java | 5 +- .../common/reflect/TypeTokenSubtypeTest.java | 52 +++++++------- .../concurrent/InterruptibleTaskTest.java | 4 +- .../common/util/concurrent/StripedTest.java | 28 ++++---- 28 files changed, 337 insertions(+), 289 deletions(-) diff --git a/android/guava-tests/benchmark/com/google/common/collect/BinaryTreeTraverserBenchmark.java b/android/guava-tests/benchmark/com/google/common/collect/BinaryTreeTraverserBenchmark.java index 2fd21e978346..75fc1f90d2ef 100644 --- a/android/guava-tests/benchmark/com/google/common/collect/BinaryTreeTraverserBenchmark.java +++ b/android/guava-tests/benchmark/com/google/common/collect/BinaryTreeTraverserBenchmark.java @@ -18,7 +18,6 @@ import com.google.caliper.Benchmark; import com.google.caliper.Param; import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; import com.google.common.primitives.Ints; import java.util.List; import java.util.Random; diff --git a/android/guava-tests/test/com/google/common/base/StringsTest.java b/android/guava-tests/test/com/google/common/base/StringsTest.java index 8eda06702a1e..ac3ad20a52dc 100644 --- a/android/guava-tests/test/com/google/common/base/StringsTest.java +++ b/android/guava-tests/test/com/google/common/base/StringsTest.java @@ -242,8 +242,7 @@ public void testLenientFormat_badArgumentToString() { public void testLenientFormat_badArgumentToString_gwtFriendly() { assertThat(Strings.lenientFormat("boiler %s plate", new ThrowsOnToString())) - .matches( - "boiler <.*> plate"); + .matches("boiler <.*> plate"); } private static class ThrowsOnToString { diff --git a/android/guava-tests/test/com/google/common/collect/CompactHashMapTest.java b/android/guava-tests/test/com/google/common/collect/CompactHashMapTest.java index 87480d0914b9..33e601556238 100644 --- a/android/guava-tests/test/com/google/common/collect/CompactHashMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/CompactHashMapTest.java @@ -37,22 +37,27 @@ public class CompactHashMapTest extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); - suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() { - @Override - protected Map create(Entry[] entries) { - Map map = CompactHashMap.create(); - for (Entry entry : entries) { - map.put(entry.getKey(), entry.getValue()); - } - return map; - } - }) - .named("CompactHashMap") - .withFeatures( - CollectionSize.ANY, MapFeature.GENERAL_PURPOSE, MapFeature.ALLOWS_NULL_KEYS, - MapFeature.ALLOWS_NULL_VALUES, CollectionFeature.SERIALIZABLE, - CollectionFeature.SUPPORTS_ITERATOR_REMOVE) - .createTestSuite()); + suite.addTest( + MapTestSuiteBuilder.using( + new TestStringMapGenerator() { + @Override + protected Map create(Entry[] entries) { + Map map = CompactHashMap.create(); + for (Entry entry : entries) { + map.put(entry.getKey(), entry.getValue()); + } + return map; + } + }) + .named("CompactHashMap") + .withFeatures( + CollectionSize.ANY, + MapFeature.GENERAL_PURPOSE, + MapFeature.ALLOWS_NULL_KEYS, + MapFeature.ALLOWS_NULL_VALUES, + CollectionFeature.SERIALIZABLE, + CollectionFeature.SUPPORTS_ITERATOR_REMOVE) + .createTestSuite()); suite.addTestSuite(CompactHashMapTest.class); return suite; } diff --git a/android/guava-tests/test/com/google/common/collect/CompactHashSetTest.java b/android/guava-tests/test/com/google/common/collect/CompactHashSetTest.java index 08eabf5523a2..e5c3a458b57e 100644 --- a/android/guava-tests/test/com/google/common/collect/CompactHashSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/CompactHashSetTest.java @@ -37,40 +37,49 @@ @GwtIncompatible // java.util.Arrays#copyOf(Object[], int), java.lang.reflect.Array public class CompactHashSetTest extends TestCase { public static Test suite() { - List> allFeatures = Arrays.>asList( - CollectionSize.ANY, - CollectionFeature.ALLOWS_NULL_VALUES, - CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, - CollectionFeature.GENERAL_PURPOSE, - CollectionFeature.REMOVE_OPERATIONS, - CollectionFeature.SERIALIZABLE, - CollectionFeature.SUPPORTS_ADD, - CollectionFeature.SUPPORTS_REMOVE); + List> allFeatures = + Arrays.>asList( + CollectionSize.ANY, + CollectionFeature.ALLOWS_NULL_VALUES, + CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, + CollectionFeature.GENERAL_PURPOSE, + CollectionFeature.REMOVE_OPERATIONS, + CollectionFeature.SERIALIZABLE, + CollectionFeature.SUPPORTS_ADD, + CollectionFeature.SUPPORTS_REMOVE); TestSuite suite = new TestSuite(); suite.addTestSuite(CompactHashSetTest.class); - suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() { - @Override protected Set create(String[] elements) { - return CompactHashSet.create(Arrays.asList(elements)); - } - }).named("CompactHashSet") - .withFeatures(allFeatures) - .createTestSuite()); - suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() { - @Override protected Set create(String[] elements) { - CompactHashSet set = CompactHashSet.create(Arrays.asList(elements)); - for (int i = 0; i < 100; i++) { - set.add(i); - } - for (int i = 0; i < 100; i++) { - set.remove(i); - } - set.trimToSize(); - return set; - } - }).named("CompactHashSet#TrimToSize") - .withFeatures(allFeatures) - .createTestSuite()); + suite.addTest( + SetTestSuiteBuilder.using( + new TestStringSetGenerator() { + @Override + protected Set create(String[] elements) { + return CompactHashSet.create(Arrays.asList(elements)); + } + }) + .named("CompactHashSet") + .withFeatures(allFeatures) + .createTestSuite()); + suite.addTest( + SetTestSuiteBuilder.using( + new TestStringSetGenerator() { + @Override + protected Set create(String[] elements) { + CompactHashSet set = CompactHashSet.create(Arrays.asList(elements)); + for (int i = 0; i < 100; i++) { + set.add(i); + } + for (int i = 0; i < 100; i++) { + set.remove(i); + } + set.trimToSize(); + return set; + } + }) + .named("CompactHashSet#TrimToSize") + .withFeatures(allFeatures) + .createTestSuite()); return suite; } diff --git a/android/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java b/android/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java index 4235f6bbfa93..f7e28572967a 100644 --- a/android/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java @@ -35,22 +35,28 @@ public class CompactLinkedHashMapTest extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); - suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() { - @Override - protected Map create(Entry[] entries) { - Map map = CompactLinkedHashMap.create(); - for (Entry entry : entries) { - map.put(entry.getKey(), entry.getValue()); - } - return map; - } - }).named("CompactLinkedHashMap").withFeatures(CollectionSize.ANY, - CollectionFeature.SUPPORTS_ITERATOR_REMOVE, - MapFeature.GENERAL_PURPOSE, - MapFeature.ALLOWS_NULL_KEYS, - MapFeature.ALLOWS_NULL_VALUES, - CollectionFeature.SERIALIZABLE, - CollectionFeature.KNOWN_ORDER).createTestSuite()); + suite.addTest( + MapTestSuiteBuilder.using( + new TestStringMapGenerator() { + @Override + protected Map create(Entry[] entries) { + Map map = CompactLinkedHashMap.create(); + for (Entry entry : entries) { + map.put(entry.getKey(), entry.getValue()); + } + return map; + } + }) + .named("CompactLinkedHashMap") + .withFeatures( + CollectionSize.ANY, + CollectionFeature.SUPPORTS_ITERATOR_REMOVE, + MapFeature.GENERAL_PURPOSE, + MapFeature.ALLOWS_NULL_KEYS, + MapFeature.ALLOWS_NULL_VALUES, + CollectionFeature.SERIALIZABLE, + CollectionFeature.KNOWN_ORDER) + .createTestSuite()); suite.addTestSuite(CompactLinkedHashMapTest.class); return suite; } @@ -119,8 +125,7 @@ public void testTrimToSize() { testHasMapEntriesInOrder(map, 1, "a", 4, "b", 3, "d", 2, "c"); } - private void testHasMapEntriesInOrder(Map map, - Object... alternatingKeysAndValues) { + private void testHasMapEntriesInOrder(Map map, Object... alternatingKeysAndValues) { List> entries = Lists.newArrayList(map.entrySet()); List keys = Lists.newArrayList(map.keySet()); List values = Lists.newArrayList(map.values()); @@ -130,8 +135,7 @@ private void testHasMapEntriesInOrder(Map map, for (int i = 0; i < map.size(); i++) { Object expectedKey = alternatingKeysAndValues[2 * i]; Object expectedValue = alternatingKeysAndValues[2 * i + 1]; - Entry expectedEntry = Maps.immutableEntry( - expectedKey, expectedValue); + Entry expectedEntry = Maps.immutableEntry(expectedKey, expectedValue); assertEquals(expectedEntry, entries.get(i)); assertEquals(expectedKey, keys.get(i)); assertEquals(expectedValue, values.get(i)); diff --git a/android/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java b/android/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java index 2e9bad2ad29b..a95e4861c2a2 100644 --- a/android/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java +++ b/android/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java @@ -37,26 +37,31 @@ @GwtIncompatible // java.util.Arrays#copyOf(Object[], int), java.lang.reflect.Array public class CompactLinkedHashSetTest extends TestCase { public static Test suite() { - List> allFeatures = Arrays.>asList( - CollectionSize.ANY, - CollectionFeature.ALLOWS_NULL_VALUES, - CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, - CollectionFeature.GENERAL_PURPOSE, - CollectionFeature.REMOVE_OPERATIONS, - CollectionFeature.SERIALIZABLE, - CollectionFeature.KNOWN_ORDER, - CollectionFeature.SUPPORTS_ADD, - CollectionFeature.SUPPORTS_REMOVE); + List> allFeatures = + Arrays.>asList( + CollectionSize.ANY, + CollectionFeature.ALLOWS_NULL_VALUES, + CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, + CollectionFeature.GENERAL_PURPOSE, + CollectionFeature.REMOVE_OPERATIONS, + CollectionFeature.SERIALIZABLE, + CollectionFeature.KNOWN_ORDER, + CollectionFeature.SUPPORTS_ADD, + CollectionFeature.SUPPORTS_REMOVE); TestSuite suite = new TestSuite(); suite.addTestSuite(CompactLinkedHashSetTest.class); - suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() { - @Override protected Set create(String[] elements) { - return CompactLinkedHashSet.create(Arrays.asList(elements)); - } - }).named("CompactLinkedHashSet") - .withFeatures(allFeatures) - .createTestSuite()); + suite.addTest( + SetTestSuiteBuilder.using( + new TestStringSetGenerator() { + @Override + protected Set create(String[] elements) { + return CompactLinkedHashSet.create(Arrays.asList(elements)); + } + }) + .named("CompactLinkedHashSet") + .withFeatures(allFeatures) + .createTestSuite()); return suite; } diff --git a/android/guava-tests/test/com/google/common/collect/ForwardingMapTest.java b/android/guava-tests/test/com/google/common/collect/ForwardingMapTest.java index 62988ed0189c..6ca5b8cc145a 100644 --- a/android/guava-tests/test/com/google/common/collect/ForwardingMapTest.java +++ b/android/guava-tests/test/com/google/common/collect/ForwardingMapTest.java @@ -329,10 +329,11 @@ protected Map delegate() { }; } - private static final ImmutableMap JUF_METHODS = ImmutableMap.of( - "java.util.function.Predicate", "test", - "java.util.function.Consumer", "accept", - "java.util.function.IntFunction", "apply"); + private static final ImmutableMap JUF_METHODS = + ImmutableMap.of( + "java.util.function.Predicate", "test", + "java.util.function.Consumer", "accept", + "java.util.function.IntFunction", "apply"); private static Object getDefaultValue(final TypeToken type) { Class rawType = type.getRawType(); @@ -387,8 +388,7 @@ private static void callAllPublicMethods(TypeToken type, T object) } } } catch (Throwable cause) { - throw new InvocationTargetException( - cause, method + " with args: " + Arrays.toString(args)); + throw new InvocationTargetException(cause, method + " with args: " + Arrays.toString(args)); } } } 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 0a927302d48d..9154a7389077 100644 --- a/android/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java +++ b/android/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java @@ -120,7 +120,7 @@ protected boolean addNode(Integer n) { * add an edge whose end-points don't already exist in the graph), you should not use this * method. * - * TODO(user): remove the addNode() calls, that's now contractually guaranteed + *

TODO(user): remove the addNode() calls, that's now contractually guaranteed * * @return {@code true} iff the graph was modified as a result of this call */ diff --git a/android/guava-tests/test/com/google/common/graph/ConfigurableDirectedGraphTest.java b/android/guava-tests/test/com/google/common/graph/ConfigurableDirectedGraphTest.java index 80533fc10155..ed998eb4226a 100644 --- a/android/guava-tests/test/com/google/common/graph/ConfigurableDirectedGraphTest.java +++ b/android/guava-tests/test/com/google/common/graph/ConfigurableDirectedGraphTest.java @@ -59,9 +59,8 @@ public void incidentEdges_selfLoop() { putEdge(N1, N1); assertThat(graph.incidentEdges(N1)).containsExactly(EndpointPair.ordered(N1, N1)); putEdge(N1, N2); - assertThat(graph.incidentEdges(N1)).containsExactly( - EndpointPair.ordered(N1, N1), - EndpointPair.ordered(N1, N2)); + assertThat(graph.incidentEdges(N1)) + .containsExactly(EndpointPair.ordered(N1, N1), EndpointPair.ordered(N1, N2)); } @Test diff --git a/android/guava-tests/test/com/google/common/graph/ConfigurableUndirectedGraphTest.java b/android/guava-tests/test/com/google/common/graph/ConfigurableUndirectedGraphTest.java index 8f8cd13bf08f..3bdfd74d7e26 100644 --- a/android/guava-tests/test/com/google/common/graph/ConfigurableUndirectedGraphTest.java +++ b/android/guava-tests/test/com/google/common/graph/ConfigurableUndirectedGraphTest.java @@ -59,9 +59,8 @@ public void incidentEdges_selfLoop() { putEdge(N1, N1); assertThat(graph.incidentEdges(N1)).containsExactly(EndpointPair.unordered(N1, N1)); putEdge(N1, N2); - assertThat(graph.incidentEdges(N1)).containsExactly( - EndpointPair.unordered(N1, N1), - EndpointPair.unordered(N1, N2)); + assertThat(graph.incidentEdges(N1)) + .containsExactly(EndpointPair.unordered(N1, N1), EndpointPair.unordered(N1, N2)); } @Test 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 beb000fdf8a2..0dd2318e9776 100644 --- a/android/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java +++ b/android/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java @@ -93,7 +93,8 @@ abstract class StringList implements List {} try { numberList.getSubtype(StringList.class); fail(); - } catch (IllegalArgumentException expected) {} + } catch (IllegalArgumentException expected) { + } } private static class OwnerTypeSubtypingTests extends SubtypeTester { @@ -230,7 +231,7 @@ private static class RecursiveTypeBoundBugExample> ifYouUseTheTypeVariableOnTheClassAndItIsRecursive( List>> arg) { - return notSubtype(arg); // isSubtype() currently incorectly considers it a subtype. + return notSubtype(arg); // isSubtype() currently incorectly considers it a subtype. } } @@ -275,15 +276,13 @@ public Iterable> listOfEnums(List> listOfEnums) { @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public UseList>>> - wildcardBoundUsesImplicitlyRecursiveBoundedWildcard( - UseList>> arg) { + wildcardBoundUsesImplicitlyRecursiveBoundedWildcard(UseList>> arg) { return isSubtype(arg); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public UseList>>> - wildcardBoundHasImplicitBoundAtsInvariantPosition( - UseList>> arg) { + wildcardBoundHasImplicitBoundAtsInvariantPosition(UseList>> arg) { return isSubtype(arg); } @@ -301,14 +300,14 @@ public Iterable> nestedExplicitEnumBoundIsSubtypeOfImplicitEnumBound( @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public Iterable>>> - implicitEnumBoundIsSubtypeOfNestedExplicitEnumBound(List> listOfEnums) { + implicitEnumBoundIsSubtypeOfNestedExplicitEnumBound(List> listOfEnums) { return isSubtype(listOfEnums); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public Iterable>> - listOfEnumsWithImplicitBoundIsSubtypeOfIterableOfEnumWithExplicitBound( - List> listOfEnums) { + listOfEnumsWithImplicitBoundIsSubtypeOfIterableOfEnumWithExplicitBound( + List> listOfEnums) { return isSubtype(listOfEnums); } @@ -326,43 +325,43 @@ public List>> typeVariableBoundOm @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public List> - wildcardUpperBoundIsNotSubtypeOfTypeVariableBound( - List> arg) { + wildcardUpperBoundIsNotSubtypeOfTypeVariableBound( + List> arg) { return notSubtype(arg); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public List>>>> - wildcardBoundUsesParameterizedTypeWithImplicitBound( - List>>> arg) { + wildcardBoundUsesParameterizedTypeWithImplicitBound( + List>>> arg) { return isSubtype(arg); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public List>>>> - wildcardBoundUsesRecursiveParameterizedTypeWithImplicitBound( - List>>> arg) { + wildcardBoundUsesRecursiveParameterizedTypeWithImplicitBound( + List>>> arg) { return isSubtype(arg); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public List>>>> - wildcardBoundUsesParameterizedTypeDefinedWithImplicitBound( - List>>> arg) { + wildcardBoundUsesParameterizedTypeDefinedWithImplicitBound( + List>>> arg) { return isSubtype(arg); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public Iterable>> - wildcardOfImplicitBoundedIsSubtypeOfWildcardOfExplicitlyBounded( - List> withImplicitBounds) { + wildcardOfImplicitBoundedIsSubtypeOfWildcardOfExplicitlyBounded( + List> withImplicitBounds) { return isSubtype(withImplicitBounds); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public Iterable>> - wildcardOfImplicitBoundedIsSubtypeOfWildcardOfExplicitlyPartialBounded( - List> withImplicitBounds) { + wildcardOfImplicitBoundedIsSubtypeOfWildcardOfExplicitlyPartialBounded( + List> withImplicitBounds) { return isSubtype(withImplicitBounds); } @@ -373,23 +372,22 @@ public Iterable>> useListOfIterableWildcard( } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) - public Iterable> - listOfExplicitBoundedIsSubtypeOfListOfImplicitlyBounded( + public Iterable> listOfExplicitBoundedIsSubtypeOfListOfImplicitlyBounded( List>> withExplicitBounds) { return isSubtype(withExplicitBounds); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public Iterable>> - wildcardOfImplicitBoundedIsNotSubtypeOfNonWildcardOfExplicitlyBounded( - List> withImplicitBounds) { + wildcardOfImplicitBoundedIsNotSubtypeOfNonWildcardOfExplicitlyBounded( + List> withImplicitBounds) { return notSubtype(withImplicitBounds); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public Iterable>> - wildcardOfImplicitBoundedIsNotSubtypeOfWildcardWithNarrowerBounds( - List> withImplicitBounds) { + wildcardOfImplicitBoundedIsNotSubtypeOfWildcardWithNarrowerBounds( + List> withImplicitBounds) { return notSubtype(withImplicitBounds); } 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 4c67d515d7c3..8f91bcc21563 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 @@ -36,7 +36,7 @@ Void runInterruptibly() throws Exception { BrokenChannel bc = new BrokenChannel(); bc.doBegin(); isInterruptibleRegistered.countDown(); - new CountDownLatch(1).await(); // the interrupt will wake us up + new CountDownLatch(1).await(); // the interrupt will wake us up return null; } @@ -95,7 +95,7 @@ Void runInterruptibly() throws Exception { slowChannel.doBegin(); isInterruptibleRegistered.countDown(); try { - new CountDownLatch(1).await(); // the interrupt will wake us up + new CountDownLatch(1).await(); // the interrupt will wake us up } catch (InterruptedException ie) { // continue } diff --git a/android/guava-tests/test/com/google/common/util/concurrent/StripedTest.java b/android/guava-tests/test/com/google/common/util/concurrent/StripedTest.java index 1bd3c95bde8f..9832c30b029c 100644 --- a/android/guava-tests/test/com/google/common/util/concurrent/StripedTest.java +++ b/android/guava-tests/test/com/google/common/util/concurrent/StripedTest.java @@ -50,18 +50,22 @@ private static List> strongImplementations() { Striped.readWriteLock(256), Striped.lock(100), Striped.lock(256), - Striped.custom(100, new Supplier() { - @Override - public Lock get() { - return new ReentrantLock(true); - } - }), - Striped.custom(256, new Supplier() { - @Override - public Lock get() { - return new ReentrantLock(true); - } - }), + Striped.custom( + 100, + new Supplier() { + @Override + public Lock get() { + return new ReentrantLock(true); + } + }), + Striped.custom( + 256, + new Supplier() { + @Override + public Lock get() { + return new ReentrantLock(true); + } + }), Striped.semaphore(100, 1), Striped.semaphore(256, 1)); } diff --git a/guava-tests/benchmark/com/google/common/collect/BinaryTreeTraverserBenchmark.java b/guava-tests/benchmark/com/google/common/collect/BinaryTreeTraverserBenchmark.java index 2fd21e978346..75fc1f90d2ef 100644 --- a/guava-tests/benchmark/com/google/common/collect/BinaryTreeTraverserBenchmark.java +++ b/guava-tests/benchmark/com/google/common/collect/BinaryTreeTraverserBenchmark.java @@ -18,7 +18,6 @@ import com.google.caliper.Benchmark; import com.google.caliper.Param; import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; import com.google.common.primitives.Ints; import java.util.List; import java.util.Random; diff --git a/guava-tests/test/com/google/common/base/StringsTest.java b/guava-tests/test/com/google/common/base/StringsTest.java index 8eda06702a1e..ac3ad20a52dc 100644 --- a/guava-tests/test/com/google/common/base/StringsTest.java +++ b/guava-tests/test/com/google/common/base/StringsTest.java @@ -242,8 +242,7 @@ public void testLenientFormat_badArgumentToString() { public void testLenientFormat_badArgumentToString_gwtFriendly() { assertThat(Strings.lenientFormat("boiler %s plate", new ThrowsOnToString())) - .matches( - "boiler <.*> plate"); + .matches("boiler <.*> plate"); } private static class ThrowsOnToString { diff --git a/guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java b/guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java index c49b80e1e6bb..2c1e1e8cb4ab 100644 --- a/guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java +++ b/guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java @@ -115,9 +115,17 @@ public void testCompute() { public void testComputeExceptionally() { try { - doParallelCacheOp(count, n -> { - cache.asMap().compute(key, (k, v) -> { throw new RuntimeException(); }); - }); + doParallelCacheOp( + count, + n -> { + cache + .asMap() + .compute( + key, + (k, v) -> { + throw new RuntimeException(); + }); + }); fail("Should not get here"); } catch (RuntimeException ex) { } diff --git a/guava-tests/test/com/google/common/collect/CompactHashMapTest.java b/guava-tests/test/com/google/common/collect/CompactHashMapTest.java index 87480d0914b9..33e601556238 100644 --- a/guava-tests/test/com/google/common/collect/CompactHashMapTest.java +++ b/guava-tests/test/com/google/common/collect/CompactHashMapTest.java @@ -37,22 +37,27 @@ public class CompactHashMapTest extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); - suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() { - @Override - protected Map create(Entry[] entries) { - Map map = CompactHashMap.create(); - for (Entry entry : entries) { - map.put(entry.getKey(), entry.getValue()); - } - return map; - } - }) - .named("CompactHashMap") - .withFeatures( - CollectionSize.ANY, MapFeature.GENERAL_PURPOSE, MapFeature.ALLOWS_NULL_KEYS, - MapFeature.ALLOWS_NULL_VALUES, CollectionFeature.SERIALIZABLE, - CollectionFeature.SUPPORTS_ITERATOR_REMOVE) - .createTestSuite()); + suite.addTest( + MapTestSuiteBuilder.using( + new TestStringMapGenerator() { + @Override + protected Map create(Entry[] entries) { + Map map = CompactHashMap.create(); + for (Entry entry : entries) { + map.put(entry.getKey(), entry.getValue()); + } + return map; + } + }) + .named("CompactHashMap") + .withFeatures( + CollectionSize.ANY, + MapFeature.GENERAL_PURPOSE, + MapFeature.ALLOWS_NULL_KEYS, + MapFeature.ALLOWS_NULL_VALUES, + CollectionFeature.SERIALIZABLE, + CollectionFeature.SUPPORTS_ITERATOR_REMOVE) + .createTestSuite()); suite.addTestSuite(CompactHashMapTest.class); return suite; } diff --git a/guava-tests/test/com/google/common/collect/CompactHashSetTest.java b/guava-tests/test/com/google/common/collect/CompactHashSetTest.java index 08eabf5523a2..e5c3a458b57e 100644 --- a/guava-tests/test/com/google/common/collect/CompactHashSetTest.java +++ b/guava-tests/test/com/google/common/collect/CompactHashSetTest.java @@ -37,40 +37,49 @@ @GwtIncompatible // java.util.Arrays#copyOf(Object[], int), java.lang.reflect.Array public class CompactHashSetTest extends TestCase { public static Test suite() { - List> allFeatures = Arrays.>asList( - CollectionSize.ANY, - CollectionFeature.ALLOWS_NULL_VALUES, - CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, - CollectionFeature.GENERAL_PURPOSE, - CollectionFeature.REMOVE_OPERATIONS, - CollectionFeature.SERIALIZABLE, - CollectionFeature.SUPPORTS_ADD, - CollectionFeature.SUPPORTS_REMOVE); + List> allFeatures = + Arrays.>asList( + CollectionSize.ANY, + CollectionFeature.ALLOWS_NULL_VALUES, + CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, + CollectionFeature.GENERAL_PURPOSE, + CollectionFeature.REMOVE_OPERATIONS, + CollectionFeature.SERIALIZABLE, + CollectionFeature.SUPPORTS_ADD, + CollectionFeature.SUPPORTS_REMOVE); TestSuite suite = new TestSuite(); suite.addTestSuite(CompactHashSetTest.class); - suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() { - @Override protected Set create(String[] elements) { - return CompactHashSet.create(Arrays.asList(elements)); - } - }).named("CompactHashSet") - .withFeatures(allFeatures) - .createTestSuite()); - suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() { - @Override protected Set create(String[] elements) { - CompactHashSet set = CompactHashSet.create(Arrays.asList(elements)); - for (int i = 0; i < 100; i++) { - set.add(i); - } - for (int i = 0; i < 100; i++) { - set.remove(i); - } - set.trimToSize(); - return set; - } - }).named("CompactHashSet#TrimToSize") - .withFeatures(allFeatures) - .createTestSuite()); + suite.addTest( + SetTestSuiteBuilder.using( + new TestStringSetGenerator() { + @Override + protected Set create(String[] elements) { + return CompactHashSet.create(Arrays.asList(elements)); + } + }) + .named("CompactHashSet") + .withFeatures(allFeatures) + .createTestSuite()); + suite.addTest( + SetTestSuiteBuilder.using( + new TestStringSetGenerator() { + @Override + protected Set create(String[] elements) { + CompactHashSet set = CompactHashSet.create(Arrays.asList(elements)); + for (int i = 0; i < 100; i++) { + set.add(i); + } + for (int i = 0; i < 100; i++) { + set.remove(i); + } + set.trimToSize(); + return set; + } + }) + .named("CompactHashSet#TrimToSize") + .withFeatures(allFeatures) + .createTestSuite()); return suite; } diff --git a/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java b/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java index 4235f6bbfa93..f7e28572967a 100644 --- a/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java +++ b/guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java @@ -35,22 +35,28 @@ public class CompactLinkedHashMapTest extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(); - suite.addTest(MapTestSuiteBuilder.using(new TestStringMapGenerator() { - @Override - protected Map create(Entry[] entries) { - Map map = CompactLinkedHashMap.create(); - for (Entry entry : entries) { - map.put(entry.getKey(), entry.getValue()); - } - return map; - } - }).named("CompactLinkedHashMap").withFeatures(CollectionSize.ANY, - CollectionFeature.SUPPORTS_ITERATOR_REMOVE, - MapFeature.GENERAL_PURPOSE, - MapFeature.ALLOWS_NULL_KEYS, - MapFeature.ALLOWS_NULL_VALUES, - CollectionFeature.SERIALIZABLE, - CollectionFeature.KNOWN_ORDER).createTestSuite()); + suite.addTest( + MapTestSuiteBuilder.using( + new TestStringMapGenerator() { + @Override + protected Map create(Entry[] entries) { + Map map = CompactLinkedHashMap.create(); + for (Entry entry : entries) { + map.put(entry.getKey(), entry.getValue()); + } + return map; + } + }) + .named("CompactLinkedHashMap") + .withFeatures( + CollectionSize.ANY, + CollectionFeature.SUPPORTS_ITERATOR_REMOVE, + MapFeature.GENERAL_PURPOSE, + MapFeature.ALLOWS_NULL_KEYS, + MapFeature.ALLOWS_NULL_VALUES, + CollectionFeature.SERIALIZABLE, + CollectionFeature.KNOWN_ORDER) + .createTestSuite()); suite.addTestSuite(CompactLinkedHashMapTest.class); return suite; } @@ -119,8 +125,7 @@ public void testTrimToSize() { testHasMapEntriesInOrder(map, 1, "a", 4, "b", 3, "d", 2, "c"); } - private void testHasMapEntriesInOrder(Map map, - Object... alternatingKeysAndValues) { + private void testHasMapEntriesInOrder(Map map, Object... alternatingKeysAndValues) { List> entries = Lists.newArrayList(map.entrySet()); List keys = Lists.newArrayList(map.keySet()); List values = Lists.newArrayList(map.values()); @@ -130,8 +135,7 @@ private void testHasMapEntriesInOrder(Map map, for (int i = 0; i < map.size(); i++) { Object expectedKey = alternatingKeysAndValues[2 * i]; Object expectedValue = alternatingKeysAndValues[2 * i + 1]; - Entry expectedEntry = Maps.immutableEntry( - expectedKey, expectedValue); + Entry expectedEntry = Maps.immutableEntry(expectedKey, expectedValue); assertEquals(expectedEntry, entries.get(i)); assertEquals(expectedKey, keys.get(i)); assertEquals(expectedValue, values.get(i)); diff --git a/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java b/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java index 2e9bad2ad29b..a95e4861c2a2 100644 --- a/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java +++ b/guava-tests/test/com/google/common/collect/CompactLinkedHashSetTest.java @@ -37,26 +37,31 @@ @GwtIncompatible // java.util.Arrays#copyOf(Object[], int), java.lang.reflect.Array public class CompactLinkedHashSetTest extends TestCase { public static Test suite() { - List> allFeatures = Arrays.>asList( - CollectionSize.ANY, - CollectionFeature.ALLOWS_NULL_VALUES, - CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, - CollectionFeature.GENERAL_PURPOSE, - CollectionFeature.REMOVE_OPERATIONS, - CollectionFeature.SERIALIZABLE, - CollectionFeature.KNOWN_ORDER, - CollectionFeature.SUPPORTS_ADD, - CollectionFeature.SUPPORTS_REMOVE); + List> allFeatures = + Arrays.>asList( + CollectionSize.ANY, + CollectionFeature.ALLOWS_NULL_VALUES, + CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION, + CollectionFeature.GENERAL_PURPOSE, + CollectionFeature.REMOVE_OPERATIONS, + CollectionFeature.SERIALIZABLE, + CollectionFeature.KNOWN_ORDER, + CollectionFeature.SUPPORTS_ADD, + CollectionFeature.SUPPORTS_REMOVE); TestSuite suite = new TestSuite(); suite.addTestSuite(CompactLinkedHashSetTest.class); - suite.addTest(SetTestSuiteBuilder.using(new TestStringSetGenerator() { - @Override protected Set create(String[] elements) { - return CompactLinkedHashSet.create(Arrays.asList(elements)); - } - }).named("CompactLinkedHashSet") - .withFeatures(allFeatures) - .createTestSuite()); + suite.addTest( + SetTestSuiteBuilder.using( + new TestStringSetGenerator() { + @Override + protected Set create(String[] elements) { + return CompactLinkedHashSet.create(Arrays.asList(elements)); + } + }) + .named("CompactLinkedHashSet") + .withFeatures(allFeatures) + .createTestSuite()); return suite; } diff --git a/guava-tests/test/com/google/common/collect/ForwardingMapTest.java b/guava-tests/test/com/google/common/collect/ForwardingMapTest.java index 62988ed0189c..6ca5b8cc145a 100644 --- a/guava-tests/test/com/google/common/collect/ForwardingMapTest.java +++ b/guava-tests/test/com/google/common/collect/ForwardingMapTest.java @@ -329,10 +329,11 @@ protected Map delegate() { }; } - private static final ImmutableMap JUF_METHODS = ImmutableMap.of( - "java.util.function.Predicate", "test", - "java.util.function.Consumer", "accept", - "java.util.function.IntFunction", "apply"); + private static final ImmutableMap JUF_METHODS = + ImmutableMap.of( + "java.util.function.Predicate", "test", + "java.util.function.Consumer", "accept", + "java.util.function.IntFunction", "apply"); private static Object getDefaultValue(final TypeToken type) { Class rawType = type.getRawType(); @@ -387,8 +388,7 @@ private static void callAllPublicMethods(TypeToken type, T object) } } } catch (Throwable cause) { - throw new InvocationTargetException( - cause, method + " with args: " + Arrays.toString(args)); + throw new InvocationTargetException(cause, method + " with args: " + Arrays.toString(args)); } } } diff --git a/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java b/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java index 319512ad277a..36e781cbb2b8 100644 --- a/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java +++ b/guava-tests/test/com/google/common/collect/ImmutableBiMapTest.java @@ -792,8 +792,7 @@ enum AdversaryType { ADVERSARIAL_KEYS { @Override List> createAdversarialEntries(int power, CallsCounter counter) { - return createAdversarialObjects(power, counter) - .stream() + return createAdversarialObjects(power, counter).stream() .map(k -> Maps.immutableEntry(k, new Object())) .collect(toList()); } @@ -801,8 +800,7 @@ enum AdversaryType { ADVERSARIAL_VALUES { @Override List> createAdversarialEntries(int power, CallsCounter counter) { - return createAdversarialObjects(power, counter) - .stream() + return createAdversarialObjects(power, counter).stream() .map(k -> Maps.immutableEntry(new Object(), k)) .collect(toList()); } diff --git a/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java b/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java index 6b9998ab6003..9e13710aaad7 100644 --- a/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java +++ b/guava-tests/test/com/google/common/graph/AbstractNetworkTest.java @@ -120,7 +120,7 @@ protected boolean addNode(Integer n) { * add an edge whose end-points don't already exist in the graph), you should not use this * method. * - * TODO(user): remove the addNode() calls, that's now contractually guaranteed + *

TODO(user): remove the addNode() calls, that's now contractually guaranteed * * @return {@code true} iff the graph was modified as a result of this call */ diff --git a/guava-tests/test/com/google/common/graph/ConfigurableDirectedGraphTest.java b/guava-tests/test/com/google/common/graph/ConfigurableDirectedGraphTest.java index 80533fc10155..ed998eb4226a 100644 --- a/guava-tests/test/com/google/common/graph/ConfigurableDirectedGraphTest.java +++ b/guava-tests/test/com/google/common/graph/ConfigurableDirectedGraphTest.java @@ -59,9 +59,8 @@ public void incidentEdges_selfLoop() { putEdge(N1, N1); assertThat(graph.incidentEdges(N1)).containsExactly(EndpointPair.ordered(N1, N1)); putEdge(N1, N2); - assertThat(graph.incidentEdges(N1)).containsExactly( - EndpointPair.ordered(N1, N1), - EndpointPair.ordered(N1, N2)); + assertThat(graph.incidentEdges(N1)) + .containsExactly(EndpointPair.ordered(N1, N1), EndpointPair.ordered(N1, N2)); } @Test diff --git a/guava-tests/test/com/google/common/graph/ConfigurableUndirectedGraphTest.java b/guava-tests/test/com/google/common/graph/ConfigurableUndirectedGraphTest.java index 8f8cd13bf08f..3bdfd74d7e26 100644 --- a/guava-tests/test/com/google/common/graph/ConfigurableUndirectedGraphTest.java +++ b/guava-tests/test/com/google/common/graph/ConfigurableUndirectedGraphTest.java @@ -59,9 +59,8 @@ public void incidentEdges_selfLoop() { putEdge(N1, N1); assertThat(graph.incidentEdges(N1)).containsExactly(EndpointPair.unordered(N1, N1)); putEdge(N1, N2); - assertThat(graph.incidentEdges(N1)).containsExactly( - EndpointPair.unordered(N1, N1), - EndpointPair.unordered(N1, N2)); + assertThat(graph.incidentEdges(N1)) + .containsExactly(EndpointPair.unordered(N1, N1), EndpointPair.unordered(N1, N2)); } @Test diff --git a/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java b/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java index beb000fdf8a2..0dd2318e9776 100644 --- a/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java +++ b/guava-tests/test/com/google/common/reflect/TypeTokenSubtypeTest.java @@ -93,7 +93,8 @@ abstract class StringList implements List {} try { numberList.getSubtype(StringList.class); fail(); - } catch (IllegalArgumentException expected) {} + } catch (IllegalArgumentException expected) { + } } private static class OwnerTypeSubtypingTests extends SubtypeTester { @@ -230,7 +231,7 @@ private static class RecursiveTypeBoundBugExample> ifYouUseTheTypeVariableOnTheClassAndItIsRecursive( List>> arg) { - return notSubtype(arg); // isSubtype() currently incorectly considers it a subtype. + return notSubtype(arg); // isSubtype() currently incorectly considers it a subtype. } } @@ -275,15 +276,13 @@ public Iterable> listOfEnums(List> listOfEnums) { @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public UseList>>> - wildcardBoundUsesImplicitlyRecursiveBoundedWildcard( - UseList>> arg) { + wildcardBoundUsesImplicitlyRecursiveBoundedWildcard(UseList>> arg) { return isSubtype(arg); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public UseList>>> - wildcardBoundHasImplicitBoundAtsInvariantPosition( - UseList>> arg) { + wildcardBoundHasImplicitBoundAtsInvariantPosition(UseList>> arg) { return isSubtype(arg); } @@ -301,14 +300,14 @@ public Iterable> nestedExplicitEnumBoundIsSubtypeOfImplicitEnumBound( @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public Iterable>>> - implicitEnumBoundIsSubtypeOfNestedExplicitEnumBound(List> listOfEnums) { + implicitEnumBoundIsSubtypeOfNestedExplicitEnumBound(List> listOfEnums) { return isSubtype(listOfEnums); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public Iterable>> - listOfEnumsWithImplicitBoundIsSubtypeOfIterableOfEnumWithExplicitBound( - List> listOfEnums) { + listOfEnumsWithImplicitBoundIsSubtypeOfIterableOfEnumWithExplicitBound( + List> listOfEnums) { return isSubtype(listOfEnums); } @@ -326,43 +325,43 @@ public List>> typeVariableBoundOm @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public List> - wildcardUpperBoundIsNotSubtypeOfTypeVariableBound( - List> arg) { + wildcardUpperBoundIsNotSubtypeOfTypeVariableBound( + List> arg) { return notSubtype(arg); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public List>>>> - wildcardBoundUsesParameterizedTypeWithImplicitBound( - List>>> arg) { + wildcardBoundUsesParameterizedTypeWithImplicitBound( + List>>> arg) { return isSubtype(arg); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public List>>>> - wildcardBoundUsesRecursiveParameterizedTypeWithImplicitBound( - List>>> arg) { + wildcardBoundUsesRecursiveParameterizedTypeWithImplicitBound( + List>>> arg) { return isSubtype(arg); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public List>>>> - wildcardBoundUsesParameterizedTypeDefinedWithImplicitBound( - List>>> arg) { + wildcardBoundUsesParameterizedTypeDefinedWithImplicitBound( + List>>> arg) { return isSubtype(arg); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public Iterable>> - wildcardOfImplicitBoundedIsSubtypeOfWildcardOfExplicitlyBounded( - List> withImplicitBounds) { + wildcardOfImplicitBoundedIsSubtypeOfWildcardOfExplicitlyBounded( + List> withImplicitBounds) { return isSubtype(withImplicitBounds); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public Iterable>> - wildcardOfImplicitBoundedIsSubtypeOfWildcardOfExplicitlyPartialBounded( - List> withImplicitBounds) { + wildcardOfImplicitBoundedIsSubtypeOfWildcardOfExplicitlyPartialBounded( + List> withImplicitBounds) { return isSubtype(withImplicitBounds); } @@ -373,23 +372,22 @@ public Iterable>> useListOfIterableWildcard( } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) - public Iterable> - listOfExplicitBoundedIsSubtypeOfListOfImplicitlyBounded( + public Iterable> listOfExplicitBoundedIsSubtypeOfListOfImplicitlyBounded( List>> withExplicitBounds) { return isSubtype(withExplicitBounds); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public Iterable>> - wildcardOfImplicitBoundedIsNotSubtypeOfNonWildcardOfExplicitlyBounded( - List> withImplicitBounds) { + wildcardOfImplicitBoundedIsNotSubtypeOfNonWildcardOfExplicitlyBounded( + List> withImplicitBounds) { return notSubtype(withImplicitBounds); } @TestSubtype(suppressGetSupertype = true, suppressGetSubtype = true) public Iterable>> - wildcardOfImplicitBoundedIsNotSubtypeOfWildcardWithNarrowerBounds( - List> withImplicitBounds) { + wildcardOfImplicitBoundedIsNotSubtypeOfWildcardWithNarrowerBounds( + List> withImplicitBounds) { return notSubtype(withImplicitBounds); } 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 4c67d515d7c3..8f91bcc21563 100644 --- a/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java @@ -36,7 +36,7 @@ Void runInterruptibly() throws Exception { BrokenChannel bc = new BrokenChannel(); bc.doBegin(); isInterruptibleRegistered.countDown(); - new CountDownLatch(1).await(); // the interrupt will wake us up + new CountDownLatch(1).await(); // the interrupt will wake us up return null; } @@ -95,7 +95,7 @@ Void runInterruptibly() throws Exception { slowChannel.doBegin(); isInterruptibleRegistered.countDown(); try { - new CountDownLatch(1).await(); // the interrupt will wake us up + new CountDownLatch(1).await(); // the interrupt will wake us up } catch (InterruptedException ie) { // continue } diff --git a/guava-tests/test/com/google/common/util/concurrent/StripedTest.java b/guava-tests/test/com/google/common/util/concurrent/StripedTest.java index 1bd3c95bde8f..9832c30b029c 100644 --- a/guava-tests/test/com/google/common/util/concurrent/StripedTest.java +++ b/guava-tests/test/com/google/common/util/concurrent/StripedTest.java @@ -50,18 +50,22 @@ private static List> strongImplementations() { Striped.readWriteLock(256), Striped.lock(100), Striped.lock(256), - Striped.custom(100, new Supplier() { - @Override - public Lock get() { - return new ReentrantLock(true); - } - }), - Striped.custom(256, new Supplier() { - @Override - public Lock get() { - return new ReentrantLock(true); - } - }), + Striped.custom( + 100, + new Supplier() { + @Override + public Lock get() { + return new ReentrantLock(true); + } + }), + Striped.custom( + 256, + new Supplier() { + @Override + public Lock get() { + return new ReentrantLock(true); + } + }), Striped.semaphore(100, 1), Striped.semaphore(256, 1)); } From 0967c796d6e6be72b0d9e8d68af66d6a7b524b54 Mon Sep 17 00:00:00 2001 From: kak Date: Tue, 5 Feb 2019 14:21:39 -0800 Subject: [PATCH 07/23] Name the method parameter 'unused' for ImmutableSortedSet.readObject(ObjectInputStream) (so the static analysis doesn't complain) RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=232557400 --- .../guava/src/com/google/common/collect/ImmutableSortedSet.java | 2 +- guava/src/com/google/common/collect/ImmutableSortedSet.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/guava/src/com/google/common/collect/ImmutableSortedSet.java b/android/guava/src/com/google/common/collect/ImmutableSortedSet.java index 1a48211a1445..d44de4d118f7 100644 --- a/android/guava/src/com/google/common/collect/ImmutableSortedSet.java +++ b/android/guava/src/com/google/common/collect/ImmutableSortedSet.java @@ -732,7 +732,7 @@ Object readResolve() { private static final long serialVersionUID = 0; } - private void readObject(ObjectInputStream stream) throws InvalidObjectException { + private void readObject(ObjectInputStream unused) throws InvalidObjectException { throw new InvalidObjectException("Use SerializedForm"); } diff --git a/guava/src/com/google/common/collect/ImmutableSortedSet.java b/guava/src/com/google/common/collect/ImmutableSortedSet.java index c318ba11319e..ea8bc744f9e1 100644 --- a/guava/src/com/google/common/collect/ImmutableSortedSet.java +++ b/guava/src/com/google/common/collect/ImmutableSortedSet.java @@ -832,7 +832,7 @@ Object readResolve() { private static final long serialVersionUID = 0; } - private void readObject(ObjectInputStream stream) throws InvalidObjectException { + private void readObject(ObjectInputStream unused) throws InvalidObjectException { throw new InvalidObjectException("Use SerializedForm"); } From 068cb9005cc701ed98e31df9b56117b86df21d0f Mon Sep 17 00:00:00 2001 From: cpovirk Date: Wed, 6 Feb 2019 08:40:26 -0800 Subject: [PATCH 08/23] Remove @Beta from APIs: collect - most Collectors (aside from BloomFilter and ImmutableRange*, as those whole classes are @Beta (though I did remove the redundant @Beta annotation from the Collector-returning methods for clarity)) - Maps: asConverter, immutableEnumMap - MultimapBuilder - Streams: stream(Iterable), concat io - ByteStreams: copy, toByteArray - CharStreams: copy, toString - Files: as(Char|Byte)(Source|Sink) util.concurrent - Futures: addCallback, getDone, getUnchecked, immediateCancelledFuture, immediateFailedFuture, immediateFuture - ListeningScheduledExecutorService - Uninterruptibles other - HtmlEscapers - Splitter.splitToList - Ticker Fixes https://github.com/google/guava/pull/3287 Fixes https://github.com/google/guava/issues/3251 (aside from ImmutableRange*, but those whole classes are @Beta, anyway) Addresses the main concerns of https://github.com/google/guava/issues/3285 but doesn't cover the broader request Fixes https://github.com/google/guava/issues/3340 Partially addresses https://github.com/google/guava/issues/3239 RELNOTES=Removed `@Beta` from a number of frequently used APIs. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=232681253 --- .../src/com/google/common/base/Splitter.java | 1 - .../src/com/google/common/base/Ticker.java | 2 -- .../src/com/google/common/collect/Maps.java | 2 -- .../common/collect/MultimapBuilder.java | 2 -- .../com/google/common/html/HtmlEscapers.java | 2 -- .../src/com/google/common/io/ByteStreams.java | 15 +++++++++- .../src/com/google/common/io/CharStreams.java | 7 ++++- .../guava/src/com/google/common/io/Files.java | 30 ++++++++++++++++++- .../common/util/concurrent/Futures.java | 19 +++++++++++- .../ListeningScheduledExecutorService.java | 2 -- .../util/concurrent/Uninterruptibles.java | 2 -- .../src/com/google/common/base/Splitter.java | 1 - guava/src/com/google/common/base/Ticker.java | 2 -- .../google/common/collect/Comparators.java | 4 ++- .../google/common/collect/ImmutableBiMap.java | 1 - .../google/common/collect/ImmutableList.java | 1 - .../common/collect/ImmutableListMultimap.java | 2 -- .../google/common/collect/ImmutableMap.java | 2 -- .../common/collect/ImmutableMultiset.java | 2 -- .../common/collect/ImmutableRangeMap.java | 1 - .../common/collect/ImmutableRangeSet.java | 1 - .../google/common/collect/ImmutableSet.java | 1 - .../common/collect/ImmutableSetMultimap.java | 2 -- .../common/collect/ImmutableSortedMap.java | 2 -- .../collect/ImmutableSortedMultiset.java | 2 -- .../common/collect/ImmutableSortedSet.java | 2 -- .../google/common/collect/ImmutableTable.java | 2 -- guava/src/com/google/common/collect/Maps.java | 4 --- .../google/common/collect/MoreCollectors.java | 2 -- .../common/collect/MultimapBuilder.java | 2 -- guava/src/com/google/common/collect/Sets.java | 1 - .../com/google/common/collect/Streams.java | 18 ++++++++++- .../com/google/common/html/HtmlEscapers.java | 2 -- .../src/com/google/common/io/ByteStreams.java | 15 +++++++++- .../src/com/google/common/io/CharStreams.java | 7 ++++- guava/src/com/google/common/io/Files.java | 30 ++++++++++++++++++- .../common/util/concurrent/Futures.java | 19 +++++++++++- .../ListeningScheduledExecutorService.java | 2 -- .../util/concurrent/Uninterruptibles.java | 2 -- 39 files changed, 154 insertions(+), 62 deletions(-) diff --git a/android/guava/src/com/google/common/base/Splitter.java b/android/guava/src/com/google/common/base/Splitter.java index d82b1de82ba0..1da372e371ff 100644 --- a/android/guava/src/com/google/common/base/Splitter.java +++ b/android/guava/src/com/google/common/base/Splitter.java @@ -408,7 +408,6 @@ private Iterator splittingIterator(CharSequence sequence) { * @return an immutable list of the segments split from the parameter * @since 15.0 */ - @Beta public List splitToList(CharSequence sequence) { checkNotNull(sequence); diff --git a/android/guava/src/com/google/common/base/Ticker.java b/android/guava/src/com/google/common/base/Ticker.java index 7b97b1533f72..a53883b46ed7 100644 --- a/android/guava/src/com/google/common/base/Ticker.java +++ b/android/guava/src/com/google/common/base/Ticker.java @@ -14,7 +14,6 @@ package com.google.common.base; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; /** @@ -28,7 +27,6 @@ * @since 10.0 (mostly * source-compatible since 9.0) */ -@Beta @GwtCompatible public abstract class Ticker { /** Constructor for use by subclasses. */ diff --git a/android/guava/src/com/google/common/collect/Maps.java b/android/guava/src/com/google/common/collect/Maps.java index 8af18a6eb6cd..15fee5266163 100644 --- a/android/guava/src/com/google/common/collect/Maps.java +++ b/android/guava/src/com/google/common/collect/Maps.java @@ -139,7 +139,6 @@ V transform(Entry entry) { * @since 14.0 */ @GwtCompatible(serializable = true) - @Beta public static , V> ImmutableMap immutableEnumMap( Map map) { if (map instanceof ImmutableEnumMap) { @@ -1363,7 +1362,6 @@ public int hashCode() { * * @since 16.0 */ - @Beta public static Converter asConverter(final BiMap bimap) { return new BiMapConverter<>(bimap); } diff --git a/android/guava/src/com/google/common/collect/MultimapBuilder.java b/android/guava/src/com/google/common/collect/MultimapBuilder.java index 482385e50a25..161c29d170ee 100644 --- a/android/guava/src/com/google/common/collect/MultimapBuilder.java +++ b/android/guava/src/com/google/common/collect/MultimapBuilder.java @@ -19,7 +19,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.CollectPreconditions.checkNonnegative; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.common.base.Supplier; import java.io.Serializable; @@ -61,7 +60,6 @@ * @param An upper bound on the value type of the generated multimap. * @since 16.0 */ -@Beta @GwtCompatible public abstract class MultimapBuilder { /* diff --git a/android/guava/src/com/google/common/html/HtmlEscapers.java b/android/guava/src/com/google/common/html/HtmlEscapers.java index 29f5e1339c2b..29eebe8aaa46 100755 --- a/android/guava/src/com/google/common/html/HtmlEscapers.java +++ b/android/guava/src/com/google/common/html/HtmlEscapers.java @@ -14,7 +14,6 @@ package com.google.common.html; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.common.escape.Escaper; import com.google.common.escape.Escapers; @@ -35,7 +34,6 @@ * @author David Beaumont * @since 15.0 */ -@Beta @GwtCompatible public final class HtmlEscapers { /** diff --git a/android/guava/src/com/google/common/io/ByteStreams.java b/android/guava/src/com/google/common/io/ByteStreams.java index 510947ef0e17..e6601be5c35b 100644 --- a/android/guava/src/com/google/common/io/ByteStreams.java +++ b/android/guava/src/com/google/common/io/ByteStreams.java @@ -48,7 +48,6 @@ * @author Colin Decker * @since 1.0 */ -@Beta @GwtIncompatible public final class ByteStreams { @@ -266,6 +265,7 @@ static byte[] toByteArray(InputStream in, long expectedSize) throws IOException * @since 20.0 */ @CanIgnoreReturnValue + @Beta public static long exhaust(InputStream in) throws IOException { long total = 0; long read; @@ -280,6 +280,7 @@ public static long exhaust(InputStream in) throws IOException { * Returns a new {@link ByteArrayDataInput} instance to read from the {@code bytes} array from the * beginning. */ + @Beta public static ByteArrayDataInput newDataInput(byte[] bytes) { return newDataInput(new ByteArrayInputStream(bytes)); } @@ -291,6 +292,7 @@ public static ByteArrayDataInput newDataInput(byte[] bytes) { * @throws IndexOutOfBoundsException if {@code start} is negative or greater than the length of * the array */ + @Beta public static ByteArrayDataInput newDataInput(byte[] bytes, int start) { checkPositionIndex(start, bytes.length); return newDataInput(new ByteArrayInputStream(bytes, start, bytes.length - start)); @@ -303,6 +305,7 @@ public static ByteArrayDataInput newDataInput(byte[] bytes, int start) { * * @since 17.0 */ + @Beta public static ByteArrayDataInput newDataInput(ByteArrayInputStream byteArrayInputStream) { return new ByteArrayDataInputStream(checkNotNull(byteArrayInputStream)); } @@ -453,6 +456,7 @@ public String readUTF() { } /** Returns a new {@link ByteArrayDataOutput} instance with a default size. */ + @Beta public static ByteArrayDataOutput newDataOutput() { return newDataOutput(new ByteArrayOutputStream()); } @@ -463,6 +467,7 @@ public static ByteArrayDataOutput newDataOutput() { * * @throws IllegalArgumentException if {@code size} is negative */ + @Beta public static ByteArrayDataOutput newDataOutput(int size) { // When called at high frequency, boxing size generates too much garbage, // so avoid doing that if we can. @@ -484,6 +489,7 @@ public static ByteArrayDataOutput newDataOutput(int size) { * * @since 17.0 */ + @Beta public static ByteArrayDataOutput newDataOutput(ByteArrayOutputStream byteArrayOutputSteam) { return new ByteArrayDataOutputStream(checkNotNull(byteArrayOutputSteam)); } @@ -659,6 +665,7 @@ public String toString() { * * @since 14.0 (since 1.0 as com.google.common.io.NullOutputStream) */ + @Beta public static OutputStream nullOutputStream() { return NULL_OUTPUT_STREAM; } @@ -671,6 +678,7 @@ public static OutputStream nullOutputStream() { * @return a length-limited {@link InputStream} * @since 14.0 (since 1.0 as com.google.common.io.LimitInputStream) */ + @Beta public static InputStream limit(InputStream in, long limit) { return new LimitedInputStream(in, limit); } @@ -757,6 +765,7 @@ public long skip(long n) throws IOException { * @throws EOFException if this stream reaches the end before reading all the bytes. * @throws IOException if an I/O error occurs. */ + @Beta public static void readFully(InputStream in, byte[] b) throws IOException { readFully(in, b, 0, b.length); } @@ -773,6 +782,7 @@ public static void readFully(InputStream in, byte[] b) throws IOException { * @throws EOFException if this stream reaches the end before reading all the bytes. * @throws IOException if an I/O error occurs. */ + @Beta public static void readFully(InputStream in, byte[] b, int off, int len) throws IOException { int read = read(in, b, off, len); if (read != len) { @@ -790,6 +800,7 @@ public static void readFully(InputStream in, byte[] b, int off, int len) throws * @throws EOFException if this stream reaches the end before skipping all the bytes * @throws IOException if an I/O error occurs, or the stream does not support skipping */ + @Beta public static void skipFully(InputStream in, long n) throws IOException { long skipped = skipUpTo(in, n); if (skipped < n) { @@ -848,6 +859,7 @@ private static long skipSafely(InputStream in, long n) throws IOException { * @throws IOException if an I/O error occurs * @since 14.0 */ + @Beta @CanIgnoreReturnValue // some processors won't return a useful result public static T readBytes(InputStream input, ByteProcessor processor) throws IOException { checkNotNull(input); @@ -883,6 +895,7 @@ public static T readBytes(InputStream input, ByteProcessor processor) thr * @return the number of bytes read * @throws IOException if an I/O error occurs */ + @Beta @CanIgnoreReturnValue // Sometimes you don't care how many bytes you actually read, I guess. // (You know that it's either going to read len bytes or stop at EOF.) diff --git a/android/guava/src/com/google/common/io/CharStreams.java b/android/guava/src/com/google/common/io/CharStreams.java index bed3388a2cb7..bc4dd510245c 100644 --- a/android/guava/src/com/google/common/io/CharStreams.java +++ b/android/guava/src/com/google/common/io/CharStreams.java @@ -43,7 +43,6 @@ * @author Colin Decker * @since 1.0 */ -@Beta @GwtIncompatible public final class CharStreams { @@ -193,6 +192,7 @@ private static StringBuilder toStringBuilder(Readable r) throws IOException { * @return a mutable {@link List} containing all the lines * @throws IOException if an I/O error occurs */ + @Beta public static List readLines(Readable r) throws IOException { List result = new ArrayList<>(); LineReader lineReader = new LineReader(r); @@ -212,6 +212,7 @@ public static List readLines(Readable r) throws IOException { * @throws IOException if an I/O error occurs * @since 14.0 */ + @Beta @CanIgnoreReturnValue // some processors won't return a useful result public static T readLines(Readable readable, LineProcessor processor) throws IOException { checkNotNull(readable); @@ -233,6 +234,7 @@ public static T readLines(Readable readable, LineProcessor processor) thr * * @since 20.0 */ + @Beta @CanIgnoreReturnValue public static long exhaust(Readable readable) throws IOException { long total = 0; @@ -254,6 +256,7 @@ public static long exhaust(Readable readable) throws IOException { * @throws EOFException if this stream reaches the end before skipping all the characters * @throws IOException if an I/O error occurs */ + @Beta public static void skipFully(Reader reader, long n) throws IOException { checkNotNull(reader); while (n > 0) { @@ -270,6 +273,7 @@ public static void skipFully(Reader reader, long n) throws IOException { * * @since 15.0 */ + @Beta public static Writer nullWriter() { return NullWriter.INSTANCE; } @@ -338,6 +342,7 @@ public String toString() { * @param target the object to which output will be sent * @return a new Writer object, unless target is a Writer, in which case the target is returned */ + @Beta public static Writer asWriter(Appendable target) { if (target instanceof Writer) { return (Writer) target; diff --git a/android/guava/src/com/google/common/io/Files.java b/android/guava/src/com/google/common/io/Files.java index 74858d735f1d..34e03f65d6b2 100644 --- a/android/guava/src/com/google/common/io/Files.java +++ b/android/guava/src/com/google/common/io/Files.java @@ -63,7 +63,6 @@ * @author Colin Decker * @since 1.0 */ -@Beta @GwtIncompatible public final class Files { @@ -83,6 +82,7 @@ private Files() {} * helpful predefined constants * @return the buffered reader */ + @Beta public static BufferedReader newReader(File file, Charset charset) throws FileNotFoundException { checkNotNull(file); checkNotNull(charset); @@ -101,6 +101,7 @@ public static BufferedReader newReader(File file, Charset charset) throws FileNo * helpful predefined constants * @return the buffered writer */ + @Beta public static BufferedWriter newWriter(File file, Charset charset) throws FileNotFoundException { checkNotNull(file); checkNotNull(charset); @@ -231,6 +232,7 @@ public static CharSink asCharSink(File file, Charset charset, FileWriteMode... m * (2^31 - 1) * @throws IOException if an I/O error occurs */ + @Beta public static byte[] toByteArray(File file) throws IOException { return asByteSource(file).read(); } @@ -246,6 +248,7 @@ public static byte[] toByteArray(File file) throws IOException { * @deprecated Prefer {@code asCharSource(file, charset).read()}. This method is scheduled to be * removed in January 2019. */ + @Beta @Deprecated public static String toString(File file, Charset charset) throws IOException { return asCharSource(file, charset).read(); @@ -261,6 +264,7 @@ public static String toString(File file, Charset charset) throws IOException { * @param to the destination file * @throws IOException if an I/O error occurs */ + @Beta public static void write(byte[] from, File to) throws IOException { asByteSink(to).write(from); } @@ -276,6 +280,7 @@ public static void write(byte[] from, File to) throws IOException { * @deprecated Prefer {@code asCharSink(to, charset).write(from)}. This method is scheduled to be * removed in January 2019. */ + @Beta @Deprecated public static void write(CharSequence from, File to, Charset charset) throws IOException { asCharSink(to, charset).write(from); @@ -291,6 +296,7 @@ public static void write(CharSequence from, File to, Charset charset) throws IOE * @param to the output stream * @throws IOException if an I/O error occurs */ + @Beta public static void copy(File from, OutputStream to) throws IOException { asByteSource(from).copyTo(to); } @@ -314,6 +320,7 @@ public static void copy(File from, OutputStream to) throws IOException { * @throws IOException if an I/O error occurs * @throws IllegalArgumentException if {@code from.equals(to)} */ + @Beta public static void copy(File from, File to) throws IOException { checkArgument(!from.equals(to), "Source %s and destination %s must be different", from, to); asByteSource(from).copyTo(asByteSink(to)); @@ -330,6 +337,7 @@ public static void copy(File from, File to) throws IOException { * @deprecated Prefer {@code asCharSource(from, charset).copyTo(to)}. This method is scheduled to * be removed in January 2019. */ + @Beta @Deprecated public static void copy(File from, Charset charset, Appendable to) throws IOException { @@ -347,6 +355,7 @@ static void copy(File from, Charset charset, Appendable to) throws IOException { * @deprecated Prefer {@code asCharSink(to, charset, FileWriteMode.APPEND).write(from)}. This * method is scheduled to be removed in January 2019. */ + @Beta @Deprecated public static void append(CharSequence from, File to, Charset charset) throws IOException { @@ -358,6 +367,7 @@ static void append(CharSequence from, File to, Charset charset) throws IOExcepti * * @throws IOException if an I/O error occurs */ + @Beta public static boolean equal(File file1, File file2) throws IOException { checkNotNull(file1); checkNotNull(file2); @@ -397,6 +407,7 @@ public static boolean equal(File file1, File file2) throws IOException { * @return the newly-created directory * @throws IllegalStateException if the directory could not be created */ + @Beta public static File createTempDir() { File baseDir = new File(System.getProperty("java.io.tmpdir")); @SuppressWarnings("GoodTime") // reading system time without TimeSource @@ -426,6 +437,7 @@ public static File createTempDir() { * @param file the file to create or update * @throws IOException if an I/O error occurs */ + @Beta @SuppressWarnings("GoodTime") // reading system time without TimeSource public static void touch(File file) throws IOException { checkNotNull(file); @@ -443,6 +455,7 @@ public static void touch(File file) throws IOException { * directories of the specified file could not be created. * @since 4.0 */ + @Beta public static void createParentDirs(File file) throws IOException { checkNotNull(file); File parent = file.getCanonicalFile().getParentFile(); @@ -473,6 +486,7 @@ public static void createParentDirs(File file) throws IOException { * @throws IOException if an I/O error occurs * @throws IllegalArgumentException if {@code from.equals(to)} */ + @Beta public static void move(File from, File to) throws IOException { checkNotNull(from); checkNotNull(to); @@ -501,6 +515,7 @@ public static void move(File from, File to) throws IOException { * @deprecated Prefer {@code asCharSource(file, charset).readFirstLine()}. This method is * scheduled to be removed in January 2019. */ + @Beta @Deprecated public static String readFirstLine(File file, Charset charset) throws IOException { @@ -523,6 +538,7 @@ static String readFirstLine(File file, Charset charset) throws IOException { * @return a mutable {@link List} containing all the lines * @throws IOException if an I/O error occurs */ + @Beta public static List readLines(File file, Charset charset) throws IOException { // don't use asCharSource(file, charset).readLines() because that returns // an immutable list, which would change the behavior of this method @@ -557,6 +573,7 @@ public List getResult() { * @deprecated Prefer {@code asCharSource(file, charset).readLines(callback)}. This method is * scheduled to be removed in January 2019. */ + @Beta @Deprecated @CanIgnoreReturnValue // some processors won't return a useful result public @@ -576,6 +593,7 @@ static T readLines(File file, Charset charset, LineProcessor callback) th * @deprecated Prefer {@code asByteSource(file).read(processor)}. This method is scheduled to be * removed in January 2019. */ + @Beta @Deprecated @CanIgnoreReturnValue // some processors won't return a useful result public @@ -594,6 +612,7 @@ static T readBytes(File file, ByteProcessor processor) throws IOException * @deprecated Prefer {@code asByteSource(file).hash(hashFunction)}. This method is scheduled to * be removed in January 2019. */ + @Beta @Deprecated public static HashCode hash(File file, HashFunction hashFunction) throws IOException { @@ -615,6 +634,7 @@ static HashCode hash(File file, HashFunction hashFunction) throws IOException { * @see FileChannel#map(MapMode, long, long) * @since 2.0 */ + @Beta public static MappedByteBuffer map(File file) throws IOException { checkNotNull(file); return map(file, MapMode.READ_ONLY); @@ -637,6 +657,7 @@ public static MappedByteBuffer map(File file) throws IOException { * @see FileChannel#map(MapMode, long, long) * @since 2.0 */ + @Beta public static MappedByteBuffer map(File file, MapMode mode) throws IOException { return mapInternal(file, mode, -1); } @@ -660,6 +681,7 @@ public static MappedByteBuffer map(File file, MapMode mode) throws IOException { * @see FileChannel#map(MapMode, long, long) * @since 2.0 */ + @Beta public static MappedByteBuffer map(File file, MapMode mode, long size) throws IOException { checkArgument(size >= 0, "size (%s) may not be negative", size); return mapInternal(file, mode, size); @@ -703,6 +725,7 @@ private static MappedByteBuffer mapInternal(File file, MapMode mode, long size) * * @since 11.0 */ + @Beta public static String simplifyPath(String pathname) { checkNotNull(pathname); if (pathname.length() == 0) { @@ -763,6 +786,7 @@ public static String simplifyPath(String pathname) { * * @since 11.0 */ + @Beta public static String getFileExtension(String fullName) { checkNotNull(fullName); String fileName = new File(fullName).getName(); @@ -780,6 +804,7 @@ public static String getFileExtension(String fullName) { * @return The file name without its path or extension. * @since 14.0 */ + @Beta public static String getNameWithoutExtension(String file) { checkNotNull(file); String fileName = new File(file).getName(); @@ -839,6 +864,7 @@ public String toString() { * * @since 23.5 */ + @Beta public static Traverser fileTraverser() { return Traverser.forTree(FILE_TREE); } @@ -868,6 +894,7 @@ private static Iterable fileTreeChildren(File file) { * * @since 15.0 */ + @Beta public static Predicate isDirectory() { return FilePredicate.IS_DIRECTORY; } @@ -877,6 +904,7 @@ public static Predicate isDirectory() { * * @since 15.0 */ + @Beta public static Predicate isFile() { return FilePredicate.IS_FILE; } 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 0ac1ca02b0a7..f050098cc5ba 100644 --- a/android/guava/src/com/google/common/util/concurrent/Futures.java +++ b/android/guava/src/com/google/common/util/concurrent/Futures.java @@ -70,7 +70,6 @@ * @author Sven Mawson * @since 1.0 */ -@Beta @GwtCompatible(emulated = true) public final class Futures extends GwtFuturesCatchingSpecialization { @@ -147,6 +146,7 @@ private Futures() {} * themselves. This method is scheduled for removal from Guava in January 2019. */ // TODO(b/72241575): Remove by 2019-01 + @Beta @Deprecated @GwtIncompatible // TODO public static CheckedFuture makeChecked( @@ -186,6 +186,7 @@ public static ListenableFuture immediateFuture(@NullableDecl V value) { * themselves. This method is scheduled for removal from Guava in January 2019. */ // TODO(b/72241893): Remove by 2019-01 + @Beta @Deprecated @GwtIncompatible // TODO public static CheckedFuture immediateCheckedFuture( @@ -233,6 +234,7 @@ public static ListenableFuture immediateCancelledFuture() { * themselves. This method is scheduled for removal from Guava in January 2019. */ // TODO(b/72241500): Remove by 2019-01 + @Beta @Deprecated @GwtIncompatible // TODO public static CheckedFuture immediateFailedCheckedFuture( @@ -247,6 +249,7 @@ public static CheckedFuture immediateFailedChecke * @throws RejectedExecutionException if the task cannot be scheduled for execution * @since 23.0 */ + @Beta public static ListenableFuture submitAsync(AsyncCallable callable, Executor executor) { TrustedListenableFutureTask task = TrustedListenableFutureTask.create(callable); executor.execute(task); @@ -259,6 +262,7 @@ public static ListenableFuture submitAsync(AsyncCallable callable, Exe * @throws RejectedExecutionException if the task cannot be scheduled for execution * @since 23.0 */ + @Beta @GwtIncompatible // java.util.concurrent.ScheduledExecutorService @SuppressWarnings("GoodTime") // should accept a java.time.Duration public static ListenableFuture scheduleAsync( @@ -318,6 +322,7 @@ public void run() { * @param executor the executor that runs {@code fallback} if {@code input} fails * @since 19.0 */ + @Beta @Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class") public static ListenableFuture catching( ListenableFuture input, @@ -386,6 +391,7 @@ public static ListenableFuture catching( * @param executor the executor that runs {@code fallback} if {@code input} fails * @since 19.0 (similar functionality in 14.0 as {@code withFallback}) */ + @Beta @Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class") public static ListenableFuture catchingAsync( ListenableFuture input, @@ -407,6 +413,7 @@ public static ListenableFuture catchingAsync( * @param scheduledExecutor The executor service to enforce the timeout. * @since 19.0 */ + @Beta @GwtIncompatible // java.util.concurrent.ScheduledExecutorService @SuppressWarnings("GoodTime") // should accept a java.time.Duration public static ListenableFuture withTimeout( @@ -456,6 +463,7 @@ public static ListenableFuture withTimeout( * input's failure (if not) * @since 19.0 (in 11.0 as {@code transform}) */ + @Beta public static ListenableFuture transformAsync( ListenableFuture input, AsyncFunction function, @@ -494,6 +502,7 @@ public static ListenableFuture transformAsync( * @return A future that holds result of the transformation. * @since 9.0 (in 2.0 as {@code compose}) */ + @Beta public static ListenableFuture transform( ListenableFuture input, Function function, Executor executor) { return AbstractTransformFuture.create(input, function, executor); @@ -519,6 +528,7 @@ public static ListenableFuture transform( * @return A future that returns the result of the transformation. * @since 10.0 */ + @Beta @GwtIncompatible // TODO public static Future lazyTransform( final Future input, final Function function) { @@ -606,6 +616,7 @@ public static ListenableFuture> allAsList( * * @since 20.0 */ + @Beta @SafeVarargs public static FutureCombiner whenAllComplete(ListenableFuture... futures) { return new FutureCombiner(false, ImmutableList.copyOf(futures)); @@ -617,6 +628,7 @@ public static FutureCombiner whenAllComplete(ListenableFuture FutureCombiner whenAllComplete( Iterable> futures) { return new FutureCombiner(false, ImmutableList.copyOf(futures)); @@ -629,6 +641,7 @@ public static FutureCombiner whenAllComplete( * * @since 20.0 */ + @Beta @SafeVarargs public static FutureCombiner whenAllSucceed(ListenableFuture... futures) { return new FutureCombiner(true, ImmutableList.copyOf(futures)); @@ -641,6 +654,7 @@ public static FutureCombiner whenAllSucceed(ListenableFuture * * @since 20.0 */ + @Beta public static FutureCombiner whenAllSucceed( Iterable> futures) { return new FutureCombiner(true, ImmutableList.copyOf(futures)); @@ -753,6 +767,7 @@ public Void call() throws Exception { * * @since 15.0 */ + @Beta public static ListenableFuture nonCancellationPropagating(ListenableFuture future) { if (future.isDone()) { return future; @@ -1146,6 +1161,7 @@ public static V getDone(Future future) throws ExecutionException { * does not have a suitable constructor * @since 19.0 (in 10.0 as {@code get}) */ + @Beta @CanIgnoreReturnValue @GwtIncompatible // reflection public static V getChecked(Future future, Class exceptionClass) @@ -1196,6 +1212,7 @@ public static V getChecked(Future future, Class e * does not have a suitable constructor * @since 19.0 (in 10.0 as {@code get} and with different parameter order) */ + @Beta @CanIgnoreReturnValue @GwtIncompatible // reflection @SuppressWarnings("GoodTime") // should accept a java.time.Duration diff --git a/android/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java b/android/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java index fbdb28632828..959a2fc28723 100644 --- a/android/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java +++ b/android/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java @@ -14,7 +14,6 @@ package com.google.common.util.concurrent; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtIncompatible; import java.util.concurrent.Callable; import java.util.concurrent.ScheduledExecutorService; @@ -29,7 +28,6 @@ * @author Chris Povirk * @since 10.0 */ -@Beta @GwtIncompatible public interface ListeningScheduledExecutorService extends ScheduledExecutorService, ListeningExecutorService { diff --git a/android/guava/src/com/google/common/util/concurrent/Uninterruptibles.java b/android/guava/src/com/google/common/util/concurrent/Uninterruptibles.java index be4a2ad2cf05..de14c1b750b4 100644 --- a/android/guava/src/com/google/common/util/concurrent/Uninterruptibles.java +++ b/android/guava/src/com/google/common/util/concurrent/Uninterruptibles.java @@ -16,7 +16,6 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; import com.google.common.base.Preconditions; @@ -39,7 +38,6 @@ * @author Anthony Zana * @since 10.0 */ -@Beta @GwtCompatible(emulated = true) public final class Uninterruptibles { diff --git a/guava/src/com/google/common/base/Splitter.java b/guava/src/com/google/common/base/Splitter.java index d82b1de82ba0..1da372e371ff 100644 --- a/guava/src/com/google/common/base/Splitter.java +++ b/guava/src/com/google/common/base/Splitter.java @@ -408,7 +408,6 @@ private Iterator splittingIterator(CharSequence sequence) { * @return an immutable list of the segments split from the parameter * @since 15.0 */ - @Beta public List splitToList(CharSequence sequence) { checkNotNull(sequence); diff --git a/guava/src/com/google/common/base/Ticker.java b/guava/src/com/google/common/base/Ticker.java index 7b97b1533f72..a53883b46ed7 100644 --- a/guava/src/com/google/common/base/Ticker.java +++ b/guava/src/com/google/common/base/Ticker.java @@ -14,7 +14,6 @@ package com.google.common.base; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; /** @@ -28,7 +27,6 @@ * @since 10.0 (mostly * source-compatible since 9.0) */ -@Beta @GwtCompatible public abstract class Ticker { /** Constructor for use by subclasses. */ diff --git a/guava/src/com/google/common/collect/Comparators.java b/guava/src/com/google/common/collect/Comparators.java index d2743589a93b..06b398f3ce1e 100644 --- a/guava/src/com/google/common/collect/Comparators.java +++ b/guava/src/com/google/common/collect/Comparators.java @@ -42,7 +42,6 @@ * @since 21.0 * @author Louis Wasserman */ -@Beta @GwtCompatible public final class Comparators { private Comparators() {} @@ -61,6 +60,7 @@ private Comparators() {} // Note: 90% of the time we don't add type parameters or wildcards that serve only to "tweak" the // desired return type. However, *nested* generics introduce a special class of problems that we // think tip it over into being worthwhile. + @Beta public static Comparator> lexicographical(Comparator comparator) { return new LexicographicalOrdering(checkNotNull(comparator)); } @@ -70,6 +70,7 @@ public static Comparator> lexicographical(Comparato * equal to the element that preceded it, according to the specified comparator. Note that this is * always true when the iterable has fewer than two elements. */ + @Beta public static boolean isInOrder(Iterable iterable, Comparator comparator) { checkNotNull(comparator); Iterator it = iterable.iterator(); @@ -91,6 +92,7 @@ public static boolean isInOrder(Iterable iterable, Comparator boolean isInStrictOrder( Iterable iterable, Comparator comparator) { checkNotNull(comparator); diff --git a/guava/src/com/google/common/collect/ImmutableBiMap.java b/guava/src/com/google/common/collect/ImmutableBiMap.java index 70f4e240cda5..d26a32c671bd 100644 --- a/guava/src/com/google/common/collect/ImmutableBiMap.java +++ b/guava/src/com/google/common/collect/ImmutableBiMap.java @@ -53,7 +53,6 @@ public abstract class ImmutableBiMap extends ImmutableBiMapFauxverideShim< * * @since 21.0 */ - @Beta public static Collector> toImmutableBiMap( Function keyFunction, Function valueFunction) { diff --git a/guava/src/com/google/common/collect/ImmutableList.java b/guava/src/com/google/common/collect/ImmutableList.java index a2843538d973..8dd49de2016b 100644 --- a/guava/src/com/google/common/collect/ImmutableList.java +++ b/guava/src/com/google/common/collect/ImmutableList.java @@ -67,7 +67,6 @@ public abstract class ImmutableList extends ImmutableCollection * * @since 21.0 */ - @Beta public static Collector> toImmutableList() { return CollectCollectors.toImmutableList(); } diff --git a/guava/src/com/google/common/collect/ImmutableListMultimap.java b/guava/src/com/google/common/collect/ImmutableListMultimap.java index decbcf63cbae..43becc62861d 100644 --- a/guava/src/com/google/common/collect/ImmutableListMultimap.java +++ b/guava/src/com/google/common/collect/ImmutableListMultimap.java @@ -79,7 +79,6 @@ public class ImmutableListMultimap extends ImmutableMultimap * * @since 21.0 */ - @Beta public static Collector> toImmutableListMultimap( Function keyFunction, Function valueFunction) { @@ -123,7 +122,6 @@ public class ImmutableListMultimap extends ImmutableMultimap * * @since 21.0 */ - @Beta public static Collector> flatteningToImmutableListMultimap( Function keyFunction, diff --git a/guava/src/com/google/common/collect/ImmutableMap.java b/guava/src/com/google/common/collect/ImmutableMap.java index dfea7dbffd61..00a789219a16 100644 --- a/guava/src/com/google/common/collect/ImmutableMap.java +++ b/guava/src/com/google/common/collect/ImmutableMap.java @@ -75,7 +75,6 @@ public abstract class ImmutableMap implements Map, Serializable { * * @since 21.0 */ - @Beta public static Collector> toImmutableMap( Function keyFunction, Function valueFunction) { @@ -92,7 +91,6 @@ public abstract class ImmutableMap implements Map, Serializable { * * @since 21.0 */ - @Beta public static Collector> toImmutableMap( Function keyFunction, Function valueFunction, diff --git a/guava/src/com/google/common/collect/ImmutableMultiset.java b/guava/src/com/google/common/collect/ImmutableMultiset.java index f1f46fcfb894..5320e3978971 100644 --- a/guava/src/com/google/common/collect/ImmutableMultiset.java +++ b/guava/src/com/google/common/collect/ImmutableMultiset.java @@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; import com.google.common.annotations.VisibleForTesting; @@ -64,7 +63,6 @@ public abstract class ImmutableMultiset extends ImmutableMultisetGwtSerializa * * @since 21.0 */ - @Beta public static Collector> toImmutableMultiset() { return toImmutableMultiset(Function.identity(), e -> 1); } diff --git a/guava/src/com/google/common/collect/ImmutableRangeMap.java b/guava/src/com/google/common/collect/ImmutableRangeMap.java index 5ebf0f4e4e5d..56f36f3f1b06 100644 --- a/guava/src/com/google/common/collect/ImmutableRangeMap.java +++ b/guava/src/com/google/common/collect/ImmutableRangeMap.java @@ -53,7 +53,6 @@ public class ImmutableRangeMap, V> implements RangeMap, V> Collector> toImmutableRangeMap( Function> keyFunction, diff --git a/guava/src/com/google/common/collect/ImmutableRangeSet.java b/guava/src/com/google/common/collect/ImmutableRangeSet.java index a9b40dcd13ab..70eb8595aeb2 100644 --- a/guava/src/com/google/common/collect/ImmutableRangeSet.java +++ b/guava/src/com/google/common/collect/ImmutableRangeSet.java @@ -63,7 +63,6 @@ public final class ImmutableRangeSet extends AbstractRange * * @since 23.1 */ - @Beta public static > Collector, ?, ImmutableRangeSet> toImmutableRangeSet() { return CollectCollectors.toImmutableRangeSet(); diff --git a/guava/src/com/google/common/collect/ImmutableSet.java b/guava/src/com/google/common/collect/ImmutableSet.java index 63cb0b2e3edc..6e870c3e63c4 100644 --- a/guava/src/com/google/common/collect/ImmutableSet.java +++ b/guava/src/com/google/common/collect/ImmutableSet.java @@ -62,7 +62,6 @@ public abstract class ImmutableSet extends ImmutableCollection implements * * @since 21.0 */ - @Beta public static Collector> toImmutableSet() { return CollectCollectors.toImmutableSet(); } diff --git a/guava/src/com/google/common/collect/ImmutableSetMultimap.java b/guava/src/com/google/common/collect/ImmutableSetMultimap.java index 7f59097b4379..5abe6803ab7d 100644 --- a/guava/src/com/google/common/collect/ImmutableSetMultimap.java +++ b/guava/src/com/google/common/collect/ImmutableSetMultimap.java @@ -83,7 +83,6 @@ public class ImmutableSetMultimap extends ImmutableMultimap * * @since 21.0 */ - @Beta public static Collector> toImmutableSetMultimap( Function keyFunction, Function valueFunction) { @@ -136,7 +135,6 @@ public class ImmutableSetMultimap extends ImmutableMultimap * * @since 21.0 */ - @Beta public static Collector> flatteningToImmutableSetMultimap( Function keyFunction, diff --git a/guava/src/com/google/common/collect/ImmutableSortedMap.java b/guava/src/com/google/common/collect/ImmutableSortedMap.java index a3d55e20bfe4..2cfba0d05611 100644 --- a/guava/src/com/google/common/collect/ImmutableSortedMap.java +++ b/guava/src/com/google/common/collect/ImmutableSortedMap.java @@ -73,7 +73,6 @@ public final class ImmutableSortedMap extends ImmutableSortedMapFauxveride * * @since 21.0 */ - @Beta public static Collector> toImmutableSortedMap( Comparator comparator, Function keyFunction, @@ -92,7 +91,6 @@ public final class ImmutableSortedMap extends ImmutableSortedMapFauxveride * * @since 21.0 */ - @Beta public static Collector> toImmutableSortedMap( Comparator comparator, Function keyFunction, diff --git a/guava/src/com/google/common/collect/ImmutableSortedMultiset.java b/guava/src/com/google/common/collect/ImmutableSortedMultiset.java index 59bdd9b526f7..ec0206314f57 100644 --- a/guava/src/com/google/common/collect/ImmutableSortedMultiset.java +++ b/guava/src/com/google/common/collect/ImmutableSortedMultiset.java @@ -17,7 +17,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtIncompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.concurrent.LazyInit; @@ -62,7 +61,6 @@ public abstract class ImmutableSortedMultiset extends ImmutableSortedMultiset * * @since 21.0 */ - @Beta public static Collector> toImmutableSortedMultiset( Comparator comparator) { return toImmutableSortedMultiset(comparator, Function.identity(), e -> 1); diff --git a/guava/src/com/google/common/collect/ImmutableSortedSet.java b/guava/src/com/google/common/collect/ImmutableSortedSet.java index ea8bc744f9e1..c025c5f111a8 100644 --- a/guava/src/com/google/common/collect/ImmutableSortedSet.java +++ b/guava/src/com/google/common/collect/ImmutableSortedSet.java @@ -20,7 +20,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.ObjectArrays.checkElementsNotNull; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; @@ -75,7 +74,6 @@ public abstract class ImmutableSortedSet extends ImmutableSortedSetFauxveride * * @since 21.0 */ - @Beta public static Collector> toImmutableSortedSet( Comparator comparator) { return CollectCollectors.toImmutableSortedSet(comparator); diff --git a/guava/src/com/google/common/collect/ImmutableTable.java b/guava/src/com/google/common/collect/ImmutableTable.java index b7b7f95d3998..04acb8b13976 100644 --- a/guava/src/com/google/common/collect/ImmutableTable.java +++ b/guava/src/com/google/common/collect/ImmutableTable.java @@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.common.base.MoreObjects; import com.google.common.collect.Tables.AbstractCell; @@ -60,7 +59,6 @@ public abstract class ImmutableTable extends AbstractTable * * @since 21.0 */ - @Beta public static Collector> toImmutableTable( Function rowFunction, Function columnFunction, diff --git a/guava/src/com/google/common/collect/Maps.java b/guava/src/com/google/common/collect/Maps.java index e3fadc9d87ec..62dc34f2d8c9 100644 --- a/guava/src/com/google/common/collect/Maps.java +++ b/guava/src/com/google/common/collect/Maps.java @@ -144,7 +144,6 @@ V transform(Entry entry) { * @since 14.0 */ @GwtCompatible(serializable = true) - @Beta public static , V> ImmutableMap immutableEnumMap( Map map) { if (map instanceof ImmutableEnumMap) { @@ -218,7 +217,6 @@ ImmutableMap toImmutableMap() { * * @since 21.0 */ - @Beta public static , V> Collector> toImmutableEnumMap( java.util.function.Function keyFunction, java.util.function.Function valueFunction) { @@ -251,7 +249,6 @@ ImmutableMap toImmutableMap() { * * @since 21.0 */ - @Beta public static , V> Collector> toImmutableEnumMap( java.util.function.Function keyFunction, java.util.function.Function valueFunction, @@ -1491,7 +1488,6 @@ public int hashCode() { * * @since 16.0 */ - @Beta public static Converter asConverter(final BiMap bimap) { return new BiMapConverter<>(bimap); } diff --git a/guava/src/com/google/common/collect/MoreCollectors.java b/guava/src/com/google/common/collect/MoreCollectors.java index 3e6cdcad2d82..f447ebeb3b54 100644 --- a/guava/src/com/google/common/collect/MoreCollectors.java +++ b/guava/src/com/google/common/collect/MoreCollectors.java @@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import java.util.ArrayList; import java.util.List; @@ -34,7 +33,6 @@ * @author Louis Wasserman * @since 21.0 */ -@Beta @GwtCompatible public final class MoreCollectors { diff --git a/guava/src/com/google/common/collect/MultimapBuilder.java b/guava/src/com/google/common/collect/MultimapBuilder.java index 482385e50a25..161c29d170ee 100644 --- a/guava/src/com/google/common/collect/MultimapBuilder.java +++ b/guava/src/com/google/common/collect/MultimapBuilder.java @@ -19,7 +19,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.CollectPreconditions.checkNonnegative; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.common.base.Supplier; import java.io.Serializable; @@ -61,7 +60,6 @@ * @param An upper bound on the value type of the generated multimap. * @since 16.0 */ -@Beta @GwtCompatible public abstract class MultimapBuilder { /* diff --git a/guava/src/com/google/common/collect/Sets.java b/guava/src/com/google/common/collect/Sets.java index a36b6be24542..a83f1b33ff94 100644 --- a/guava/src/com/google/common/collect/Sets.java +++ b/guava/src/com/google/common/collect/Sets.java @@ -181,7 +181,6 @@ ImmutableSet toImmutableSet() { * * @since 21.0 */ - @Beta public static > Collector> toImmutableEnumSet() { return (Collector) Accumulator.TO_IMMUTABLE_ENUM_SET; } diff --git a/guava/src/com/google/common/collect/Streams.java b/guava/src/com/google/common/collect/Streams.java index d4b292999143..974c18db9f9e 100644 --- a/guava/src/com/google/common/collect/Streams.java +++ b/guava/src/com/google/common/collect/Streams.java @@ -51,7 +51,6 @@ * * @since 21.0 */ -@Beta @GwtCompatible public final class Streams { /** @@ -69,6 +68,7 @@ public static Stream stream(Iterable iterable) { * * @deprecated There is no reason to use this; just invoke {@code collection.stream()} directly. */ + @Beta @Deprecated public static Stream stream(Collection collection) { return collection.stream(); @@ -78,6 +78,7 @@ public static Stream stream(Collection collection) { * Returns a sequential {@link Stream} of the remaining contents of {@code iterator}. Do not use * {@code iterator} directly after passing it to this method. */ + @Beta public static Stream stream(Iterator iterator) { return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, 0), false); } @@ -86,6 +87,7 @@ public static Stream stream(Iterator iterator) { * If a value is present in {@code optional}, returns a stream containing only that element, * otherwise returns an empty stream. */ + @Beta public static Stream stream(com.google.common.base.Optional optional) { return optional.isPresent() ? Stream.of(optional.get()) : Stream.of(); } @@ -96,6 +98,7 @@ public static Stream stream(com.google.common.base.Optional optional) * *

Java 9 users: use {@code optional.stream()} instead. */ + @Beta public static Stream stream(java.util.Optional optional) { return optional.isPresent() ? Stream.of(optional.get()) : Stream.of(); } @@ -106,6 +109,7 @@ public static Stream stream(java.util.Optional optional) { * *

Java 9 users: use {@code optional.stream()} instead. */ + @Beta public static IntStream stream(OptionalInt optional) { return optional.isPresent() ? IntStream.of(optional.getAsInt()) : IntStream.empty(); } @@ -116,6 +120,7 @@ public static IntStream stream(OptionalInt optional) { * *

Java 9 users: use {@code optional.stream()} instead. */ + @Beta public static LongStream stream(OptionalLong optional) { return optional.isPresent() ? LongStream.of(optional.getAsLong()) : LongStream.empty(); } @@ -126,6 +131,7 @@ public static LongStream stream(OptionalLong optional) { * *

Java 9 users: use {@code optional.stream()} instead. */ + @Beta public static DoubleStream stream(OptionalDouble optional) { return optional.isPresent() ? DoubleStream.of(optional.getAsDouble()) : DoubleStream.empty(); } @@ -236,6 +242,7 @@ public static DoubleStream concat(DoubleStream... streams) { * href="http://gee.cs.oswego.edu/dl/html/StreamParallelGuidance.html">efficiently splittable. * This may harm parallel performance. */ + @Beta public static Stream zip( Stream streamA, Stream streamB, BiFunction function) { checkNotNull(streamA); @@ -297,6 +304,7 @@ public boolean tryAdvance(Consumer action) { * * @since 22.0 */ + @Beta public static void forEachPair( Stream streamA, Stream streamB, BiConsumer consumer) { checkNotNull(consumer); @@ -345,6 +353,7 @@ private static class TemporaryPair { *

The order of the resulting stream is defined if and only if the order of the original stream * was defined. */ + @Beta public static Stream mapWithIndex( Stream stream, FunctionWithIndex function) { checkNotNull(stream); @@ -427,6 +436,7 @@ Splitr createSplit(Spliterator from, long i) { *

The order of the resulting stream is defined if and only if the order of the original stream * was defined. */ + @Beta public static Stream mapWithIndex(IntStream stream, IntFunctionWithIndex function) { checkNotNull(stream); checkNotNull(function); @@ -505,6 +515,7 @@ Splitr createSplit(Spliterator.OfInt from, long i) { *

The order of the resulting stream is defined if and only if the order of the original stream * was defined. */ + @Beta public static Stream mapWithIndex(LongStream stream, LongFunctionWithIndex function) { checkNotNull(stream); checkNotNull(function); @@ -583,6 +594,7 @@ Splitr createSplit(Spliterator.OfLong from, long i) { *

The order of the resulting stream is defined if and only if the order of the original stream * was defined. */ + @Beta public static Stream mapWithIndex( DoubleStream stream, DoubleFunctionWithIndex function) { checkNotNull(stream); @@ -748,6 +760,7 @@ public interface DoubleFunctionWithIndex { * @see Stream#findFirst() * @throws NullPointerException if the last element of the stream is null */ + @Beta public static java.util.Optional findLast(Stream stream) { class OptionalState { boolean set = false; @@ -822,6 +835,7 @@ T get() { * @see IntStream#findFirst() * @throws NullPointerException if the last element of the stream is null */ + @Beta public static OptionalInt findLast(IntStream stream) { // findLast(Stream) does some allocation, so we might as well box some more java.util.Optional boxedLast = findLast(stream.boxed()); @@ -840,6 +854,7 @@ public static OptionalInt findLast(IntStream stream) { * @see LongStream#findFirst() * @throws NullPointerException if the last element of the stream is null */ + @Beta public static OptionalLong findLast(LongStream stream) { // findLast(Stream) does some allocation, so we might as well box some more java.util.Optional boxedLast = findLast(stream.boxed()); @@ -858,6 +873,7 @@ public static OptionalLong findLast(LongStream stream) { * @see DoubleStream#findFirst() * @throws NullPointerException if the last element of the stream is null */ + @Beta public static OptionalDouble findLast(DoubleStream stream) { // findLast(Stream) does some allocation, so we might as well box some more java.util.Optional boxedLast = findLast(stream.boxed()); diff --git a/guava/src/com/google/common/html/HtmlEscapers.java b/guava/src/com/google/common/html/HtmlEscapers.java index 29f5e1339c2b..29eebe8aaa46 100644 --- a/guava/src/com/google/common/html/HtmlEscapers.java +++ b/guava/src/com/google/common/html/HtmlEscapers.java @@ -14,7 +14,6 @@ package com.google.common.html; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.common.escape.Escaper; import com.google.common.escape.Escapers; @@ -35,7 +34,6 @@ * @author David Beaumont * @since 15.0 */ -@Beta @GwtCompatible public final class HtmlEscapers { /** diff --git a/guava/src/com/google/common/io/ByteStreams.java b/guava/src/com/google/common/io/ByteStreams.java index 510947ef0e17..e6601be5c35b 100644 --- a/guava/src/com/google/common/io/ByteStreams.java +++ b/guava/src/com/google/common/io/ByteStreams.java @@ -48,7 +48,6 @@ * @author Colin Decker * @since 1.0 */ -@Beta @GwtIncompatible public final class ByteStreams { @@ -266,6 +265,7 @@ static byte[] toByteArray(InputStream in, long expectedSize) throws IOException * @since 20.0 */ @CanIgnoreReturnValue + @Beta public static long exhaust(InputStream in) throws IOException { long total = 0; long read; @@ -280,6 +280,7 @@ public static long exhaust(InputStream in) throws IOException { * Returns a new {@link ByteArrayDataInput} instance to read from the {@code bytes} array from the * beginning. */ + @Beta public static ByteArrayDataInput newDataInput(byte[] bytes) { return newDataInput(new ByteArrayInputStream(bytes)); } @@ -291,6 +292,7 @@ public static ByteArrayDataInput newDataInput(byte[] bytes) { * @throws IndexOutOfBoundsException if {@code start} is negative or greater than the length of * the array */ + @Beta public static ByteArrayDataInput newDataInput(byte[] bytes, int start) { checkPositionIndex(start, bytes.length); return newDataInput(new ByteArrayInputStream(bytes, start, bytes.length - start)); @@ -303,6 +305,7 @@ public static ByteArrayDataInput newDataInput(byte[] bytes, int start) { * * @since 17.0 */ + @Beta public static ByteArrayDataInput newDataInput(ByteArrayInputStream byteArrayInputStream) { return new ByteArrayDataInputStream(checkNotNull(byteArrayInputStream)); } @@ -453,6 +456,7 @@ public String readUTF() { } /** Returns a new {@link ByteArrayDataOutput} instance with a default size. */ + @Beta public static ByteArrayDataOutput newDataOutput() { return newDataOutput(new ByteArrayOutputStream()); } @@ -463,6 +467,7 @@ public static ByteArrayDataOutput newDataOutput() { * * @throws IllegalArgumentException if {@code size} is negative */ + @Beta public static ByteArrayDataOutput newDataOutput(int size) { // When called at high frequency, boxing size generates too much garbage, // so avoid doing that if we can. @@ -484,6 +489,7 @@ public static ByteArrayDataOutput newDataOutput(int size) { * * @since 17.0 */ + @Beta public static ByteArrayDataOutput newDataOutput(ByteArrayOutputStream byteArrayOutputSteam) { return new ByteArrayDataOutputStream(checkNotNull(byteArrayOutputSteam)); } @@ -659,6 +665,7 @@ public String toString() { * * @since 14.0 (since 1.0 as com.google.common.io.NullOutputStream) */ + @Beta public static OutputStream nullOutputStream() { return NULL_OUTPUT_STREAM; } @@ -671,6 +678,7 @@ public static OutputStream nullOutputStream() { * @return a length-limited {@link InputStream} * @since 14.0 (since 1.0 as com.google.common.io.LimitInputStream) */ + @Beta public static InputStream limit(InputStream in, long limit) { return new LimitedInputStream(in, limit); } @@ -757,6 +765,7 @@ public long skip(long n) throws IOException { * @throws EOFException if this stream reaches the end before reading all the bytes. * @throws IOException if an I/O error occurs. */ + @Beta public static void readFully(InputStream in, byte[] b) throws IOException { readFully(in, b, 0, b.length); } @@ -773,6 +782,7 @@ public static void readFully(InputStream in, byte[] b) throws IOException { * @throws EOFException if this stream reaches the end before reading all the bytes. * @throws IOException if an I/O error occurs. */ + @Beta public static void readFully(InputStream in, byte[] b, int off, int len) throws IOException { int read = read(in, b, off, len); if (read != len) { @@ -790,6 +800,7 @@ public static void readFully(InputStream in, byte[] b, int off, int len) throws * @throws EOFException if this stream reaches the end before skipping all the bytes * @throws IOException if an I/O error occurs, or the stream does not support skipping */ + @Beta public static void skipFully(InputStream in, long n) throws IOException { long skipped = skipUpTo(in, n); if (skipped < n) { @@ -848,6 +859,7 @@ private static long skipSafely(InputStream in, long n) throws IOException { * @throws IOException if an I/O error occurs * @since 14.0 */ + @Beta @CanIgnoreReturnValue // some processors won't return a useful result public static T readBytes(InputStream input, ByteProcessor processor) throws IOException { checkNotNull(input); @@ -883,6 +895,7 @@ public static T readBytes(InputStream input, ByteProcessor processor) thr * @return the number of bytes read * @throws IOException if an I/O error occurs */ + @Beta @CanIgnoreReturnValue // Sometimes you don't care how many bytes you actually read, I guess. // (You know that it's either going to read len bytes or stop at EOF.) diff --git a/guava/src/com/google/common/io/CharStreams.java b/guava/src/com/google/common/io/CharStreams.java index bed3388a2cb7..bc4dd510245c 100644 --- a/guava/src/com/google/common/io/CharStreams.java +++ b/guava/src/com/google/common/io/CharStreams.java @@ -43,7 +43,6 @@ * @author Colin Decker * @since 1.0 */ -@Beta @GwtIncompatible public final class CharStreams { @@ -193,6 +192,7 @@ private static StringBuilder toStringBuilder(Readable r) throws IOException { * @return a mutable {@link List} containing all the lines * @throws IOException if an I/O error occurs */ + @Beta public static List readLines(Readable r) throws IOException { List result = new ArrayList<>(); LineReader lineReader = new LineReader(r); @@ -212,6 +212,7 @@ public static List readLines(Readable r) throws IOException { * @throws IOException if an I/O error occurs * @since 14.0 */ + @Beta @CanIgnoreReturnValue // some processors won't return a useful result public static T readLines(Readable readable, LineProcessor processor) throws IOException { checkNotNull(readable); @@ -233,6 +234,7 @@ public static T readLines(Readable readable, LineProcessor processor) thr * * @since 20.0 */ + @Beta @CanIgnoreReturnValue public static long exhaust(Readable readable) throws IOException { long total = 0; @@ -254,6 +256,7 @@ public static long exhaust(Readable readable) throws IOException { * @throws EOFException if this stream reaches the end before skipping all the characters * @throws IOException if an I/O error occurs */ + @Beta public static void skipFully(Reader reader, long n) throws IOException { checkNotNull(reader); while (n > 0) { @@ -270,6 +273,7 @@ public static void skipFully(Reader reader, long n) throws IOException { * * @since 15.0 */ + @Beta public static Writer nullWriter() { return NullWriter.INSTANCE; } @@ -338,6 +342,7 @@ public String toString() { * @param target the object to which output will be sent * @return a new Writer object, unless target is a Writer, in which case the target is returned */ + @Beta public static Writer asWriter(Appendable target) { if (target instanceof Writer) { return (Writer) target; diff --git a/guava/src/com/google/common/io/Files.java b/guava/src/com/google/common/io/Files.java index 74858d735f1d..34e03f65d6b2 100644 --- a/guava/src/com/google/common/io/Files.java +++ b/guava/src/com/google/common/io/Files.java @@ -63,7 +63,6 @@ * @author Colin Decker * @since 1.0 */ -@Beta @GwtIncompatible public final class Files { @@ -83,6 +82,7 @@ private Files() {} * helpful predefined constants * @return the buffered reader */ + @Beta public static BufferedReader newReader(File file, Charset charset) throws FileNotFoundException { checkNotNull(file); checkNotNull(charset); @@ -101,6 +101,7 @@ public static BufferedReader newReader(File file, Charset charset) throws FileNo * helpful predefined constants * @return the buffered writer */ + @Beta public static BufferedWriter newWriter(File file, Charset charset) throws FileNotFoundException { checkNotNull(file); checkNotNull(charset); @@ -231,6 +232,7 @@ public static CharSink asCharSink(File file, Charset charset, FileWriteMode... m * (2^31 - 1) * @throws IOException if an I/O error occurs */ + @Beta public static byte[] toByteArray(File file) throws IOException { return asByteSource(file).read(); } @@ -246,6 +248,7 @@ public static byte[] toByteArray(File file) throws IOException { * @deprecated Prefer {@code asCharSource(file, charset).read()}. This method is scheduled to be * removed in January 2019. */ + @Beta @Deprecated public static String toString(File file, Charset charset) throws IOException { return asCharSource(file, charset).read(); @@ -261,6 +264,7 @@ public static String toString(File file, Charset charset) throws IOException { * @param to the destination file * @throws IOException if an I/O error occurs */ + @Beta public static void write(byte[] from, File to) throws IOException { asByteSink(to).write(from); } @@ -276,6 +280,7 @@ public static void write(byte[] from, File to) throws IOException { * @deprecated Prefer {@code asCharSink(to, charset).write(from)}. This method is scheduled to be * removed in January 2019. */ + @Beta @Deprecated public static void write(CharSequence from, File to, Charset charset) throws IOException { asCharSink(to, charset).write(from); @@ -291,6 +296,7 @@ public static void write(CharSequence from, File to, Charset charset) throws IOE * @param to the output stream * @throws IOException if an I/O error occurs */ + @Beta public static void copy(File from, OutputStream to) throws IOException { asByteSource(from).copyTo(to); } @@ -314,6 +320,7 @@ public static void copy(File from, OutputStream to) throws IOException { * @throws IOException if an I/O error occurs * @throws IllegalArgumentException if {@code from.equals(to)} */ + @Beta public static void copy(File from, File to) throws IOException { checkArgument(!from.equals(to), "Source %s and destination %s must be different", from, to); asByteSource(from).copyTo(asByteSink(to)); @@ -330,6 +337,7 @@ public static void copy(File from, File to) throws IOException { * @deprecated Prefer {@code asCharSource(from, charset).copyTo(to)}. This method is scheduled to * be removed in January 2019. */ + @Beta @Deprecated public static void copy(File from, Charset charset, Appendable to) throws IOException { @@ -347,6 +355,7 @@ static void copy(File from, Charset charset, Appendable to) throws IOException { * @deprecated Prefer {@code asCharSink(to, charset, FileWriteMode.APPEND).write(from)}. This * method is scheduled to be removed in January 2019. */ + @Beta @Deprecated public static void append(CharSequence from, File to, Charset charset) throws IOException { @@ -358,6 +367,7 @@ static void append(CharSequence from, File to, Charset charset) throws IOExcepti * * @throws IOException if an I/O error occurs */ + @Beta public static boolean equal(File file1, File file2) throws IOException { checkNotNull(file1); checkNotNull(file2); @@ -397,6 +407,7 @@ public static boolean equal(File file1, File file2) throws IOException { * @return the newly-created directory * @throws IllegalStateException if the directory could not be created */ + @Beta public static File createTempDir() { File baseDir = new File(System.getProperty("java.io.tmpdir")); @SuppressWarnings("GoodTime") // reading system time without TimeSource @@ -426,6 +437,7 @@ public static File createTempDir() { * @param file the file to create or update * @throws IOException if an I/O error occurs */ + @Beta @SuppressWarnings("GoodTime") // reading system time without TimeSource public static void touch(File file) throws IOException { checkNotNull(file); @@ -443,6 +455,7 @@ public static void touch(File file) throws IOException { * directories of the specified file could not be created. * @since 4.0 */ + @Beta public static void createParentDirs(File file) throws IOException { checkNotNull(file); File parent = file.getCanonicalFile().getParentFile(); @@ -473,6 +486,7 @@ public static void createParentDirs(File file) throws IOException { * @throws IOException if an I/O error occurs * @throws IllegalArgumentException if {@code from.equals(to)} */ + @Beta public static void move(File from, File to) throws IOException { checkNotNull(from); checkNotNull(to); @@ -501,6 +515,7 @@ public static void move(File from, File to) throws IOException { * @deprecated Prefer {@code asCharSource(file, charset).readFirstLine()}. This method is * scheduled to be removed in January 2019. */ + @Beta @Deprecated public static String readFirstLine(File file, Charset charset) throws IOException { @@ -523,6 +538,7 @@ static String readFirstLine(File file, Charset charset) throws IOException { * @return a mutable {@link List} containing all the lines * @throws IOException if an I/O error occurs */ + @Beta public static List readLines(File file, Charset charset) throws IOException { // don't use asCharSource(file, charset).readLines() because that returns // an immutable list, which would change the behavior of this method @@ -557,6 +573,7 @@ public List getResult() { * @deprecated Prefer {@code asCharSource(file, charset).readLines(callback)}. This method is * scheduled to be removed in January 2019. */ + @Beta @Deprecated @CanIgnoreReturnValue // some processors won't return a useful result public @@ -576,6 +593,7 @@ static T readLines(File file, Charset charset, LineProcessor callback) th * @deprecated Prefer {@code asByteSource(file).read(processor)}. This method is scheduled to be * removed in January 2019. */ + @Beta @Deprecated @CanIgnoreReturnValue // some processors won't return a useful result public @@ -594,6 +612,7 @@ static T readBytes(File file, ByteProcessor processor) throws IOException * @deprecated Prefer {@code asByteSource(file).hash(hashFunction)}. This method is scheduled to * be removed in January 2019. */ + @Beta @Deprecated public static HashCode hash(File file, HashFunction hashFunction) throws IOException { @@ -615,6 +634,7 @@ static HashCode hash(File file, HashFunction hashFunction) throws IOException { * @see FileChannel#map(MapMode, long, long) * @since 2.0 */ + @Beta public static MappedByteBuffer map(File file) throws IOException { checkNotNull(file); return map(file, MapMode.READ_ONLY); @@ -637,6 +657,7 @@ public static MappedByteBuffer map(File file) throws IOException { * @see FileChannel#map(MapMode, long, long) * @since 2.0 */ + @Beta public static MappedByteBuffer map(File file, MapMode mode) throws IOException { return mapInternal(file, mode, -1); } @@ -660,6 +681,7 @@ public static MappedByteBuffer map(File file, MapMode mode) throws IOException { * @see FileChannel#map(MapMode, long, long) * @since 2.0 */ + @Beta public static MappedByteBuffer map(File file, MapMode mode, long size) throws IOException { checkArgument(size >= 0, "size (%s) may not be negative", size); return mapInternal(file, mode, size); @@ -703,6 +725,7 @@ private static MappedByteBuffer mapInternal(File file, MapMode mode, long size) * * @since 11.0 */ + @Beta public static String simplifyPath(String pathname) { checkNotNull(pathname); if (pathname.length() == 0) { @@ -763,6 +786,7 @@ public static String simplifyPath(String pathname) { * * @since 11.0 */ + @Beta public static String getFileExtension(String fullName) { checkNotNull(fullName); String fileName = new File(fullName).getName(); @@ -780,6 +804,7 @@ public static String getFileExtension(String fullName) { * @return The file name without its path or extension. * @since 14.0 */ + @Beta public static String getNameWithoutExtension(String file) { checkNotNull(file); String fileName = new File(file).getName(); @@ -839,6 +864,7 @@ public String toString() { * * @since 23.5 */ + @Beta public static Traverser fileTraverser() { return Traverser.forTree(FILE_TREE); } @@ -868,6 +894,7 @@ private static Iterable fileTreeChildren(File file) { * * @since 15.0 */ + @Beta public static Predicate isDirectory() { return FilePredicate.IS_DIRECTORY; } @@ -877,6 +904,7 @@ public static Predicate isDirectory() { * * @since 15.0 */ + @Beta public static Predicate isFile() { return FilePredicate.IS_FILE; } diff --git a/guava/src/com/google/common/util/concurrent/Futures.java b/guava/src/com/google/common/util/concurrent/Futures.java index c5ebd710885c..dc2f104500b5 100644 --- a/guava/src/com/google/common/util/concurrent/Futures.java +++ b/guava/src/com/google/common/util/concurrent/Futures.java @@ -70,7 +70,6 @@ * @author Sven Mawson * @since 1.0 */ -@Beta @GwtCompatible(emulated = true) public final class Futures extends GwtFuturesCatchingSpecialization { @@ -147,6 +146,7 @@ private Futures() {} * themselves. This method is scheduled for removal from Guava in January 2019. */ // TODO(b/72241575): Remove by 2019-01 + @Beta @Deprecated @GwtIncompatible // TODO public static CheckedFuture makeChecked( @@ -186,6 +186,7 @@ public static ListenableFuture immediateFuture(@Nullable V value) { * themselves. This method is scheduled for removal from Guava in January 2019. */ // TODO(b/72241893): Remove by 2019-01 + @Beta @Deprecated @GwtIncompatible // TODO public static CheckedFuture immediateCheckedFuture( @@ -233,6 +234,7 @@ public static ListenableFuture immediateCancelledFuture() { * themselves. This method is scheduled for removal from Guava in January 2019. */ // TODO(b/72241500): Remove by 2019-01 + @Beta @Deprecated @GwtIncompatible // TODO public static CheckedFuture immediateFailedCheckedFuture( @@ -247,6 +249,7 @@ public static CheckedFuture immediateFailedChecke * @throws RejectedExecutionException if the task cannot be scheduled for execution * @since 23.0 */ + @Beta public static ListenableFuture submitAsync(AsyncCallable callable, Executor executor) { TrustedListenableFutureTask task = TrustedListenableFutureTask.create(callable); executor.execute(task); @@ -259,6 +262,7 @@ public static ListenableFuture submitAsync(AsyncCallable callable, Exe * @throws RejectedExecutionException if the task cannot be scheduled for execution * @since 23.0 */ + @Beta @GwtIncompatible // java.util.concurrent.ScheduledExecutorService @SuppressWarnings("GoodTime") // should accept a java.time.Duration public static ListenableFuture scheduleAsync( @@ -318,6 +322,7 @@ public void run() { * @param executor the executor that runs {@code fallback} if {@code input} fails * @since 19.0 */ + @Beta @Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class") public static ListenableFuture catching( ListenableFuture input, @@ -386,6 +391,7 @@ public static ListenableFuture catching( * @param executor the executor that runs {@code fallback} if {@code input} fails * @since 19.0 (similar functionality in 14.0 as {@code withFallback}) */ + @Beta @Partially.GwtIncompatible("AVAILABLE but requires exceptionType to be Throwable.class") public static ListenableFuture catchingAsync( ListenableFuture input, @@ -407,6 +413,7 @@ public static ListenableFuture catchingAsync( * @param scheduledExecutor The executor service to enforce the timeout. * @since 19.0 */ + @Beta @GwtIncompatible // java.util.concurrent.ScheduledExecutorService @SuppressWarnings("GoodTime") // should accept a java.time.Duration public static ListenableFuture withTimeout( @@ -456,6 +463,7 @@ public static ListenableFuture withTimeout( * input's failure (if not) * @since 19.0 (in 11.0 as {@code transform}) */ + @Beta public static ListenableFuture transformAsync( ListenableFuture input, AsyncFunction function, @@ -494,6 +502,7 @@ public static ListenableFuture transformAsync( * @return A future that holds result of the transformation. * @since 9.0 (in 2.0 as {@code compose}) */ + @Beta public static ListenableFuture transform( ListenableFuture input, Function function, Executor executor) { return AbstractTransformFuture.create(input, function, executor); @@ -519,6 +528,7 @@ public static ListenableFuture transform( * @return A future that returns the result of the transformation. * @since 10.0 */ + @Beta @GwtIncompatible // TODO public static Future lazyTransform( final Future input, final Function function) { @@ -606,6 +616,7 @@ public static ListenableFuture> allAsList( * * @since 20.0 */ + @Beta @SafeVarargs public static FutureCombiner whenAllComplete(ListenableFuture... futures) { return new FutureCombiner(false, ImmutableList.copyOf(futures)); @@ -617,6 +628,7 @@ public static FutureCombiner whenAllComplete(ListenableFuture FutureCombiner whenAllComplete( Iterable> futures) { return new FutureCombiner(false, ImmutableList.copyOf(futures)); @@ -629,6 +641,7 @@ public static FutureCombiner whenAllComplete( * * @since 20.0 */ + @Beta @SafeVarargs public static FutureCombiner whenAllSucceed(ListenableFuture... futures) { return new FutureCombiner(true, ImmutableList.copyOf(futures)); @@ -641,6 +654,7 @@ public static FutureCombiner whenAllSucceed(ListenableFuture * * @since 20.0 */ + @Beta public static FutureCombiner whenAllSucceed( Iterable> futures) { return new FutureCombiner(true, ImmutableList.copyOf(futures)); @@ -753,6 +767,7 @@ public Void call() throws Exception { * * @since 15.0 */ + @Beta public static ListenableFuture nonCancellationPropagating(ListenableFuture future) { if (future.isDone()) { return future; @@ -1146,6 +1161,7 @@ public static V getDone(Future future) throws ExecutionException { * does not have a suitable constructor * @since 19.0 (in 10.0 as {@code get}) */ + @Beta @CanIgnoreReturnValue @GwtIncompatible // reflection public static V getChecked(Future future, Class exceptionClass) @@ -1196,6 +1212,7 @@ public static V getChecked(Future future, Class e * does not have a suitable constructor * @since 19.0 (in 10.0 as {@code get} and with different parameter order) */ + @Beta @CanIgnoreReturnValue @GwtIncompatible // reflection @SuppressWarnings("GoodTime") // should accept a java.time.Duration diff --git a/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java b/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java index fbdb28632828..959a2fc28723 100644 --- a/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java +++ b/guava/src/com/google/common/util/concurrent/ListeningScheduledExecutorService.java @@ -14,7 +14,6 @@ package com.google.common.util.concurrent; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtIncompatible; import java.util.concurrent.Callable; import java.util.concurrent.ScheduledExecutorService; @@ -29,7 +28,6 @@ * @author Chris Povirk * @since 10.0 */ -@Beta @GwtIncompatible public interface ListeningScheduledExecutorService extends ScheduledExecutorService, ListeningExecutorService { diff --git a/guava/src/com/google/common/util/concurrent/Uninterruptibles.java b/guava/src/com/google/common/util/concurrent/Uninterruptibles.java index be4a2ad2cf05..de14c1b750b4 100644 --- a/guava/src/com/google/common/util/concurrent/Uninterruptibles.java +++ b/guava/src/com/google/common/util/concurrent/Uninterruptibles.java @@ -16,7 +16,6 @@ import static java.util.concurrent.TimeUnit.NANOSECONDS; -import com.google.common.annotations.Beta; import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; import com.google.common.base.Preconditions; @@ -39,7 +38,6 @@ * @author Anthony Zana * @since 10.0 */ -@Beta @GwtCompatible(emulated = true) public final class Uninterruptibles { From e7ec53773bcf89533496de1611ac4dddd876fb54 Mon Sep 17 00:00:00 2001 From: tszymanski Date: Wed, 6 Feb 2019 15:15:12 -0800 Subject: [PATCH 09/23] Add some known UTF-8 hash values to Murmur3_32 tests. UTF-8 is more comparable between platforms than relying on Java's internal encoding. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=232756904 --- .../com/google/common/hash/Murmur3Hash32Test.java | 12 ++++++++++++ .../com/google/common/hash/Murmur3Hash32Test.java | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/android/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java b/android/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java index 2e16dfea02eb..de86e4bbd86b 100644 --- a/android/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java +++ b/android/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java @@ -51,6 +51,18 @@ public void testKnownStringInputs() { -528633700, murmur3_32().hashUnencodedChars("The quick brown fox jumps over the lazy dog")); } + public void testKnownUtf8StringInputs() { + assertHash(0, murmur3_32().hashString("", Charsets.UTF_8)); + assertHash(0xcfbda5d1, murmur3_32().hashString("k", Charsets.UTF_8)); + assertHash(0xa167dbf3, murmur3_32().hashString("hell", Charsets.UTF_8)); + assertHash(0x248bfa47, murmur3_32().hashString("hello", Charsets.UTF_8)); + assertHash(0x3d41b97c, murmur3_32().hashString("http://www.google.com/", Charsets.UTF_8)); + assertHash( + 0x2e4ff723, + murmur3_32().hashString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)); + assertHash(0xfc5ba834, murmur3_32().hashString("毎月1日,毎週月曜日", Charsets.UTF_8)); + } + @SuppressWarnings("deprecation") public void testSimpleStringUtf8() { assertEquals( diff --git a/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java b/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java index 2e16dfea02eb..de86e4bbd86b 100644 --- a/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java +++ b/guava-tests/test/com/google/common/hash/Murmur3Hash32Test.java @@ -51,6 +51,18 @@ public void testKnownStringInputs() { -528633700, murmur3_32().hashUnencodedChars("The quick brown fox jumps over the lazy dog")); } + public void testKnownUtf8StringInputs() { + assertHash(0, murmur3_32().hashString("", Charsets.UTF_8)); + assertHash(0xcfbda5d1, murmur3_32().hashString("k", Charsets.UTF_8)); + assertHash(0xa167dbf3, murmur3_32().hashString("hell", Charsets.UTF_8)); + assertHash(0x248bfa47, murmur3_32().hashString("hello", Charsets.UTF_8)); + assertHash(0x3d41b97c, murmur3_32().hashString("http://www.google.com/", Charsets.UTF_8)); + assertHash( + 0x2e4ff723, + murmur3_32().hashString("The quick brown fox jumps over the lazy dog", Charsets.UTF_8)); + assertHash(0xfc5ba834, murmur3_32().hashString("毎月1日,毎週月曜日", Charsets.UTF_8)); + } + @SuppressWarnings("deprecation") public void testSimpleStringUtf8() { assertEquals( From da2895f5c3a55b84771488e0f8a38c67e0f63543 Mon Sep 17 00:00:00 2001 From: kak Date: Thu, 7 Feb 2019 08:58:48 -0800 Subject: [PATCH 10/23] Remove @CanIgnoreReturnValue from Ordering.sortedCopy() and immutableSortedCopy(). RELNOTES=Remove `@CanIgnoreReturnValue` from `Ordering.sortedCopy()` and `immutableSortedCopy()`. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=232883462 --- android/guava/src/com/google/common/collect/Ordering.java | 2 -- guava/src/com/google/common/collect/Ordering.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/android/guava/src/com/google/common/collect/Ordering.java b/android/guava/src/com/google/common/collect/Ordering.java index cb876a7bb2cf..9b42e7545172 100644 --- a/android/guava/src/com/google/common/collect/Ordering.java +++ b/android/guava/src/com/google/common/collect/Ordering.java @@ -837,7 +837,6 @@ public List greatestOf(Iterator iterator, int k) { * calling {@link Collections#sort(List)}. */ // TODO(kevinb): rerun benchmarks including new options - @CanIgnoreReturnValue // TODO(kak): Consider removing this public List sortedCopy(Iterable elements) { @SuppressWarnings("unchecked") // does not escape, and contains only E's E[] array = (E[]) Iterables.toArray(elements); @@ -861,7 +860,6 @@ public List sortedCopy(Iterable elements) { * @since 3.0 */ // TODO(kevinb): rerun benchmarks including new options - @CanIgnoreReturnValue // TODO(kak): Consider removing this before internal migration public ImmutableList immutableSortedCopy(Iterable elements) { return ImmutableList.sortedCopyOf(this, elements); } diff --git a/guava/src/com/google/common/collect/Ordering.java b/guava/src/com/google/common/collect/Ordering.java index 2e80688418ad..adb49e3d6940 100644 --- a/guava/src/com/google/common/collect/Ordering.java +++ b/guava/src/com/google/common/collect/Ordering.java @@ -837,7 +837,6 @@ public List greatestOf(Iterator iterator, int k) { * calling {@link Collections#sort(List)}. */ // TODO(kevinb): rerun benchmarks including new options - @CanIgnoreReturnValue // TODO(kak): Consider removing this public List sortedCopy(Iterable elements) { @SuppressWarnings("unchecked") // does not escape, and contains only E's E[] array = (E[]) Iterables.toArray(elements); @@ -861,7 +860,6 @@ public List sortedCopy(Iterable elements) { * @since 3.0 */ // TODO(kevinb): rerun benchmarks including new options - @CanIgnoreReturnValue // TODO(kak): Consider removing this before internal migration public ImmutableList immutableSortedCopy(Iterable elements) { return ImmutableList.sortedCopyOf(this, elements); } From b1933ce7d8c8ff0fac90b494b33ab8af159e1906 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Mon, 11 Feb 2019 08:05:04 -0800 Subject: [PATCH 11/23] Make a constructor private. (I'm looking into EnumMap stuff for other reasons, and I got to wondering if this was used outside the file. Nope.) RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=233408580 --- .../super/com/google/common/collect/ImmutableEnumMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableEnumMap.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableEnumMap.java index c438d267f681..5e3583ebab70 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableEnumMap.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableEnumMap.java @@ -36,7 +36,7 @@ static ImmutableMap asImmutable(Map map) { return new ImmutableEnumMap(map); } - ImmutableEnumMap(Map delegate) { + private ImmutableEnumMap(Map delegate) { super(WellBehavedMap.wrap(delegate)); } } From 2115c74c21ab47c3a41c2fb73a16aa6d051bf784 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Mon, 11 Feb 2019 09:08:12 -0800 Subject: [PATCH 12/23] Delete WellBehavedMap. The bug it worked around was fixed in Java 7: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=6312706 And I don't believe it was ever present under Android: https://android.googlesource.com/platform/libcore/+/fdb2704414a9ed92394ada0d1395e4db86889465/luni/src/main/java/java/util/EnumMap.java#146 I haven't looked for the absolute first version ever of GWT, but the still very old GWT file doesn't have the bug, either. Deleting this class will simplify some work I'm doing around our EnumMap usage for j2cl. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=233418344 --- .../common/collect/WellBehavedMapTest.java | 104 ------------------ .../com/google/common/collect/EnumBiMap.java | 8 +- .../google/common/collect/EnumHashBiMap.java | 5 +- .../google/common/collect/WellBehavedMap.java | 99 ----------------- .../common/collect/ImmutableEnumMap.java | 2 +- .../collect/WellBehavedMapTest_gwt.java | 40 ------- .../common/collect/WellBehavedMapTest.java | 104 ------------------ .../com/google/common/collect/EnumBiMap.java | 8 +- .../google/common/collect/EnumHashBiMap.java | 5 +- .../google/common/collect/WellBehavedMap.java | 99 ----------------- 10 files changed, 9 insertions(+), 465 deletions(-) delete mode 100644 android/guava-tests/test/com/google/common/collect/WellBehavedMapTest.java delete mode 100644 android/guava/src/com/google/common/collect/WellBehavedMap.java delete mode 100644 guava-gwt/test/com/google/common/collect/WellBehavedMapTest_gwt.java delete mode 100644 guava-tests/test/com/google/common/collect/WellBehavedMapTest.java delete mode 100644 guava/src/com/google/common/collect/WellBehavedMap.java diff --git a/android/guava-tests/test/com/google/common/collect/WellBehavedMapTest.java b/android/guava-tests/test/com/google/common/collect/WellBehavedMapTest.java deleted file mode 100644 index 4875531a2b50..000000000000 --- a/android/guava-tests/test/com/google/common/collect/WellBehavedMapTest.java +++ /dev/null @@ -1,104 +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.GwtCompatible; -import java.util.EnumMap; -import java.util.Map.Entry; -import java.util.Set; -import junit.framework.TestCase; - -@GwtCompatible -public class WellBehavedMapTest extends TestCase { - enum Foo { - X, - Y, - Z, - T - } - - public void testEntrySet_contain() { - WellBehavedMap map = WellBehavedMap.wrap(new EnumMap(Foo.class)); - map.putAll(ImmutableMap.of(Foo.X, 1, Foo.Y, 2, Foo.Z, 3)); - - // testing with the exact entry - assertTrue(map.entrySet().contains(Maps.immutableEntry(Foo.X, 1))); - assertTrue(map.entrySet().contains(Maps.immutableEntry(Foo.Y, new Integer(2)))); - - // testing an entry with a contained key, but not the same value - assertFalse(map.entrySet().contains(Maps.immutableEntry(Foo.X, 5))); - - // testing a non-existent key - assertFalse(map.entrySet().contains(Maps.immutableEntry(Foo.T, 0))); - } - - public void testEntry_setValue() { - WellBehavedMap map = WellBehavedMap.wrap(new EnumMap(Foo.class)); - map.putAll(ImmutableMap.of(Foo.X, 1, Foo.Y, 2, Foo.Z, 3)); - - for (Entry entry : map.entrySet()) { - entry.setValue(entry.getValue() + 5); - } - - assertEquals(ImmutableMap.of(Foo.X, 6, Foo.Y, 7, Foo.Z, 8), map); - } - - public void testEntriesAreMutableAndConsistent() { - WellBehavedMap map = WellBehavedMap.wrap(new EnumMap(Foo.class)); - map.putAll(ImmutableMap.of(Foo.X, 1)); - - Entry entry1 = Iterables.getOnlyElement(map.entrySet()); - Entry entry2 = Iterables.getOnlyElement(map.entrySet()); - - // the entries are constructed and forgotten, thus different - assertNotSame(entry1, entry2); - - Set> entrySet = map.entrySet(); - - assertTrue(entrySet.contains(entry1)); - assertTrue(entrySet.contains(entry2)); - - // mutating entry - entry1.setValue(2); - - // entry2 is also modified - assertEquals(entry1.getValue(), entry2.getValue()); - - // and both are still contained in the set - assertTrue(entrySet.contains(entry1)); - assertTrue(entrySet.contains(entry2)); - } - - public void testEntrySet_remove() { - WellBehavedMap map = WellBehavedMap.wrap(new EnumMap(Foo.class)); - map.putAll(ImmutableMap.of(Foo.X, 1, Foo.Y, 2, Foo.Z, 3)); - Set> entrySet = map.entrySet(); - - // removing an existing entry, verifying consistency - Entry entry = Maps.immutableEntry(Foo.Y, 2); - assertTrue(entrySet.remove(entry)); - assertFalse(map.containsKey(Foo.Y)); - assertNull(map.get(Foo.Y)); - assertFalse(entrySet.contains(entry)); - - // we didn't have that entry, not removed - assertFalse(entrySet.remove(Maps.immutableEntry(Foo.T, 4))); - - // we didn't have that entry, only , must not remove - assertFalse(entrySet.remove(Maps.immutableEntry(Foo.Z, 5))); - } -} diff --git a/android/guava/src/com/google/common/collect/EnumBiMap.java b/android/guava/src/com/google/common/collect/EnumBiMap.java index 84b9e3090a2c..f72b8b96f706 100644 --- a/android/guava/src/com/google/common/collect/EnumBiMap.java +++ b/android/guava/src/com/google/common/collect/EnumBiMap.java @@ -69,9 +69,7 @@ public static , V extends Enum> EnumBiMap create(Map< } private EnumBiMap(Class keyType, Class valueType) { - super( - WellBehavedMap.wrap(new EnumMap(keyType)), - WellBehavedMap.wrap(new EnumMap(valueType))); + super(new EnumMap(keyType), new EnumMap(valueType)); this.keyType = keyType; this.valueType = valueType; } @@ -133,9 +131,7 @@ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFo stream.defaultReadObject(); keyType = (Class) stream.readObject(); valueType = (Class) stream.readObject(); - setDelegates( - WellBehavedMap.wrap(new EnumMap(keyType)), - WellBehavedMap.wrap(new EnumMap(valueType))); + setDelegates(new EnumMap(keyType), new EnumMap(valueType)); 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 b67e126758f2..0a7e52e12756 100644 --- a/android/guava/src/com/google/common/collect/EnumHashBiMap.java +++ b/android/guava/src/com/google/common/collect/EnumHashBiMap.java @@ -71,7 +71,7 @@ public static , V> EnumHashBiMap create(Map keyType) { super( - WellBehavedMap.wrap(new EnumMap(keyType)), + new EnumMap(keyType), Maps.newHashMapWithExpectedSize(keyType.getEnumConstants().length)); this.keyType = keyType; } @@ -117,8 +117,7 @@ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFo stream.defaultReadObject(); keyType = (Class) stream.readObject(); setDelegates( - WellBehavedMap.wrap(new EnumMap(keyType)), - new HashMap(keyType.getEnumConstants().length * 3 / 2)); + new EnumMap(keyType), new HashMap(keyType.getEnumConstants().length * 3 / 2)); Serialization.populateMap(this, stream); } diff --git a/android/guava/src/com/google/common/collect/WellBehavedMap.java b/android/guava/src/com/google/common/collect/WellBehavedMap.java deleted file mode 100644 index 78cb9cc0af10..000000000000 --- a/android/guava/src/com/google/common/collect/WellBehavedMap.java +++ /dev/null @@ -1,99 +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.GwtCompatible; -import com.google.j2objc.annotations.WeakOuter; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import org.checkerframework.checker.nullness.compatqual.MonotonicNonNullDecl; - -/** - * Workaround for EnumMap - * bug. If you want to pass an {@code EnumMap}, with the intention of using its {@code - * entrySet()} method, you should wrap the {@code EnumMap} in this class instead. - * - *

This class is not thread-safe even if the underlying map is. - * - * @author Dimitris Andreou - */ -@GwtCompatible -final class WellBehavedMap extends ForwardingMap { - private final Map delegate; - @MonotonicNonNullDecl private Set> entrySet; - - private WellBehavedMap(Map delegate) { - this.delegate = delegate; - } - - /** - * Wraps the given map into a {@code WellBehavedEntriesMap}, which intercepts its {@code - * entrySet()} method by taking the {@code Set keySet()} and transforming it to {@code - * Set>}. All other invocations are delegated as-is. - */ - static WellBehavedMap wrap(Map delegate) { - return new WellBehavedMap<>(delegate); - } - - @Override - protected Map delegate() { - return delegate; - } - - @Override - public Set> entrySet() { - Set> es = entrySet; - if (es != null) { - return es; - } - return entrySet = new EntrySet(); - } - - @WeakOuter - private final class EntrySet extends Maps.EntrySet { - @Override - Map map() { - return WellBehavedMap.this; - } - - @Override - public Iterator> iterator() { - return new TransformedIterator>(keySet().iterator()) { - @Override - Entry transform(final K key) { - return new AbstractMapEntry() { - @Override - public K getKey() { - return key; - } - - @Override - public V getValue() { - return get(key); - } - - @Override - public V setValue(V value) { - return put(key, value); - } - }; - } - }; - } - } -} diff --git a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableEnumMap.java b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableEnumMap.java index 5e3583ebab70..f49899166265 100644 --- a/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableEnumMap.java +++ b/guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableEnumMap.java @@ -37,6 +37,6 @@ static ImmutableMap asImmutable(Map map) { } private ImmutableEnumMap(Map delegate) { - super(WellBehavedMap.wrap(delegate)); + super(delegate); } } diff --git a/guava-gwt/test/com/google/common/collect/WellBehavedMapTest_gwt.java b/guava-gwt/test/com/google/common/collect/WellBehavedMapTest_gwt.java deleted file mode 100644 index 78204a9bec92..000000000000 --- a/guava-gwt/test/com/google/common/collect/WellBehavedMapTest_gwt.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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; -public class WellBehavedMapTest_gwt extends com.google.gwt.junit.client.GWTTestCase { -@Override public String getModuleName() { - return "com.google.common.collect.testModule"; -} -public void testEntriesAreMutableAndConsistent() throws Exception { - com.google.common.collect.WellBehavedMapTest testCase = new com.google.common.collect.WellBehavedMapTest(); - testCase.testEntriesAreMutableAndConsistent(); -} - -public void testEntrySet_contain() throws Exception { - com.google.common.collect.WellBehavedMapTest testCase = new com.google.common.collect.WellBehavedMapTest(); - testCase.testEntrySet_contain(); -} - -public void testEntrySet_remove() throws Exception { - com.google.common.collect.WellBehavedMapTest testCase = new com.google.common.collect.WellBehavedMapTest(); - testCase.testEntrySet_remove(); -} - -public void testEntry_setValue() throws Exception { - com.google.common.collect.WellBehavedMapTest testCase = new com.google.common.collect.WellBehavedMapTest(); - testCase.testEntry_setValue(); -} -} diff --git a/guava-tests/test/com/google/common/collect/WellBehavedMapTest.java b/guava-tests/test/com/google/common/collect/WellBehavedMapTest.java deleted file mode 100644 index 4875531a2b50..000000000000 --- a/guava-tests/test/com/google/common/collect/WellBehavedMapTest.java +++ /dev/null @@ -1,104 +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.GwtCompatible; -import java.util.EnumMap; -import java.util.Map.Entry; -import java.util.Set; -import junit.framework.TestCase; - -@GwtCompatible -public class WellBehavedMapTest extends TestCase { - enum Foo { - X, - Y, - Z, - T - } - - public void testEntrySet_contain() { - WellBehavedMap map = WellBehavedMap.wrap(new EnumMap(Foo.class)); - map.putAll(ImmutableMap.of(Foo.X, 1, Foo.Y, 2, Foo.Z, 3)); - - // testing with the exact entry - assertTrue(map.entrySet().contains(Maps.immutableEntry(Foo.X, 1))); - assertTrue(map.entrySet().contains(Maps.immutableEntry(Foo.Y, new Integer(2)))); - - // testing an entry with a contained key, but not the same value - assertFalse(map.entrySet().contains(Maps.immutableEntry(Foo.X, 5))); - - // testing a non-existent key - assertFalse(map.entrySet().contains(Maps.immutableEntry(Foo.T, 0))); - } - - public void testEntry_setValue() { - WellBehavedMap map = WellBehavedMap.wrap(new EnumMap(Foo.class)); - map.putAll(ImmutableMap.of(Foo.X, 1, Foo.Y, 2, Foo.Z, 3)); - - for (Entry entry : map.entrySet()) { - entry.setValue(entry.getValue() + 5); - } - - assertEquals(ImmutableMap.of(Foo.X, 6, Foo.Y, 7, Foo.Z, 8), map); - } - - public void testEntriesAreMutableAndConsistent() { - WellBehavedMap map = WellBehavedMap.wrap(new EnumMap(Foo.class)); - map.putAll(ImmutableMap.of(Foo.X, 1)); - - Entry entry1 = Iterables.getOnlyElement(map.entrySet()); - Entry entry2 = Iterables.getOnlyElement(map.entrySet()); - - // the entries are constructed and forgotten, thus different - assertNotSame(entry1, entry2); - - Set> entrySet = map.entrySet(); - - assertTrue(entrySet.contains(entry1)); - assertTrue(entrySet.contains(entry2)); - - // mutating entry - entry1.setValue(2); - - // entry2 is also modified - assertEquals(entry1.getValue(), entry2.getValue()); - - // and both are still contained in the set - assertTrue(entrySet.contains(entry1)); - assertTrue(entrySet.contains(entry2)); - } - - public void testEntrySet_remove() { - WellBehavedMap map = WellBehavedMap.wrap(new EnumMap(Foo.class)); - map.putAll(ImmutableMap.of(Foo.X, 1, Foo.Y, 2, Foo.Z, 3)); - Set> entrySet = map.entrySet(); - - // removing an existing entry, verifying consistency - Entry entry = Maps.immutableEntry(Foo.Y, 2); - assertTrue(entrySet.remove(entry)); - assertFalse(map.containsKey(Foo.Y)); - assertNull(map.get(Foo.Y)); - assertFalse(entrySet.contains(entry)); - - // we didn't have that entry, not removed - assertFalse(entrySet.remove(Maps.immutableEntry(Foo.T, 4))); - - // we didn't have that entry, only , must not remove - assertFalse(entrySet.remove(Maps.immutableEntry(Foo.Z, 5))); - } -} diff --git a/guava/src/com/google/common/collect/EnumBiMap.java b/guava/src/com/google/common/collect/EnumBiMap.java index 84b9e3090a2c..f72b8b96f706 100644 --- a/guava/src/com/google/common/collect/EnumBiMap.java +++ b/guava/src/com/google/common/collect/EnumBiMap.java @@ -69,9 +69,7 @@ public static , V extends Enum> EnumBiMap create(Map< } private EnumBiMap(Class keyType, Class valueType) { - super( - WellBehavedMap.wrap(new EnumMap(keyType)), - WellBehavedMap.wrap(new EnumMap(valueType))); + super(new EnumMap(keyType), new EnumMap(valueType)); this.keyType = keyType; this.valueType = valueType; } @@ -133,9 +131,7 @@ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFo stream.defaultReadObject(); keyType = (Class) stream.readObject(); valueType = (Class) stream.readObject(); - setDelegates( - WellBehavedMap.wrap(new EnumMap(keyType)), - WellBehavedMap.wrap(new EnumMap(valueType))); + setDelegates(new EnumMap(keyType), new EnumMap(valueType)); 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 1a5f0f51b9cb..47094aefdcd7 100644 --- a/guava/src/com/google/common/collect/EnumHashBiMap.java +++ b/guava/src/com/google/common/collect/EnumHashBiMap.java @@ -71,7 +71,7 @@ public static , V> EnumHashBiMap create(Map keyType) { super( - WellBehavedMap.wrap(new EnumMap(keyType)), + new EnumMap(keyType), Maps.newHashMapWithExpectedSize(keyType.getEnumConstants().length)); this.keyType = keyType; } @@ -117,8 +117,7 @@ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFo stream.defaultReadObject(); keyType = (Class) stream.readObject(); setDelegates( - WellBehavedMap.wrap(new EnumMap(keyType)), - new HashMap(keyType.getEnumConstants().length * 3 / 2)); + new EnumMap(keyType), new HashMap(keyType.getEnumConstants().length * 3 / 2)); Serialization.populateMap(this, stream); } diff --git a/guava/src/com/google/common/collect/WellBehavedMap.java b/guava/src/com/google/common/collect/WellBehavedMap.java deleted file mode 100644 index aec7d12844ad..000000000000 --- a/guava/src/com/google/common/collect/WellBehavedMap.java +++ /dev/null @@ -1,99 +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.GwtCompatible; -import com.google.j2objc.annotations.WeakOuter; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import org.checkerframework.checker.nullness.qual.MonotonicNonNull; - -/** - * Workaround for EnumMap - * bug. If you want to pass an {@code EnumMap}, with the intention of using its {@code - * entrySet()} method, you should wrap the {@code EnumMap} in this class instead. - * - *

This class is not thread-safe even if the underlying map is. - * - * @author Dimitris Andreou - */ -@GwtCompatible -final class WellBehavedMap extends ForwardingMap { - private final Map delegate; - @MonotonicNonNull private Set> entrySet; - - private WellBehavedMap(Map delegate) { - this.delegate = delegate; - } - - /** - * Wraps the given map into a {@code WellBehavedEntriesMap}, which intercepts its {@code - * entrySet()} method by taking the {@code Set keySet()} and transforming it to {@code - * Set>}. All other invocations are delegated as-is. - */ - static WellBehavedMap wrap(Map delegate) { - return new WellBehavedMap<>(delegate); - } - - @Override - protected Map delegate() { - return delegate; - } - - @Override - public Set> entrySet() { - Set> es = entrySet; - if (es != null) { - return es; - } - return entrySet = new EntrySet(); - } - - @WeakOuter - private final class EntrySet extends Maps.EntrySet { - @Override - Map map() { - return WellBehavedMap.this; - } - - @Override - public Iterator> iterator() { - return new TransformedIterator>(keySet().iterator()) { - @Override - Entry transform(final K key) { - return new AbstractMapEntry() { - @Override - public K getKey() { - return key; - } - - @Override - public V getValue() { - return get(key); - } - - @Override - public V setValue(V value) { - return put(key, value); - } - }; - } - }; - } - } -} From 1d49ade94c3e7d2c056893a630739c8a6b897f66 Mon Sep 17 00:00:00 2001 From: tomxlee Date: Tue, 12 Feb 2019 09:14:23 -0800 Subject: [PATCH 13/23] Internal GWT change ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=233617662 --- .../common/annotations/Annotations.gwt.xml | 5 +- .../src/com/google/common/base/Base.gwt.xml | 11 ++-- .../src/com/google/common/cache/Cache.gwt.xml | 17 +++--- .../com/google/common/collect/Collect.gwt.xml | 20 +++---- .../com/google/common/escape/Escape.gwt.xml | 11 ++-- .../src/com/google/common/html/Html.gwt.xml | 11 ++-- guava-gwt/src/com/google/common/io/Io.gwt.xml | 17 +++--- .../src/com/google/common/math/Math.gwt.xml | 14 ++--- .../src/com/google/common/net/Net.gwt.xml | 26 ++++----- .../common/primitives/Primitives.gwt.xml | 14 ++--- .../common/util/concurrent/Concurrent.gwt.xml | 14 ++--- .../src/com/google/common/xml/Xml.gwt.xml | 14 ++--- .../publicsuffix/PublicSuffixPatterns.gwt.xml | 47 +++++++--------- .../publicsuffix/PublicSuffixType.gwt.xml | 41 ++++++-------- .../common/collect/testing/Testing.gwt.xml | 23 +++----- .../collect/testing/google/Google.gwt.xml | 53 ++++++++----------- .../common/escape/testing/Testing.gwt.xml | 45 +++++++--------- .../com/google/common/testing/Testing.gwt.xml | 17 +++--- 18 files changed, 155 insertions(+), 245 deletions(-) diff --git a/guava-gwt/src/com/google/common/annotations/Annotations.gwt.xml b/guava-gwt/src/com/google/common/annotations/Annotations.gwt.xml index d8167055b46b..9a44903f8f4a 100644 --- a/guava-gwt/src/com/google/common/annotations/Annotations.gwt.xml +++ b/guava-gwt/src/com/google/common/annotations/Annotations.gwt.xml @@ -1,6 +1,7 @@ - + + @@ -13,7 +14,5 @@ - - diff --git a/guava-gwt/src/com/google/common/base/Base.gwt.xml b/guava-gwt/src/com/google/common/base/Base.gwt.xml index 1fcbe108e2eb..bf126708dde7 100644 --- a/guava-gwt/src/com/google/common/base/Base.gwt.xml +++ b/guava-gwt/src/com/google/common/base/Base.gwt.xml @@ -1,6 +1,9 @@ - + + + + @@ -14,10 +17,4 @@ - - - - - - diff --git a/guava-gwt/src/com/google/common/cache/Cache.gwt.xml b/guava-gwt/src/com/google/common/cache/Cache.gwt.xml index 174b2fac127c..e744149d3734 100644 --- a/guava-gwt/src/com/google/common/cache/Cache.gwt.xml +++ b/guava-gwt/src/com/google/common/cache/Cache.gwt.xml @@ -1,6 +1,11 @@ - + + + + + + @@ -14,14 +19,4 @@ - - - - - - - - - - diff --git a/guava-gwt/src/com/google/common/collect/Collect.gwt.xml b/guava-gwt/src/com/google/common/collect/Collect.gwt.xml index 0439cf6bad01..7f494be3ff13 100644 --- a/guava-gwt/src/com/google/common/collect/Collect.gwt.xml +++ b/guava-gwt/src/com/google/common/collect/Collect.gwt.xml @@ -1,6 +1,12 @@ - + + + + + + + @@ -14,16 +20,4 @@ - - - - - - - - - - - - diff --git a/guava-gwt/src/com/google/common/escape/Escape.gwt.xml b/guava-gwt/src/com/google/common/escape/Escape.gwt.xml index c442ad25fbe5..ae395d6481dd 100644 --- a/guava-gwt/src/com/google/common/escape/Escape.gwt.xml +++ b/guava-gwt/src/com/google/common/escape/Escape.gwt.xml @@ -1,6 +1,9 @@ - + + + + @@ -14,10 +17,4 @@ - - - - - - diff --git a/guava-gwt/src/com/google/common/html/Html.gwt.xml b/guava-gwt/src/com/google/common/html/Html.gwt.xml index d59eeaaceb6a..1ca66cf1eb19 100644 --- a/guava-gwt/src/com/google/common/html/Html.gwt.xml +++ b/guava-gwt/src/com/google/common/html/Html.gwt.xml @@ -1,6 +1,9 @@ - + + + + @@ -13,11 +16,5 @@ - - - - - - diff --git a/guava-gwt/src/com/google/common/io/Io.gwt.xml b/guava-gwt/src/com/google/common/io/Io.gwt.xml index c4287c1e0d2b..94b9f999196c 100644 --- a/guava-gwt/src/com/google/common/io/Io.gwt.xml +++ b/guava-gwt/src/com/google/common/io/Io.gwt.xml @@ -1,6 +1,11 @@ - + + + + + + @@ -14,14 +19,4 @@ - - - - - - - - - - diff --git a/guava-gwt/src/com/google/common/math/Math.gwt.xml b/guava-gwt/src/com/google/common/math/Math.gwt.xml index 686f3c531b44..8b0eb749fa90 100644 --- a/guava-gwt/src/com/google/common/math/Math.gwt.xml +++ b/guava-gwt/src/com/google/common/math/Math.gwt.xml @@ -1,6 +1,10 @@ - + + + + + @@ -14,12 +18,4 @@ - - - - - - - - diff --git a/guava-gwt/src/com/google/common/net/Net.gwt.xml b/guava-gwt/src/com/google/common/net/Net.gwt.xml index f1da2e724b07..7b1c5d956478 100644 --- a/guava-gwt/src/com/google/common/net/Net.gwt.xml +++ b/guava-gwt/src/com/google/common/net/Net.gwt.xml @@ -1,6 +1,14 @@ - + + + + + + + + + @@ -14,20 +22,4 @@ - - - - - - - - - - - - - - - - diff --git a/guava-gwt/src/com/google/common/primitives/Primitives.gwt.xml b/guava-gwt/src/com/google/common/primitives/Primitives.gwt.xml index b52382ddcd70..1a3c2506caf1 100644 --- a/guava-gwt/src/com/google/common/primitives/Primitives.gwt.xml +++ b/guava-gwt/src/com/google/common/primitives/Primitives.gwt.xml @@ -1,6 +1,10 @@ - + + + + + @@ -14,12 +18,4 @@ - - - - - - - - diff --git a/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml b/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml index aa59ee17793c..05416aa584f1 100644 --- a/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml +++ b/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml @@ -1,6 +1,10 @@ - + + + + + @@ -14,12 +18,4 @@ - - - - - - - - diff --git a/guava-gwt/src/com/google/common/xml/Xml.gwt.xml b/guava-gwt/src/com/google/common/xml/Xml.gwt.xml index 8fad4a6acfcc..e8b3e70403ca 100644 --- a/guava-gwt/src/com/google/common/xml/Xml.gwt.xml +++ b/guava-gwt/src/com/google/common/xml/Xml.gwt.xml @@ -1,6 +1,10 @@ - + + + + + @@ -14,12 +18,4 @@ - - - - - - - - diff --git a/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.gwt.xml b/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.gwt.xml index beb498b406bb..1984797a562d 100644 --- a/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.gwt.xml +++ b/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.gwt.xml @@ -1,29 +1,22 @@ - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixType.gwt.xml b/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixType.gwt.xml index d95b658c750d..0838ee8e55ab 100644 --- a/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixType.gwt.xml +++ b/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixType.gwt.xml @@ -1,26 +1,19 @@ - + - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/guava-gwt/test/com/google/common/collect/testing/Testing.gwt.xml b/guava-gwt/test/com/google/common/collect/testing/Testing.gwt.xml index 978168748f16..ec21d39d8754 100644 --- a/guava-gwt/test/com/google/common/collect/testing/Testing.gwt.xml +++ b/guava-gwt/test/com/google/common/collect/testing/Testing.gwt.xml @@ -1,6 +1,13 @@ - + + + + + + + + @@ -14,18 +21,4 @@ - - - - - - - - - - - - - - diff --git a/guava-gwt/test/com/google/common/collect/testing/google/Google.gwt.xml b/guava-gwt/test/com/google/common/collect/testing/google/Google.gwt.xml index 0f7ee40a9818..7eb9a79bdc0b 100644 --- a/guava-gwt/test/com/google/common/collect/testing/google/Google.gwt.xml +++ b/guava-gwt/test/com/google/common/collect/testing/google/Google.gwt.xml @@ -1,32 +1,25 @@ - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/guava-gwt/test/com/google/common/escape/testing/Testing.gwt.xml b/guava-gwt/test/com/google/common/escape/testing/Testing.gwt.xml index c06ebbb4b817..26ad24aae0a9 100644 --- a/guava-gwt/test/com/google/common/escape/testing/Testing.gwt.xml +++ b/guava-gwt/test/com/google/common/escape/testing/Testing.gwt.xml @@ -1,28 +1,21 @@ - + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/guava-gwt/test/com/google/common/testing/Testing.gwt.xml b/guava-gwt/test/com/google/common/testing/Testing.gwt.xml index e65cd647beff..f56cef2b7437 100644 --- a/guava-gwt/test/com/google/common/testing/Testing.gwt.xml +++ b/guava-gwt/test/com/google/common/testing/Testing.gwt.xml @@ -1,6 +1,11 @@ - + + + + + + @@ -14,14 +19,4 @@ - - - - - - - - - - From 46a2123f4b077840b4b466fe6344579ac4b52bad Mon Sep 17 00:00:00 2001 From: zlt Date: Tue, 12 Feb 2019 10:10:55 -0800 Subject: [PATCH 14/23] Automated rollback of commit 1d49ade94c3e7d2c056893a630739c8a6b897f66 *** Original change description *** Internal GWT change *** ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=233628983 --- .../common/annotations/Annotations.gwt.xml | 5 +- .../src/com/google/common/base/Base.gwt.xml | 11 ++-- .../src/com/google/common/cache/Cache.gwt.xml | 17 +++--- .../com/google/common/collect/Collect.gwt.xml | 20 ++++--- .../com/google/common/escape/Escape.gwt.xml | 11 ++-- .../src/com/google/common/html/Html.gwt.xml | 11 ++-- guava-gwt/src/com/google/common/io/Io.gwt.xml | 17 +++--- .../src/com/google/common/math/Math.gwt.xml | 14 +++-- .../src/com/google/common/net/Net.gwt.xml | 26 +++++---- .../common/primitives/Primitives.gwt.xml | 14 +++-- .../common/util/concurrent/Concurrent.gwt.xml | 14 +++-- .../src/com/google/common/xml/Xml.gwt.xml | 14 +++-- .../publicsuffix/PublicSuffixPatterns.gwt.xml | 47 +++++++++------- .../publicsuffix/PublicSuffixType.gwt.xml | 41 ++++++++------ .../common/collect/testing/Testing.gwt.xml | 23 +++++--- .../collect/testing/google/Google.gwt.xml | 53 +++++++++++-------- .../common/escape/testing/Testing.gwt.xml | 45 +++++++++------- .../com/google/common/testing/Testing.gwt.xml | 17 +++--- 18 files changed, 245 insertions(+), 155 deletions(-) diff --git a/guava-gwt/src/com/google/common/annotations/Annotations.gwt.xml b/guava-gwt/src/com/google/common/annotations/Annotations.gwt.xml index 9a44903f8f4a..d8167055b46b 100644 --- a/guava-gwt/src/com/google/common/annotations/Annotations.gwt.xml +++ b/guava-gwt/src/com/google/common/annotations/Annotations.gwt.xml @@ -1,7 +1,6 @@ + - - @@ -14,5 +13,7 @@ + + diff --git a/guava-gwt/src/com/google/common/base/Base.gwt.xml b/guava-gwt/src/com/google/common/base/Base.gwt.xml index bf126708dde7..1fcbe108e2eb 100644 --- a/guava-gwt/src/com/google/common/base/Base.gwt.xml +++ b/guava-gwt/src/com/google/common/base/Base.gwt.xml @@ -1,9 +1,6 @@ + - - - - @@ -17,4 +14,10 @@ + + + + + + diff --git a/guava-gwt/src/com/google/common/cache/Cache.gwt.xml b/guava-gwt/src/com/google/common/cache/Cache.gwt.xml index e744149d3734..174b2fac127c 100644 --- a/guava-gwt/src/com/google/common/cache/Cache.gwt.xml +++ b/guava-gwt/src/com/google/common/cache/Cache.gwt.xml @@ -1,11 +1,6 @@ + - - - - - - @@ -19,4 +14,14 @@ + + + + + + + + + + diff --git a/guava-gwt/src/com/google/common/collect/Collect.gwt.xml b/guava-gwt/src/com/google/common/collect/Collect.gwt.xml index 7f494be3ff13..0439cf6bad01 100644 --- a/guava-gwt/src/com/google/common/collect/Collect.gwt.xml +++ b/guava-gwt/src/com/google/common/collect/Collect.gwt.xml @@ -1,12 +1,6 @@ + - - - - - - - @@ -20,4 +14,16 @@ + + + + + + + + + + + + diff --git a/guava-gwt/src/com/google/common/escape/Escape.gwt.xml b/guava-gwt/src/com/google/common/escape/Escape.gwt.xml index ae395d6481dd..c442ad25fbe5 100644 --- a/guava-gwt/src/com/google/common/escape/Escape.gwt.xml +++ b/guava-gwt/src/com/google/common/escape/Escape.gwt.xml @@ -1,9 +1,6 @@ + - - - - @@ -17,4 +14,10 @@ + + + + + + diff --git a/guava-gwt/src/com/google/common/html/Html.gwt.xml b/guava-gwt/src/com/google/common/html/Html.gwt.xml index 1ca66cf1eb19..d59eeaaceb6a 100644 --- a/guava-gwt/src/com/google/common/html/Html.gwt.xml +++ b/guava-gwt/src/com/google/common/html/Html.gwt.xml @@ -1,9 +1,6 @@ + - - - - @@ -16,5 +13,11 @@ + + + + + + diff --git a/guava-gwt/src/com/google/common/io/Io.gwt.xml b/guava-gwt/src/com/google/common/io/Io.gwt.xml index 94b9f999196c..c4287c1e0d2b 100644 --- a/guava-gwt/src/com/google/common/io/Io.gwt.xml +++ b/guava-gwt/src/com/google/common/io/Io.gwt.xml @@ -1,11 +1,6 @@ + - - - - - - @@ -19,4 +14,14 @@ + + + + + + + + + + diff --git a/guava-gwt/src/com/google/common/math/Math.gwt.xml b/guava-gwt/src/com/google/common/math/Math.gwt.xml index 8b0eb749fa90..686f3c531b44 100644 --- a/guava-gwt/src/com/google/common/math/Math.gwt.xml +++ b/guava-gwt/src/com/google/common/math/Math.gwt.xml @@ -1,10 +1,6 @@ + - - - - - @@ -18,4 +14,12 @@ + + + + + + + + diff --git a/guava-gwt/src/com/google/common/net/Net.gwt.xml b/guava-gwt/src/com/google/common/net/Net.gwt.xml index 7b1c5d956478..f1da2e724b07 100644 --- a/guava-gwt/src/com/google/common/net/Net.gwt.xml +++ b/guava-gwt/src/com/google/common/net/Net.gwt.xml @@ -1,14 +1,6 @@ + - - - - - - - - - @@ -22,4 +14,20 @@ + + + + + + + + + + + + + + + + diff --git a/guava-gwt/src/com/google/common/primitives/Primitives.gwt.xml b/guava-gwt/src/com/google/common/primitives/Primitives.gwt.xml index 1a3c2506caf1..b52382ddcd70 100644 --- a/guava-gwt/src/com/google/common/primitives/Primitives.gwt.xml +++ b/guava-gwt/src/com/google/common/primitives/Primitives.gwt.xml @@ -1,10 +1,6 @@ + - - - - - @@ -18,4 +14,12 @@ + + + + + + + + diff --git a/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml b/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml index 05416aa584f1..aa59ee17793c 100644 --- a/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml +++ b/guava-gwt/src/com/google/common/util/concurrent/Concurrent.gwt.xml @@ -1,10 +1,6 @@ + - - - - - @@ -18,4 +14,12 @@ + + + + + + + + diff --git a/guava-gwt/src/com/google/common/xml/Xml.gwt.xml b/guava-gwt/src/com/google/common/xml/Xml.gwt.xml index e8b3e70403ca..8fad4a6acfcc 100644 --- a/guava-gwt/src/com/google/common/xml/Xml.gwt.xml +++ b/guava-gwt/src/com/google/common/xml/Xml.gwt.xml @@ -1,10 +1,6 @@ + - - - - - @@ -18,4 +14,12 @@ + + + + + + + + diff --git a/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.gwt.xml b/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.gwt.xml index 1984797a562d..beb498b406bb 100644 --- a/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.gwt.xml +++ b/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixPatterns.gwt.xml @@ -1,22 +1,29 @@ - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixType.gwt.xml b/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixType.gwt.xml index 0838ee8e55ab..d95b658c750d 100644 --- a/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixType.gwt.xml +++ b/guava-gwt/src/com/google/thirdparty/publicsuffix/PublicSuffixType.gwt.xml @@ -1,19 +1,26 @@ - + - - - - - - - - - - - - - - - - + + + + + + + + + diff --git a/guava-gwt/test/com/google/common/collect/testing/Testing.gwt.xml b/guava-gwt/test/com/google/common/collect/testing/Testing.gwt.xml index ec21d39d8754..978168748f16 100644 --- a/guava-gwt/test/com/google/common/collect/testing/Testing.gwt.xml +++ b/guava-gwt/test/com/google/common/collect/testing/Testing.gwt.xml @@ -1,13 +1,6 @@ + - - - - - - - - @@ -21,4 +14,18 @@ + + + + + + + + + + + + + + diff --git a/guava-gwt/test/com/google/common/collect/testing/google/Google.gwt.xml b/guava-gwt/test/com/google/common/collect/testing/google/Google.gwt.xml index 7eb9a79bdc0b..0f7ee40a9818 100644 --- a/guava-gwt/test/com/google/common/collect/testing/google/Google.gwt.xml +++ b/guava-gwt/test/com/google/common/collect/testing/google/Google.gwt.xml @@ -1,25 +1,32 @@ - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/guava-gwt/test/com/google/common/escape/testing/Testing.gwt.xml b/guava-gwt/test/com/google/common/escape/testing/Testing.gwt.xml index 26ad24aae0a9..c06ebbb4b817 100644 --- a/guava-gwt/test/com/google/common/escape/testing/Testing.gwt.xml +++ b/guava-gwt/test/com/google/common/escape/testing/Testing.gwt.xml @@ -1,21 +1,28 @@ - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + diff --git a/guava-gwt/test/com/google/common/testing/Testing.gwt.xml b/guava-gwt/test/com/google/common/testing/Testing.gwt.xml index f56cef2b7437..e65cd647beff 100644 --- a/guava-gwt/test/com/google/common/testing/Testing.gwt.xml +++ b/guava-gwt/test/com/google/common/testing/Testing.gwt.xml @@ -1,11 +1,6 @@ + - - - - - - @@ -19,4 +14,14 @@ + + + + + + + + + + From 76c954518752acb36256009840ed004eef412291 Mon Sep 17 00:00:00 2001 From: kstanger Date: Wed, 13 Feb 2019 12:53:55 -0800 Subject: [PATCH 15/23] Use J2ObjC's @RetainedWith annotation instead of @Weak on ImmutableMap.keySet to prevent crashes on iOS. TESTED=Created a map inside a autorelease pool and saved a reference to the keyset. Checked that the keyset functions correctly outside the autorelease pool. Checked that both the keyset and the map are deallocated by the autorelease pool when not holding a reference to the keyset. Did this test with both ImmutableMap.of(<2 entries>) and ImmutableBiMap.of(<2 entries>). RELNOTES=J2ObjC: Fixes crashes from use of `ImmutableMap.keySet()`. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=233811320 --- android/guava/src/com/google/common/collect/ImmutableMap.java | 3 ++- .../src/com/google/common/collect/ImmutableMapKeySet.java | 3 +-- guava/src/com/google/common/collect/ImmutableMap.java | 3 ++- guava/src/com/google/common/collect/ImmutableMapKeySet.java | 3 +-- guava/src/com/google/common/collect/RegularImmutableMap.java | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/android/guava/src/com/google/common/collect/ImmutableMap.java b/android/guava/src/com/google/common/collect/ImmutableMap.java index 5c1ca77ca01f..a25c423385dc 100644 --- a/android/guava/src/com/google/common/collect/ImmutableMap.java +++ b/android/guava/src/com/google/common/collect/ImmutableMap.java @@ -25,6 +25,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.concurrent.LazyInit; +import com.google.j2objc.annotations.RetainedWith; import com.google.j2objc.annotations.WeakOuter; import java.io.Serializable; import java.util.AbstractMap; @@ -537,7 +538,7 @@ public ImmutableSet> entrySet() { abstract ImmutableSet> createEntrySet(); - @LazyInit private transient ImmutableSet keySet; + @LazyInit @RetainedWith private transient ImmutableSet keySet; /** * Returns an immutable set of the keys in this map, in the same order that they appear in {@link diff --git a/android/guava/src/com/google/common/collect/ImmutableMapKeySet.java b/android/guava/src/com/google/common/collect/ImmutableMapKeySet.java index 2b78941e7201..77babc276e5d 100644 --- a/android/guava/src/com/google/common/collect/ImmutableMapKeySet.java +++ b/android/guava/src/com/google/common/collect/ImmutableMapKeySet.java @@ -18,7 +18,6 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; -import com.google.j2objc.annotations.Weak; import java.io.Serializable; import org.checkerframework.checker.nullness.compatqual.NullableDecl; @@ -30,7 +29,7 @@ */ @GwtCompatible(emulated = true) final class ImmutableMapKeySet extends IndexedImmutableSet { - @Weak private final ImmutableMap map; + private final ImmutableMap map; ImmutableMapKeySet(ImmutableMap map) { this.map = map; diff --git a/guava/src/com/google/common/collect/ImmutableMap.java b/guava/src/com/google/common/collect/ImmutableMap.java index 00a789219a16..0f6562b92ec0 100644 --- a/guava/src/com/google/common/collect/ImmutableMap.java +++ b/guava/src/com/google/common/collect/ImmutableMap.java @@ -26,6 +26,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.concurrent.LazyInit; +import com.google.j2objc.annotations.RetainedWith; import com.google.j2objc.annotations.WeakOuter; import java.io.Serializable; import java.util.AbstractMap; @@ -718,7 +719,7 @@ public ImmutableSet> entrySet() { abstract ImmutableSet> createEntrySet(); - @LazyInit private transient ImmutableSet keySet; + @LazyInit @RetainedWith private transient ImmutableSet keySet; /** * Returns an immutable set of the keys in this map, in the same order that they appear in {@link diff --git a/guava/src/com/google/common/collect/ImmutableMapKeySet.java b/guava/src/com/google/common/collect/ImmutableMapKeySet.java index b858023b65c2..56110a87e774 100644 --- a/guava/src/com/google/common/collect/ImmutableMapKeySet.java +++ b/guava/src/com/google/common/collect/ImmutableMapKeySet.java @@ -20,7 +20,6 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; -import com.google.j2objc.annotations.Weak; import java.io.Serializable; import java.util.Spliterator; import java.util.function.Consumer; @@ -34,7 +33,7 @@ */ @GwtCompatible(emulated = true) final class ImmutableMapKeySet extends IndexedImmutableSet { - @Weak private final ImmutableMap map; + private final ImmutableMap map; ImmutableMapKeySet(ImmutableMap map) { this.map = map; diff --git a/guava/src/com/google/common/collect/RegularImmutableMap.java b/guava/src/com/google/common/collect/RegularImmutableMap.java index d8f1fff6bbd4..f78180daee9f 100644 --- a/guava/src/com/google/common/collect/RegularImmutableMap.java +++ b/guava/src/com/google/common/collect/RegularImmutableMap.java @@ -209,7 +209,7 @@ ImmutableSet createKeySet() { @GwtCompatible(emulated = true) private static final class KeySet extends IndexedImmutableSet { - @Weak private final RegularImmutableMap map; + private final RegularImmutableMap map; KeySet(RegularImmutableMap map) { this.map = map; From 63d0b31e62b4d4da33ec61a1d84d026391ffd126 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Thu, 14 Feb 2019 08:48:16 -0800 Subject: [PATCH 16/23] Annotate checkNotNull's input and output as @NonNull. We don't want to go down the road of annotating most things @NonNull, as we eventually want to use tools that assume that that's the default. However, it's pretty weird for checkNotNull() to return a @Nullable value in the minds of some tools, so let's annotate just that method and see how it goes. RELNOTES=Annotated `checkNotNull`'s input and output as `@NonNull`. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=233963788 --- .../com/google/common/base/Preconditions.java | 138 ++++++++++++------ .../com/google/common/base/Preconditions.java | 64 ++++---- 2 files changed, 132 insertions(+), 70 deletions(-) diff --git a/android/guava/src/com/google/common/base/Preconditions.java b/android/guava/src/com/google/common/base/Preconditions.java index ecf9c40f6fbc..ca81c66b71f3 100644 --- a/android/guava/src/com/google/common/base/Preconditions.java +++ b/android/guava/src/com/google/common/base/Preconditions.java @@ -18,6 +18,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; +import org.checkerframework.checker.nullness.compatqual.NonNullDecl; import org.checkerframework.checker.nullness.compatqual.NullableDecl; /** @@ -883,7 +884,8 @@ public static void checkState( * @see Verify#verifyNotNull Verify.verifyNotNull() */ @CanIgnoreReturnValue - public static T checkNotNull(T reference) { + @NonNullDecl + public static T checkNotNull(@NonNullDecl T reference) { if (reference == null) { throw new NullPointerException(); } @@ -901,7 +903,9 @@ public static T checkNotNull(T reference) { * @see Verify#verifyNotNull Verify.verifyNotNull() */ @CanIgnoreReturnValue - public static T checkNotNull(T reference, @NullableDecl Object errorMessage) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T reference, @NullableDecl Object errorMessage) { if (reference == null) { throw new NullPointerException(String.valueOf(errorMessage)); } @@ -924,8 +928,9 @@ public static T checkNotNull(T reference, @NullableDecl Object errorMessage) * @see Verify#verifyNotNull Verify.verifyNotNull() */ @CanIgnoreReturnValue - public static T checkNotNull( - T reference, + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T reference, @NullableDecl String errorMessageTemplate, @NullableDecl Object... errorMessageArgs) { if (reference == null) { @@ -942,7 +947,9 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @NullableDecl String errorMessageTemplate, char p1) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, char p1) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1)); } @@ -957,7 +964,9 @@ public static T checkNotNull(T obj, @NullableDecl String errorMessageTemplat * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @NullableDecl String errorMessageTemplate, int p1) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, int p1) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1)); } @@ -972,7 +981,9 @@ public static T checkNotNull(T obj, @NullableDecl String errorMessageTemplat * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @NullableDecl String errorMessageTemplate, long p1) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, long p1) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1)); } @@ -987,8 +998,9 @@ public static T checkNotNull(T obj, @NullableDecl String errorMessageTemplat * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1)); } @@ -1003,8 +1015,9 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, char p1, char p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, char p1, char p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1019,8 +1032,9 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, char p1, int p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, char p1, int p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1035,8 +1049,9 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, char p1, long p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, char p1, long p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1051,8 +1066,12 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, char p1, @NullableDecl Object p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, + @NullableDecl String errorMessageTemplate, + char p1, + @NullableDecl Object p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1067,8 +1086,9 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, int p1, char p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, int p1, char p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1083,8 +1103,9 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, int p1, int p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, int p1, int p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1099,8 +1120,9 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, int p1, long p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, int p1, long p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1115,8 +1137,12 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, int p1, @NullableDecl Object p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, + @NullableDecl String errorMessageTemplate, + int p1, + @NullableDecl Object p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1131,8 +1157,9 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, long p1, char p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, long p1, char p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1147,8 +1174,9 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, long p1, int p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, long p1, int p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1163,8 +1191,9 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, long p1, long p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, long p1, long p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1179,8 +1208,12 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, long p1, @NullableDecl Object p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, + @NullableDecl String errorMessageTemplate, + long p1, + @NullableDecl Object p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1195,8 +1228,12 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, char p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, + @NullableDecl String errorMessageTemplate, + @NullableDecl Object p1, + char p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1211,8 +1248,12 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, int p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, + @NullableDecl String errorMessageTemplate, + @NullableDecl Object p1, + int p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1227,8 +1268,12 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, long p2) { + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, + @NullableDecl String errorMessageTemplate, + @NullableDecl Object p1, + long p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1243,8 +1288,9 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, @NullableDecl Object p2) { @@ -1262,8 +1308,9 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, @NullableDecl Object p2, @@ -1282,8 +1329,9 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( - T obj, + @NonNullDecl + public static T checkNotNull( + @NonNullDecl T obj, @NullableDecl String errorMessageTemplate, @NullableDecl Object p1, @NullableDecl Object p2, diff --git a/guava/src/com/google/common/base/Preconditions.java b/guava/src/com/google/common/base/Preconditions.java index 681294ed279b..f62b88005a64 100644 --- a/guava/src/com/google/common/base/Preconditions.java +++ b/guava/src/com/google/common/base/Preconditions.java @@ -18,6 +18,7 @@ import com.google.common.annotations.GwtCompatible; import com.google.errorprone.annotations.CanIgnoreReturnValue; +import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; /** @@ -872,7 +873,7 @@ public static void checkState( * @see Verify#verifyNotNull Verify.verifyNotNull() */ @CanIgnoreReturnValue - public static T checkNotNull(T reference) { + public static T checkNotNull(T reference) { if (reference == null) { throw new NullPointerException(); } @@ -890,7 +891,8 @@ public static T checkNotNull(T reference) { * @see Verify#verifyNotNull Verify.verifyNotNull() */ @CanIgnoreReturnValue - public static T checkNotNull(T reference, @Nullable Object errorMessage) { + public static T checkNotNull( + T reference, @Nullable Object errorMessage) { if (reference == null) { throw new NullPointerException(String.valueOf(errorMessage)); } @@ -913,7 +915,7 @@ public static T checkNotNull(T reference, @Nullable Object errorMessage) { * @see Verify#verifyNotNull Verify.verifyNotNull() */ @CanIgnoreReturnValue - public static T checkNotNull( + public static T checkNotNull( T reference, @Nullable String errorMessageTemplate, Object @Nullable ... errorMessageArgs) { if (reference == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, errorMessageArgs)); @@ -929,7 +931,8 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, char p1) { + public static T checkNotNull( + T obj, @Nullable String errorMessageTemplate, char p1) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1)); } @@ -944,7 +947,8 @@ public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, c * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, int p1) { + public static T checkNotNull( + T obj, @Nullable String errorMessageTemplate, int p1) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1)); } @@ -959,7 +963,8 @@ public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, i * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, long p1) { + public static T checkNotNull( + T obj, @Nullable String errorMessageTemplate, long p1) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1)); } @@ -974,7 +979,7 @@ public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, l * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( + public static T checkNotNull( T obj, @Nullable String errorMessageTemplate, @Nullable Object p1) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1)); @@ -990,7 +995,8 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, char p1, char p2) { + public static T checkNotNull( + T obj, @Nullable String errorMessageTemplate, char p1, char p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1005,7 +1011,8 @@ public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, c * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, char p1, int p2) { + public static T checkNotNull( + T obj, @Nullable String errorMessageTemplate, char p1, int p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1020,7 +1027,8 @@ public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, c * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, char p1, long p2) { + public static T checkNotNull( + T obj, @Nullable String errorMessageTemplate, char p1, long p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1035,7 +1043,7 @@ public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, c * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( + public static T checkNotNull( T obj, @Nullable String errorMessageTemplate, char p1, @Nullable Object p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); @@ -1051,7 +1059,8 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, int p1, char p2) { + public static T checkNotNull( + T obj, @Nullable String errorMessageTemplate, int p1, char p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1066,7 +1075,8 @@ public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, i * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, int p1, int p2) { + public static T checkNotNull( + T obj, @Nullable String errorMessageTemplate, int p1, int p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1081,7 +1091,8 @@ public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, i * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, int p1, long p2) { + public static T checkNotNull( + T obj, @Nullable String errorMessageTemplate, int p1, long p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1096,7 +1107,7 @@ public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, i * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( + public static T checkNotNull( T obj, @Nullable String errorMessageTemplate, int p1, @Nullable Object p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); @@ -1112,7 +1123,8 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, long p1, char p2) { + public static T checkNotNull( + T obj, @Nullable String errorMessageTemplate, long p1, char p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1127,7 +1139,8 @@ public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, l * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, long p1, int p2) { + public static T checkNotNull( + T obj, @Nullable String errorMessageTemplate, long p1, int p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1142,7 +1155,8 @@ public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, l * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, long p1, long p2) { + public static T checkNotNull( + T obj, @Nullable String errorMessageTemplate, long p1, long p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); } @@ -1157,7 +1171,7 @@ public static T checkNotNull(T obj, @Nullable String errorMessageTemplate, l * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( + public static T checkNotNull( T obj, @Nullable String errorMessageTemplate, long p1, @Nullable Object p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); @@ -1173,7 +1187,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( + public static T checkNotNull( T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, char p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); @@ -1189,7 +1203,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( + public static T checkNotNull( T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, int p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); @@ -1205,7 +1219,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( + public static T checkNotNull( T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, long p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); @@ -1221,7 +1235,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( + public static T checkNotNull( T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, @Nullable Object p2) { if (obj == null) { throw new NullPointerException(lenientFormat(errorMessageTemplate, p1, p2)); @@ -1237,7 +1251,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( + public static T checkNotNull( T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, @@ -1257,7 +1271,7 @@ public static T checkNotNull( * @since 20.0 (varargs overload since 2.0) */ @CanIgnoreReturnValue - public static T checkNotNull( + public static T checkNotNull( T obj, @Nullable String errorMessageTemplate, @Nullable Object p1, From 998858f9abd06b3774bf72a3b4f2fdaa18a88ceb Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Fri, 15 Feb 2019 14:04:31 -0800 Subject: [PATCH 17/23] Document the JDK 9+ alternative to `Maps#immutableEntry` Fixes #3385 RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=234208826 --- android/guava/src/com/google/common/collect/Maps.java | 3 +++ guava/src/com/google/common/collect/Maps.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/android/guava/src/com/google/common/collect/Maps.java b/android/guava/src/com/google/common/collect/Maps.java index 15fee5266163..73b635726f8c 100644 --- a/android/guava/src/com/google/common/collect/Maps.java +++ b/android/guava/src/com/google/common/collect/Maps.java @@ -1242,6 +1242,9 @@ public static ImmutableMap fromProperties(Properties properties) * *

The returned entry is serializable. * + *

Java 9 users: consider using {@code java.util.Map.entry(key, value)} if the key and + * value are non-null and the entry does not need to be serializable. + * * @param key the key to be associated with the returned entry * @param value the value to be associated with the returned entry */ diff --git a/guava/src/com/google/common/collect/Maps.java b/guava/src/com/google/common/collect/Maps.java index 62dc34f2d8c9..38fd601a1039 100644 --- a/guava/src/com/google/common/collect/Maps.java +++ b/guava/src/com/google/common/collect/Maps.java @@ -1368,6 +1368,9 @@ public static ImmutableMap fromProperties(Properties properties) * *

The returned entry is serializable. * + *

Java 9 users: consider using {@code java.util.Map.entry(key, value)} if the key and + * value are non-null and the entry does not need to be serializable. + * * @param key the key to be associated with the returned entry * @param value the value to be associated with the returned entry */ From 7eafede7552490351956e8038bb07596b227e3ef Mon Sep 17 00:00:00 2001 From: kevinb Date: Fri, 15 Feb 2019 14:22:08 -0800 Subject: [PATCH 18/23] Modernize book reference. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=234212413 --- .../com/google/common/primitives/ImmutableDoubleArray.java | 4 ++-- .../src/com/google/common/primitives/ImmutableIntArray.java | 4 ++-- .../src/com/google/common/primitives/ImmutableLongArray.java | 4 ++-- .../com/google/common/primitives/ImmutableDoubleArray.java | 4 ++-- guava/src/com/google/common/primitives/ImmutableIntArray.java | 4 ++-- .../src/com/google/common/primitives/ImmutableLongArray.java | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/android/guava/src/com/google/common/primitives/ImmutableDoubleArray.java b/android/guava/src/com/google/common/primitives/ImmutableDoubleArray.java index b3d1dbbf0281..adfd9b0a9892 100644 --- a/android/guava/src/com/google/common/primitives/ImmutableDoubleArray.java +++ b/android/guava/src/com/google/common/primitives/ImmutableDoubleArray.java @@ -36,8 +36,8 @@ *

Advantages compared to {@code double[]}: * *

    - *
  • All the many well-known advantages of immutability (read Effective Java, second - * edition, Item 15). + *
  • All the many well-known advantages of immutability (read Effective Java, third + * edition, Item 17). *
  • Has the value-based (not identity-based) {@link #equals}, {@link #hashCode}, and {@link * #toString} behavior you expect. *
  • Offers useful operations beyond just {@code get} and {@code length}, so you don't have to diff --git a/android/guava/src/com/google/common/primitives/ImmutableIntArray.java b/android/guava/src/com/google/common/primitives/ImmutableIntArray.java index 9dfaf71221e3..f500314bd5a5 100644 --- a/android/guava/src/com/google/common/primitives/ImmutableIntArray.java +++ b/android/guava/src/com/google/common/primitives/ImmutableIntArray.java @@ -36,8 +36,8 @@ *

    Advantages compared to {@code int[]}: * *

      - *
    • All the many well-known advantages of immutability (read Effective Java, second - * edition, Item 15). + *
    • All the many well-known advantages of immutability (read Effective Java, third + * edition, Item 17). *
    • Has the value-based (not identity-based) {@link #equals}, {@link #hashCode}, and {@link * #toString} behavior you expect *
    • Offers useful operations beyond just {@code get} and {@code length}, so you don't have to diff --git a/android/guava/src/com/google/common/primitives/ImmutableLongArray.java b/android/guava/src/com/google/common/primitives/ImmutableLongArray.java index e43a7cb2cc26..1f3e07918d20 100644 --- a/android/guava/src/com/google/common/primitives/ImmutableLongArray.java +++ b/android/guava/src/com/google/common/primitives/ImmutableLongArray.java @@ -36,8 +36,8 @@ *

      Advantages compared to {@code long[]}: * *

        - *
      • All the many well-known advantages of immutability (read Effective Java, second - * edition, Item 15). + *
      • All the many well-known advantages of immutability (read Effective Java, third + * edition, Item 17). *
      • Has the value-based (not identity-based) {@link #equals}, {@link #hashCode}, and {@link * #toString} behavior you expect. *
      • Offers useful operations beyond just {@code get} and {@code length}, so you don't have to diff --git a/guava/src/com/google/common/primitives/ImmutableDoubleArray.java b/guava/src/com/google/common/primitives/ImmutableDoubleArray.java index 46e0b0ad7cfb..f2111cb1b4b6 100644 --- a/guava/src/com/google/common/primitives/ImmutableDoubleArray.java +++ b/guava/src/com/google/common/primitives/ImmutableDoubleArray.java @@ -41,8 +41,8 @@ *

        Advantages compared to {@code double[]}: * *

          - *
        • All the many well-known advantages of immutability (read Effective Java, second - * edition, Item 15). + *
        • All the many well-known advantages of immutability (read Effective Java, third + * edition, Item 17). *
        • Has the value-based (not identity-based) {@link #equals}, {@link #hashCode}, and {@link * #toString} behavior you expect. *
        • Offers useful operations beyond just {@code get} and {@code length}, so you don't have to diff --git a/guava/src/com/google/common/primitives/ImmutableIntArray.java b/guava/src/com/google/common/primitives/ImmutableIntArray.java index 8eb35d360a51..6d1e8a06bcd4 100644 --- a/guava/src/com/google/common/primitives/ImmutableIntArray.java +++ b/guava/src/com/google/common/primitives/ImmutableIntArray.java @@ -41,8 +41,8 @@ *

          Advantages compared to {@code int[]}: * *

            - *
          • All the many well-known advantages of immutability (read Effective Java, second - * edition, Item 15). + *
          • All the many well-known advantages of immutability (read Effective Java, third + * edition, Item 17). *
          • Has the value-based (not identity-based) {@link #equals}, {@link #hashCode}, and {@link * #toString} behavior you expect. *
          • Offers useful operations beyond just {@code get} and {@code length}, so you don't have to diff --git a/guava/src/com/google/common/primitives/ImmutableLongArray.java b/guava/src/com/google/common/primitives/ImmutableLongArray.java index a4161b282890..280afd0eafc8 100644 --- a/guava/src/com/google/common/primitives/ImmutableLongArray.java +++ b/guava/src/com/google/common/primitives/ImmutableLongArray.java @@ -41,8 +41,8 @@ *

            Advantages compared to {@code long[]}: * *

              - *
            • All the many well-known advantages of immutability (read Effective Java, second - * edition, Item 15). + *
            • All the many well-known advantages of immutability (read Effective Java, third + * edition, Item 17). *
            • Has the value-based (not identity-based) {@link #equals}, {@link #hashCode}, and {@link * #toString} behavior you expect. *
            • Offers useful operations beyond just {@code get} and {@code length}, so you don't have to From 81f191e80265001b3dc8b4544cd0bb277a05ba7b Mon Sep 17 00:00:00 2001 From: lukes Date: Fri, 15 Feb 2019 19:18:44 -0800 Subject: [PATCH 19/23] Create constants for the SourceMap header None of the tests like this header name, so each required some workarounds. RELNOTES=Add the SourceMap header to HttpHeaders ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=234254287 --- .../test/com/google/common/net/HttpHeadersTest.java | 2 ++ android/guava/src/com/google/common/net/HttpHeaders.java | 8 ++++++++ .../test/com/google/common/net/HttpHeadersTest.java | 2 ++ guava/src/com/google/common/net/HttpHeaders.java | 8 ++++++++ 4 files changed, 20 insertions(+) diff --git a/android/guava-tests/test/com/google/common/net/HttpHeadersTest.java b/android/guava-tests/test/com/google/common/net/HttpHeadersTest.java index a9d6253ba6d2..65e6fdb85a4f 100644 --- a/android/guava-tests/test/com/google/common/net/HttpHeadersTest.java +++ b/android/guava-tests/test/com/google/common/net/HttpHeadersTest.java @@ -39,6 +39,8 @@ public void testConstantNameMatchesString() throws Exception { ImmutableBiMap.of( "ETAG", "ETag", + "SOURCE_MAP", + "SourceMap", "X_WEBKIT_CSP", "X-WebKit-CSP", "X_WEBKIT_CSP_REPORT_ONLY", diff --git a/android/guava/src/com/google/common/net/HttpHeaders.java b/android/guava/src/com/google/common/net/HttpHeaders.java index ae18f189f458..db60e9f0eb43 100644 --- a/android/guava/src/com/google/common/net/HttpHeaders.java +++ b/android/guava/src/com/google/common/net/HttpHeaders.java @@ -296,6 +296,14 @@ private ReferrerPolicyValues() {} public static final String SET_COOKIE = "Set-Cookie"; /** The HTTP {@code Set-Cookie2} header field name. */ public static final String SET_COOKIE2 = "Set-Cookie2"; + + /** + * The HTTP {@code SourceMap} header field name. + * + * @since NEXT + */ + @Beta public static final String SOURCE_MAP = "SourceMap"; + /** * The HTTP {@code * Strict-Transport-Security} header field name. diff --git a/guava-tests/test/com/google/common/net/HttpHeadersTest.java b/guava-tests/test/com/google/common/net/HttpHeadersTest.java index a9d6253ba6d2..65e6fdb85a4f 100644 --- a/guava-tests/test/com/google/common/net/HttpHeadersTest.java +++ b/guava-tests/test/com/google/common/net/HttpHeadersTest.java @@ -39,6 +39,8 @@ public void testConstantNameMatchesString() throws Exception { ImmutableBiMap.of( "ETAG", "ETag", + "SOURCE_MAP", + "SourceMap", "X_WEBKIT_CSP", "X-WebKit-CSP", "X_WEBKIT_CSP_REPORT_ONLY", diff --git a/guava/src/com/google/common/net/HttpHeaders.java b/guava/src/com/google/common/net/HttpHeaders.java index ae18f189f458..db60e9f0eb43 100644 --- a/guava/src/com/google/common/net/HttpHeaders.java +++ b/guava/src/com/google/common/net/HttpHeaders.java @@ -296,6 +296,14 @@ private ReferrerPolicyValues() {} public static final String SET_COOKIE = "Set-Cookie"; /** The HTTP {@code Set-Cookie2} header field name. */ public static final String SET_COOKIE2 = "Set-Cookie2"; + + /** + * The HTTP {@code SourceMap} header field name. + * + * @since NEXT + */ + @Beta public static final String SOURCE_MAP = "SourceMap"; + /** * The HTTP {@code * Strict-Transport-Security} header field name. From db6ada7b4f9db07b8de6ec549ca7e2ab6079b354 Mon Sep 17 00:00:00 2001 From: magdaz Date: Wed, 20 Feb 2019 07:48:03 -0800 Subject: [PATCH 20/23] Internal GWT change RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=234795462 --- guava-gwt/test/com/google/common/base/testModule.gwt.xml | 1 + guava-gwt/test/com/google/common/cache/testModule.gwt.xml | 1 + guava-gwt/test/com/google/common/collect/testModule.gwt.xml | 1 + .../test/com/google/common/collect/testing/testModule.gwt.xml | 1 + guava-gwt/test/com/google/common/escape/testModule.gwt.xml | 1 + guava-gwt/test/com/google/common/html/testModule.gwt.xml | 1 + guava-gwt/test/com/google/common/io/testModule.gwt.xml | 1 + guava-gwt/test/com/google/common/math/testModule.gwt.xml | 1 + guava-gwt/test/com/google/common/net/testModule.gwt.xml | 1 + guava-gwt/test/com/google/common/primitives/testModule.gwt.xml | 1 + guava-gwt/test/com/google/common/testing/testModule.gwt.xml | 1 + .../test/com/google/common/util/concurrent/testModule.gwt.xml | 1 + guava-gwt/test/com/google/common/xml/testModule.gwt.xml | 1 + 13 files changed, 13 insertions(+) diff --git a/guava-gwt/test/com/google/common/base/testModule.gwt.xml b/guava-gwt/test/com/google/common/base/testModule.gwt.xml index afefbb8a25ef..326194d79908 100644 --- a/guava-gwt/test/com/google/common/base/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/base/testModule.gwt.xml @@ -1,5 +1,6 @@ + diff --git a/guava-gwt/test/com/google/common/cache/testModule.gwt.xml b/guava-gwt/test/com/google/common/cache/testModule.gwt.xml index 874969f00903..4a2a4e718590 100644 --- a/guava-gwt/test/com/google/common/cache/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/cache/testModule.gwt.xml @@ -1,5 +1,6 @@ + diff --git a/guava-gwt/test/com/google/common/collect/testModule.gwt.xml b/guava-gwt/test/com/google/common/collect/testModule.gwt.xml index d35baa3a76a5..068334b8e485 100644 --- a/guava-gwt/test/com/google/common/collect/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/collect/testModule.gwt.xml @@ -1,5 +1,6 @@ + diff --git a/guava-gwt/test/com/google/common/collect/testing/testModule.gwt.xml b/guava-gwt/test/com/google/common/collect/testing/testModule.gwt.xml index eb6fb2de7c0b..d70f1d862632 100644 --- a/guava-gwt/test/com/google/common/collect/testing/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/collect/testing/testModule.gwt.xml @@ -1,5 +1,6 @@ + diff --git a/guava-gwt/test/com/google/common/escape/testModule.gwt.xml b/guava-gwt/test/com/google/common/escape/testModule.gwt.xml index 9eb2464ddc0e..ae6d05bc9e64 100644 --- a/guava-gwt/test/com/google/common/escape/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/escape/testModule.gwt.xml @@ -1,5 +1,6 @@ + diff --git a/guava-gwt/test/com/google/common/html/testModule.gwt.xml b/guava-gwt/test/com/google/common/html/testModule.gwt.xml index 0346ed12be98..3e03493ae7ee 100644 --- a/guava-gwt/test/com/google/common/html/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/html/testModule.gwt.xml @@ -1,5 +1,6 @@ + diff --git a/guava-gwt/test/com/google/common/io/testModule.gwt.xml b/guava-gwt/test/com/google/common/io/testModule.gwt.xml index 134e66da7ef1..9e58e0592c2d 100644 --- a/guava-gwt/test/com/google/common/io/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/io/testModule.gwt.xml @@ -1,5 +1,6 @@ + diff --git a/guava-gwt/test/com/google/common/math/testModule.gwt.xml b/guava-gwt/test/com/google/common/math/testModule.gwt.xml index 91255e3213fc..76a0c99d5405 100644 --- a/guava-gwt/test/com/google/common/math/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/math/testModule.gwt.xml @@ -1,5 +1,6 @@ + diff --git a/guava-gwt/test/com/google/common/net/testModule.gwt.xml b/guava-gwt/test/com/google/common/net/testModule.gwt.xml index 94bc88ce5290..a42cced5d6f4 100644 --- a/guava-gwt/test/com/google/common/net/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/net/testModule.gwt.xml @@ -1,5 +1,6 @@ + diff --git a/guava-gwt/test/com/google/common/primitives/testModule.gwt.xml b/guava-gwt/test/com/google/common/primitives/testModule.gwt.xml index 4bec90064e3f..935d3bd7aa2f 100644 --- a/guava-gwt/test/com/google/common/primitives/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/primitives/testModule.gwt.xml @@ -1,5 +1,6 @@ + diff --git a/guava-gwt/test/com/google/common/testing/testModule.gwt.xml b/guava-gwt/test/com/google/common/testing/testModule.gwt.xml index cab3664b4bbb..c3cea41306bd 100644 --- a/guava-gwt/test/com/google/common/testing/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/testing/testModule.gwt.xml @@ -1,5 +1,6 @@ + diff --git a/guava-gwt/test/com/google/common/util/concurrent/testModule.gwt.xml b/guava-gwt/test/com/google/common/util/concurrent/testModule.gwt.xml index 3b8a217269a8..34c94d6bef6a 100644 --- a/guava-gwt/test/com/google/common/util/concurrent/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/util/concurrent/testModule.gwt.xml @@ -1,5 +1,6 @@ + diff --git a/guava-gwt/test/com/google/common/xml/testModule.gwt.xml b/guava-gwt/test/com/google/common/xml/testModule.gwt.xml index b66ff38d9608..d377994ca45e 100644 --- a/guava-gwt/test/com/google/common/xml/testModule.gwt.xml +++ b/guava-gwt/test/com/google/common/xml/testModule.gwt.xml @@ -1,5 +1,6 @@ + From 05ac56322f6c3a4b0109aab2b46671716f109cb5 Mon Sep 17 00:00:00 2001 From: kstanger Date: Fri, 22 Feb 2019 09:39:55 -0800 Subject: [PATCH 21/23] Use J2ObjC's @RetainedWith annotation instead of @Weak on ImmutableMap.values to prevent crashes on iOS. TESTED=Created a map inside an autorelease pool and saved a reference to the values collection. Checked that the values collection functions correctly outside the autorelease pool. Checked that both the values collection and the map are deallocated by the autorelease pool when not holding a strong reference to the values collection. Did this test with ImmutableMap.of(<2 entries>) and ImmutableMap.copyOf(). RELNOTES=J2ObjC: Fixes crashes from use of `ImmutableMap.values()`. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=235206171 --- android/guava/src/com/google/common/collect/ImmutableMap.java | 2 +- .../src/com/google/common/collect/ImmutableMapValues.java | 3 +-- guava/src/com/google/common/collect/ImmutableMap.java | 2 +- guava/src/com/google/common/collect/ImmutableMapValues.java | 3 +-- guava/src/com/google/common/collect/RegularImmutableMap.java | 3 +-- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/android/guava/src/com/google/common/collect/ImmutableMap.java b/android/guava/src/com/google/common/collect/ImmutableMap.java index a25c423385dc..1f25b7942680 100644 --- a/android/guava/src/com/google/common/collect/ImmutableMap.java +++ b/android/guava/src/com/google/common/collect/ImmutableMap.java @@ -572,7 +572,7 @@ public K next() { }; } - @LazyInit private transient ImmutableCollection values; + @LazyInit @RetainedWith private transient ImmutableCollection values; /** * Returns an immutable collection of the values in this map, in the same order that they appear diff --git a/android/guava/src/com/google/common/collect/ImmutableMapValues.java b/android/guava/src/com/google/common/collect/ImmutableMapValues.java index 2c94e5c4b210..4a0e3960d581 100644 --- a/android/guava/src/com/google/common/collect/ImmutableMapValues.java +++ b/android/guava/src/com/google/common/collect/ImmutableMapValues.java @@ -18,7 +18,6 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; -import com.google.j2objc.annotations.Weak; import java.io.Serializable; import java.util.Map.Entry; import org.checkerframework.checker.nullness.compatqual.NullableDecl; @@ -31,7 +30,7 @@ */ @GwtCompatible(emulated = true) final class ImmutableMapValues extends ImmutableCollection { - @Weak private final ImmutableMap map; + private final ImmutableMap map; ImmutableMapValues(ImmutableMap map) { this.map = map; diff --git a/guava/src/com/google/common/collect/ImmutableMap.java b/guava/src/com/google/common/collect/ImmutableMap.java index 0f6562b92ec0..0a376ed9cfeb 100644 --- a/guava/src/com/google/common/collect/ImmutableMap.java +++ b/guava/src/com/google/common/collect/ImmutableMap.java @@ -757,7 +757,7 @@ Spliterator keySpliterator() { return CollectSpliterators.map(entrySet().spliterator(), Entry::getKey); } - @LazyInit private transient ImmutableCollection values; + @LazyInit @RetainedWith private transient ImmutableCollection values; /** * Returns an immutable collection of the values in this map, in the same order that they appear diff --git a/guava/src/com/google/common/collect/ImmutableMapValues.java b/guava/src/com/google/common/collect/ImmutableMapValues.java index 6ccf98f6a26b..2c13c472c6bd 100644 --- a/guava/src/com/google/common/collect/ImmutableMapValues.java +++ b/guava/src/com/google/common/collect/ImmutableMapValues.java @@ -20,7 +20,6 @@ import com.google.common.annotations.GwtCompatible; import com.google.common.annotations.GwtIncompatible; -import com.google.j2objc.annotations.Weak; import java.io.Serializable; import java.util.Map.Entry; import java.util.Spliterator; @@ -35,7 +34,7 @@ */ @GwtCompatible(emulated = true) final class ImmutableMapValues extends ImmutableCollection { - @Weak private final ImmutableMap map; + private final ImmutableMap map; ImmutableMapValues(ImmutableMap map) { this.map = map; diff --git a/guava/src/com/google/common/collect/RegularImmutableMap.java b/guava/src/com/google/common/collect/RegularImmutableMap.java index f78180daee9f..3c74dc2d967c 100644 --- a/guava/src/com/google/common/collect/RegularImmutableMap.java +++ b/guava/src/com/google/common/collect/RegularImmutableMap.java @@ -26,7 +26,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMapEntry.NonTerminalImmutableMapEntry; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import com.google.j2objc.annotations.Weak; import java.io.Serializable; import java.util.function.BiConsumer; import org.checkerframework.checker.nullness.qual.Nullable; @@ -264,7 +263,7 @@ ImmutableCollection createValues() { @GwtCompatible(emulated = true) private static final class Values extends ImmutableList { - @Weak final RegularImmutableMap map; + final RegularImmutableMap map; Values(RegularImmutableMap map) { this.map = map; From d8bdef58d54712286d86a9146778d25614fd3c9a Mon Sep 17 00:00:00 2001 From: cpovirk Date: Fri, 22 Feb 2019 12:48:58 -0800 Subject: [PATCH 22/23] Fix Javadoc breakage under JDK11 canary. https://bugs.openjdk.java.net/browse/JDK-8212233 https://bugs.openjdk.java.net/browse/JDK-8193030 RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=235241314 --- android/guava/pom.xml | 4 ++-- android/pom.xml | 1 + guava/pom.xml | 4 ++-- pom.xml | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/android/guava/pom.xml b/android/guava/pom.xml index 822a88e4c357..7a17eec030a8 100644 --- a/android/guava/pom.xml +++ b/android/guava/pom.xml @@ -127,8 +127,8 @@ ${project.build.sourceDirectory}:${project.build.directory}/jdk-sources - com.google.common - com.google.common.base.internal + + com.google.common.base.internal,com.google.thirdparty.publicsuffix,com.oracle,com.sun,java,javax,jdk,org,sun diff --git a/android/pom.xml b/android/pom.xml index ae67dd8b5337..6a17e9c6b7d6 100644 --- a/android/pom.xml +++ b/android/pom.xml @@ -167,6 +167,7 @@ -Xdoclint:-html true + 8 diff --git a/guava/pom.xml b/guava/pom.xml index b7562b0b8c8d..077b9587f9b2 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -127,8 +127,8 @@ ${project.build.sourceDirectory}:${project.build.directory}/jdk-sources - com.google.common - com.google.common.base.internal + + com.google.common.base.internal,com.google.thirdparty.publicsuffix,com.oracle,com.sun,java,javax,jdk,org,sun diff --git a/pom.xml b/pom.xml index 7578dbd72086..f18cced6edc8 100644 --- a/pom.xml +++ b/pom.xml @@ -163,6 +163,7 @@ -Xdoclint:-html true + 8 From be02df5ad4a530d5cb206a7042de8c2f5dbbff32 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Mon, 25 Feb 2019 07:17:22 -0800 Subject: [PATCH 23/23] Remove GWT emulations that are no longer needed as of GWT 2.8.2. RELNOTES=Removed GWT emulations that are no longer needed as of GWT 2.8.2. This means that GWT projects that use this version of Guava must use GWT 2.8.2 or higher. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=235524613 --- guava-gwt/src-super/java/lang/Lang.gwt.xml | 1 - .../super/java/lang/InterruptedException.java | 32 -- guava-gwt/src-super/java/util/Util.gwt.xml | 6 - .../super/java/util/concurrent/Callable.java | 26 -- .../concurrent/CancellationException.java | 27 -- .../util/concurrent/ConcurrentHashMap.java | 149 -------- .../java/util/concurrent/ConcurrentMap.java | 35 -- .../super/java/util/concurrent/Delayed.java | 16 - .../util/concurrent/ExecutionException.java | 38 -- .../super/java/util/concurrent/Executor.java | 22 -- .../super/java/util/concurrent/Executors.java | 47 --- .../super/java/util/concurrent/Future.java | 42 --- .../RejectedExecutionException.java | 34 -- .../java/util/concurrent/RunnableFuture.java | 20 -- .../java/util/concurrent/ScheduledFuture.java | 18 - .../super/java/util/concurrent/TimeUnit.java | 336 ------------------ .../util/concurrent/TimeoutException.java | 26 -- .../util/concurrent/atomic/AtomicBoolean.java | 73 ---- .../util/concurrent/atomic/AtomicInteger.java | 109 ------ .../util/concurrent/atomic/AtomicLong.java | 109 ------ 20 files changed, 1166 deletions(-) delete mode 100644 guava-gwt/src-super/java/lang/Lang.gwt.xml delete mode 100644 guava-gwt/src-super/java/lang/super/java/lang/InterruptedException.java delete mode 100644 guava-gwt/src-super/java/util/Util.gwt.xml delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/Callable.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/CancellationException.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/ConcurrentHashMap.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/ConcurrentMap.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/Delayed.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/ExecutionException.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/Executor.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/Executors.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/Future.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/RejectedExecutionException.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/RunnableFuture.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/ScheduledFuture.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/TimeUnit.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/TimeoutException.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicBoolean.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicInteger.java delete mode 100644 guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicLong.java diff --git a/guava-gwt/src-super/java/lang/Lang.gwt.xml b/guava-gwt/src-super/java/lang/Lang.gwt.xml deleted file mode 100644 index bd7134fce2b1..000000000000 --- a/guava-gwt/src-super/java/lang/Lang.gwt.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/guava-gwt/src-super/java/lang/super/java/lang/InterruptedException.java b/guava-gwt/src-super/java/lang/super/java/lang/InterruptedException.java deleted file mode 100644 index 9bfcecec7642..000000000000 --- a/guava-gwt/src-super/java/lang/super/java/lang/InterruptedException.java +++ /dev/null @@ -1,32 +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 java.lang; - -/** - * Minimal emulation of {@link java.lang.InterruptedException}, that should only be used in method - * signatures. New GWT code should not reference this class at all. It is here only to ease the - * GWTification of common code. - * - * @author Tom O'Neill - */ -public class InterruptedException extends Exception { - public InterruptedException() {} - - public InterruptedException(String message) { - super(message); - } -} diff --git a/guava-gwt/src-super/java/util/Util.gwt.xml b/guava-gwt/src-super/java/util/Util.gwt.xml deleted file mode 100644 index 1968a1e606ce..000000000000 --- a/guava-gwt/src-super/java/util/Util.gwt.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/Callable.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/Callable.java deleted file mode 100644 index 607d3f76d599..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/Callable.java +++ /dev/null @@ -1,26 +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 java.util.concurrent; - -/** - * Emulation of Callable. - * - * @author Charles Fry - */ -public interface Callable { - V call() throws Exception; -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/CancellationException.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/CancellationException.java deleted file mode 100644 index 29bd332e6bad..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/CancellationException.java +++ /dev/null @@ -1,27 +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 java.util.concurrent; - -/** Emulation of CancellationException. */ -public class CancellationException extends IllegalStateException { - - public CancellationException() {} - - public CancellationException(String message) { - super(message); - } -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/ConcurrentHashMap.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/ConcurrentHashMap.java deleted file mode 100644 index 7367f04c00a1..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/ConcurrentHashMap.java +++ /dev/null @@ -1,149 +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 java.util.concurrent; - -import java.util.AbstractMap; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * Minimal emulation of {@link java.util.concurrent.ConcurrentHashMap}. Note that the javascript - * interpreter is - * single-threaded, it is essentially a {@link java.util.HashMap}, implementing the new methods - * introduced by {@link ConcurrentMap}. - * - * @author Hayward Chan - */ -public class ConcurrentHashMap extends AbstractMap implements ConcurrentMap { - - private final Map backingMap; - - public ConcurrentHashMap() { - this.backingMap = new HashMap(); - } - - public ConcurrentHashMap(int initialCapacity) { - this.backingMap = new HashMap(initialCapacity); - } - - public ConcurrentHashMap(int initialCapacity, float loadFactor) { - this.backingMap = new HashMap(initialCapacity, loadFactor); - } - - public ConcurrentHashMap(Map t) { - this.backingMap = new HashMap(t); - } - - public V putIfAbsent(K key, V value) { - if (!containsKey(key)) { - return put(key, value); - } else { - return get(key); - } - } - - public boolean remove(Object key, Object value) { - if (containsKey(key) && get(key).equals(value)) { - remove(key); - return true; - } else { - return false; - } - } - - public boolean replace(K key, V oldValue, V newValue) { - if (oldValue == null || newValue == null) { - throw new NullPointerException(); - } else if (containsKey(key) && get(key).equals(oldValue)) { - put(key, newValue); - return true; - } else { - return false; - } - } - - public V replace(K key, V value) { - if (value == null) { - throw new NullPointerException(); - } else if (containsKey(key)) { - return put(key, value); - } else { - return null; - } - } - - @Override - public boolean containsKey(Object key) { - if (key == null) { - throw new NullPointerException(); - } - return backingMap.containsKey(key); - } - - @Override - public V get(Object key) { - if (key == null) { - throw new NullPointerException(); - } - return backingMap.get(key); - } - - @Override - public V put(K key, V value) { - if (key == null || value == null) { - throw new NullPointerException(); - } - return backingMap.put(key, value); - } - - @Override - public boolean containsValue(Object value) { - if (value == null) { - throw new NullPointerException(); - } - return backingMap.containsValue(value); - } - - @Override - public V remove(Object key) { - if (key == null) { - throw new NullPointerException(); - } - return backingMap.remove(key); - } - - @Override - public Set> entrySet() { - return backingMap.entrySet(); - } - - public boolean contains(Object value) { - return containsValue(value); - } - - public Enumeration elements() { - return Collections.enumeration(values()); - } - - public Enumeration keys() { - return Collections.enumeration(keySet()); - } -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/ConcurrentMap.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/ConcurrentMap.java deleted file mode 100644 index 49c05ce22d2b..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/ConcurrentMap.java +++ /dev/null @@ -1,35 +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 java.util.concurrent; - -import java.util.Map; - -/** - * Minimal GWT emulation of a map providing atomic operations. - * - * @author Jesse Wilson - */ -public interface ConcurrentMap extends Map { - - V putIfAbsent(K key, V value); - - boolean remove(Object key, Object value); - - V replace(K key, V value); - - boolean replace(K key, V oldValue, V newValue); -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/Delayed.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/Delayed.java deleted file mode 100644 index 4fa57f20280e..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/Delayed.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * This file is a modified version of - * http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/Delayed.java?revision=1.11 - * which contained the following notice: - * - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -package java.util.concurrent; - -/** Emulation of Delayed. */ -public interface Delayed extends Comparable { - long getDelay(TimeUnit unit); -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/ExecutionException.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/ExecutionException.java deleted file mode 100644 index 7484438d8943..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/ExecutionException.java +++ /dev/null @@ -1,38 +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 java.util.concurrent; - -/** - * Emulation of ExecutionException. - * - * @author Charles Fry - */ -public class ExecutionException extends Exception { - protected ExecutionException() {} - - protected ExecutionException(String message) { - super(message); - } - - public ExecutionException(String message, Throwable cause) { - super(message, cause); - } - - public ExecutionException(Throwable cause) { - super(cause); - } -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/Executor.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/Executor.java deleted file mode 100644 index d74ec076af7a..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/Executor.java +++ /dev/null @@ -1,22 +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 java.util.concurrent; - -/** Emulation of Executor. */ -public interface Executor { - void execute(Runnable command); -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/Executors.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/Executors.java deleted file mode 100644 index afb41e2ea69c..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/Executors.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is a modified version of - * http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/Executors.java?revision=1.90 - * which contained the following notice: - * - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -package java.util.concurrent; - -/** Emulation of executors. */ -public class Executors { - - public static Callable callable(Runnable task, T result) { - if (task == null) { - throw new NullPointerException(); - } - return new RunnableAdapter(task, result); - } - - public static Callable callable(Runnable task) { - if (task == null) { - throw new NullPointerException(); - } - return new RunnableAdapter(task, null); - } - - static final class RunnableAdapter implements Callable { - - final Runnable task; - final T result; - - RunnableAdapter(Runnable task, T result) { - this.task = task; - this.result = result; - } - - public T call() { - task.run(); - return result; - } - } - - private Executors() {} -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/Future.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/Future.java deleted file mode 100644 index f52ac619b33e..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/Future.java +++ /dev/null @@ -1,42 +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 java.util.concurrent; - -/** - * Emulation of Future. Since GWT environment is single threaded, attempting to block on the future - * by calling {@link #get()} or {@link #get(long, TimeUnit)} when the future is not yet done is - * considered illegal because it would lead to a deadlock. Future implementations must throw {@link - * IllegalStateException} to avoid a deadlock. - * - * @param value type returned by the future. - */ -public interface Future { - boolean cancel(boolean mayInterruptIfRunning); - - boolean isCancelled(); - - boolean isDone(); - - // Even though the 'get' methods below are blocking, they are the only built-in APIs to get the - // result of the {@code Future}, hence they are not removed. The implementation must throw {@link - // IllegalStateException} if the {@code Future} is not done yet (see the class javadoc). - - V get() throws InterruptedException, ExecutionException; - - V get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException; -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/RejectedExecutionException.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/RejectedExecutionException.java deleted file mode 100644 index 56a19f7f25f1..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/RejectedExecutionException.java +++ /dev/null @@ -1,34 +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 java.util.concurrent; - -/** GWT emulation of RejectedExecutionException. */ -public class RejectedExecutionException extends RuntimeException { - public RejectedExecutionException() {} - - public RejectedExecutionException(String message) { - super(message); - } - - public RejectedExecutionException(String message, Throwable cause) { - super(message, cause); - } - - public RejectedExecutionException(Throwable cause) { - super(cause); - } -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/RunnableFuture.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/RunnableFuture.java deleted file mode 100644 index c33168a491af..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/RunnableFuture.java +++ /dev/null @@ -1,20 +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 java.util.concurrent; - -/** Emulation of RunnableFuture. */ -public interface RunnableFuture extends Runnable, Future {} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/ScheduledFuture.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/ScheduledFuture.java deleted file mode 100644 index 5aab49fef93e..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/ScheduledFuture.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This file is a modified version of - * http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/ScheduledFuture.java?revision=1.6 - * which contained the following notice: - * - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -package java.util.concurrent; - -/** - * Emulation of ScheduleFuture. - * - * @param value type returned by the future. - */ -public interface ScheduledFuture extends Delayed, Future {} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeUnit.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeUnit.java deleted file mode 100644 index d2966f1a4576..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeUnit.java +++ /dev/null @@ -1,336 +0,0 @@ -/* - * This file is a modified version of - * http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/TimeUnit.java - * which contained the following notice: - * - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -package java.util.concurrent; - -/** - * GWT emulation of TimeUnit, created by removing unsupported operations from Doug Lea's public - * domain version. - */ -public enum TimeUnit { - NANOSECONDS { - public long toNanos(long d) { - return d; - } - - public long toMicros(long d) { - return d / C1_C0; - } - - public long toMillis(long d) { - return d / C2_C0; - } - - public long toSeconds(long d) { - return d / C3_C0; - } - - public long toMinutes(long d) { - return d / C4_C0; - } - - public long toHours(long d) { - return d / C5_C0; - } - - public long toDays(long d) { - return d / C6_C0; - } - - public long convert(long d, TimeUnit u) { - return u.toNanos(d); - } - }, - MICROSECONDS { - public long toNanos(long d) { - return x(d, C1_C0, MAX_C1_C0); - } - - public long toMicros(long d) { - return d; - } - - public long toMillis(long d) { - return d / C2_C1; - } - - public long toSeconds(long d) { - return d / C3_C1; - } - - public long toMinutes(long d) { - return d / C4_C1; - } - - public long toHours(long d) { - return d / C5_C1; - } - - public long toDays(long d) { - return d / C6_C1; - } - - public long convert(long d, TimeUnit u) { - return u.toMicros(d); - } - }, - MILLISECONDS { - public long toNanos(long d) { - return x(d, C2_C0, MAX_C2_C0); - } - - public long toMicros(long d) { - return x(d, C2_C1, MAX_C2_C1); - } - - public long toMillis(long d) { - return d; - } - - public long toSeconds(long d) { - return d / C3_C2; - } - - public long toMinutes(long d) { - return d / C4_C2; - } - - public long toHours(long d) { - return d / C5_C2; - } - - public long toDays(long d) { - return d / C6_C2; - } - - public long convert(long d, TimeUnit u) { - return u.toMillis(d); - } - }, - SECONDS { - public long toNanos(long d) { - return x(d, C3_C0, MAX_C3_C0); - } - - public long toMicros(long d) { - return x(d, C3_C1, MAX_C3_C1); - } - - public long toMillis(long d) { - return x(d, C3_C2, MAX_C3_C2); - } - - public long toSeconds(long d) { - return d; - } - - public long toMinutes(long d) { - return d / C4_C3; - } - - public long toHours(long d) { - return d / C5_C3; - } - - public long toDays(long d) { - return d / C6_C3; - } - - public long convert(long d, TimeUnit u) { - return u.toSeconds(d); - } - }, - MINUTES { - public long toNanos(long d) { - return x(d, C4_C0, MAX_C4_C0); - } - - public long toMicros(long d) { - return x(d, C4_C1, MAX_C4_C1); - } - - public long toMillis(long d) { - return x(d, C4_C2, MAX_C4_C2); - } - - public long toSeconds(long d) { - return x(d, C4_C3, MAX_C4_C3); - } - - public long toMinutes(long d) { - return d; - } - - public long toHours(long d) { - return d / C5_C4; - } - - public long toDays(long d) { - return d / C6_C4; - } - - public long convert(long d, TimeUnit u) { - return u.toMinutes(d); - } - }, - HOURS { - public long toNanos(long d) { - return x(d, C5_C0, MAX_C5_C0); - } - - public long toMicros(long d) { - return x(d, C5_C1, MAX_C5_C1); - } - - public long toMillis(long d) { - return x(d, C5_C2, MAX_C5_C2); - } - - public long toSeconds(long d) { - return x(d, C5_C3, MAX_C5_C3); - } - - public long toMinutes(long d) { - return x(d, C5_C4, MAX_C5_C4); - } - - public long toHours(long d) { - return d; - } - - public long toDays(long d) { - return d / C6_C5; - } - - public long convert(long d, TimeUnit u) { - return u.toHours(d); - } - }, - DAYS { - public long toNanos(long d) { - return x(d, C6_C0, MAX_C6_C0); - } - - public long toMicros(long d) { - return x(d, C6_C1, MAX_C6_C1); - } - - public long toMillis(long d) { - return x(d, C6_C2, MAX_C6_C2); - } - - public long toSeconds(long d) { - return x(d, C6_C3, MAX_C6_C3); - } - - public long toMinutes(long d) { - return x(d, C6_C4, MAX_C6_C4); - } - - public long toHours(long d) { - return x(d, C6_C5, MAX_C6_C5); - } - - public long toDays(long d) { - return d; - } - - public long convert(long d, TimeUnit u) { - return u.toDays(d); - } - }; - - // Handy constants for conversion methods - private static final long C0 = 1L; - private static final long C1 = C0 * 1000L; - private static final long C2 = C1 * 1000L; - private static final long C3 = C2 * 1000L; - private static final long C4 = C3 * 60L; - private static final long C5 = C4 * 60L; - private static final long C6 = C5 * 24L; - - private static final long MAX = Long.MAX_VALUE; - - private static final long C6_C0 = C6 / C0; - private static final long C6_C1 = C6 / C1; - private static final long C6_C2 = C6 / C2; - private static final long C6_C3 = C6 / C3; - private static final long C6_C4 = C6 / C4; - private static final long C6_C5 = C6 / C5; - - private static final long C5_C0 = C5 / C0; - private static final long C5_C1 = C5 / C1; - private static final long C5_C2 = C5 / C2; - private static final long C5_C3 = C5 / C3; - private static final long C5_C4 = C5 / C4; - - private static final long C4_C0 = C4 / C0; - private static final long C4_C1 = C4 / C1; - private static final long C4_C2 = C4 / C2; - private static final long C4_C3 = C4 / C3; - - private static final long C3_C0 = C3 / C0; - private static final long C3_C1 = C3 / C1; - private static final long C3_C2 = C3 / C2; - - private static final long C2_C0 = C2 / C0; - private static final long C2_C1 = C2 / C1; - - private static final long C1_C0 = C1 / C0; - - private static final long MAX_C6_C0 = MAX / C6_C0; - private static final long MAX_C6_C1 = MAX / C6_C1; - private static final long MAX_C6_C2 = MAX / C6_C2; - private static final long MAX_C6_C3 = MAX / C6_C3; - private static final long MAX_C6_C4 = MAX / C6_C4; - private static final long MAX_C6_C5 = MAX / C6_C5; - - private static final long MAX_C5_C0 = MAX / C5_C0; - private static final long MAX_C5_C1 = MAX / C5_C1; - private static final long MAX_C5_C2 = MAX / C5_C2; - private static final long MAX_C5_C3 = MAX / C5_C3; - private static final long MAX_C5_C4 = MAX / C5_C4; - - private static final long MAX_C4_C0 = MAX / C4_C0; - private static final long MAX_C4_C1 = MAX / C4_C1; - private static final long MAX_C4_C2 = MAX / C4_C2; - private static final long MAX_C4_C3 = MAX / C4_C3; - - private static final long MAX_C3_C0 = MAX / C3_C0; - private static final long MAX_C3_C1 = MAX / C3_C1; - private static final long MAX_C3_C2 = MAX / C3_C2; - - private static final long MAX_C2_C0 = MAX / C2_C0; - private static final long MAX_C2_C1 = MAX / C2_C1; - - private static final long MAX_C1_C0 = MAX / C1_C0; - - static long x(long d, long m, long over) { - if (d > over) return Long.MAX_VALUE; - if (d < -over) return Long.MIN_VALUE; - return d * m; - } - - public abstract long convert(long sourceDuration, TimeUnit sourceUnit); - - public abstract long toNanos(long duration); - - public abstract long toMicros(long duration); - - public abstract long toMillis(long duration); - - public abstract long toSeconds(long duration); - - public abstract long toMinutes(long duration); - - public abstract long toHours(long duration); - - public abstract long toDays(long duration); -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeoutException.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeoutException.java deleted file mode 100644 index 4cbf128fafc4..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/TimeoutException.java +++ /dev/null @@ -1,26 +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 java.util.concurrent; - -/** Emulation of TimeoutException. */ -public class TimeoutException extends Exception { - public TimeoutException() {} - - public TimeoutException(String message) { - super(message); - } -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicBoolean.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicBoolean.java deleted file mode 100644 index 4be46d42bdd9..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicBoolean.java +++ /dev/null @@ -1,73 +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. - */ -/** - * Atomically sets the value to the given updated value if the current value {@code ==} the expected - * value. - * - *

              May fail spuriously and does not provide ordering - * guarantees, so is only rarely an appropriate alternative to {@code compareAndSet}. - * - * @param expect the expected value - * @param update the new value - * @return true if successful. - */ -package java.util.concurrent.atomic; - -/** GWT emulation of AtomicBoolean. */ -public class AtomicBoolean implements java.io.Serializable { - private boolean value; - - public AtomicBoolean(boolean initialValue) { - value = initialValue; - } - - public AtomicBoolean() {} - - public final boolean get() { - return value; - } - - public final boolean compareAndSet(boolean expect, boolean update) { - if (get() == expect) { - set(update); - return true; - } - - return false; - } - - public boolean weakCompareAndSet(boolean expect, boolean update) { - return compareAndSet(expect, update); - } - - public final void set(boolean newValue) { - value = newValue; - } - - public final void lazySet(boolean newValue) { - set(newValue); - } - - public final boolean getAndSet(boolean newValue) { - boolean current = get(); - set(newValue); - return current; - } - - public String toString() { - return Boolean.toString(get()); - } -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicInteger.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicInteger.java deleted file mode 100644 index 0a680f3be550..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicInteger.java +++ /dev/null @@ -1,109 +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 java.util.concurrent.atomic; - -/** - * GWT emulated version of {@link AtomicInteger}. It's a thin wrapper around the primitive {@code - * int}. - * - * @author Hayward Chan - */ -public class AtomicInteger extends Number implements java.io.Serializable { - - private int value; - - public AtomicInteger(int initialValue) { - value = initialValue; - } - - public AtomicInteger() {} - - public final int get() { - return value; - } - - public final void set(int newValue) { - value = newValue; - } - - public final void lazySet(int newValue) { - set(newValue); - } - - public final int getAndSet(int newValue) { - int current = value; - value = newValue; - return current; - } - - public final boolean compareAndSet(int expect, int update) { - if (value == expect) { - value = update; - return true; - } else { - return false; - } - } - - public final int getAndIncrement() { - return value++; - } - - public final int getAndDecrement() { - return value--; - } - - public final int getAndAdd(int delta) { - int current = value; - value += delta; - return current; - } - - public final int incrementAndGet() { - return ++value; - } - - public final int decrementAndGet() { - return --value; - } - - public final int addAndGet(int delta) { - value += delta; - return value; - } - - @Override - public String toString() { - return Integer.toString(value); - } - - public int intValue() { - return value; - } - - public long longValue() { - return (long) value; - } - - public float floatValue() { - return (float) value; - } - - public double doubleValue() { - return (double) value; - } -} diff --git a/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicLong.java b/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicLong.java deleted file mode 100644 index af782b3a6bbe..000000000000 --- a/guava-gwt/src-super/java/util/super/java/util/concurrent/atomic/AtomicLong.java +++ /dev/null @@ -1,109 +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 java.util.concurrent.atomic; - -/** - * GWT emulated version of {@link AtomicLong}. It's a thin wrapper around the primitive {@code - * long}. - * - * @author Jige Yu - */ -public class AtomicLong extends Number implements java.io.Serializable { - - private long value; - - public AtomicLong(long initialValue) { - this.value = initialValue; - } - - public AtomicLong() {} - - public final long get() { - return value; - } - - public final void set(long newValue) { - value = newValue; - } - - public final void lazySet(long newValue) { - set(newValue); - } - - public final long getAndSet(long newValue) { - long current = value; - value = newValue; - return current; - } - - public final boolean compareAndSet(long expect, long update) { - if (value == expect) { - value = update; - return true; - } else { - return false; - } - } - - public final long getAndIncrement() { - return value++; - } - - public final long getAndDecrement() { - return value--; - } - - public final long getAndAdd(long delta) { - long current = value; - value += delta; - return current; - } - - public final long incrementAndGet() { - return ++value; - } - - public final long decrementAndGet() { - return --value; - } - - public final long addAndGet(long delta) { - value += delta; - return value; - } - - @Override - public String toString() { - return Long.toString(value); - } - - public int intValue() { - return (int) value; - } - - public long longValue() { - return value; - } - - public float floatValue() { - return (float) value; - } - - public double doubleValue() { - return (double) value; - } -}

    - *
  1. {@code canonicalize(t)} always produces the equal result for equivalent types. For example - * both {@code Enum} and {@code Enum>} canonicalize to - * {@code Enum}. - *
  2. {@code canonicalize(t)} produces a "literal" supertype of t. - * For example: {@code Enum>} canonicalizes to {@code Enum}, which is - * a supertype (if we disregard the upper bound is implicitly an Enum too). - *
  3. If {@code canonicalize(A) == canonicalize(B)}, then {@code Foo.isSubtypeOf(Foo)} and - * vice versa. i.e. {@code A.is(B)} and {@code B.is(A)}. - *
  4. {@code canonicalize(canonicalize(A)) == canonicalize(A)}. + *
  5. {@code canonicalize(t)} always produces the equal result for equivalent types. For + * example both {@code Enum} and {@code Enum>} canonicalize to {@code + * Enum}. + *
  6. {@code canonicalize(t)} produces a "literal" supertype of t. For example: {@code Enum>} canonicalizes to {@code Enum}, which is a supertype (if we disregard + * the upper bound is implicitly an Enum too). + *
  7. If {@code canonicalize(A) == canonicalize(B)}, then {@code Foo.isSubtypeOf(Foo)} + * and vice versa. i.e. {@code A.is(B)} and {@code B.is(A)}. + *
  8. {@code canonicalize(canonicalize(A)) == canonicalize(A)}. *

    - *
  1. {@code canonicalize(t)} always produces the equal result for equivalent types. For example - * both {@code Enum} and {@code Enum>} canonicalize to - * {@code Enum}. - *
  2. {@code canonicalize(t)} produces a "literal" supertype of t. - * For example: {@code Enum>} canonicalizes to {@code Enum}, which is - * a supertype (if we disregard the upper bound is implicitly an Enum too). - *
  3. If {@code canonicalize(A) == canonicalize(B)}, then {@code Foo.isSubtypeOf(Foo)} and - * vice versa. i.e. {@code A.is(B)} and {@code B.is(A)}. - *
  4. {@code canonicalize(canonicalize(A)) == canonicalize(A)}. + *
  5. {@code canonicalize(t)} always produces the equal result for equivalent types. For + * example both {@code Enum} and {@code Enum>} canonicalize to {@code + * Enum}. + *
  6. {@code canonicalize(t)} produces a "literal" supertype of t. For example: {@code Enum>} canonicalizes to {@code Enum}, which is a supertype (if we disregard + * the upper bound is implicitly an Enum too). + *
  7. If {@code canonicalize(A) == canonicalize(B)}, then {@code Foo.isSubtypeOf(Foo)} + * and vice versa. i.e. {@code A.is(B)} and {@code B.is(A)}. + *
  8. {@code canonicalize(canonicalize(A)) == canonicalize(A)}. *