Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6624527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:39:51+00:00 2026-05-25T21:39:51+00:00

As of Guava 10, MapMaker.softKeys is deprecated, and the corresponding method doesn’t exist in

  • 0

As of Guava 10, MapMaker.softKeys is deprecated, and the corresponding method doesn’t exist in CacheBuilder.

Why was this change made? What do I need to do with existing code that use it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:39:52+00:00Added an answer on May 25, 2026 at 9:39 pm

    I wrote the question because, initially, I did genuinely wonder why (as I had existing code that used softKeys). However, the reason was obvious on reflection and I decided to post it here, in case someone else also uses softKeys and was wondering the same thing.

    In short, the reason was that softKeys never made any sense in the first place. Thus, its initial inclusion was in itself a mistake, one which the Guava developers are rectifying via deprecation.

    In general, you use soft references if you want the object to stick around for a little after all the strong references are gone; in contrast, with weak references, the object usually gets collected soon once there are no strong or soft references left. This is useful for cached values that you want to hold on to temporarily, so that a lookup using the corresponding key will “revive” a strong reference for the value.

    However, this behaviour doesn’t make any sense for keys:

    • Since softKeys and weakKeys maps use an identity-based lookup, the only way to get at an entry of interest is to posess a strong reference to its key.† Thus, once there are no strong key references left, the entry is effectively dead (with no possibility of revival).
    • The only practical difference between softKeys and weakKeys is how long an entry remains in the map after all the strong references to its key are gone. Since such entries are dead anyway, using softKeys instead of weakKeys only delays the entry’s eviction, for no good reason.

    Thus, most times when coming across code that uses softKeys, a much more suitable replacement is weakKeys.

    † I am not considering the case of fetching the entry via iteration, or anything other than key-based lookup, since maps are primarily about key-based operations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Guava 10+, Google deprecated Files.deleteDirectoryContents() . JavaDoc says Deprecated. This method suffers from
Browsing through Guava libraries I saw this weird signature on the readLines method of
Guava libraries are powerful, but I’m not sure what all the possibilities of this
I love Google Guava and use it a lot, but there is one method
I'm using Guava-05-snapshot, with Sun's JDK 1.6 The code blows up executing this snippet:
I have the following code: new MapMaker().expireAfterAccess(SESSION_EXPIRATION, TimeUnit.MILLISECONDS).makeMap(); In guava 10 it said it
Does Guava provide a method to get a default value if a passed object
I've got a Guava Cache (or rather, I am migrating from MapMaker to Cache
MapMaker maximumSize in google guava library is marked as @Beta . It's a very
I am having trouble using the MapMaker from google-guava. Here is the code: package

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.