On Jul 18, 2017 2:25 PM, "Rob Tompkins" <chtom...@gmail.com> wrote:

I'm stuck in the in-between here with the following thought: HashTable
certainly feels like a collection of objects, but it clearly extends
Dictionary and isn't in the collections family. But we are in java.util
here and not in java.lang, so that feels more like it could be in
collections. Plus properties are essentially a map, despite they're being
implemented on top of hashtable.


HashTable<K, V> extends Dictionary<K,V> implements Map<K,V>.

Of course,  Properties extends HashTable <Object, Object> because legacy.

In jdk 9, Properties still extends HashTable.
 However, HashTable now has a magic package private constructor
"HashTable(Void)", which is used by Properties to tell HashTable to go sit
in a corner, with all fields left set to default values.

Properties now uses a ConcurrentHashMap internally, with only a few methods
remaining synchronized. Everything gets delegated to the chm.

Still full of unchecked goodness.

And a great example of  how sometimes inheritance is so useless you just
compose and delegate anyway.

Simon

Reply via email to