google/guava
 Watch   
 Star   
 Fork   
5 days ago
guava

33.2.0

Android users: Please test recent Guava versions

If you know of Guava Android users who have not yet upgraded to at least release 33.0.0, please encourage them to upgrade, preferably to today's release, 33.2.0. These releases have begun adding Java 8+ APIs to guava-android. While we don't anticipate problems, we do anticipate that any unexpected problems could force a disruptive rollback. To minimize any disruption, we'd like to catch any such problems early.

Please let us know of any problems you encounter.

Maven

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>33.2.0-jre</version>
  <!-- or, for Android: -->
  <version>33.2.0-android</version>
</dependency>

Jar files

Guava requires one runtime dependency, which you can download here:

Javadoc

JDiff

Changelog

  • Dropped testing for Android versions before Lollipop (API Level 21). Guava may stop working under older versions in the future, or it may have done so already.
  • Fixed a GWT compilation breakage under Gradle. (858caf425c)
  • collect: Made our Collector APIs (e.g., ImmutableList.toImmutableList()) available in guava-android. More Java 8 APIs will follow in future releases. (96fca0b747)
    • As always, streams are available to Android code only when that code enables library desugaring or targets a new enough API Level (24 (Nougat) for many stream APIs). (But note that we test only with library desugaring, so we don't currently know if API Level 24 is high enough to use our Collector APIs unless you have also enabled library desugaring.) Guava users who avoid the Collector APIs do not need to meet this requirement.
  • collect: Fixed a potential NullPointerException in ImmutableMap.Builder on a rare code path. (70a98115d8)
  • net: Added HttpHeaders constants Ad-Auction-Allowed, Permissions-Policy-Report-Only, and Sec-GPC. (7dc01ed27b, 41d0d9a833, 38c8017bd44b7919b112f1c99f3d8ce4b058ae5d)
2024-03-14 02:21:59
guava

33.1.0

Maven

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>33.1.0-jre</version>
  <!-- or, for Android: -->
  <version>33.1.0-android</version>
</dependency>

Jar files

Guava requires one runtime dependency, which you can download here:

Javadoc

JDiff

Changelog

  • Updated our Error Prone dependency to 2.26.1, which includes a JPMS-ready jar of annotations. If you use the Error Prone annotations in a modular build of your own code, you may need to add a requires line for them. (d48c6dfbb8, c6e91c498ced26631029d1bdfdb9154d4a217368)
  • base: Added a Duration overload for Suppliers.memoizeWithExpiration. (76e46ec35b)
  • base: Deprecated the remaining two overloads of Throwables.propagateIfPossible. They won't be deleted, but we recommend migrating off them. (cf86414a87)
  • cache: Fixed a bug that could cause false "recursive load" reports during refresh. (0e1aebf73e)
  • graph: Changed the return types of transitiveClosure() and reachableNodes() to Immutable* types. reachableNodes() already returned an immutable object (even though that was not reflected in the declared return type); transitiveClosure() used to return a mutable object. The old signatures remain available, so this change does not break binary compatibility. (09e655f6c1)
  • graph: Changed the behavior of views returned by graph accessor methods that take a graph element as input: They now throw IllegalStateException when that element is removed from the graph. (8dca776341)
  • hash: Optimized Checksum-based hash functions for Java 9+. (afb35a5d1b)
  • testing: Exposed FakeTicker Duration methods to Android users. (f346bbb6a7)
  • util.concurrent: Deprecated the constructors of UncheckedExecutionException and ExecutionError that don't accept a cause. We won't remove these constructors, but we recommend migrating off them, as users of those classes often assume that instances will contain a cause. (1bb3c4386b)
  • util.concurrent: Improved the correctness of racy accesses for J2ObjC users. (d3232b71ce)
2023-12-19 04:32:56
guava

33.0.0

Maven

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>33.0.0-jre</version>
  <!-- or, for Android: -->
  <version>33.0.0-android</version>
</dependency>

Jar files

Guava requires one runtime dependency, which you can download here:

Javadoc

JDiff

Changelog

  • This version of guava-android contains some package-private methods whose signature includes the Java 8 Collector API. This is a test to identify any problems before we expose those methods publicly to users. Please report any problems that you encounter. (73dbf7ef26)
  • Changed various classes to catch Exception instead of RuntimeException even when only RuntimeException is theoretically possible. This can help code that throws undeclared exceptions, as some bytecode rewriters (e.g., Robolectric) and languages (e.g., Kotlin) do. (c294c23760, 747924e, b2baf48)
  • Added an Automatic-Module-Name to failureaccess, Guava's one strong runtime dependency. (280b5d2f60)
  • reflect: In guava-android only, removed Invokable.getAnnotatedReturnType() and Parameter.getAnnotatedType(). These methods never worked in an Android VM, and to reflect that, they were born @Deprecated, @Beta, and @DoNotCall. They're now preventing us from rolling out some new Android compatibility testing. This is the only binary-incompatible change in this release, and it should have no effect in practice. Still, we bump the major version number to follow Semantic Versioning. (045cd8428f)
  • util.concurrent: Changed our implementations to avoid eagerly initializing loggers during class loading. This can help performance, especially under Android. (4fe1df56bd)
2023-10-11 04:34:53
guava

32.1.3

Maven

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>32.1.3-jre</version>
  <!-- or, for Android: -->
  <version>32.1.3-android</version>
</dependency>

Jar files

Guava requires one runtime dependency, which you can download here:

Javadoc

JDiff

Changelog

  • Changed Gradle Metadata to include dependency versions directly. This may address "Could not find some-dependency" errors that some users have reported (which might be a result of users' excluding guava-parent). (c6d35cf1a5)
  • collect: Changed Multisets.unmodifiableMultiset(set).removeIf(predicate) to throw an exception always, even if nothing matches predicate. (61dbccfda3)
  • graph: Fixed the behavior of Graph/ValueGraph views for a node when that node is removed from the graph. (950799691c)
  • io: Fixed Files.createTempDir and FileBackedOutputStream under Windows services, a rare use case. (The fix actually covers only Java 9+ because Java 8 would require an additional approach. Let us know if you need support under Java 8.) (f87f68cd3e)
  • net: Made MediaType.parse allow and skip over whitespace around the / and = separator tokens in addition to the ; separator, for which it was already being allowed. (2786f83291)
  • util.concurrent: Tweaked Futures.getChecked constructor-selection behavior: The method continues to prefer to call constructors with a String parameter, but now it breaks ties based on whether the constructor has a Throwable parameter. Beyond that, the choice of constructor remains undefined. (For this and other reasons, we discourage the use of getChecked.) (59cfb2267a)
2023-08-01 05:01:20
guava

32.1.2

Maven

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>32.1.2-jre</version>
  <!-- or, for Android: -->
  <version>32.1.2-android</version>
</dependency>

Jar files

Guava requires one runtime dependency, which you can download here:

Javadoc

JDiff

Changelog

  • Removed the section of our Gradle metadata that caused Gradle to report conflicts with listenablefuture. (9ed0fa65ab)
  • Changed our Maven project to avoid affecting which version of Mockito our Gradle users see. (71a16d5a74)
  • collect: Under J2CL, exposed ImmutableList and ImmutableSet methods copyOf and of for JavaScript usage. (b41968f5f2)
  • net: Optimized InternetDomainName construction. (3a1d18fbefa10218988a0fbbb6e1fada012397bf, eaa62eb09548a6f1b7a757e21d8852724b631cab)
2023-06-30 22:23:44
guava

32.1.1

Maven

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>32.1.1-jre</version>
  <!-- or, for Android: -->
  <version>32.1.1-android</version>
</dependency>

Jar files

Guava requires one runtime dependency, which you can download here:

Javadoc

JDiff

Changelog

  • Fixed our broken Gradle metadata from 32.1.0. Sorry again for the trouble.
2023-06-30 02:37:59
guava

32.1.0

Maven

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>32.1.0-jre</version>
  <!-- or, for Android: -->
  <version>32.1.0-android</version>
</dependency>

Jar files

Guava requires one runtime dependency, which you can download here:

Javadoc

JDiff

Changelog

Gradle Module Metadata

The Gradle team has contributed a metadata file for Guava. If you use Gradle 6 or higher, you will see better handling of two kinds of dependency conflicts, plus another small feature related to our dependencies:

Selecting the appropriate flavor

When Gradle automatically selects the newest version of Guava in your dependency graph, it will now also select the appropriate flavor (-android or -jre) based on whether you project targets Android or not. For example, if you depend on 32.1.0-android and 30.0-jre, Gradle will select 32.1.0-jre. This is the version most likely to be compatible with all your dependencies.

In the unusual event that you need to override Gradle's choice of flavor, you can do so as follows:

dependencies.constraints {
  implementation("com.google.guava:guava") {
    attributes {
      attribute(
        TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, 
        objects.named(TargetJvmEnvironment, TargetJvmEnvironment.ANDROID))
    }
  }
}

// If the above leads to a conflict error because there are additional transitive dependencies to Guava, then use:
configurations.all {
  resolutionStrategy.capabilitiesResolution.withCapability("com.google.guava:guava") {
    select(candidates.find { it.variantName.contains("android") })
  }
}
Reporting dependencies that overlap with Guava

If your dependency graph contains the very old google-collections or the hacky listenablefuture, Gradle will now report that those libraries contain duplicates of Guava classes. When this happens, you'll need to tell Gradle to select Guava:

configurations.all {
  resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
    select("com.google.guava:guava:0")
  }
  // and/or
  resolutionStrategy.capabilitiesResolution.withCapability("com.google.guava:listenablefuture") {
    select("com.google.guava:guava:0")
  }
}
Omitting annotations at runtime

One dependency of Guava that is not needed at runtime (j2objc-annotations) is now omitted from the runtime classpath. (We may omit others in the future. See #6606.)

Other changes

  • collect: Tweaked more nullness annotations. (501a01631f742bbcb73cf46ae409abf567903944, 5c2359087acc36c86ed42f1875ce69b7be231868)
  • hash: Enhanced crc32c() to use Java's hardware-accelerated implementation where available. (65c7f10ff0)
  • util.concurrent: Added Duration-based default methods to ListeningExecutorService. (e7714b0b8b)
  • Began updating Javadoc to focus less on APIs that have been superseded by additions to the JDK. We're also looking to add more documentation that directs users to JDK equivalents for our APIs. Further PRs welcome! (c9efc479950e40be4a11daa707dcf9258745cc2e, 01dcc2e6104e9bd0392cb19029edf2c581425b67)
  • Fixed some problems with using Guava from a Java Agent. (But we don't test that configuration, and we don't know how well we'll be able to keep it working.) (e42d4e863b, de62703987)
  • Fixed BootstrapMethodError when using CacheBuilder from a custom system class loader. (As with the previous item, we're not sure how well we'll be able to keep this use case working.) (a667c38772)
  • Suppressed a harmless unusable-by-js warning seen by users of guava-gwt.
2023-06-09 06:27:10
guava

32.0.1

Maven

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>32.0.1-jre</version>
  <!-- or, for Android: -->
  <version>32.0.1-android</version>
</dependency>

Jar files

Guava requires one runtime dependency, which you can download here:

Javadoc

JDiff

Changelog

  • io: Fixed Files.createTempDir and FileBackedOutputStream under Windows, which broke as part of the security fix in release 32.0.0. Sorry for the trouble. (fdbf77d3f2)
2023-05-27 06:14:55
guava

v32.0.0

Maven

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>32.0.0-jre</version>
  <!-- or, for Android: -->
  <version>32.0.0-android</version>
</dependency>

Jar files

Guava requires one runtime dependency, which you can download here:

Javadoc

JDiff

Changelog

Security fixes

While CVE-2020-8908 was officially closed when we deprecated Files.createTempDir in Guava 30.0, we've heard from users that even recent versions of Guava have been listed as vulnerable in other databases of security vulnerabilities. In response, we've reimplemented the method (and the very rarely used FileBackedOutputStream class, which had a similar issue) to eliminate the insecure behavior entirely. This change technically carries small risks (dicussed under "Incompatible changes" below), but we expect no practical risk to users.

Incompatible changes

Although this release bumps Guava's major version number, it makes no binary-incompatible changes to the guava artifact. Still, it makes a few changes that may cause problems for users in less common situations:

  • This release makes a binary-incompatible change to a @Beta API in the separate artifact guava-testlib. Specifically, we changed the return type of TestingExecutors.sameThreadScheduledExecutor to ListeningScheduledExecutorService. The old return type was a package-private class, which caused the Kotlin compiler to produce warnings. (dafaa3e435)
  • This release adds two methods to the Android flavor of Guava: Invokable.getAnnotatedReturnType() and Parameter.getAnnotatedType(). Those methods do not work under an Android VM; we added them only to help our tests of the Android flavor (since we also run those tests under a JRE). Android VMs tolerate such methods as long as the app does not call them or perform reflection on them, and builds tolerate them because of our new Proguard configurations (discussed below). Thus, we expect no impact to most users. However, we could imagine build problems for users who have set up their own build system for the Android flavor of Guava. Please report any problems so that we can judge how safely we might be able to add other methods to the Android flavor in the future, such as APIs that use Java 8 classes like Stream. (b30e73cfa81ad15c1023c17cfd083255a3df0105)
  • This release removes various APIs from the guava-gwt. This affects only users of GWT. The APIs we removed are Enums, Sets.complementOf, and the Enum*BiMap classes's keyType() and valueType() methods. These changes prepare for the removal of reflective enum-related APIs from J2CL. If one of these changes causes you problems as a GWT user, let us know. (c3a155dc85, 09db2c29ae, 3de12be516)
  • The new implementations of Files.createTempDir and FileBackedOutputStream are annotated as @J2ObjCIncompatible. If you need to use them under J2ObjC, contact us. (56dc928a25)
  • Because the new version of Files.createTempDir restricts permissions to the current user, it could break any user that relies on letting other users access the directory.
  • The new versions of Files.createTempDir and FileBackedOutputStream throw an exception if they can't create the directory or file securely. This is possible only under Android Ice Cream Sandwich, a very old version of Android that is the oldest one we test Guava with.

Other changes

  • Removed @Beta from almost all APIs. For details, see the bottom of the release notes. At this point, it's probably simpler to look at a list of APIs that still are @Beta, such as this list for guava-jre. Most of the remaining @Beta APIs are in graph and hash.
  • Enhanced the Guava jar to include Proguard configurations that are picked up automatically by the Android Gradle Plugin. This should help with warnings that were promoted to errors in Android Gradle Plugin 8.x. (aeba1e1b2d)
  • Enhanced the Guava jar to include information about method parameters in its class files. If you use static analyzers that look at method-parameter names, you may see new warnings or errors if they are now able to detect mismatches. But mostly, you may see better tooltips and autocompletion in IDEs. (59d174cfbe)
  • Improved nullness annotations on a few classes.
  • Modified classes with "serial proxies" to declare exception-throwing readObject methods, in accordance with best practice. (e62d6a0456)
  • collect: Fixed Maps.newHashMapWithExpectedSize to stop allocating maps that were larger than they needed to be. (6ad621e76d)
  • collect: Made various APIs work J2CL: Maps.immutableEnumMap+toImmutableEnumMap, EnumMultiset, CollectorTester. Previously, the APIs were present but failed at runtime. (b62c88e630, 23ff91848f, 852a7d3fe9)
  • collect: Optimized memory usage for Interner and MapMaker. (a2e8f3c7ce)
  • graph: Changed directed graphs to reject attempts to add undirected edges. (76260d9b3c)
  • io: Added BaseEncoding.ignoreCase() to support case-insensitive decoding. (9c1e5dea4b)
  • net: Added HttpHeaders constants:
    • No-Vary-Search (688b9c2cfa)
    • Sec-CH-DPR (75a3d4dd36)
    • Sec-CH-UA-Wow64 (49e6b9c4a1)
    • Sec-CH-Viewport-Width and Sec-CH-Viewport-Height (44df85a829)
    • Supports-Loading-Mode (0d5c16fc6b)
  • net: Added the MediaType constant for JWT. (f942fd2c0e)
  • primitives: Added rotate() for arrays of all primitive types. (cd338fa2bc, 6e9057d0f2)
  • util.concurrent: Changed AbstractFuture to run interruptTask() just before afterDone(). Until this change, it ran slightly earlier than that: We used to run it before unblocking any pending get() calls, and now we run it after. (b337be6089)
  • util.concurrent: Fixed some cases in which we could catch InterruptedException but fail to restore the interrupt bit. (8f0350a21a)
@Beta removal list
  • base: Utf8 (211907cb8b)
  • base: more APIs (b0cc461da5)
  • collect: Multimaps.asMap(...)` (df0081f28f)
  • collect: FluentIterable APIs (73b2f7bee0)
  • collect: Forwarding[Foo] APIs (9760dbcd4c)
  • collect: ImmutableFoo.Builder.builderWithExpectedSize(...), orderEntriesByValue(...), and Entry-related APIs (61be35ce49)
  • collect: RangeMap, RangeSet, and friends (fe12c81e79)
  • collect: more APIs (98820c77f9, e5e0f660cc)
  • io: ByteStreams (48979309a5)
  • io: more APIs (a5892560de)
  • math: various APIs (912815e4e2)
  • primitives: Longs.tryParse(...) and friends (b3d48564c6)
  • primitives: UnsignedLongs (b240e8ce14)
  • primitives: more APIs (fcec25f45e, ab4302aa53)
  • reflect: Invokable and some methods in TypeToken (a195f7d604)
  • reflect: Parameter (except getAnnotatedType() in guava-android) (b561eb14c2)
  • testing: various APIs (b331769af3, 74ad9b8a1f)
  • util.concurrent: FluentFuture (b9a2d58503)
  • util.concurrent: Futures (15a0c9fd57)
  • util.concurrent: Striped (ba8ad69d03)
  • util.concurrent: various MoreExecutors APIs (a3571b408f)
  • util.concurrent: more APIs (bbaf76a199)
2022-03-01 05:06:35
guava

31.1

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 the Throwables methods lazyStackTrace and lazyStackTraceIsLazy. They are no longer useful on any current platform. (6ebd7d8648)
  • collect: Added a new method ImmutableMap.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 the buildKeepingLast() change, the idiom ImmutableList.copyOf(Maps.transformValues(map, function)) may produce different results if function has side-effects. (This is not recommended.) (68500b2c09)
  • hash: Added Hashing.fingerprint2011(). (13f703c25f)
  • io: Changed ByteStreams.nullOutputStream() to follow the contract of OutputStream.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: Added HttpHeaders constant for Access-Control-Allow-Private-Network. (6dabbdf9c9)
  • util.concurrent: Added accumulate/update methods for AtomicDouble and AtomicDoubleArray. (2d875d327a)

APIs promoted from @Beta

  • base: Throwables methods getCausalChain and getCauseAs (dd462afa6b)
  • collect: Streams methods mapWithIndex and findLast (8079a29463)
  • collect: the remaining methods in Comparators: min, max, lexicographical, emptiesFirst, emptiesLast, isInOrder, isInStrictOrder (a3e411c3a4)
  • escape: various APIs (468c68a6ac)
  • io: various APIs in Files (828d9ee74e)
  • net: various APIs (261ac7afbf)
  • reflect: various APIs (9f6a384020)
  • testlib: various APIs (93a8f02f56)
  • util.concurrent: AsyncCallable, ListenableScheduledFuture, and ClosingFuture (8b4ad17dcf)
  • util.concurrent: ExecutionSequencer, MoreExecutors.newSequentialExecutor, and Monitor (189d668a95)
  • util.concurrent: Futures methods: submit, submitAsync, scheduleAsync, nonCancellationPropagating, inCompletionOrder (e015172847)
  • util.concurrent: Uninterruptibles: awaitTerminationUninterruptibly and the Duration overloads in the class (825de9a2d0)
  • util.concurrent: the FluentFuture type, its factory methods, and addCallback (9c7e13b5d4)