Some Guava features were really useful for Java 7 application because Guava was bringing APIs missing in the JDK. Java 8 fixed some of these limitations. When migrating an application to Java 8 or even when starting a new one, it’s recommended to prefer Java 8 APIs over Guava ones to ease its maintenance: developers don’t need to learn how to use two APIs and can stick to the standard one.

Java 9 brought even more useful methods to the standard Java library and if Java version is equal to or higher than 9, these standard methods should be used.

This rule raises an issue when the following Guava APIs are used:

Guava API Java 8 API

com.google.common.io.BaseEncoding#base64()

java.util.Base64

com.google.common.io.BaseEncoding#base64Url()

java.util.Base64

com.google.common.base.Joiner.on()

java.lang.String#join() or java.util.stream.Collectors#joining()

com.google.common.base.Optional#of()

java.util.Optional#of()

com.google.common.base.Optional#absent()

java.util.Optional#empty()

com.google.common.base.Optional#fromNullable()

java.util.Optional#ofNullable()

com.google.common.base.Optional

java.util.Optional

com.google.common.base.Predicate

java.util.function.Predicate

com.google.common.base.Function

java.util.function.Function

com.google.common.base.Supplier

java.util.function.Supplier

com.google.common.io.Files.createTempDir

java.nio.file.Files.createTempDirectory

Guava API Java 9 API

com.google.common.collect.ImmutableSet#of()

java.util.Set#of()

com.google.common.collect.ImmutableList#of()

java.util.List#of()

com.google.common.collect.ImmutableMap#of()

java.util.Map#of() or java.util.Map#ofEntries()