-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Release22
- 22.0 was released on May 22, 2017.
- 22.0-rc1 was released on May 2, 2017.
(See ReleaseHistory.)
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: 22.0-android
.
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 -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
MoreFiles
class (added in 21.0) is not present because it requires (and is only useful with) support for thejava.nio.file
APIs, which are not supported on Android. - Some optimizations have been made to a number of data structures (primarily our
ImmutableCollection
implementations) to make them better for use on Android: lower memory footprint and less garbage generated in their use, for example.
Java 8:
Android / Java 7:
Guava | Guava (Android) | Guava (GWT) | |
---|---|---|---|
Maven Identifier | com.google.guava:guava:22.0 | com.google.guava:guava:22.0-android | com.google.guava:guava-gwt:22.0 |
Jar | guava-22.0.jar | guava-22.0-android.jar | guava-gwt-22.0.jar |
Javadoc | guava-22.0-javadoc.jar | guava-22.0-android-javadoc.jar | guava-gwt-22.0-javadoc.jar |
Sources | guava-22.0-sources.jar | guava-22.0-android-sources.jar | guava-gwt-22.0-sources.jar |
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).
(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 List
directly).
-
ImmutableIntArray
and.Builder
-
ImmutableLongArray
and.Builder
-
ImmutableDoubleArray
and.Builder
-
Stopwatch.elapsed()
: returns the elapsed time as ajava.time.Duration
. -
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.
-
Comparators.empties(First|Last)()
:Comparator
s forjava.util.Optional
s -
Comparators.(least|greatest)(k, Comparator)
:Collector
s for collecting the least/greatestk
elements (according to aComparator
) from aStream
to aList
(faster and more memory efficient than sorting and limiting the stream). - New
Collector
s forMultiset
s andImmutable(Sorted)Multiset
s that take aToIntFunction
to 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. Tables.synchronizedTable(Table)
- All
common.graph
methods that previously acceptedObject
for nodes/edges now require the specified node/edge type. This breaks all custom implementations ofGraph
,Network
andValueGraph
. -
ValueGraph
no longer extendsGraph
;Graphs.equivalence()
has been deprecated in favor of the more usualequals()
methods on each interface (now thatValueGraph
andGraph
no longer need to have compatible definitions).
-
BloomFilter.approximateElementCount()
: Estimate of the number of distinct elements that have been added to the Bloom filter. -
Hashing.md5()
andHashing.sha1()
: Deprecated. Will continue to exist to allow interoperation with systems requiring them.
-
CharSink.writeLines(Stream[, String])
: Methods for writing elements of aStream
ofCharSequence
s as lines to aCharSink
. -
CharSource.lines()
: Returns aStream<String>
(which must be closed!) of lines of text from aCharSource
. -
CharSource.forEachLine(Consumer)
: For-each over the lines of text in aCharSource
. -
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.) -
TimeLimiter
:callWithTimeout
(taking aboolean interruptible
) deprecated;callWithTimeout
,callUninterruptiblyWithTimeout
,runWithTimeout
andrunUninterruptiblyWithTimeout
added.
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.
- Introduction
- Basic Utilities
- Collections
- Graphs
- Caches
- Functional Idioms
- Concurrency
- Strings
- Networking
- Primitives
- Ranges
- I/O
- Hashing
- EventBus
- Math
- Reflection
- Releases
- Tips
- Glossary
- Mailing List
- Stack Overflow
- Android Overview
- Footprint of JDK/Guava data structures