Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

Which Guava features are still useful in a Java 25 codebase, and which have been replaced by the JDK? Give examples of each.

The JDK has replaced much of Guava's original reason to exist: java.util.Optional, Objects.requireNonNull, String.join and Collectors.joining, List.of and List.copyOf, and java.nio.file.Files cover the old helpers. Guava is still valuable for collection types the JDK lacks, such as Multimap, Multiset, BiMap, Table, RangeSet and RangeMap, and its ImmutableList and ImmutableMap remain useful as ordered, builder-friendly types that document immutability. Its cache is in maintenance in favour of Caffeine, and features such as hashing, primitive utilities, RateLimiter and EventBus need judgement case by case.

Why this question is asked

Guava arrived when Java 6 was current and filled many gaps at once, so older codebases use it everywhere. On Java 25, a lot of those uses are redundant, and a few are still the best tool available. Interviewers ask this question to see whether we know the modern JDK well enough to tell the two apart, which matters when we decide what to allow in new code and how to keep dependencies small. In this answer, we will go through the parts the JDK has replaced, the collection types Guava still does best, the special place of its immutable collections, the cache and Caffeine, and the features that need judgement, including why EventBus is discouraged.

1What the JDK Has Replaced

Many of Guava's early helpers now have direct JDK equivalents, and new code should use those. Guava's Optional was the model for java.util.Optional in Java 8. Preconditions.checkNotNull is covered by Objects.requireNonNull, and index checks by Objects.checkIndex. Joiner for simple cases is String.join or Collectors.joining. ImmutableList.of for small fixed lists is List.of, and copying into an unmodifiable list is List.copyOf. Guava's Files helpers are mostly covered by java.nio.file.Files, which reads and writes whole files in one call since Java 11. Strings.isNullOrEmpty has String.isEmpty and isBlank, though the null case still needs a check.

Java
Objects.requireNonNull(order, "order"); // was Preconditions.checkNotNull
String csv = String.join(",", List.of("a", "b", "c")); // "a,b,c", was Joiner.on(',')
List<String> fixed = List.of("red", "green"); // unmodifiable, was ImmutableList.of
List<String> copy = List.copyOf(names); // unmodifiable copy
String text = Files.readString(Path.of("notes.txt")); // was Guava Files.asCharSource
Optional<User> user = repository.findById(id); // was com.google.common.base.Optional
Guava features on a Java 25 codebase
Guava featureStatusUse instead or keep
OptionalReplacedjava.util.Optional
Preconditions null checksReplacedObjects.requireNonNull, checkIndex
Joiner (simple)ReplacedString.join, Collectors.joining
ImmutableList.of (small lists)Mostly replacedList.of, List.copyOf
Files helpersMostly replacedjava.nio.file.Files
Multimap, Multiset, BiMap, TableStill usefulNo JDK equivalent
RangeSet, RangeMapStill usefulNo JDK equivalent
Cache (CacheBuilder)MaintenanceCaffeine
Hashing, RateLimiter, EventBusCase by caseSee below

Notice one behavioural difference: List.of and List.copyOf reject null elements, as Guava's immutable collections always did, so code that moves from Arrays.asList to List.of may start throwing NullPointerException on data that contained nulls. That is usually a bug being revealed, not created.

2Collection Types the JDK Still Lacks

Guava's richest remaining value is its collection types. A Multimap maps a key to many values, without us managing a Map<K, List<V>> by hand. A Multiset counts occurrences. A BiMap is a map that can be looked up in both directions, with unique values. A Table has two keys, a row and a column, like a spreadsheet. RangeSet and RangeMap store ranges, such as price bands or time windows, and answer which range contains a value.

Java
ListMultimap<String, String> tags = ArrayListMultimap.create();
tags.put("order-1", "urgent");
tags.put("order-1", "gift");
tags.get("order-1"); // [urgent, gift]
tags.get("order-9"); // []: never null
Multiset<String> words = HashMultiset.create(List.of("a", "b", "a"));
words.count("a"); // 2
BiMap<String, Integer> codes = HashBiMap.create(Map.of("EUR", 978, "USD", 840));
codes.inverse().get(978); // "EUR"
RangeMap<Integer, String> bands = TreeRangeMap.create();
bands.put(Range.closedOpen(0, 100), "small");
bands.put(Range.closedOpen(100, 1_000), "medium");
bands.get(250); // "medium"

Each of these can be written with plain JDK collections, but the hand-written versions repeat the same fiddly code (computeIfAbsent, two maps kept in sync, a TreeMap with floorEntry and a bounds check) in every place they are needed, and each copy is a chance for a bug.

3Why ImmutableList and ImmutableMap Still Matter

