Clone this wiki locally
Guava Release 21.0: Release Notes
- 21.0 was released on January 12, 2017.
- 21.0-rc2 was released on January 3, 2017.
- 21.0-rc1 was released on December 19, 2016.
Using Guava in your project
See UseGuavaInYourBuild for help integrating Guava into your build environment.
Important: Guava 21.0 requires Java 8. If you need Java 6, 7 or Android compatibility, use Guava 20.0 for now. Guava 22.0 and on will introduce a Java 6/Android compatible backport of Guava that includes all of the latest changes that don't require Java 8.
5+ issues are resolved in this release.
Full JDiff Report of changes since release 20.0.
Significant API additions and changes
Supplier: changed to extend the new
java.util.functioninterfaces with the same names.
fromJavaUtilmethods for easy conversion between Guava's
Objects: removed deprecated
toStringHelpermethods (both found on
MoreObjectssince Guava 18.0).
New default methods on
ConcurrentMap that were added in Java 8 are now implemented and safe to use for
Many APIs in collect now have better implementations of many of the
default methods added to
Map types in Java 8.
Comparators: With the addition of many useful methods to the
Comparatortype in Java 8,
Orderingnow provides little benefit.
Comparatorsis a new location for methods on
Orderingthat still don't have a good equivalent in the JDK.
Streams: Utility class for working with
java.util.stream.Stream. Includes methods for creating streams (such as
concat(Stream...)) and methods that do things with streams (such as
MoreCollectors: Factories for
java.util.stream.Collectorobjects; note that
Collectors for Guava's collection types are generally found on those types themselves rather than here.
Interners.InternerBuilder: Builder for
Internerinstances, with options similar to those found on
MapMaker. Created with
MapConstraints: deprecated since 19.0.
ForwardingBlockingDeque: deprecated; moved to
Immutable*types: added methods to all named
ImmutableList.toImmutableList()) which return a
Collectorfor collecting a
Streaminto an immutable collection/map object. As with most methods that create
Collectors, these are generally intended to be used as static imports.
Collectorobjects that collect to a
Collectorobjects that collect to an
toImmutableEnumSetmethod returning a
Collectorthat collects to an
Collectorobjects that collect to a
RangeSet: added default
- A number of rarely-used methods on concrete implementations of Guava collection types that aren't present on the interface they implement have been deprecated. These include:
MoreFiles: New class which contains methods similar to those in
Files, but for use with
- This includes
deleteDirectoryContentsmethods which are secure against race conditions that Java previously had no way of dealing with provided that the
SecureDirectoryStream(modern Linux versions do; Windows [NTFS at least] does not). For security, these will throw an exception if
SecureDirectoryStreamis not supported unless
RecursiveDeleteOption.ALLOW_INSECUREis passed when calling the method.
- Most classes: added
constrainToRange([type] value, [type] min, [type] max)methods which constrain the given value to the closed range defined by the
maxvalues. They return the value itself if it's within the range, the
minif it's below the range and the
maxif it's above the range.
ForwardingBlockingDeque: added; moved from
BlockingDequeis a concurrent type rather than a standard collection (it's defined in
AtomicLongMap: added a number of methods such as
accumulateAndGet(K, LongBinaryOperator)that take advantage of new Java functional types.
sameThreadExecutor(); deprecated since 18.0 in favor of