From ba20f65c93a82f93ed90bd98f1936300e636a7f4 Mon Sep 17 00:00:00 2001 From: Cowtowncoder Date: Wed, 13 May 2015 15:19:14 -0700 Subject: [PATCH] Minor fix related to #792, may help (but not necessarily fully solve) --- release-notes/VERSION | 1 + .../introspect/POJOPropertiesCollector.java | 16 ++++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/release-notes/VERSION b/release-notes/VERSION index 18c56e8d27..25d0de773e 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -16,6 +16,7 @@ Project: jackson-databind #785: Add handlings for classes which are available in `Thread.currentThread().getContextClassLoader()` (contributed by Charles A) - Fix handling of Enums wrt JSON Schema, when 'toString()' used for serialization +- Minor improvement to handling of implicit names for Creator parameters 2.5.3 (24-Apr-2015) diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java index 576f94a4b6..6f4f275b17 100644 --- a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java +++ b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertiesCollector.java @@ -463,7 +463,7 @@ protected void _addCreators() */ protected void _addCreatorParam(AnnotatedParameter param) { - // JDK 8, paranamer can give implicit name + // JDK 8, paranamer, Scala can give implicit name String impl = _annotationIntrospector.findImplicitPropertyName(param); if (impl == null) { impl = ""; @@ -488,17 +488,12 @@ protected void _addCreatorParam(AnnotatedParameter param) // shouldn't need to worry about @JsonIgnore, since creators only added // if so annotated - /* 14-Apr-2014, tatu: Not ideal, since we should not start with explicit name, ever; - * but with current set up we also can not just use empty name. - * This will cause failure for [#323] until we figure out a better way to handle - * the problem; possibly by creating a placeholder container for "anonymous" - * creator parameters. + /* 13-May-2015, tatu: We should try to start with implicit name, similar to how + * fields and methods work; but unlike those, we don't necessarily have + * implicit name to use (pre-Java8 at least). So: */ - POJOPropertyBuilder prop = expl ? _property(pn) : _property(impl); - // should use this (or similar) instead: -// POJOPropertyBuilder prop = _property(impl); + POJOPropertyBuilder prop = (expl && impl.isEmpty()) ? _property(pn) : _property(impl); prop.addCtor(param, pn, expl, true, false); - _creatorProperties.add(prop); } @@ -745,6 +740,7 @@ protected void _renameProperties() POJOPropertyBuilder prop = entry.getValue(); Collection l = prop.findExplicitNames(); + // no explicit names? Implicit one is fine as is if (l.isEmpty()) { continue;