List.of and Map.of are unmodifiable, but their type is still List or Map, so a method signature does not tell the caller whether the collection can change. ImmutableList as a return or field type documents and guarantees immutability in the type itself. ImmutableMap and ImmutableSet also preserve insertion order, while Map.of and Set.of have an unspecified iteration order that can differ between runs. And Guava's builders are convenient for collections assembled step by step: ImmutableMap.builder().put(...).put(...).buildOrThrow().

So in code that values these properties, for example a library's public API or configuration objects that must iterate in a stable order, Guava's immutable types remain a reasonable choice. For simple local lists, List.of is enough.

4The Cache and Caffeine

Guava's CacheBuilder was the standard in-process cache for years. It still works, but the Guava team considers it in maintenance and recommends Caffeine, a cache library by one of the original authors that was designed as its successor. Caffeine has a very similar builder API, better hit rates thanks to its eviction policy, better performance under concurrency, and an asynchronous cache. Spring's cache abstraction supports Caffeine directly. Migrating is usually a matter of changing the builder class and a few method names.

Java
Cache<String, Price> prices = Caffeine.newBuilder()
.maximumSize(10_000)
.expireAfterWrite(Duration.ofMinutes(5))
.build();
prices.get("SKU-1", sku -> priceService.load(sku)); // loads once, then cached

5Features That Need Judgement

Some Guava features have no exact replacement and are neither clearly good nor clearly obsolete. Hashing offers non-cryptographic hash functions such as Murmur3 and utilities like consistent hashing, which the JDK lacks; for cryptographic hashes we use MessageDigest. The primitives utilities (Ints, Longs, UnsignedInteger) overlap partly with JDK methods such as Integer.parseUnsignedInt and Math.floorMod. RateLimiter is handy for a simple per-process rate limit, but it is marked beta and only limits within one JVM; for limits across instances we need a distributed limiter such as Bucket4j or one at the gateway.

EventBus is the case where Guava's own documentation steers us away. It is discussed in the first follow-up below.

6Follow-up questions

Why is Guava's EventBus discouraged?

Because it hides the connections between parts of the application. A publisher posts an event and some subscriber somewhere receives it, found by reflection through @Subscribe annotations, so reading the code no longer tells us who reacts to what. Errors in subscribers are passed to a handler instead of the publisher, which makes failures easy to miss, and there is no support for ordering guarantees, back-pressure or persistence. Guava's documentation itself recommends against it for new code and suggests explicit calls, dependency injection, or a proper messaging or reactive library. In Spring applications, ApplicationEventPublisher with @EventListener is the usual in-process alternative, and a message broker for anything across services.

Should we remove Guava from a Java 25 codebase?

Not as a goal in itself. We stop using the parts the JDK replaced, especially in new code, and keep the parts that add real value such as Multimap and RangeMap. Since many libraries bring Guava in transitively anyway, removing our direct use does not always remove the dependency, so the main benefit is clarity, not size.

Is Guava's ImmutableList faster than List.of?

Not meaningfully for typical sizes; both are compact, unmodifiable implementations. The reasons to choose one or the other are the type in the signature, ordering guarantees and builders, not speed.

7Conclusion

In this answer, we sorted Guava's features for a Java 25 codebase. Optional, null checks, simple joining, small immutable lists and file helpers have JDK replacements that new code should use. Multimap, Multiset, BiMap, Table, RangeSet and RangeMap have no JDK equivalent and remain useful, and ImmutableList and ImmutableMap still add ordering, builders and immutability in the type. The cache is in maintenance in favour of Caffeine, while hashing, primitive utilities, RateLimiter and EventBus need case-by-case judgement, with EventBus discouraged by Guava itself.

What to say in the interviewAbout 70 seconds aloud

Open with

A lot of Guava has been replaced by the JDK. Guava's Optional became java.util.Optional, null checks are Objects.requireNonNull, simple joining is String.join or Collectors.joining, small immutable lists are List.of and List.copyOf, and the file helpers are covered by java.nio.file.Files, so I'd use those in new code.

Then, if they want more

What Guava still does best is collection types the JDK doesn't have: Multimap, Multiset, BiMap, Table, RangeSet and RangeMap. Writing those by hand means repeating computeIfAbsent code or keeping two maps in sync. I also still like ImmutableList and ImmutableMap where the type matters: they document immutability in the signature, preserve insertion order unlike Map.of, and have convenient builders.

Guava's cache is in maintenance mode, and the recommended replacement is Caffeine, which has a similar API and better performance.

The rest is case by case: hashing like Murmur3 has no JDK equivalent, the primitives utilities overlap partly with the JDK, RateLimiter is beta and only works within one JVM, and EventBus is discouraged by Guava's own documentation because it hides dependencies and swallows errors, so in Spring I'd use application events or a message broker instead.

About this answer

Last updated
12 November 2026
Versions it names
Java 25, Java 11, Java 6, Java 8
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Which Guava features are still useful in a Java 25 codebase, and which have been...": https://scrivio-interview-library.netlify.app/java/utility-libraries/9901867e6b/