Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Guava Release 22.0: Release Notes
- 22.0 was released on May 22, 2017.
- 22.0-rc1 was released on May 2, 2017.
New: Android version
The main Guava artifact (
22.0) requires Java 8, as it has since 21.0.
New in 22.0 is a version of Guava targeted at Android, differentiated by its version number:
While the focus of this version is on Android, it's also the version you should use if you need to target Java 7.
We're using version number rather than artifact ID to differentiate so that Maven can detect both versions being in its dependency tree; having both in the dependency tree should be avoided. The intent is that the Android version always be a strict subset of what's available in the main/Java 8 version, so anything compiled against version N of the Android version will work when run against the Java 8 version. So if you're a library depending on Guava and want to support Android and/or Java 7 users, you should depend on the
So what's different in the Android version?
- Primarily, Java 8-specific changes made in 21.0 are not present. Nothing extends new Java 8 types and APIs for supporting new Java 8 APIs are removed. See the API diffs between the Java 8 and Android versions for specifics.
- While not Java 8, the
MoreFilesclass (added in 21.0) is not present because it requires (and is only useful with) support for the
java.nio.fileAPIs, which are not supported on Android.
- Some optimizations have been made to a number of data structures (primarily our
ImmutableCollectionimplementations) to make them better for use on Android: lower memory footprint and less garbage generated in their use, for example.
Android / Java 7:
Using Guava in your project
|Guava||Guava (Android)||Guava (GWT)|
See UseGuavaInYourBuild for help integrating Guava into your build environment.
9+ issues are resolved in this release.
- Java 8: Full JDiff Report of changes since release 21.0.
- Android: Full JDiff Report of changes since release 20.0 (the previous release that could be used on Android).
Significant API additions and changes
(For Android, see the changes for 21.0, ignoring those that are Java 8 specific, or the JDiff report linked above.)
New immutable primitive array types! Think of these as
ImmutableList for primitive types (but not implementing
Stopwatch.elapsed(): returns the elapsed time as a
Throwables.getCauseAs(Throwable, Class<X>): a way of getting the cause of an exception and casting it to a specific type without losing the original exception stack trace if the cause is not that type.
Collectors for collecting the least/greatest
kelements (according to a
Comparator) from a
List(faster and more memory efficient than sorting and limiting the stream).
Immutable(Sorted)Multisets that take a
ToIntFunctionto get counts for elements.
RangeMap.putCoalescing(Range<K>, V): Inserts the given range and value to the map, merging it with any connected entries with equal values.
Streams.forEachPair(Stream, Stream, BiConsumer): For-each over pairs of corresponding elements from two streams.
common.graphmethods that previously accepted
Objectfor nodes/edges now require the specified node/edge type. This breaks all custom implementations of
ValueGraphno longer extends
Graphs.equivalence()has been deprecated in favor of the more usual
equals()methods on each interface (now that
Graphno longer need to have compatible definitions).
BloomFilter.approximateElementCount(): Estimate of the number of distinct elements that have been added to the Bloom filter.
Hashing.sha1(): Deprecated. Will continue to exist to allow interoperation with systems requiring them.
CharSink.writeLines(Stream[, String]): Methods for writing elements of a
CharSequences as lines to a
CharSource.lines(): Returns a
Stream<String>(which must be closed!) of lines of text from a
CharSource.forEachLine(Consumer): For-each over the lines of text in a
Files: Many methods that are redundant with creating a source or sink for a file and calling a method on it are now deprecated.
MoreFiles.equal(Path, Path): Returns whether or not two files are regular files containing the same bytes.
CheckedFuture: Deprecated. (See the javadoc for details.)
boolean interruptible) deprecated;
Guava's dependencies on some annotation-only libraries are no longer
<optional>true</optional>. This makes them available at runtime and at compile time for libraries that compile against Guava. This fixes some projects' compile errors (#2721), but it may introduce dependency conflicts into other projects (#2824). If you see dependency conflicts, we believe you should be safe excluding all but the newest version of each of the annotation libraries.