[concurrency-interest] Navigable{Map, Set} must not inherit fromSorted{Map, Set}

Tim Peierls tim at peierls.net
Mon Sep 5 10:47:14 EDT 2005

Remi Forax wrote:
> I can invert the test but this code was written two years ago and not by me.
> It works so i prefer not to touch it if it's possible.
> I have to maintain the program and extends some specific parts.
> It seems not a good idea to have to rewrite a code because i want to 
> retrofit a class.
> The fact that NavigableSet inherits from SortedSet prevents me to 
> retrofit my class without changing some other parts of the program.

I'm encountering similar difficulties. I wrote some classes back before Collections came out that 
have been working perfectly for years. I'd like to retrofit them to implement Collection 
interfaces, but the interface hierarchy used by Collections is incompatible with algorithms I am 
using. I could go back and modify my code, but it depends on some intricate instanceof tests that 
I'm afraid are too delicate to mess with (and I'm not sure at this point exactly how they work), 
so instead I'd like to ask if it would be possible to change the Collections interface hierarchy 
so that Map implements Set.

I've done some initial work to verify that this could be accomplished in a way that would not 
cause any problems for existing code. If anyone is interested I can describe the technique.


More information about the Concurrency-interest mailing list