You end up with exactly the same problems as you normally get when mutating an object which is used as a key in a hash-based map, and this is easily demonstrated:
import java.util.*;
import com.google.common.collect.*;
public class Test {
public static void main(String[] args) {
HashBiMap<String, HashSet<String>> bimap = HashBiMap.create();
HashSet<String> set = new HashSet<>();
bimap.put("foo", set);
System.out.println(bimap.inverse().get(set)); // foo
set.add("bar");
System.out.println(bimap.inverse().get(set)); // null
}
}
So no, it's not safe to do this. Ideally, you should use an immutable type as the key to completely prevent this from happening rather than relying on being careful with when you mutate the objects in question.