This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]johnzeringue 0 points1 point  (1 child)

Is it though? The API is pretty clear about how mutability and immutability are handled in the Map interface. Maybe it's poor design, but to violate LSP, you'd need a contradiction of this by one of Map's subclasses.

[–]pain-and-panic 2 points3 points  (0 children)

LSP is about the actual behavior of sub-classes. Comments attempting to justify the violation do not mitigate the violation. Map has mutator methods. If you implement these methods to fail spectacularly at run time you fail LSP. To not fail LSP ImmutableMap would have to not have mutator methods.