@@ -0,0 +1,2223 @@
+package com.fasterxml.jackson.databind.seq;%0A%0Aimport java.io.IOException;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;%0Aimport com.fasterxml.jackson.annotation.PropertyAccessor;%0Aimport com.fasterxml.jackson.core.JsonGenerator;%0Aimport com.fasterxml.jackson.core.JsonProcessingException;%0Aimport com.fasterxml.jackson.databind.*;%0Aimport com.fasterxml.jackson.databind.SerializerProvider;%0Aimport com.fasterxml.jackson.databind.module.SimpleModule;%0Aimport com.fasterxml.jackson.databind.type.MapType;%0A%0A// for %5Bdatabind#827%5D%0Apublic class PolyMapWriterTest extends BaseMapTest%0A%7B%0A    static class CustomKey %7B%0A        String a;%0A        int b;%0A%0A        public String toString() %7B return %22BAD-KEY%22; %7D%0A    %7D%0A    %0A    public class CustomKeySerializer extends JsonSerializer%3CCustomKey%3E %7B%0A        @Override%0A        public void serialize(CustomKey key, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException %7B%0A            jsonGenerator.writeFieldName(key.a + %22,%22 + key.b);%0A        %7D%0A    %7D%0A    %0A    @Test%0A    public void testPolyCustomKeySerializer() throws Exception %7B%0A        ObjectMapper mapper = new ObjectMapper();%0A        mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE);%0A        mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);%0A        mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);%0A        %0A        SimpleModule module = new SimpleModule(%22keySerializerModule%22);%0A        module.addKeySerializer(CustomKey.class, new CustomKeySerializer());%0A        mapper.registerModule(module);%0A%0A        Map%3CCustomKey, String%3E map = new HashMap%3CCustomKey, String%3E();%0A        CustomKey key = new CustomKey();%0A        key.a = %22foo%22;%0A        key.b = 1;%0A        map.put(key, %22bar%22);%0A%0A        final MapType type = mapper.getTypeFactory().constructMapType(%0A                Map.class, CustomKey.class, String.class);%0A        final ObjectWriter writer = mapper.writerFor(type);%0A        String json = writer.writeValueAsString(map);%0A               %0A        Assert.assertEquals(%22%5B%5C%22java.util.HashMap%5C%22,%7B%5C%22foo,1%5C%22:%5C%22bar%5C%22%7D%5D%22, json);%0A    %7D%0A%0A%7D%0A

add unit test for #827 to show the problem