cowwoc wrote:
I noticed that TreeMap (and maybe other classes) require a user to either
pass in a Comparator or ensure that all keys must implement Comparable. The
TreeMap code then uses a utility method whenever it needs to compare two
keys:
I'm not going to comment about performance, but there is a problem with
serialisation.
TreeMap.comparator is final (and non-transient).
TreeMaps serialised with earlier versions will be deserialised with null
comparator. So, comparator would either need to be made non-final or
sun.misc.Unsafe used.
For the serialisation case, it would be necessary to change writeObject
to use putFields rather than defaultWriteObject (not very nice, but not
half as nasty as I originally thought).
Tom Hawtin