You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current way entrySet() is handled in unmodifiable wrapper is wrong—users can still modify the map using Entry.setValue(). An entirely custom unmodifiable wrapper is necessary (as the JDK does).
The text was updated successfully, but these errors were encountered:
Because making an entry set unmodifiable simply means that you cannot add or remove entries. It does not prevent you from reading an entry and invoking setValue(), thus modifying the underlying collection. Key sets and value collections do not have this problem.
Ah, I see.
I think It can be done without defining a new composition class from scratch. Just make a (package private) variantion of unmodifiableSet that will also wrap the Entry values. (Best approach would probably be a subclass of UnmodifiableSet, and override any ways of getting values to instead return the wrapper Entrys)
Would require some care, but we won't have to implement a whole wrapper from scratch.
The current way entrySet() is handled in unmodifiable wrapper is wrong—users can still modify the map using Entry.setValue(). An entirely custom unmodifiable wrapper is necessary (as the JDK does).
The text was updated successfully, but these errors were encountered: