diff --git a/src/main/java/com/fasterxml/jackson/databind/BeanDescription.java b/src/main/java/com/fasterxml/jackson/databind/BeanDescription.java index 42ba47dddb..c11fbea072 100644 --- a/src/main/java/com/fasterxml/jackson/databind/BeanDescription.java +++ b/src/main/java/com/fasterxml/jackson/databind/BeanDescription.java @@ -74,7 +74,7 @@ protected BeanDescription(JavaType type) { * types of member object, such as return and argument types of * methods and constructors, and types of fields. * - * @deprecated Since 2.7, use {@link #resolveType(java.lang.reflect.Type)} instead. + * @deprecated Since 2.7, should not need to access bindings directly */ @Deprecated public abstract TypeBindings bindingsForBeanType(); @@ -82,7 +82,11 @@ protected BeanDescription(JavaType type) { /** * Method for resolving given JDK type, using this bean as the * generic type resolution context. + * + * @deprecated Since 2.8, should simply call getType of + * property accessor directly. */ + @Deprecated public abstract JavaType resolveType(java.lang.reflect.Type jdkType); /** 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 c18e43e602..b8f19603ff 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/BasicDeserializerFactory.java @@ -837,16 +837,11 @@ protected SettableBeanProperty constructCreatorProperty(DeserializationContext c metadata = PropertyMetadata.construct(req, desc, idx, def); } } - // 15-Oct-2015, tatu: Not 100% if context needed; removing it does not make any - // existing unit tests fail. Still seems like the right thing to do. - JavaType t0 = beanDesc.resolveType(param.getParameterType()); - BeanProperty.Std property = new BeanProperty.Std(name, t0, + JavaType t0 = param.getType(); + JavaType type = resolveTypeOverrides(ctxt, t0, param); + BeanProperty.Std property = new BeanProperty.Std(name, type, intr.findWrapperName(param), beanDesc.getClassAnnotations(), param, metadata); - JavaType type = resolveType(ctxt, beanDesc, t0, param); - if (type != t0) { - property = property.withType(type); - } // Is there an annotation that specifies exact deserializer? JsonDeserializer deser = findDeserializerFromAnnotation(ctxt, param); @@ -865,7 +860,7 @@ protected SettableBeanProperty constructCreatorProperty(DeserializationContext c typeDeser, beanDesc.getClassAnnotations(), param, index, injectableValueId, metadata); if (deser != null) { - // As per [Issue#462] need to ensure we contextualize deserializer before passing it on + // As per [databind#462] need to ensure we contextualize deserializer before passing it on deser = ctxt.handlePrimaryContextualization(deser, prop, type); prop = prop.withValueDeserializer(deser); } @@ -1856,14 +1851,15 @@ protected T modifyTypeByAnnotation(DeserializationContext c } /** - * Helper method used to resolve method return types and field - * types. The main trick here is that the containing bean may - * have type variable binding information (when deserializing - * using generic type passed as type reference), which is - * needed in some cases. + * Helper method used to resolve additional type-related annotation information + * like type overrides, or handler (serializer, deserializer) overrides, + * so that from declared field, property or constructor parameter type + * is used as the base and modified based on annotations, if any. + * + * @since 2.8 Renamed in 2.8, used to be called resolveType */ - protected JavaType resolveType(DeserializationContext ctxt, - BeanDescription beanDesc, JavaType type, AnnotatedMember member) + protected JavaType resolveTypeOverrides(DeserializationContext ctxt, + JavaType type, AnnotatedMember member) throws JsonMappingException { AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); @@ -1918,7 +1914,18 @@ protected JavaType resolveType(DeserializationContext ctxt, } return type; } - + + /** + * @deprecated since 2.8 call {@link #resolveTypeOverrides} instead. + */ + @Deprecated // since 2.8 + protected JavaType resolveType(DeserializationContext ctxt, + BeanDescription beanDesc, JavaType type, AnnotatedMember member) + throws JsonMappingException + { + return resolveTypeOverrides(ctxt, type, member); + } + protected EnumResolver constructEnumResolver(Class enumClass, DeserializationConfig config, AnnotatedMethod jsonValueMethod) { @@ -1934,6 +1941,10 @@ protected EnumResolver constructEnumResolver(Class enumClass, return EnumResolver.constructUnsafe(enumClass, config.getAnnotationIntrospector()); } + /** + * @deprecated since 2.8 call findJsonValueMethod on {@link BeanDescription} instead + */ + @Deprecated // not used, possibly remove as early as 2.9 protected AnnotatedMethod _findJsonValueFor(DeserializationConfig config, JavaType enumType) { if (enumType == null) { diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java index 58e1856f1d..663daabffc 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializerFactory.java @@ -697,7 +697,7 @@ protected SettableAnyProperty constructAnySetter(DeserializationContext ctxt, BeanProperty.Std property = new BeanProperty.Std(PropertyName.construct(setter.getName()), type, null, beanDesc.getClassAnnotations(), setter, PropertyMetadata.STD_OPTIONAL); - type = resolveType(ctxt, beanDesc, type, setter); + type = resolveTypeOverrides(ctxt, type, setter); /* AnySetter can be annotated with @JsonDeserialize (etc) just like a * regular setter... so let's see if those are used. @@ -738,7 +738,7 @@ protected SettableBeanProperty constructSettableProperty(DeserializationContext BeanProperty.Std property = new BeanProperty.Std(propDef.getFullName(), propType0, propDef.getWrapperName(), beanDesc.getClassAnnotations(), mutator, propDef.getMetadata()); - JavaType type = resolveType(ctxt, beanDesc, propType0, mutator); + JavaType type = resolveTypeOverrides(ctxt, propType0, mutator); // did type change? if (type != propType0) { property = property.withType(type); @@ -790,8 +790,8 @@ protected SettableBeanProperty constructSetterlessProperty(DeserializationContex // First: does the Method specify the deserializer to use? If so, let's use it. JsonDeserializer propDeser = findDeserializerFromAnnotation(ctxt, getter); type = modifyTypeByAnnotation(ctxt, getter, type); - // As per [Issue#501], need full resolution: - type = resolveType(ctxt, beanDesc, type, getter); + // As per [databind#501], need full resolution: + type = resolveTypeOverrides(ctxt, type, getter); TypeDeserializer typeDeser = type.getTypeHandler(); SettableBeanProperty prop = new SetterlessProperty(propDef, type, typeDeser, beanDesc.getClassAnnotations(), getter); diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/BasicBeanDescription.java b/src/main/java/com/fasterxml/jackson/databind/introspect/BasicBeanDescription.java index 692b1050a9..b48eb2477a 100644 --- a/src/main/java/com/fasterxml/jackson/databind/introspect/BasicBeanDescription.java +++ b/src/main/java/com/fasterxml/jackson/databind/introspect/BasicBeanDescription.java @@ -252,6 +252,7 @@ public TypeBindings bindingsForBeanType() { } @Override + @Deprecated // since 2.8 public JavaType resolveType(java.lang.reflect.Type jdkType) { if (jdkType == null) { return null;