diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index 9c6ba0ed8a..eb8d7e0467 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -1183,6 +1183,10 @@ Yona Appletree (Yona-Appletree@github) property name is specified (2.12.0) +Youri Bonnaffé (youribonnaffe@github) + * Contributed #2709: Support for JDK 14 record types + (2.12.0) + David Bidorff (bidorffOL@github) * Reported, contributed fix for #2719: `FAIL_ON_IGNORED_PROPERTIES` does not throw on `READONLY` properties with an explicit name diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index d3be51e76a..03cbe45b66 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -38,6 +38,8 @@ Project: jackson-databind #2683: Explicitly fail (de)serialization of `java.time.*` types in absence of registered custom (de)serializers #2707: Improve description included in by `DeserializationContext.handleUnexpectedToken()` +#2709: Support for JDK 14 record types + (contributed by Youri B) #2719: `FAIL_ON_IGNORED_PROPERTIES` does not throw on `READONLY` properties with an explicit name (reported, fix contributed by David B) diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java b/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java index 09337a03f0..e9fcb537b2 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java @@ -555,7 +555,7 @@ protected void _addDeserializerConstructors(DeserializationContext ctxt, */ protected void _addRecordConstructor(DeserializationContext ctxt, BeanDescription beanDesc, CreatorCollector creators, - AnnotatedConstructor canonical, List names) + AnnotatedConstructor canonical, List implicitNames) throws JsonMappingException { final int argCount = canonical.getParameterCount(); @@ -565,7 +565,10 @@ protected void _addRecordConstructor(DeserializationContext ctxt, for (int i = 0; i < argCount; ++i) { final AnnotatedParameter param = canonical.getParameter(i); JacksonInject.Value injectable = intr.findInjectableValue(param); - final PropertyName name = PropertyName.construct(names.get(i)); + PropertyName name = intr.findNameForDeserialization(param); + if (name == null || name.isEmpty()) { + name = PropertyName.construct(implicitNames.get(i)); + } properties[i] = constructCreatorProperty(ctxt, beanDesc, name, i, param, injectable); } creators.addPropertyCreator(canonical, false, properties); diff --git a/src/main/java/com/fasterxml/jackson/databind/jdk14/JDK14Util.java b/src/main/java/com/fasterxml/jackson/databind/jdk14/JDK14Util.java index d8454ac7bc..f8b6e7ad70 100644 --- a/src/main/java/com/fasterxml/jackson/databind/jdk14/JDK14Util.java +++ b/src/main/java/com/fasterxml/jackson/databind/jdk14/JDK14Util.java @@ -3,7 +3,6 @@ import java.lang.reflect.Method; import java.util.Collections; import java.util.List; -import java.util.Map; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator.Mode; @@ -11,11 +10,7 @@ import com.fasterxml.jackson.databind.BeanDescription; import com.fasterxml.jackson.databind.DeserializationConfig; import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.deser.impl.CreatorCollector; import com.fasterxml.jackson.databind.introspect.AnnotatedConstructor; -import com.fasterxml.jackson.databind.introspect.AnnotatedWithParams; -import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition; -import com.fasterxml.jackson.databind.introspect.VisibilityChecker; import com.fasterxml.jackson.databind.util.ClassUtil; /**