Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
<!-- or, for Android: -->
<version>31.1-android</version>
</dependency>
Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
-
base
: Deprecated theThrowables
methodslazyStackTrace
andlazyStackTraceIsLazy
. They are no longer useful on any current platform. (6ebd7d8648) -
collect
: Added a new methodImmutableMap.Builder.buildKeepingLast()
, which keeps the last value for any given key rather than throwing an exception when a key appears more than once. (68500b2c09) -
collect
: As a side-effect of thebuildKeepingLast()
change, the idiomImmutableList.copyOf(Maps.transformValues(map, function))
may produce different results iffunction
has side-effects. (This is not recommended.) (68500b2c09) -
hash
: AddedHashing.fingerprint2011()
. (13f703c25f) -
io
: ChangedByteStreams.nullOutputStream()
to follow the contract ofOutputStream.write
by throwing an exception if the range of bytes is out of bounds. (1cd85d01c9) -
net
: Added@CheckReturnValue
to the package (with a few exceptions). (a0e2577de6) -
net
: AddedHttpHeaders
constant forAccess-Control-Allow-Private-Network
. (6dabbdf9c9) -
util.concurrent
: Added accumulate/update methods forAtomicDouble
andAtomicDoubleArray
. (2d875d327a)
@Beta
APIs promoted from -
base
:Throwables
methodsgetCausalChain
andgetCauseAs
(dd462afa6b) -
collect
:Streams
methodsmapWithIndex
andfindLast
(8079a29463) -
collect
: the remaining methods inComparators
:min
,max
,lexicographical
,emptiesFirst
,emptiesLast
,isInOrder
,isInStrictOrder
(a3e411c3a4) -
escape
: various APIs (468c68a6ac) -
io
: various APIs inFiles
(828d9ee74e) -
net
: various APIs (261ac7afbf) -
reflect
: various APIs (9f6a384020) -
testlib
: various APIs (93a8f02f56) -
util.concurrent
:AsyncCallable
,ListenableScheduledFuture
, andClosingFuture
(8b4ad17dcf) -
util.concurrent
:ExecutionSequencer
,MoreExecutors.newSequentialExecutor
, andMonitor
(189d668a95) -
util.concurrent
:Futures
methods:submit
,submitAsync
,scheduleAsync
,nonCancellationPropagating
,inCompletionOrder
(e015172847) -
util.concurrent
:Uninterruptibles
:awaitTerminationUninterruptibly
and theDuration
overloads in the class (825de9a2d0) -
util.concurrent
: theFluentFuture
type, its factory methods, andaddCallback
(9c7e13b5d4)
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
<!-- or, for Android: -->
<version>31.0.1-android</version>
</dependency>
Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
- Fixed GWT compilation failure introduced in release 31.0. (0ad6d6d9e1)
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0-jre</version>
<!-- or, for Android: -->
<version>31.0-android</version>
</dependency>
Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
patch release 31.0.1): guava-gwt breaks GWT compilation
Known issue (fixed inOther Guava artifacts aren't affected, only users of GWT. (If you are using GWT, you would know it.)
Sorry for missing this during release: It was a known issue, and we had a partial workaround in place, but I forgot to include the problem in the list of release blockers.
To pick up the fix, upgrade to 31.0.1.
Main changes
-
Changed
guava-android
to generate Java 8 bytecode. We still restrict ourselves to using APIs available on Ice Cream Sandwich. So, as long as you have enabled Java 8 language features for your Android build, this change should have no effect on Android projects. This change does drop support for Java 7 JREs, as announced last year. - Annotated Guava much more thoroughly for nullness. For details, see the bottom of the release notes.
-
base
: ChangedFunctions.forSupplier
andPredicates.instanceOf
to accept an additional type argument to specify the input type for the returnedFunction
/Predicate
. The flexibility we're adding should typically not be necessary if users follow the PECS principle, but it can be useful in some cases, particularly around nullness analysis. Note that this change may require updates to callers' source code (to specify an additional type argument). Still, it maintains binary compatibility. (75110e936d) -
collect
: AddedImmutableMap.ofEntries
, likeMap.ofEntries
but forImmutableMap
. (cd3b4197fb) -
collect
: Added overloads ofImmutableMap.of
,ImmutableBiMap.of
, andImmutableSortedMap.of
for up to 10 entries. (d5c30e3f19) -
collect
: RenamedImmutableMap.Builder.build()
tobuildOrThrow()
. The existingbuild()
method will continue to exist but may be deprecated, and the new name should be used in new code. (4bbe12c4e0) -
collect
: Removed@Beta
fromInterner
andInterners
. (cf31f3a31d) -
collect
: Added@InlineMe
toStreams.stream(Optional)
and friends. (a176cd60f1) -
graph
: MadeEndpointPair.adjacentNode
require anN
instead of accept anyObject
. (b0be21d46c) -
hash
: Removed@Beta
fromHashFunction
. (e1cc195cfb) -
hash
: Deprecated buggymurmur3_32
, and introducedmurmur3_32_fixed
. (a36f08fe31) -
io
: ChangedCharStreams.asWriter(appendable).write(string[, ...])
to reject a nullstring
. (50e7dddf5c) -
io
: Fixed a bug inFileBackedOutputStream
cleanup: If writing to the temp file fails, we now delete it before propagating the exception. (6e054cea7b) -
net
: ChangedHostAndPort.fromString
to reject port numbers spelled with non-ASCII digits. (53fd1d7612) -
net
: AddedHttpHeaders
constants forX-Device-Ip
,X-Device-Referer
,X-Device-Accept-Language
,X-Device-Requested-With
,Sec-CH-Prefers-Color-Scheme
,Sec-CH-UA-Bitness
, andKeep-Alive
. (da375be86a, b23b277422, 281edd4b6e, 9c88f9ad6d) -
primitives
: Fixed a rounding bug inUnsignedLong.doubleValue()
. (e61cf2e8d7) -
reflect
: Changed the type hierarchy ofInvokable
:Invokable
no longer inherits fromAccessibleObject
orGenericDeclaration
, though it continues to define instance methods with the same signatures as the formerly inherited ones. This is technically a breaking API change to this@Beta
API. We think it very unlikely that anyone is affected in practice. (12af215974) -
testlib
: EnhancedNullPointerTester
to allow a parameter of type<T extends @Nullable Object>
to benull
. (e85672246f) -
testlib
: Fixed bug affecting derived tests of custom collection test suites: ThesetUp
andtearDown
methods are now copied to derived test suites. (c7d9fef73b) -
util.concurrent
: AddedServiceManager.startupDurations()
. (c95ba5a298) -
util.concurrent
: Removed the GWT-only overloads ofFutures.catching
andcatchingAsync
that let callers omit theExecutor
. This matches a change made years ago to the non-GWT API. If this breaks your GWT client code compilation, you can fix it by passing an additional parameter,MoreExecutors.directExecutor()
(0ff2f78959)
Nullness annotations
Previously, we annotated all parameters that could be null
, and we did not annotate elsewhere reliably. Now:
- We consistently annotate return types for nullness.
- We annotate "components" of types, like the element type of an array or list and the bound of a type parameter. (To take advantage, Kotlin users can set
-Xtype-enhancement-improvements-strict-mode
.)- However, we don't yet annotate any type parameters as non-nullable.
- In our annotations (including on parameters), we distinguish between
@Nullable T
("always nullable, regardless of the type argument used forT
") andT
("nullable only if the type argument is"). - We have temporarily increased our usage of jsr305, which we will ultimately phase out. (To take advantage, Kotlin users can set
-Xjsr305=strict
.)- We use
@CheckForNull
instead of a type-annotation@Nullable
wherever possible. This makes the nullness information available to more Kotlin users. - We've introduced a custom jsr305 annotation that informs Kotlin that unannotated return types are non-null (just like our usage of
@ParametersAreNonnullByDefault
already did for parameter types).
- We use
(Known issue: We are missing annotations on the TypeToInstanceMap
classes. We'll fix this in a future release.)
By providing additional nullness information, this release may result in more errors or warnings from any nullness analyzers you might use. If so, you may need to fix or suppress them as usual. For advice, see the documentation for the analyzer you're using, such as that for the Checker Framework or for Kotlin.
We will be using more annotations to provide more nullness information in the future.
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1.1-jre</version>
<!-- or, for Android: -->
<version>30.1.1-android</version>
</dependency>
Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
- Increased the aggressiveness of Guava 30.1's warning log message for running
guava-android
under a Java 7 VM. (Android VMs are unaffected.) If the warning itself causes you trouble, you can eliminate it by silencing the logger forcom.google.common.base.Preconditions
(which is used only for this warning). This warning prepares for removing support for Java 7 in 2021. Please report any problems. We have tried to make the warning as safe as possible, but anytime a common library logs, especially as aggressively as we do in this new release, there is the potential forNullPointerException
or even deadlock. (To be clear, Guava will not log under Java 8 or Android, but it will under Java 7.) (00c25e9b11) -
cache
: Fixed compatibility betweenasMap().compute(...)
and a load. (42bf4f4eb7) -
cache
: Added@CheckReturnValue
to some APIs. (a5ef129ffc) -
collect
: Added@DoNotCall
to the mutator methods on immutable types (6ae9532d11) -
hash
: Removed@Beta
fromHashCode
. (2c9f161e10) -
io
: Removed@Beta
fromCountingOutputStream
. (d394bac847)
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.1-jre</version>
<!-- or, for Android: -->
<version>30.1-android</version>
</dependency>
Javadoc
JDiff
Changelog
- If you use guava-android in an Android project (as opposed to from a Java VM), you will need to enable desugaring of Java 8 language features if you have not already done so. (And if you are releasing an Android library, then anyone who uses that library will also have to enable desugaring.) We expect for nearly all Android projects to have already enabled desugaring. But if this causes problems for you, please let us know on issue #5358. The purpose of this change is to detect potential problems for users now so that we can plan to use Java 8 language features in our implementation later this year.
- Introduced a warning log message when running
guava-android
under a Java 7 VM. (Android VMs are unaffected, aside from the need to use desugaring, described in the previous bullet.) This warning is not guaranteed to be logged when running under Java 7, so please don't rely on it as your only warning about future problems. If the warning itself causes you trouble, you can eliminate it by silencing the logger forcom.google.common.base.MoreObjects$ToStringHelper
(which is used only for this warning). This warning prepares for removing support for Java 7 in 2021. Please report any problems. We have tried to make the warning as safe as possible, but anytime a common library logs, there is the potential forNullPointerException
or even deadlock. (To be clear, Guava will not log under Java 8 or Android, but it may log under Java 7.) (dc52e6e385)- Note that we subsequently made this warning more aggressive in Guava 30.1.1, including changing the logger it uses to
com.google.common.base.Preconditions
.
- Note that we subsequently made this warning more aggressive in Guava 30.1.1, including changing the logger it uses to
-
base
: DeprecatedStandardSystemProperty.JAVA_EXT_DIRS
. We do not plan to remove the API, but note that, under recent versions of Java, that property always has a value ofnull
. (38abf07772) -
net
: AddedHttpHeaders
constants forOrigin-Isolation
andX-Request-ID
. (a48fb4f724, 8319d201cd) -
reflect
: AddedClassInfo.isTopLevel()
. (410627262b) -
util.concurrent
: AddedClosingFuture.submitAsync(AsyncClosingCallable)
. (c5e2d8d5cb)
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.0-jre</version>
<!-- or, for Android: -->
<version>30.0-android</version>
</dependency>
Javadoc
JDiff
Changelog
-
Guava types can no longer be sent over GWT-RPC. Even the earlier, temporary way to reenable support (
guava.gwt.emergency_reenable_rpc
) no longer has an effect. (0cb89dd110) -
cache
: Fixed memory leak inLocalCache
under j2objc. (5e519d91d0) -
collect
: Added two-elementmin
andmax
methods toComparators
. (958186c071) -
collect
: Removed@Beta
fromMultimaps.toMultimap
. (b6b4dc49b1) -
collect
: Made the set returned byImmutableMap<K, V>.keySet()
serializable as long asK
is serializable, even ifV
is not (and similarly forvalues()
). (f5a69c33fc) -
collect
: Fixed bug inpowerSet.equals(otherPowerSet)
would erroneously returnfalse
if the two power sets' underlying sets were equal but had a different iteration order. (215b1f0dd7) -
collect
: Eliminated j2objc retain-cycle inSingletonImmutableBiMap
. (0ad38b88bd) -
eventbus
: Prevented@Subscribe
from being applied to a method that takes a primitive, as that will never be called. (554546c971) -
graph
: MadeTraverser.breadthFirst()
lazier, and optimizedTraverser
more generally. (32f2d770f7, b5210ca95c) -
graph
: Added@DoNotMock
toTraverser
. (6410f18c06) -
io
: DeprecatedFiles.createTempDir()
. (fec0dbc463) (CVE-2020-8908; continuing discussion in https://github.com/google/guava/issues/4011) -
[update: My mistake: This was rolled back, so it did not make 30.0.]io
: UpgradedByteStreams.copy(InputStream, OutputStream)
to use the fasterFileChannel
if possible. (a1e9a0bd12) -
math
: AddedroundToDouble
toBigDecimalMath
,BigIntegerMath
, andLongMath
. (bee4f3c7ed, 2b5c096ddf, 633abf2c62) -
net
: AddedMediaType
constants for several font/ types. (571cf66bac) -
net
: AddedHttpHeaders
constants forCross-Origin-Embedder-Policy(-Report-Only)?
. (c3bf73187a) -
testing
: MadeEqualsTester
test that non-String
objects are not equal to theirString
representations. (c9570eae69) -
util.concurrent
: AddedClosingFuture
. (52e048ed6c) -
util.concurrent
: Removed the deprecated 1-argServiceManager.addListener(Listener)
. Use the 2-argaddListener(Listener, Executor)
overload, setting the executor todirectExecutor()
for equivalent behavior. (dfb0001714) -
util.concurrent
: ChangedAbstractFuture.toString()
to no longer include thetoString()
of the result. (2ebf27fd45) -
util.concurrent
: AddedawaitTerminationUninterruptibly
. (f07b9540dc)
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>29.0-jre</version>
<!-- or, for Android: -->
<version>29.0-android</version>
</dependency>
Javadoc
JDiff
Changelog
-
Guava types can no longer be sent over GWT-RPC. To temporarily reenable support, set the
guava.gwt.emergency_reenable_rpc
system property totrue
. (5214a10b1e)- This is the only breaking change in this release, and it affects only users of the
guava-gwt
artifact, not people who use only theguava
artifact. This release contains no changes that break binary compatibility for any users.
- This is the only breaking change in this release, and it affects only users of the
- API documentation for Guava classes is now easier to reach. For example, for
ImmutableList
, visit guava.dev/ImmutableList. Also, more easily access the index at guava.dev/api. -
collect
: AnnotatedFluentIterable.from(FluentIterable)
with@DoNotCall
. (b1c77b7df3) -
collect
: Madeceiling
,floor
,headSet(E, boolean)
, andtailSet(E, boolean)
methods available in the GWT-emulatedImmutableSortedSet
. (7e0fe90ca8, 5f2fbf27b2) -
graph
: Made it possible to set a stable incident edge order by calling the newly added method[Value]Graph.Builder.incidentEdgeOrder(ElementOrder.stable())
. (70164025a8) -
graph
: AddedincidentEdgeOrder()
to the[Value]Graph
interfaces. (cde576ec00) -
util.concurrent
: AddedDuration
-baseddefault
methods toListeningScheduledExecutorService
. (931e83f969) -
util.concurrent
: AddedimmediateVoidFuture
. (9f3bae5853) -
util.concurrent
: Removed@Beta
fromService
and related classes. (dc46627fea) -
util.concurrent
: Deprecated the 1-arg overload ofServiceManager.addListener
. (86e3620125) -
util.concurrent
: Changed the return type ofServiceManager.servicesByState()
toImmutableSetMultimap
(but also retained a method with the old signature for binary compatibility). (31999ae6f5) -
util.concurrent
: Made it safe to load theAbstractFuture
class from aForkJoinPool
thread under a security manager. (6e0c5b5d50)
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.2-jre</version>
<!-- or, for Android: -->
<version>28.2-android</version>
</dependency>
Javadoc
JDiff
Changelog
-
Warning to users of GWT-RPC: The first Guava release of 2020 will remove support for GWT-serializing Guava types. To test ahead of time with GWT-RPC support for Guava types disabled, set the
guava.gwt.emergency_reenable_rpc
system property tofalse
. (Even without the system property enabled, apps will now log warnings when sending Guava types over GWT-RPC.) (08bbf53ab0) -
base
: AddedSplitter.splitToStream()
. -
concurrent
: AddedFutures.submit()
(c7ef0cc93b) -
concurrent
: MadeplatformThreadFactory()
and related utilities (mainly*Service
) work under Java 11 App Engine, and tweaked other App Engine threading behavior. (e3ee00d6769d219c9646a17114fa00e2955b54aa) -
concurrent
: Addedcatch
toStackOverflowError
inAbstractFuture.toString
to prevent long chains of futures from failingtoString
calls. (a2e6acc009) -
concurrent
: MadeListenableFuture
implementThenable
via a default interface method in GWT/j2cl (e0bac74571). -
graph
: Fixed bug inAbstractNetwork.hasEdgeConnecting()
causing it to throw if either endpoint was not in the graph. Originally reported as #3721. (2ee7f9da69) -
graph
: Fixed data race. (0e94fb5bb8) -
math
: AddedStream
support toStats
andStatsAccumulator
. (e2f4eba636) -
math
: AddedQuantiles
compute()
methods which return aMap
now return a map with entries in the same order in which the indexes were provided. (786c3d84f1) -
net
: Added support for scope IDs for IPv6 addresses. (8a7d36a8e5044096919a3512aa6734c95032f38c) -
net
: AddedtoBigInteger
andfromIpv4BigInteger
/fromIpv6BigInteger
toInetAddresses
for manipulatingInetAddresses
asBigIntegers
(d7a0b3d367) -
net
: AddedMediaType
constants for application/opensearchdescription+xml (f79c4fe0a7) and MPEG-DASH (67dd062cb9), as well as a constant for the header Cross-Origin-Opener-Policy (4ef2111641). -
net
: MadeMediaType
reject empty type, subtype, and attribute (b080067) and non-ASCII parameter values (2278123479). Also, made it serialize empty parameter values to quoted strings (2278123479). - Added
@DoNotMock
to several types. (4eea0f79c2, add430908ec77c1859f84bd753b84a5eca57b327) - Removed dependency on
animal-sniffer-annotations
. (5f37e53fd7)
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.1-jre</version>
<!-- or, for Android: -->
<version>28.1-android</version>
</dependency>
Javadoc
JDiff
Changelog
-
collect
: AddedRangeMap.merge
, analogous toMap.merge
. (687252d35) -
collect
: Fixed a bug inImmutableSet.Builder
that could lead to infinite loops when building multiple sets from the same builder. (0007cb257) -
io
: Fixed an issue where theInputStream
returned byBaseEncoding.decodingStream(Reader)
could fail to throwDecodingException
while decoding an invalid string. (ddd4a49fb) -
net
: AddedMediaType
for "image/heif" and "image/jp2" (508696a4c) -
net
: AddedUpgrade-Insecure-Requests
header toHttpHeaders
. (6a8b716af) -
concurrent
: Fixed potential memory leak inFutures.whenAllSucceed/whenAllComplete
(494834bd4)
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.0-jre</version>
<!-- or, for Android: -->
<version>28.0-android</version>
</dependency>
Javadoc
JDiff
Changelog
-
collect
: AddedDuration
-based overloads to someQueues
methods. (21d06cf1d48175ab5cdf3d88f1776d3cba227b37) -
net
: AddedMediaType
for "application/geo+json". (36cd5cfc5) -
net
: Added a number of constants toHttpHeaders
. -
concurrent
: Removed deprecatedCheckedFuture
and related utilities. (3dd22fe75) -
concurrent
: AddedDuration
-based overloads to many methods. -
concurrent
: Removed@Beta
fromsetFuture
. (5ec136091) -
concurrent
: Added deprecatedFluentFuture.from(FluentFuture)
to point out redundant code. (f9f280776) -
graph
: AddedGraphBuilder.immutable()
,ValueGraphBuilder.immutable()
andNetworkBuilder.immutable()
for building immutable graphs in a fluent way. - J2ObjC: Fixed crashes from use of
ImmutableMap.entrySet()
. (74fc49faf)