title: Why won't this generic java code compile?
body: <p>In this simplified example I have a generic class, and a method that returns a Map regardless of the type parameter.  Why does the compiler wipe out the types on the map when I don't specify a type on the containing class?</p>
  
  <pre><code>import java.util.Map;
  
  public class MyClass&lt;T&gt;
  {
      public Map&lt;String, String&gt; getMap()
      {   
          return null;
      }
  
      public void test()
      {   
          MyClass&lt;Object&gt; success = new MyClass&lt;Object&gt;();
          String s = success.getMap().get("");
  
          MyClass unchecked = new MyClass();
          Map&lt;String, String&gt; map = unchecked.getMap();  // Unchecked warning, why?
          String s2 = map.get("");
  
          MyClass fail = new MyClass();
          String s3 = fail.getMap().get("");  // Compiler error, why?
      }
  }
  </code></pre>
  
  <p>I get this compiler error.</p>
  
  <pre><code>MyClass.java:20: incompatible types
  found   : java.lang.Object
  required: java.lang.String
                  String s3 = fail.getMap().get("");  // Compiler error
  </code></pre>