Feature suggestion: Provide efficient way for nullable value lookup in Map

some-java-user-99206970363698485155 at vodafonemail.de some-java-user-99206970363698485155 at vodafonemail.de
Tue Jan 8 15:50:09 UTC 2019


Yes it is now possible to implement the methods `getKey(Object key)` and `getEntry(Object key)` 
requested by JDK-6552529 as default methods, however both would have to include that
"The default implementation returns the provided key. Overriding implementations may return the 
actual key used by the map."
In this case it is questionable how useful the methods actually are, e.g.
  Two key objects k1 and k2 with `k1.equals(k2)`
  Two objects m1 and m2 of different map implementations both containing k1.
  Then the following is possible:
  m1.getKey(k2) == k2 // true
  m2.getKey(k2) == k2 // false

> Brian Goetz <brian.goetz at oracle.com> hat am 7. Januar 2019 um 00:54 geschrieben:
> 
> 
> FYI, the comment about compatibility was obsoleted by the addition of 
> default methods in Java 8.


More information about the core-libs-dev mailing list