title: Can not construct Map key of type java.lang.Class from String: unable to parse key as Class
body: <p>I am having problems deserializing an object containing map with <code>Class</code> as key:</p>
  
  <pre><code>public class TestSerializeMap {
  
      public static class TestClass {
          private Map&lt;Class&lt;? extends Object&gt;, String&gt; map = new HashMap&lt;&gt;();
  
          public TestClass() {
          }
  
          public Map&lt;Class&lt;? extends Object&gt;, String&gt; getMap() {
              return map;
          }
      }
  
      @Test
      public void testPropertyMapWithClassAsKey() throws Exception {
          TestClass testClass = new TestClass();
          testClass.getMap().put(ArrayList.class, "ArrayList");
          testClass.getMap().put(HashMap.class, "HashMap");
  
          ObjectMapper mapper = new ObjectMapper();
  
          String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(testClass);
          System.out.println(json);
          mapper.readValue(json, TestClass.class);
      }
  }
  </code></pre>
  
  <p>Throws this exception:</p>
  
  <pre><code>com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not construct     Map key of type java.lang.Class from String "class java.util.ArrayList": not a valid representation: Can not construct Map key of type java.lang.Class from String "class java.util.ArrayList": unable to parse key as Class
   at [Source: {
    "map" : {
      "class java.util.ArrayList" : "ArrayList",
      "class java.util.HashMap" : "HashMap"
    }
  }; line: 3, column: 5]
   at [Source: {
    "map" : {
      "class java.util.ArrayList" : "ArrayList",
      "class java.util.HashMap" : "HashMap"
    }
  }; line: 3, column: 5] (through reference chain: org.test.TestClass["map"])
      at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:55)
      at com.fasterxml.jackson.databind.DeserializationContext.weirdKeyException(DeserializationContext.java:913)
      at com.fasterxml.jackson.databind.deser.std.StdKeyDeserializer.deserializeKey(StdKeyDeserializer.java:131)
      at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBind(MapDeserializer.java:404)
      at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:333)
      at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:25)
      ...
  </code></pre>
  
  <p>When I am trying to serialize the map directly:</p>
  
  <pre><code>@Test
  public void testMapWithClassAsKey() throws Exception {
      Map&lt;Class&lt;? extends Object&gt;, String&gt; map = new HashMap&lt;&gt;();
      map.put(ArrayList.class, "ArrayList");
      map.put(HashMap.class, "HashMap");
  
      ObjectMapper mapper = new ObjectMapper();
  
      String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map);
      System.out.println(json);
      mapper.readValue(json, Map.class);
  }
  </code></pre>
  
  <p>Then it works correctly.
  What am I missing in my first test?</p>
  
  <p>EDIT:</p>
  
  <p>Found out that the second test was incorrect. It should be:</p>
  
  <pre><code>@Test
  public void testMapWithClassAsKey() throws Exception {
      Map&lt;Class&lt;? extends Object&gt;, String&gt; map = new HashMap&lt;&gt;();
      map.put(ArrayList.class, "ArrayList");
      map.put(HashMap.class, "HashMap");
  
      ObjectMapper mapper = new ObjectMapper();
  
      String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map);
      System.out.println(json);
      mapper.readValue(json, new TypeReference&lt;Map&lt;Class&lt;? extends Object&gt;, String&gt;&gt;(){});
  }
  </code></pre>
  
  <p>Now it fails with same exception as the first one.</p>