On Mon, 22 Mar 2021 16:41:10 GMT, Daniel Fuchs <dfu...@openjdk.org> wrote:

>> Actually, I just noticed that the `List<String>`s are still modifiable. The 
>> constructor might have to create an intermediate `Map<String,List<String>>` 
>> with unmodifiable Lists and then you create an unmodifiable Map from that. 
>> 
>> As regards the comment above, yes you want to maintain that behavior. Could 
>> you normalize the key here and then just return `map.get(key).get(0)` (with 
>> suitable null checks)?
>
> Argh. Good catch Michael.  So now we'd also have to reimplement values(), 
> entrySet(), and get() to wrap things into unmodifiableList... Or could we get 
> away with providing an immutable snapshot instead of an immutable view? (we 
> don't need to normalize anything though since the normalization is done 
> already by the header's object wrapped in the UnmodifiableMap)

Thanks for catching that. The `List<String>` is now wrapped in an unmodifiable 
map, and some cases were added to the test.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3032

Reply via email to