title: Jackson JDK8 Data Type and Parameter Names modules don't play together
body: <p>It seems to me Jackson JDK8 Data Type module occasionally ignores Parameter Names module which seems a little bit surprising, given that both demand JDK8 and solve specific-use cases with regards to JDK8. </p>
  
  <p>The issue here is that I could not find a way to make JSON deserialization work without parameter names specified explicitly (which is what Parameter Names module is supposed to be all about). It is also exhibiting this behaviour only when trying to pass in JDK8-specific type (<code>Optional&lt;T&gt;</code>) in container object constructor (i.e. normally, this works and I have tested that). The code is compiled with javac parameter <code>-parameters</code>.</p>
  
  <p>The question is - how to make it work so that I can leverage the Parameter Names module (i.e. don't need to specify annotation+value in the constructor and let it figure out the property name by argument name)?</p>
  
  <p>I may be mistaken and haven't looked at the code under the bonnet so I'd like to hear if there is something I have missed.</p>
  
  <p>Let's consider this simple example.</p>
  
  <p>Version stack (all latest versions as of this writing):</p>
  
  <pre><code>private val jacksonVer = "2.6.1"
  private val jacksonCore: ModuleID = "com.fasterxml.jackson.core" % "jackson-core" % jacksonVer withSources() withJavadoc()
  private val jacksonDataBind: ModuleID = "com.fasterxml.jackson.core" % "jackson-databind" % jacksonVer withSources() withJavadoc()
  private val jacksonAnnotations: ModuleID = "com.fasterxml.jackson.core" % "jackson-annotations" % jacksonVer withSources() withJavadoc()
  private val jacksonParamNames: ModuleID = "com.fasterxml.jackson.module" % "jackson-module-parameter-names" % "2.6.2" withSources() withJavadoc()
  private val jacksonJdk8DataType: ModuleID = "com.fasterxml.jackson.datatype" % "jackson-datatype-jdk8" % "2.4.3" withSources() withJavadoc()
  </code></pre>
  
  <p>Container:</p>
  
  <pre><code>private static class SimpleTest {
      @JsonProperty private Optional&lt;String&gt; s1;
      @JsonProperty private Optional&lt;String&gt; s2;
      @JsonProperty private Map&lt;String, String&gt; map;
  
      private SimpleTest(@JsonProperty("s1") Optional&lt;String&gt; s1, @JsonProperty("s2") Optional&lt;String&gt; s2, @JsonProperty("map") Map&lt;String, String&gt; map) {
          this.s1 = s1;
          this.s2 = s2;
          this.map = map;
      }
  
      static SimpleTest of(Optional&lt;String&gt; s1, Optional&lt;String&gt; s2, Map&lt;String, String&gt; m) {
          return new SimpleTest(s1, s2, m);
      }
  }
  </code></pre>
  
  <p>Serialization:</p>
  
  <pre><code>@Test
  public void testSer() throws JsonProcessingException {
      SimpleTest test = SimpleTest.of(Optional.of("a"), Optional.empty(), Collections.emptyMap());
      System.out.println(JacksonUtil.getMapper().writeValueAsString(test));
  }
  </code></pre>
  
  <p>Deserialization:</p>
  
  <pre><code>@Test
  public void testDeser() throws IOException {
      String json = "{\n" +
              "  \"s1\" : \"a\",\n" +
              "  \"map\" : { }\n" +
              "}";
      JacksonUtil.getMapper().readValue(json, SimpleTest.class);
  }
  </code></pre>
  
  <p>Running <code>testSer()</code> with such a container yields:</p>
  
  <pre><code>{
    "s1" : "a",
    "s2" : null,
    "map" : { }
  }
  </code></pre>
  
  <p>Running <code>testDeser()</code> with input such as this</p>
  
  <pre><code>{
    "s1" : "a",
    "map" : { }
  }
  </code></pre>
  
  <p>also works, and yields expected results (<code>s1</code> has value, <code>s2</code> is <code>Optional.empty</code> and <code>map</code> is empty) but only if the container constructor is defined as above. I could <em>not</em> get it work in following combinations:<br>
  1) </p>
  
  <pre><code>private SimpleTest(Optional&lt;String&gt; s1, Optional&lt;String&gt; s2, Map&lt;String, String&gt; map) {...}
  </code></pre>
  
  <p>2) </p>
  
  <pre><code>private SimpleTest(@JsonProperty Optional&lt;String&gt; s1, @JsonProperty Optional&lt;String&gt; s2, @JsonProperty Map&lt;String, String&gt; map) {...}
  </code></pre>
  
  <p>By rights, both should work but they don't - both approaches yield the following stacktrace:</p>
  
  <pre><code>com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class com._3esi.load.bootstrap.ScratchPad$SimpleTest]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)
   at [Source: {
    "s1" : "a",
    "map" : { }
  }; line: 2, column: 3]
      at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)
      at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1106)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:294)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:131)
      at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3731)
      at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2724)
  </code></pre>
  
  <p>What am I missing here?</p>