On 04/19/2017 11:49 AM, Peter Levart wrote:
I was not aware of the new Map.ofEntries method. Nice to see more
space efficient map implementations being added to the JDK.
Admittedly, I used this method in a way not envisioned by the author.
Maybe there's a reason there is no Map.copyOf(Map) method there, which
would make this even simpler. If there was one, it would be too easy
to (mis)use it instead of Collections.unmodifiableMap(Map), albeit
with a slightly different semantics, and force re-hashing-copying of
big maps where there is no need to do that. But it would be a pretty
nice replacement for the following idiom:
Collections.unmodifiableMap(new HashMap<>(someMap))
Sometimes I wish that besides public, protected, "package-private" and
private, Java also had an "expert protected" access modifier ;-)
Regards, Peter