-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Release22
- 22.0-rc1 was released on May 2, 2017.
(See ReleaseHistory.)
The main Guava artifact (22.0-rc1) 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-rc1-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 libarary 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
MoreFilesclass (added in 21.0) is not present because it requires (and is only useful with) support for thejava.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.
Java 8:
Android / Java 7:
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).
-
ImmutableIntArrayand.Builder -
ImmutableLongArrayand.Builder -
ImmutableDoubleArrayand.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)():Comparators forjava.util.Optionals -
Comparators.(least|greatest)(k, Comparator):Collectors for collecting the least/greatestkelements (according to aComparator) from aStreamto aList(faster and more memory efficient than sorting and limiting the stream). - New
Collectors forMultisets andImmutable(Sorted)Multisets that take aToIntFunctionto get counts for elements. RangeMap.putCoalescing(Range<K>, V)-
Streams.forEachPair(Stream, Stream, BiConsumer): For-each over pairs of corresponding elements from two streams. Tables.synchronizedTable(Table)
A variety of changes here. See API diffs for graph.
-
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 aStreamofCharSequences 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,runWithTimeoutandrunUninterruptiblyWithTimeoutadded.
- 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