title: Why does java.util.Properties implement Map<Object,Object> and not Map<String,String>
body: <p>The <code>java.util.Properties</code> class is meant to represent a map where the keys and values are both Strings. This is because <code>Properties</code> objects are used to read <code>.properties</code> files, which are text files.</p>
  
  <p>So, why in Java 5 did they retrofit this class to implement <code>Map&lt;Object,Object&gt;</code> and not <code>Map&lt;String,String&gt;</code>? </p>
  
  <p>The <a href="http://java.sun.com/j2se/1.5.0/docs/api/" rel="noreferrer">javadoc</a> states:</p>
  
  <blockquote>
    <p>Because Properties inherits from Hashtable, the put and putAll methods can be applied to a Properties object. Their use is strongly discouraged as they allow the caller to insert entries whose keys or values are not Strings. The setProperty method should be used instead. If the store or save method is called on a "compromised" Properties object that contains a non-String key or value, the call will fail.</p>
  </blockquote>
  
  <p>Since the keys and values are both supposed to be Strings then why not enforce that statically by using the proper generic type?</p>
  
  <p>I guess making <code>Properties</code> implement <code>Map&lt;String,String&gt;</code> would not be fully backward compatible with code written for pre-Java 5. If you have older code that sticks non-strings into a Properties object then that code would no longer compile with Java 5. But... isn't that a good thing? Isn't the whole point of generics to catch such type errors at compile time?</p>