From 0a04ff2443e7a7fff566257e33e8978f6331a77d Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 14 Apr 2025 20:18:43 -0700 Subject: [PATCH 1/3] Fixed #5094: add lazy construction of BeanDescription for deserialization --- release-notes/VERSION | 2 + .../databind/AbstractTypeResolver.java | 4 +- .../jackson/databind/BeanDescription.java | 4 + .../databind/DeserializationContext.java | 28 ++- .../databind/deser/AbstractDeserializer.java | 12 +- .../deser/BasicDeserializerFactory.java | 226 +++++++++--------- .../deser/BeanDeserializerBuilder.java | 31 ++- .../deser/BeanDeserializerFactory.java | 174 +++++++------- .../databind/deser/DeserializerCache.java | 44 ++-- .../databind/deser/DeserializerFactory.java | 22 +- .../jackson/databind/deser/Deserializers.java | 52 ++-- .../deser/ValueDeserializerModifier.java | 22 +- .../databind/deser/ValueInstantiator.java | 9 +- .../databind/deser/ValueInstantiators.java | 10 +- .../databind/deser/bean/BeanDeserializer.java | 4 +- .../deser/bean/BeanDeserializerBase.java | 8 +- .../deser/bean/BuilderBasedDeserializer.java | 11 +- .../databind/deser/bean/CreatorCollector.java | 20 +- .../deser/std/StdValueInstantiator.java | 2 +- .../exc/InvalidDefinitionException.java | 5 + .../ext/javatime/JavaTimeInitializer.java | 6 +- .../deser/JavaTimeDeserializerModifier.java | 2 +- .../jsontype/impl/SubTypeValidator.java | 4 +- .../module/SimpleAbstractTypeResolver.java | 2 +- .../databind/module/SimpleDeserializers.java | 18 +- .../module/SimpleValueInstantiators.java | 6 +- .../deser/CustomDeserializersTest.java | 4 +- .../BeanDeserializerModifier4216Test.java | 3 +- .../BeanDeserializerModifier4356Test.java | 3 +- .../deser/bean/BeanDeserializerTest.java | 46 ++-- .../deser/creators/EnumCreatorTest.java | 5 +- .../creators/JsonCreatorNoArgs4777Test.java | 7 +- .../creators/NullValueViaCreatorTest.java | 2 +- .../creators/TestCustomValueInstDefaults.java | 10 +- .../module/TestCustomEnumKeyDeserializer.java | 2 +- .../databind/module/TestTypeModifiers.java | 11 +- .../databind/tofix/NodeContext2049Test.java | 7 +- 37 files changed, 441 insertions(+), 387 deletions(-) diff --git a/release-notes/VERSION b/release-notes/VERSION index cde52a338b..06c66d7708 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -9,6 +9,8 @@ Versions: 3.x (for earlier see VERSION-2.x) #5093: Change the way `BeanDescription` passed during serializer construction to use `Supplier` +#5094: Change the way `BeanDescription` passed during deserializer construction + to use `Supplier` 3.0.0-rc3 (13-Apr-2025) diff --git a/src/main/java/tools/jackson/databind/AbstractTypeResolver.java b/src/main/java/tools/jackson/databind/AbstractTypeResolver.java index f024cbe226..9d1e141fd2 100644 --- a/src/main/java/tools/jackson/databind/AbstractTypeResolver.java +++ b/src/main/java/tools/jackson/databind/AbstractTypeResolver.java @@ -39,14 +39,14 @@ public JavaType findTypeMapping(DeserializationConfig config, JavaType type) { * including defaulting. * * @param config Configuration in use - * @param typeDesc Description of the POJO type to resolve + * @param typeDescRef Description of the POJO type to resolve * * @return Resolved concrete type (which should retain generic * type parameters of input type, if any), if resolution succeeds; * null if resolver does not know how to resolve given type */ public JavaType resolveAbstractType(DeserializationConfig config, - BeanDescription typeDesc) { + BeanDescription.Supplier typeDescRef) { return null; } } diff --git a/src/main/java/tools/jackson/databind/BeanDescription.java b/src/main/java/tools/jackson/databind/BeanDescription.java index ec7e5b7095..2952956180 100644 --- a/src/main/java/tools/jackson/databind/BeanDescription.java +++ b/src/main/java/tools/jackson/databind/BeanDescription.java @@ -323,6 +323,10 @@ public AnnotatedClass getClassInfo() { return get().getClassInfo(); } + public Annotations getClassAnnotations() { + return get().getClassAnnotations(); + } + @Override public BeanDescription get() { if (_beanDesc == null) { diff --git a/src/main/java/tools/jackson/databind/DeserializationContext.java b/src/main/java/tools/jackson/databind/DeserializationContext.java index 28937cda1d..85626214ce 100644 --- a/src/main/java/tools/jackson/databind/DeserializationContext.java +++ b/src/main/java/tools/jackson/databind/DeserializationContext.java @@ -536,12 +536,31 @@ public BeanDescription introspectBeanDescriptionForCreation(JavaType type) { return classIntrospector().introspectForCreation(type); } + public BeanDescription.Supplier lazyIntrospectBeanDescriptionForCreation(JavaType type) { + return new BeanDescription.Supplier(type) { + @Override + public BeanDescription _construct(JavaType forType) { + return introspectBeanDescriptionForCreation(forType); + } + }; + } + public BeanDescription introspectBeanDescriptionForBuilder(JavaType builderType, BeanDescription valueTypeDesc) { return classIntrospector().introspectForDeserializationWithBuilder(builderType, valueTypeDesc); } + public BeanDescription.Supplier lazyIntrospectBeanDescriptionForBuilder(final JavaType builderType, + final BeanDescription valueTypeDesc) { + return new BeanDescription.Supplier(builderType) { + @Override + public BeanDescription _construct(JavaType forType) { + return introspectBeanDescriptionForBuilder(forType, valueTypeDesc); + } + }; + } + /* /********************************************************************** /* Misc config access @@ -1890,8 +1909,15 @@ public T reportBadTypeDefinition(BeanDescription bean, * regarding specific property (of a type), unrelated to actual JSON content to map. * Default behavior is to construct and throw a {@link DatabindException}. */ + public T reportBadPropertyDefinition(BeanDescription.Supplier beanDescRef, + BeanPropertyDefinition prop, String msg, Object... msgArgs) + throws DatabindException + { + return reportBadPropertyDefinition(beanDescRef.get(), prop, msg, msgArgs); + } + public T reportBadPropertyDefinition(BeanDescription bean, BeanPropertyDefinition prop, - String msg, Object... msgArgs) + String msg, Object... msgArgs) throws DatabindException { msg = _format(msg, msgArgs); diff --git a/src/main/java/tools/jackson/databind/deser/AbstractDeserializer.java b/src/main/java/tools/jackson/databind/deser/AbstractDeserializer.java index 1ca3d85add..e805bb6617 100644 --- a/src/main/java/tools/jackson/databind/deser/AbstractDeserializer.java +++ b/src/main/java/tools/jackson/databind/deser/AbstractDeserializer.java @@ -52,10 +52,10 @@ public class AbstractDeserializer * to bind) */ public AbstractDeserializer(BeanDeserializerBuilder builder, - BeanDescription beanDesc, Map backRefProps, + Map backRefProps, Map props) { - _baseType = beanDesc.getType(); + _baseType = builder.getType(); _objectIdReader = builder.getObjectIdReader(); _backRefProperties = backRefProps; _properties = props; @@ -66,9 +66,9 @@ public AbstractDeserializer(BeanDeserializerBuilder builder, _acceptDouble = (cls == Double.TYPE) || cls.isAssignableFrom(Double.class); } - protected AbstractDeserializer(BeanDescription beanDesc) + protected AbstractDeserializer(JavaType baseType) { - _baseType = beanDesc.getType(); + _baseType = baseType; _objectIdReader = null; _backRefProperties = null; Class cls = _baseType.getRawClass(); @@ -96,8 +96,8 @@ protected AbstractDeserializer(AbstractDeserializer base, * Factory method used when constructing instances for non-POJO types, like * {@link java.util.Map}s. */ - public static AbstractDeserializer constructForNonPOJO(BeanDescription beanDesc) { - return new AbstractDeserializer(beanDesc); + public static AbstractDeserializer constructForNonPOJO(BeanDescription.Supplier beanDescRef) { + return new AbstractDeserializer(beanDescRef.getType()); } @Override diff --git a/src/main/java/tools/jackson/databind/deser/BasicDeserializerFactory.java b/src/main/java/tools/jackson/databind/deser/BasicDeserializerFactory.java index a6c01189c7..a2edea8c98 100644 --- a/src/main/java/tools/jackson/databind/deser/BasicDeserializerFactory.java +++ b/src/main/java/tools/jackson/databind/deser/BasicDeserializerFactory.java @@ -139,14 +139,14 @@ public final DeserializerFactory withValueInstantiators(ValueInstantiators insta */ @Override public ValueInstantiator findValueInstantiator(DeserializationContext ctxt, - BeanDescription beanDesc) + BeanDescription.Supplier beanDescRef) { final DeserializationConfig config = ctxt.getConfig(); final boolean hasCustom = _factoryConfig.hasValueInstantiators(); ValueInstantiator instantiator = null; // Check @JsonValueInstantiator before anything else - AnnotatedClass ac = beanDesc.getClassInfo(); + AnnotatedClass ac = beanDescRef.getClassInfo(); Object instDef = config.getAnnotationIntrospector().findValueInstantiator(ctxt.getConfig(), ac); if (instDef != null) { instantiator = _valueInstantiatorInstance(config, ac, instDef); @@ -154,13 +154,13 @@ public ValueInstantiator findValueInstantiator(DeserializationContext ctxt, if (instantiator == null) { // Second: see if some of standard Jackson/JDK types might provide value // instantiators. - instantiator = JDKValueInstantiators.findStdValueInstantiator(config, beanDesc.getBeanClass()); + instantiator = JDKValueInstantiators.findStdValueInstantiator(config, beanDescRef.getBeanClass()); // Third: custom value instantiators via provider? if (instantiator == null) { if (hasCustom) { for (ValueInstantiators insts : _factoryConfig.valueInstantiators()) { - instantiator = insts.findValueInstantiator(config, beanDesc); + instantiator = insts.findValueInstantiator(config, beanDescRef); if (instantiator != null) { break; } @@ -168,7 +168,7 @@ public ValueInstantiator findValueInstantiator(DeserializationContext ctxt, } // Fourth: create default one, if no custom if (instantiator == null) { - instantiator = _constructDefaultValueInstantiator(ctxt, beanDesc); + instantiator = _constructDefaultValueInstantiator(ctxt, beanDescRef); } } } @@ -176,17 +176,17 @@ public ValueInstantiator findValueInstantiator(DeserializationContext ctxt, // finally: anyone want to modify ValueInstantiator? if (hasCustom) { for (ValueInstantiators insts : _factoryConfig.valueInstantiators()) { - instantiator = insts.modifyValueInstantiator(config, beanDesc, instantiator); + instantiator = insts.modifyValueInstantiator(config, beanDescRef, instantiator); // let's do sanity check; easier to spot buggy handlers if (instantiator == null) { - ctxt.reportBadTypeDefinition(beanDesc, + ctxt.reportBadTypeDefinition(beanDescRef, "Broken registered ValueInstantiators (of type %s): returned null ValueInstantiator", insts.getClass().getName()); } } } if (instantiator != null) { - instantiator = instantiator.createContextual(ctxt, beanDesc); + instantiator = instantiator.createContextual(ctxt, beanDescRef); } return instantiator; @@ -197,16 +197,16 @@ public ValueInstantiator findValueInstantiator(DeserializationContext ctxt, * using annotations (like @JsonCreator) and visibility rules */ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationContext ctxt, - BeanDescription beanDesc) + BeanDescription.Supplier beanDescRef) { final MapperConfig config = ctxt.getConfig(); - final PotentialCreators potentialCreators = beanDesc.getPotentialCreators(); + final PotentialCreators potentialCreators = beanDescRef.get().getPotentialCreators(); final ConstructorDetector ctorDetector = config.getConstructorDetector(); // need to construct suitable visibility checker: - final VisibilityChecker vchecker = config.getDefaultVisibilityChecker(beanDesc.getBeanClass(), - beanDesc.getClassInfo()); + final VisibilityChecker vchecker = config.getDefaultVisibilityChecker(beanDescRef.getBeanClass(), + beanDescRef.getClassInfo()); - final CreatorCollector creators = new CreatorCollector(beanDesc, config); + final CreatorCollector creators = new CreatorCollector(config, beanDescRef.getType()); // 21-May-2024, tatu: [databind#4515] Rewritten to use PotentialCreators if (potentialCreators.hasPropertiesBased()) { @@ -218,7 +218,7 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo creators.setDefaultCreator(primaryPropsBased.creator()); } else { // Start by assigning the primary (and only) properties-based creator - _addSelectedPropertiesBasedCreator(ctxt, beanDesc, creators, + _addSelectedPropertiesBasedCreator(ctxt, beanDescRef, creators, CreatorCandidate.construct(config, primaryPropsBased.creator(), primaryPropsBased.propertyDefs())); } @@ -226,15 +226,15 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo // Continue with explicitly annotated delegating Creators boolean hasExplicitDelegating = _addExplicitDelegatingCreators(ctxt, - beanDesc, creators, + beanDescRef, creators, potentialCreators.getExplicitDelegating()); // constructors only usable on concrete types: - if (beanDesc.getType().isConcrete()) { + if (beanDescRef.getType().isConcrete()) { // 25-Jan-2017, tatu: As per [databind#1501], [databind#1502], [databind#1503], best // for now to skip attempts at using anything but no-args constructor (see // `InnerClassProperty` construction for that) - final boolean isNonStaticInnerClass = beanDesc.isNonStaticInnerClass(); + final boolean isNonStaticInnerClass = beanDescRef.get().isNonStaticInnerClass(); if (isNonStaticInnerClass) { // TODO: look for `@JsonCreator` annotated ones, throw explicit exception? } else { @@ -243,7 +243,7 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo // in list of constructors, so needs to be handled separately. // However, we may have added one for 0-args Factory method earlier, so: if (!creators.hasDefaultCreator()) { - AnnotatedConstructor defaultCtor = beanDesc.findDefaultConstructor(); + AnnotatedConstructor defaultCtor = beanDescRef.get().findDefaultConstructor(); if (defaultCtor != null) { creators.setDefaultCreator(defaultCtor); } @@ -251,9 +251,9 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo // 18-Sep-2020, tatu: Although by default implicit introspection is allowed, 2.12 // has settings to prevent that either generally, or at least for JDK types - final boolean findImplicit = ctorDetector.shouldIntrospectorImplicitConstructors(beanDesc.getBeanClass()); + final boolean findImplicit = ctorDetector.shouldIntrospectorImplicitConstructors(beanDescRef.getBeanClass()); if (findImplicit) { - _addImplicitDelegatingConstructors(ctxt, beanDesc, vchecker, + _addImplicitDelegatingConstructors(ctxt, beanDescRef, vchecker, creators, potentialCreators.getImplicitDelegatingConstructors()); } @@ -311,7 +311,7 @@ public ValueInstantiator _valueInstantiatorInstance(DeserializationConfig config */ private boolean _addExplicitDelegatingCreators(DeserializationContext ctxt, - BeanDescription beanDesc, + BeanDescription.Supplier beanDescRef, CreatorCollector creators, List potentials) { @@ -319,14 +319,14 @@ private boolean _addExplicitDelegatingCreators(DeserializationContext ctxt, boolean added = false; for (PotentialCreator ctor : potentials) { - added |= _addExplicitDelegatingCreator(ctxt, beanDesc, creators, + added |= _addExplicitDelegatingCreator(ctxt, beanDescRef, creators, CreatorCandidate.construct(config, ctor.creator(), null)); } return added; } private void _addImplicitDelegatingConstructors(DeserializationContext ctxt, - BeanDescription beanDesc, VisibilityChecker vchecker, + BeanDescription.Supplier beanDescRef, VisibilityChecker vchecker, CreatorCollector creators, List potentials) { @@ -360,12 +360,12 @@ private void _addImplicitDelegatingConstructors(DeserializationContext ctxt, if (injectable != null) { ++injectCount; - properties[i] = constructCreatorProperty(ctxt, beanDesc, null, i, param, injectable); + properties[i] = constructCreatorProperty(ctxt, beanDescRef, null, i, param, injectable); continue; } NameTransformer unwrapper = intr.findUnwrappingNameTransformer(config, param); if (unwrapper != null) { - properties[i] = constructCreatorProperty(ctxt, beanDesc, + properties[i] = constructCreatorProperty(ctxt, beanDescRef, UnwrappedPropertyHandler.creatorParamName(i), i, param, null); } } @@ -411,7 +411,7 @@ private void _addImplicitDelegatingFactories(DeserializationContext ctxt, * Helper method called when there is the explicit "is-creator" with mode of "delegating" */ private boolean _addExplicitDelegatingCreator(DeserializationContext ctxt, - BeanDescription beanDesc, CreatorCollector creators, + BeanDescription.Supplier beanDescRef, CreatorCollector creators, CreatorCandidate candidate) { // Somewhat simple: find injectable values, if any, ensure there is one @@ -431,7 +431,7 @@ private boolean _addExplicitDelegatingCreator(DeserializationContext ctxt, AnnotatedParameter param = candidate.parameter(i); JacksonInject.Value injectId = candidate.injection(i); if (injectId != null) { - properties[i] = constructCreatorProperty(ctxt, beanDesc, null, i, param, injectId); + properties[i] = constructCreatorProperty(ctxt, beanDescRef, null, i, param, injectId); continue; } if (ix < 0) { @@ -439,13 +439,13 @@ private boolean _addExplicitDelegatingCreator(DeserializationContext ctxt, continue; } // Illegal to have more than one value to delegate to - ctxt.reportBadTypeDefinition(beanDesc, + ctxt.reportBadTypeDefinition(beanDescRef, "More than one argument (#%d and #%d) left as delegating for Creator %s: only one allowed", ix, i, candidate); } // Also, let's require that one Delegating argument does exist if (ix < 0) { - ctxt.reportBadTypeDefinition(beanDesc, + ctxt.reportBadTypeDefinition(beanDescRef, "No argument left as delegating for Creator %s: exactly one required", candidate); } // 17-Jan-2018, tatu: as per [databind#1853] need to ensure we will distinguish @@ -461,7 +461,7 @@ private boolean _addExplicitDelegatingCreator(DeserializationContext ctxt, * Helper method called to add the single chosen "properties-based" Creator (if any). */ private void _addSelectedPropertiesBasedCreator(DeserializationContext ctxt, - BeanDescription beanDesc, CreatorCollector creators, + BeanDescription.Supplier beanDescRef, CreatorCollector creators, CreatorCandidate candidate) { final DeserializationConfig config = ctxt.getConfig(); @@ -477,7 +477,7 @@ private void _addSelectedPropertiesBasedCreator(DeserializationContext ctxt, boolean isAnySetter = Boolean.TRUE.equals(ctxt.getAnnotationIntrospector().hasAnySetter(config, param)); if (isAnySetter) { if (anySetterIx >= 0) { - ctxt.reportBadTypeDefinition(beanDesc, + ctxt.reportBadTypeDefinition(beanDescRef, "More than one 'any-setter' specified (parameter #%d vs #%d)", anySetterIx, i); } else { @@ -488,17 +488,17 @@ private void _addSelectedPropertiesBasedCreator(DeserializationContext ctxt, // as that will not work with Creators well at all NameTransformer unwrapper = intr.findUnwrappingNameTransformer(config, param); if (unwrapper != null) { - properties[i] = constructCreatorProperty(ctxt, beanDesc, + properties[i] = constructCreatorProperty(ctxt, beanDescRef, UnwrappedPropertyHandler.creatorParamName(i), i, param, null); } // Must be injectable or have name; without either won't work if ((name == null) && (injectId == null)) { - ctxt.reportBadTypeDefinition(beanDesc, + ctxt.reportBadTypeDefinition(beanDescRef, "Argument #%d of Creator %s has no property name (and is not Injectable): can not use as property-based Creator", i, candidate); } } - properties[i] = constructCreatorProperty(ctxt, beanDesc, name, i, param, injectId); + properties[i] = constructCreatorProperty(ctxt, beanDescRef, name, i, param, injectId); } creators.addPropertyCreator(candidate.creator(), true, properties); } @@ -562,7 +562,7 @@ private boolean _handleSingleArgumentCreator(CreatorCollector creators, * factory method) */ protected SettableBeanProperty constructCreatorProperty(DeserializationContext ctxt, - BeanDescription beanDesc, PropertyName name, int index, + BeanDescription.Supplier beanDescRef, PropertyName name, int index, AnnotatedParameter param, JacksonInject.Value injectable) { @@ -600,7 +600,7 @@ protected SettableBeanProperty constructCreatorProperty(DeserializationContext c // Note: contextualization of typeDeser _should_ occur in constructor of CreatorProperty // so it is not called directly here SettableBeanProperty prop = CreatorProperty.construct(name, type, property.getWrapperName(), - typeDeser, beanDesc.getClassAnnotations(), param, index, injectable, + typeDeser, beanDescRef.get().getClassAnnotations(), param, index, injectable, metadata); ValueDeserializer deser = findDeserializerFromAnnotation(ctxt, param); if (deser == null) { @@ -711,7 +711,7 @@ protected boolean _checkIfCreatorPropertyBased(AnnotationIntrospector intr, @Override public ValueDeserializer createArrayDeserializer(DeserializationContext ctxt, - ArrayType type, final BeanDescription beanDesc) + ArrayType type, BeanDescription.Supplier beanDescRef) { final DeserializationConfig config = ctxt.getConfig(); JavaType elemType = type.getContentType(); @@ -727,7 +727,7 @@ public ValueDeserializer createArrayDeserializer(DeserializationContext ctxt, } // 23-Nov-2010, tatu: Custom array deserializer? ValueDeserializer deser = _findCustomArrayDeserializer(type, - config, beanDesc, elemTypeDeser, contentDeser); + config, beanDescRef, elemTypeDeser, contentDeser); if (deser == null) { if (contentDeser == null) { if (elemType.isPrimitive()) { @@ -743,7 +743,7 @@ public ValueDeserializer createArrayDeserializer(DeserializationContext ctxt, // and then new with 2.2: ability to post-process it too (databind#120) if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - deser = mod.modifyArrayDeserializer(config, type, beanDesc, deser); + deser = mod.modifyArrayDeserializer(config, type, beanDescRef, deser); } } return deser; @@ -758,7 +758,7 @@ public ValueDeserializer createArrayDeserializer(DeserializationContext ctxt, @SuppressWarnings("unchecked") @Override public ValueDeserializer createCollectionDeserializer(DeserializationContext ctxt, - CollectionType type, BeanDescription beanDesc) + CollectionType type, BeanDescription.Supplier beanDescRef) { JavaType contentType = type.getContentType(); // Very first thing: is deserializer hard-coded for elements? @@ -773,7 +773,7 @@ public ValueDeserializer createCollectionDeserializer(DeserializationContext } // 23-Nov-2010, tatu: Custom deserializer? ValueDeserializer deser = _findCustomCollectionDeserializer(type, - config, beanDesc, contentTypeDeser, contentDeser); + config, beanDescRef, contentTypeDeser, contentDeser); if (deser == null) { Class collectionClass = type.getRawClass(); if (contentDeser == null) { // not defined by annotation @@ -804,11 +804,11 @@ public ValueDeserializer createCollectionDeserializer(DeserializationContext if (implType != null) { type = implType; // But if so, also need to re-check creators... - beanDesc = ctxt.introspectBeanDescriptionForCreation(type); + beanDescRef = ctxt.lazyIntrospectBeanDescriptionForCreation(type); } } if (deser == null) { - ValueInstantiator inst = findValueInstantiator(ctxt, beanDesc); + ValueInstantiator inst = findValueInstantiator(ctxt, beanDescRef); if (!inst.canCreateUsingDefault()) { // [databind#161]: No default constructor for ArrayBlockingQueue... if (type.hasRawClass(ArrayBlockingQueue.class)) { @@ -832,7 +832,7 @@ public ValueDeserializer createCollectionDeserializer(DeserializationContext // allow post-processing it too if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - deser = mod.modifyCollectionDeserializer(config, type, beanDesc, deser); + deser = mod.modifyCollectionDeserializer(config, type, beanDescRef, deser); } } return deser; @@ -851,7 +851,7 @@ protected CollectionType _mapAbstractCollectionType(JavaType type, Deserializati // Copied almost verbatim from "createCollectionDeserializer" -- should try to share more code @Override public ValueDeserializer createCollectionLikeDeserializer(DeserializationContext ctxt, - CollectionLikeType type, final BeanDescription beanDesc) + CollectionLikeType type, BeanDescription.Supplier beanDescRef) { JavaType contentType = type.getContentType(); // Very first thing: is deserializer hard-coded for elements? @@ -865,13 +865,13 @@ public ValueDeserializer createCollectionLikeDeserializer(DeserializationCont if (contentTypeDeser == null) { contentTypeDeser = ctxt.findTypeDeserializer(contentType); } - ValueDeserializer deser = _findCustomCollectionLikeDeserializer(type, config, beanDesc, + ValueDeserializer deser = _findCustomCollectionLikeDeserializer(type, config, beanDescRef, contentTypeDeser, contentDeser); if (deser != null) { // ability to post-process it too (databind#120) if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - deser = mod.modifyCollectionLikeDeserializer(config, type, beanDesc, deser); + deser = mod.modifyCollectionLikeDeserializer(config, type, beanDescRef, deser); } } } @@ -886,7 +886,7 @@ public ValueDeserializer createCollectionLikeDeserializer(DeserializationCont @Override public ValueDeserializer createMapDeserializer(DeserializationContext ctxt, - MapType type, BeanDescription beanDesc) + MapType type, BeanDescription.Supplier beanDescRef) { final DeserializationConfig config = ctxt.getConfig(); JavaType keyType = type.getKeyType(); @@ -906,7 +906,7 @@ public ValueDeserializer createMapDeserializer(DeserializationContext ctxt, } // 23-Nov-2010, tatu: Custom deserializer? - ValueDeserializer deser = _findCustomMapDeserializer(type, config, beanDesc, + ValueDeserializer deser = _findCustomMapDeserializer(type, config, beanDescRef, keyDes, contentTypeDeser, contentDeser); if (deser == null) { @@ -926,7 +926,7 @@ public ValueDeserializer createMapDeserializer(DeserializationContext ctxt, if (mapClass == EnumMap.class) { inst = null; } else { - inst = findValueInstantiator(ctxt, beanDesc); + inst = findValueInstantiator(ctxt, beanDescRef); } if (!keyType.isEnumImplType()) { throw new IllegalArgumentException("Cannot construct EnumMap; generic (key) type not available"); @@ -953,7 +953,7 @@ public ValueDeserializer createMapDeserializer(DeserializationContext ctxt, type = (MapType) implType; mapClass = type.getRawClass(); // But if so, also need to re-check creators... - beanDesc = ctxt.introspectBeanDescriptionForCreation(type); + beanDescRef = ctxt.lazyIntrospectBeanDescriptionForCreation(type); } // 11-Nov-2024, tatu: Related to [databind#4783] let's not fail on // abstract Maps so they can work with merge (or factory methods) @@ -965,19 +965,19 @@ public ValueDeserializer createMapDeserializer(DeserializationContext ctxt, } } if (deser == null) { - ValueInstantiator inst = findValueInstantiator(ctxt, beanDesc); + ValueInstantiator inst = findValueInstantiator(ctxt, beanDescRef); // 01-May-2016, tatu: Which base type to use here gets tricky, since // most often it ought to be `Map` or `EnumMap`, but due to abstract // mapping it will more likely be concrete type like `HashMap`. // So, for time being, just pass `Map.class` MapDeserializer md = new MapDeserializer(type, inst, keyDes, contentDeser, contentTypeDeser); JsonIgnoreProperties.Value ignorals = config.getDefaultPropertyIgnorals(Map.class, - beanDesc.getClassInfo()); + beanDescRef.getClassInfo()); Set ignored = (ignorals == null) ? null : ignorals.findIgnoredForDeserialization(); md.setIgnorableProperties(ignored); JsonIncludeProperties.Value inclusions = config.getDefaultPropertyInclusions(Map.class, - beanDesc.getClassInfo()); + beanDescRef.getClassInfo()); Set included = inclusions == null ? null : inclusions.getIncluded(); md.setIncludableProperties(included); deser = md; @@ -986,7 +986,7 @@ public ValueDeserializer createMapDeserializer(DeserializationContext ctxt, } if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - deser = mod.modifyMapDeserializer(config, type, beanDesc, deser); + deser = mod.modifyMapDeserializer(config, type, beanDescRef, deser); } } return deser; @@ -1005,7 +1005,7 @@ protected MapType _mapAbstractMapType(JavaType type, DeserializationConfig confi // Copied almost verbatim from "createMapDeserializer" -- should try to share more code @Override public ValueDeserializer createMapLikeDeserializer(DeserializationContext ctxt, - MapLikeType type, final BeanDescription beanDesc) + MapLikeType type, BeanDescription.Supplier beanDescRef) { JavaType keyType = type.getKeyType(); JavaType contentType = type.getContentType(); @@ -1029,12 +1029,12 @@ public ValueDeserializer createMapLikeDeserializer(DeserializationContext ctx contentTypeDeser = ctxt.findTypeDeserializer(contentType); } ValueDeserializer deser = _findCustomMapLikeDeserializer(type, config, - beanDesc, keyDes, contentTypeDeser, contentDeser); + beanDescRef, keyDes, contentTypeDeser, contentDeser); if (deser != null) { // ability to post-process it too (Issue#120) if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - deser = mod.modifyMapLikeDeserializer(config, type, beanDesc, deser); + deser = mod.modifyMapLikeDeserializer(config, type, beanDescRef, deser); } } } @@ -1052,12 +1052,12 @@ public ValueDeserializer createMapLikeDeserializer(DeserializationContext ctx */ @Override public ValueDeserializer createEnumDeserializer(DeserializationContext ctxt, - JavaType type, BeanDescription beanDesc) + JavaType type, BeanDescription.Supplier beanDescRef) { final DeserializationConfig config = ctxt.getConfig(); final Class enumClass = type.getRawClass(); // 23-Nov-2010, tatu: Custom deserializer? - ValueDeserializer deser = _findCustomEnumDeserializer(enumClass, config, beanDesc); + ValueDeserializer deser = _findCustomEnumDeserializer(enumClass, config, beanDescRef); if (deser == null) { // 12-Feb-2020, tatu: while we can't really create real deserializer for `Enum.class`, @@ -1066,14 +1066,14 @@ public ValueDeserializer createEnumDeserializer(DeserializationContext ctxt, // We could check `type.getTypeHandler()` to look for that case but seems like we // may as well simply create placeholder (AbstractDeserializer) regardless if (enumClass == Enum.class) { - return AbstractDeserializer.constructForNonPOJO(beanDesc); + return AbstractDeserializer.constructForNonPOJO(beanDescRef); } - ValueInstantiator valueInstantiator = _constructDefaultValueInstantiator(ctxt, beanDesc); + ValueInstantiator valueInstantiator = _constructDefaultValueInstantiator(ctxt, beanDescRef); SettableBeanProperty[] creatorProps = (valueInstantiator == null) ? null : valueInstantiator.getFromObjectArguments(config); // May have @JsonCreator for static factory method: - for (AnnotatedMethod factory : beanDesc.getFactoryMethods()) { + for (AnnotatedMethod factory : beanDescRef.get().getFactoryMethods()) { if (_hasCreatorAnnotation(config, factory)) { if (factory.getParameterCount() == 0) { // [databind#960] deser = EnumDeserializer.deserializerForNoArgsCreator(config, enumClass, factory); @@ -1088,18 +1088,18 @@ public ValueDeserializer createEnumDeserializer(DeserializationContext ctxt, } deser = EnumDeserializer.deserializerForCreator( config, enumClass, factory, valueInstantiator, creatorProps, - constructEnumResolver(ctxt, enumClass, beanDesc)); + constructEnumResolver(ctxt, enumClass, beanDescRef)); break; } } // Need to consider @JsonValue if one found if (deser == null) { - deser = new EnumDeserializer(constructEnumResolver(ctxt, enumClass, beanDesc), + deser = new EnumDeserializer(constructEnumResolver(ctxt, enumClass, beanDescRef), config.isEnabled(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS), - constructEnumNamingStrategyResolver(config, beanDesc.getClassInfo()), + constructEnumNamingStrategyResolver(config, beanDescRef.getClassInfo()), // since 2.16 - EnumResolver.constructUsingToString(config, beanDesc.getClassInfo()) + EnumResolver.constructUsingToString(config, beanDescRef.getClassInfo()) ); } } @@ -1107,7 +1107,7 @@ public ValueDeserializer createEnumDeserializer(DeserializationContext ctxt, // and then post-process it too if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - deser = mod.modifyEnumDeserializer(config, type, beanDesc, deser); + deser = mod.modifyEnumDeserializer(config, type, beanDescRef, deser); } } return deser; @@ -1115,13 +1115,13 @@ public ValueDeserializer createEnumDeserializer(DeserializationContext ctxt, @Override public ValueDeserializer createTreeDeserializer(DeserializationConfig config, - JavaType nodeType, BeanDescription beanDesc) + JavaType nodeType, BeanDescription.Supplier beanDescRef) { @SuppressWarnings("unchecked") Class nodeClass = (Class) nodeType.getRawClass(); // 23-Nov-2010, tatu: Custom deserializer? ValueDeserializer custom = _findCustomTreeNodeDeserializer(nodeClass, config, - beanDesc); + beanDescRef); if (custom != null) { return custom; } @@ -1130,7 +1130,7 @@ public ValueDeserializer createTreeDeserializer(DeserializationConfig config, @Override public ValueDeserializer createReferenceDeserializer(DeserializationContext ctxt, - ReferenceType type, BeanDescription beanDesc) + ReferenceType type, BeanDescription.Supplier beanDescRef) { JavaType contentType = type.getContentType(); // Very first thing: is deserializer hard-coded for elements? @@ -1142,7 +1142,7 @@ public ValueDeserializer createReferenceDeserializer(DeserializationContext c if (contentTypeDeser == null) { // or if not, may be able to find: contentTypeDeser = ctxt.findTypeDeserializer(contentType); } - ValueDeserializer deser = _findCustomReferenceDeserializer(type, config, beanDesc, + ValueDeserializer deser = _findCustomReferenceDeserializer(type, config, beanDescRef, contentTypeDeser, contentDeser); if (deser == null) { @@ -1150,7 +1150,7 @@ public ValueDeserializer createReferenceDeserializer(DeserializationContext c if (type.isTypeOrSubTypeOf(Optional.class)) { // Not sure this can really work but let's try: ValueInstantiator inst = type.hasRawClass(Optional.class) ? null - : findValueInstantiator(ctxt, beanDesc); + : findValueInstantiator(ctxt, beanDescRef); return new Jdk8OptionalDeserializer(type, inst, contentTypeDeser, contentDeser); } if (type.isTypeOrSubTypeOf(AtomicReference.class)) { @@ -1158,7 +1158,7 @@ public ValueDeserializer createReferenceDeserializer(DeserializationContext c // without either forcing merging (to avoid having to create instance) // or something else... ValueInstantiator inst = type.hasRawClass(AtomicReference.class) ? null - : findValueInstantiator(ctxt, beanDesc); + : findValueInstantiator(ctxt, beanDescRef); return new AtomicReferenceDeserializer(type, inst, contentTypeDeser, contentDeser); } if (type.hasRawClass(OptionalInt.class)) { @@ -1175,7 +1175,7 @@ public ValueDeserializer createReferenceDeserializer(DeserializationContext c // and then post-process if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - deser = mod.modifyReferenceDeserializer(config, type, beanDesc, deser); + deser = mod.modifyReferenceDeserializer(config, type, beanDescRef, deser); } } } @@ -1192,7 +1192,7 @@ public ValueDeserializer createReferenceDeserializer(DeserializationContext c * Overridable method called after checking all other types. */ protected ValueDeserializer findOptionalStdDeserializer(DeserializationContext ctxt, - JavaType type, BeanDescription beanDesc) + JavaType type, BeanDescription.Supplier beanDescRef) { return OptionalHandlerFactory.instance.findDeserializer(ctxt.getConfig(), type); } @@ -1247,29 +1247,31 @@ private KeyDeserializer _createEnumKeyDeserializer(DeserializationContext ctxt, final DeserializationConfig config = ctxt.getConfig(); Class enumClass = type.getRawClass(); - BeanDescription beanDesc = ctxt.introspectBeanDescription(type); + BeanDescription.Supplier beanDescRef = ctxt.lazyIntrospectBeanDescription(type); + final AnnotatedClass classInfo = beanDescRef.getClassInfo(); + // 24-Sep-2015, bim: a key deserializer is the preferred thing. - KeyDeserializer des = findKeyDeserializerFromAnnotation(ctxt, beanDesc.getClassInfo()); + KeyDeserializer des = findKeyDeserializerFromAnnotation(ctxt, beanDescRef.getClassInfo()); if (des != null) { return des; } else { // 24-Sep-2015, bim: if no key deser, look for enum deserializer first, then a plain deser. - ValueDeserializer custom = _findCustomEnumDeserializer(enumClass, config, beanDesc); + ValueDeserializer custom = _findCustomEnumDeserializer(enumClass, config, beanDescRef); if (custom != null) { return JDKKeyDeserializers.constructDelegatingKeyDeserializer(config, type, custom); } - ValueDeserializer valueDesForKey = findDeserializerFromAnnotation(ctxt, beanDesc.getClassInfo()); + ValueDeserializer valueDesForKey = findDeserializerFromAnnotation(ctxt, classInfo); if (valueDesForKey != null) { return JDKKeyDeserializers.constructDelegatingKeyDeserializer(config, type, valueDesForKey); } } - EnumResolver enumRes = constructEnumResolver(ctxt, enumClass, beanDesc); - EnumResolver byEnumNamingResolver = constructEnumNamingStrategyResolver(config, beanDesc.getClassInfo()); - EnumResolver byToStringResolver = EnumResolver.constructUsingToString(config, beanDesc.getClassInfo()); - EnumResolver byIndexResolver = EnumResolver.constructUsingIndex(config, beanDesc.getClassInfo()); + EnumResolver enumRes = constructEnumResolver(ctxt, enumClass, beanDescRef); + EnumResolver byEnumNamingResolver = constructEnumNamingStrategyResolver(config, classInfo); + EnumResolver byToStringResolver = EnumResolver.constructUsingToString(config, classInfo); + EnumResolver byIndexResolver = EnumResolver.constructUsingIndex(config, classInfo); // May have @JsonCreator for static factory method - for (AnnotatedMethod factory : beanDesc.getFactoryMethods()) { + for (AnnotatedMethod factory : beanDescRef.get().getFactoryMethods()) { if (_hasCreatorAnnotation(config, factory)) { int argCount = factory.getParameterCount(); if (argCount == 1) { @@ -1383,7 +1385,7 @@ public boolean hasExplicitDeserializerFor(DatabindContext ctxt, * API types. */ public ValueDeserializer findDefaultDeserializer(DeserializationContext ctxt, - JavaType type, BeanDescription beanDesc) + JavaType type, BeanDescription.Supplier beanDescRef) { Class rawType = type.getRawClass(); // Object ("untyped"), and as of 2.10 (see [databind#2115]), `java.io.Serializable` @@ -1411,7 +1413,7 @@ public ValueDeserializer findDefaultDeserializer(DeserializationContext ctxt, JavaType elemType = (tps == null || tps.length != 1) ? TypeFactory.unknownType() : tps[0]; CollectionType ct = tf.constructCollectionType(Collection.class, elemType); // Should we re-introspect beanDesc? For now let's not... - return createCollectionDeserializer(ctxt, ct, beanDesc); + return createCollectionDeserializer(ctxt, ct, beanDescRef); } if (rawType == CLASS_MAP_ENTRY) { // 28-Apr-2015, tatu: TypeFactory does it all for us already so @@ -1441,7 +1443,7 @@ public ValueDeserializer findDefaultDeserializer(DeserializationContext ctxt, if (rawType == TokenBuffer.class) { return new TokenBufferDeserializer(); } - ValueDeserializer deser = findOptionalStdDeserializer(ctxt, type, beanDesc); + ValueDeserializer deser = findOptionalStdDeserializer(ctxt, type, beanDescRef); if (deser != null) { return deser; } @@ -1461,10 +1463,10 @@ private JavaType _findRemappedType(DeserializationConfig config, Class rawTyp */ protected ValueDeserializer _findCustomTreeNodeDeserializer(Class type, - DeserializationConfig config, BeanDescription beanDesc) + DeserializationConfig config, BeanDescription.Supplier beanDescRef) { for (Deserializers d : _factoryConfig.deserializers()) { - ValueDeserializer deser = d.findTreeNodeDeserializer(type, config, beanDesc); + ValueDeserializer deser = d.findTreeNodeDeserializer(type, config, beanDescRef); if (deser != null) { return deser; } @@ -1473,11 +1475,11 @@ protected ValueDeserializer _findCustomTreeNodeDeserializer(Class _findCustomReferenceDeserializer(ReferenceType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer contentTypeDeserializer, ValueDeserializer contentDeserializer) { for (Deserializers d : _factoryConfig.deserializers()) { - ValueDeserializer deser = d.findReferenceDeserializer(type, config, beanDesc, + ValueDeserializer deser = d.findReferenceDeserializer(type, config, beanDescRef, contentTypeDeserializer, contentDeserializer); if (deser != null) { return deser; @@ -1488,10 +1490,10 @@ protected ValueDeserializer _findCustomReferenceDeserializer(ReferenceType ty @SuppressWarnings("unchecked") protected ValueDeserializer _findCustomBeanDeserializer(JavaType type, - DeserializationConfig config, BeanDescription beanDesc) + DeserializationConfig config, BeanDescription.Supplier beanDescRef) { for (Deserializers d : _factoryConfig.deserializers()) { - ValueDeserializer deser = d.findBeanDeserializer(type, config, beanDesc); + ValueDeserializer deser = d.findBeanDeserializer(type, config, beanDescRef); if (deser != null) { return (ValueDeserializer) deser; } @@ -1500,12 +1502,12 @@ protected ValueDeserializer _findCustomBeanDeserializer(JavaType type, } protected ValueDeserializer _findCustomArrayDeserializer(ArrayType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { for (Deserializers d : _factoryConfig.deserializers()) { ValueDeserializer deser = d.findArrayDeserializer(type, config, - beanDesc, elementTypeDeserializer, elementDeserializer); + beanDescRef, elementTypeDeserializer, elementDeserializer); if (deser != null) { return deser; } @@ -1514,12 +1516,12 @@ protected ValueDeserializer _findCustomArrayDeserializer(ArrayType type, } protected ValueDeserializer _findCustomCollectionDeserializer(CollectionType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { for (Deserializers d : _factoryConfig.deserializers()) { - ValueDeserializer deser = d.findCollectionDeserializer(type, config, beanDesc, - elementTypeDeserializer, elementDeserializer); + ValueDeserializer deser = d.findCollectionDeserializer(type, config, + beanDescRef, elementTypeDeserializer, elementDeserializer); if (deser != null) { return deser; } @@ -1528,12 +1530,12 @@ protected ValueDeserializer _findCustomCollectionDeserializer(CollectionType } protected ValueDeserializer _findCustomCollectionLikeDeserializer(CollectionLikeType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { for (Deserializers d : _factoryConfig.deserializers()) { - ValueDeserializer deser = d.findCollectionLikeDeserializer(type, config, beanDesc, - elementTypeDeserializer, elementDeserializer); + ValueDeserializer deser = d.findCollectionLikeDeserializer(type, config, + beanDescRef, elementTypeDeserializer, elementDeserializer); if (deser != null) { return deser; } @@ -1542,10 +1544,10 @@ protected ValueDeserializer _findCustomCollectionLikeDeserializer(CollectionL } protected ValueDeserializer _findCustomEnumDeserializer(Class type, - DeserializationConfig config, BeanDescription beanDesc) + DeserializationConfig config, BeanDescription.Supplier beanDescRef) { for (Deserializers d : _factoryConfig.deserializers()) { - ValueDeserializer deser = d.findEnumDeserializer(type, config, beanDesc); + ValueDeserializer deser = d.findEnumDeserializer(type, config, beanDescRef); if (deser != null) { return deser; } @@ -1554,12 +1556,12 @@ protected ValueDeserializer _findCustomEnumDeserializer(Class type, } protected ValueDeserializer _findCustomMapDeserializer(MapType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { for (Deserializers d : _factoryConfig.deserializers()) { - ValueDeserializer deser = d.findMapDeserializer(type, config, beanDesc, + ValueDeserializer deser = d.findMapDeserializer(type, config, beanDescRef, keyDeserializer, elementTypeDeserializer, elementDeserializer); if (deser != null) { return deser; @@ -1569,12 +1571,12 @@ protected ValueDeserializer _findCustomMapDeserializer(MapType type, } protected ValueDeserializer _findCustomMapLikeDeserializer(MapLikeType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { for (Deserializers d : _factoryConfig.deserializers()) { - ValueDeserializer deser = d.findMapLikeDeserializer(type, config, beanDesc, + ValueDeserializer deser = d.findMapLikeDeserializer(type, config, beanDescRef, keyDeserializer, elementTypeDeserializer, elementDeserializer); if (deser != null) { return deser; @@ -1697,17 +1699,17 @@ protected JavaType resolveMemberAndTypeAnnotations(DeserializationContext ctxt, } protected EnumResolver constructEnumResolver(DeserializationContext ctxt, - Class enumClass, BeanDescription beanDesc) + Class enumClass, BeanDescription.Supplier beanDescRef) { - AnnotatedMember jvAcc = beanDesc.findJsonValueAccessor(); + AnnotatedMember jvAcc = beanDescRef.get().findJsonValueAccessor(); if (jvAcc != null) { if (ctxt.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(jvAcc.getMember(), ctxt.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); } - return EnumResolver.constructUsingMethod(ctxt.getConfig(), beanDesc.getClassInfo(), jvAcc); + return EnumResolver.constructUsingMethod(ctxt.getConfig(), beanDescRef.getClassInfo(), jvAcc); } - return EnumResolver.constructFor(ctxt.getConfig(), beanDesc.getClassInfo()); + return EnumResolver.constructFor(ctxt.getConfig(), beanDescRef.getClassInfo()); } /** diff --git a/src/main/java/tools/jackson/databind/deser/BeanDeserializerBuilder.java b/src/main/java/tools/jackson/databind/deser/BeanDeserializerBuilder.java index 1c9a92adbe..d2c97b0940 100644 --- a/src/main/java/tools/jackson/databind/deser/BeanDeserializerBuilder.java +++ b/src/main/java/tools/jackson/databind/deser/BeanDeserializerBuilder.java @@ -43,7 +43,7 @@ public class BeanDeserializerBuilder /** * Introspected information about POJO for deserializer to handle */ - protected final BeanDescription _beanDesc; + protected final BeanDescription.Supplier _beanDescRef; /* /********************************************************************** @@ -127,10 +127,10 @@ public class BeanDeserializerBuilder /********************************************************************** */ - public BeanDeserializerBuilder(BeanDescription beanDesc, + public BeanDeserializerBuilder(BeanDescription.Supplier beanDescRef, DeserializationContext ctxt) { - _beanDesc = beanDesc; + _beanDescRef = beanDescRef; _context = ctxt; _config = ctxt.getConfig(); } @@ -141,7 +141,7 @@ public BeanDeserializerBuilder(BeanDescription beanDesc, */ protected BeanDeserializerBuilder(BeanDeserializerBuilder src) { - _beanDesc = src._beanDesc; + _beanDescRef = src._beanDescRef; _context = src._context; _config = src._config; @@ -201,7 +201,8 @@ public void addProperty(SettableBeanProperty prop) { SettableBeanProperty old = _properties.put(prop.getName(), prop); if (old != null && old != prop) { // should never occur... - throw new IllegalArgumentException("Duplicate property '"+prop.getName()+"' for "+_beanDesc.getType()); + throw new IllegalArgumentException("Duplicate property '"+prop.getName() + +"' for "+_beanDescRef.getType()); } } @@ -326,6 +327,10 @@ public void setPOJOBuilder(AnnotatedMethod buildMethod, JsonPOJOBuilder.Value co /********************************************************************** */ + public JavaType getType() { + return _beanDescRef.getType(); + } + /** * Method that allows accessing all properties that this * builder currently contains. @@ -400,7 +405,7 @@ public ValueDeserializer build() new ObjectIdValueProperty(_objectIdReader, PropertyMetadata.STD_REQUIRED)); } return new BeanDeserializer(this, - _beanDesc, _constructPropMap(props), _backRefProperties, _ignorableProps, _ignoreAllUnknown, _includableProps, + _beanDescRef, _constructPropMap(props), _backRefProperties, _ignorableProps, _ignoreAllUnknown, _includableProps, _anyViews(props)); } @@ -410,7 +415,7 @@ _beanDesc, _constructPropMap(props), _backRefProperties, _ignorableProps, _ignor * ("polymorphic deserialization") */ public AbstractDeserializer buildAbstract() { - return new AbstractDeserializer(this, _beanDesc, _backRefProperties, _properties); + return new AbstractDeserializer(this, _backRefProperties, _properties); } /** @@ -423,9 +428,9 @@ public ValueDeserializer buildBuilderBased(JavaType valueType, String expBuil if (_buildMethod == null) { // as per [databind#777], allow empty name if (!expBuildMethodName.isEmpty()) { - _context.reportBadDefinition(_beanDesc.getType(), + _context.reportBadDefinition(_beanDescRef.getType(), String.format("Builder class %s does not have build method (name: '%s')", - ClassUtil.getTypeDescription(_beanDesc.getType()), + ClassUtil.getTypeDescription(_beanDescRef.getType()), expBuildMethodName)); } } else { @@ -435,7 +440,7 @@ public ValueDeserializer buildBuilderBased(JavaType valueType, String expBuil if ((rawBuildType != rawValueType) && !rawBuildType.isAssignableFrom(rawValueType) && !rawValueType.isAssignableFrom(rawBuildType)) { - _context.reportBadDefinition(_beanDesc.getType(), + _context.reportBadDefinition(_beanDescRef.getType(), String.format("Build method `%s` has wrong return type (%s), not compatible with POJO type (%s)", _buildMethod.getFullName(), ClassUtil.getClassDescription(rawBuildType), @@ -463,7 +468,7 @@ public ValueDeserializer buildBuilderBased(JavaType valueType, String expBuil protected ValueDeserializer createBuilderBasedDeserializer(JavaType valueType, BeanPropertyMap propertyMap, boolean anyViews) { return new BuilderBasedDeserializer(this, - _beanDesc, valueType, propertyMap, _backRefProperties, _ignorableProps, _ignoreAllUnknown, + _beanDescRef, valueType, propertyMap, _backRefProperties, _ignorableProps, _ignoreAllUnknown, _includableProps, anyViews); } @@ -581,7 +586,7 @@ protected BeanPropertyMap _constructPropMap(Collection pro { // 07-May-2020, tatu: First find combination of per-type config overrides (higher // precedence) and per-type annotations (lower): - JsonFormat.Value format = _beanDesc.findExpectedFormat(null); + JsonFormat.Value format = _beanDescRef.get().findExpectedFormat(null); // and see if any of those has explicit definition; if not, use global baseline default Boolean B = format.getFeature(JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES); boolean caseInsensitive = (B == null) @@ -621,7 +626,7 @@ protected PropertyName[][] _collectAliases(Collection prop protected void _handleBadAccess(IllegalArgumentException e0) { try { - _context.reportBadTypeDefinition(_beanDesc, e0.getMessage()); + _context.reportBadTypeDefinition(_beanDescRef.get(), e0.getMessage()); } catch (DatabindException e) { if (e.getCause() == null) { e.initCause(e0); diff --git a/src/main/java/tools/jackson/databind/deser/BeanDeserializerFactory.java b/src/main/java/tools/jackson/databind/deser/BeanDeserializerFactory.java index 202e7cdcc1..73c65100a6 100644 --- a/src/main/java/tools/jackson/databind/deser/BeanDeserializerFactory.java +++ b/src/main/java/tools/jackson/databind/deser/BeanDeserializerFactory.java @@ -93,16 +93,16 @@ public DeserializerFactory withConfig(DeserializerFactoryConfig config) @SuppressWarnings("unchecked") @Override public ValueDeserializer createBeanDeserializer(DeserializationContext ctxt, - JavaType type, BeanDescription beanDesc) + JavaType type, BeanDescription.Supplier beanDescRef) { final DeserializationConfig config = ctxt.getConfig(); // First: we may also have custom overrides: - ValueDeserializer deser = _findCustomBeanDeserializer(type, config, beanDesc); + ValueDeserializer deser = _findCustomBeanDeserializer(type, config, beanDescRef); if (deser != null) { // [databind#2392] if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - deser = mod.modifyDeserializer(ctxt.getConfig(), beanDesc, deser); + deser = mod.modifyDeserializer(ctxt.getConfig(), beanDescRef, deser); } } return (ValueDeserializer) deser; @@ -110,7 +110,7 @@ public ValueDeserializer createBeanDeserializer(DeserializationContext c // One more thing to check: do we have an exception type (Throwable or its // sub-classes)? If so, need slightly different handling. if (type.isThrowable()) { - return buildThrowableDeserializer(ctxt, type, beanDesc); + return buildThrowableDeserializer(ctxt, type, beanDescRef); } // Or, for abstract types, may have alternate means for resolution // (defaulting, materialization) @@ -119,16 +119,16 @@ public ValueDeserializer createBeanDeserializer(DeserializationContext c // not something we could materialize anything for if (type.isAbstract() && !type.isPrimitive() && !type.isEnumType()) { // Let's make it possible to materialize abstract types. - JavaType concreteType = materializeAbstractType(ctxt, type, beanDesc); + JavaType concreteType = materializeAbstractType(ctxt, type, beanDescRef); if (concreteType != null) { // important: introspect actual implementation (abstract class or // interface doesn't have constructors, for one) - beanDesc = ctxt.introspectBeanDescription(concreteType); - return buildBeanDeserializer(ctxt, concreteType, beanDesc); + beanDescRef = ctxt.lazyIntrospectBeanDescription(concreteType); + return buildBeanDeserializer(ctxt, concreteType, beanDescRef); } } // Otherwise, may want to check handlers for standard types, from superclass: - deser = findStdDeserializer(ctxt, type, beanDesc); + deser = findStdDeserializer(ctxt, type, beanDescRef); if (deser != null) { return (ValueDeserializer)deser; } @@ -138,22 +138,23 @@ public ValueDeserializer createBeanDeserializer(DeserializationContext c return null; } // For checks like [databind#1599] - _validateSubType(ctxt, type, beanDesc); + _validateSubType(ctxt, type, beanDescRef); // 05-May-2020, tatu: [databind#2683] Let's actually pre-emptively catch // certain types (for now, java.time.*) to give better error messages - deser = _findUnsupportedTypeDeserializer(ctxt, type, beanDesc); + deser = _findUnsupportedTypeDeserializer(ctxt, type, beanDescRef); if (deser != null) { return (ValueDeserializer)deser; } // Use generic bean introspection to build deserializer - return buildBeanDeserializer(ctxt, type, beanDesc); + return buildBeanDeserializer(ctxt, type, beanDescRef); } @Override public ValueDeserializer createBuilderBasedDeserializer( - DeserializationContext ctxt, JavaType valueType, BeanDescription valueBeanDesc, + DeserializationContext ctxt, JavaType valueType, + BeanDescription.Supplier valueBeanDescRef, Class builderClass) { // First: need a BeanDescription for builder class @@ -163,10 +164,11 @@ public ValueDeserializer createBuilderBasedDeserializer( } else { builderType = ctxt.constructType(builderClass); } - BeanDescription builderDesc = ctxt.introspectBeanDescriptionForBuilder(builderType, valueBeanDesc); - // 20-Aug-2020, tatu: May want to change at some point (after 2.12) to pass "valueBeanDesc" + BeanDescription.Supplier builderDescRef = ctxt.lazyIntrospectBeanDescriptionForBuilder(builderType, + valueBeanDescRef.get()); + // 20-Aug-2020, tatu: May want to change at some point to pass "valueBeanDesc" // too; no urgent need at this point - return buildBuilderBasedDeserializer(ctxt, valueType, builderDesc); + return buildBuilderBasedDeserializer(ctxt, valueType, builderDescRef); } /** @@ -174,16 +176,16 @@ public ValueDeserializer createBuilderBasedDeserializer( * deserializer registered for given type. */ protected ValueDeserializer findStdDeserializer(DeserializationContext ctxt, - JavaType type, BeanDescription beanDesc) + JavaType type, BeanDescription.Supplier beanDescRef) { // note: we do NOT check for custom deserializers here, caller has already // done that - ValueDeserializer deser = findDefaultDeserializer(ctxt, type, beanDesc); + ValueDeserializer deser = findDefaultDeserializer(ctxt, type, beanDescRef); // Also: better ensure these are post-processable? if (deser != null) { if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - deser = mod.modifyDeserializer(ctxt.getConfig(), beanDesc, deser); + deser = mod.modifyDeserializer(ctxt.getConfig(), beanDescRef, deser); } } } @@ -198,7 +200,7 @@ protected ValueDeserializer findStdDeserializer(DeserializationContext ctxt, * support module not registered. */ protected ValueDeserializer _findUnsupportedTypeDeserializer(DeserializationContext ctxt, - JavaType type, BeanDescription beanDesc) + JavaType type, BeanDescription.Supplier beanDescRef) { // 05-May-2020, tatu: Should we check for possible Shape override to "POJO"? // (to let users force 'serialize-as-POJO'? Or not? @@ -214,12 +216,12 @@ protected ValueDeserializer _findUnsupportedTypeDeserializer(Deserializa } protected JavaType materializeAbstractType(DeserializationContext ctxt, - JavaType type, BeanDescription beanDesc) + JavaType type, BeanDescription.Supplier beanDescRef) { final DeserializationConfig config = ctxt.getConfig(); // May have multiple resolvers, call in precedence order until one returns non-null for (AbstractTypeResolver r : config.abstractTypeResolvers()) { - JavaType concrete = r.resolveAbstractType(config, beanDesc); + JavaType concrete = r.resolveAbstractType(config, beanDescRef); if (concrete != null) { return concrete; } @@ -243,7 +245,7 @@ protected JavaType materializeAbstractType(DeserializationContext ctxt, */ @SuppressWarnings("unchecked") public ValueDeserializer buildBeanDeserializer(DeserializationContext ctxt, - JavaType type, BeanDescription beanDesc) + JavaType type, BeanDescription.Supplier beanDescRef) { // First: check what creators we can use, if any ValueInstantiator valueInstantiator; @@ -253,7 +255,7 @@ public ValueDeserializer buildBeanDeserializer(DeserializationContext ct * probably won't work and needs to be added elsewhere. */ try { - valueInstantiator = findValueInstantiator(ctxt, beanDesc); + valueInstantiator = findValueInstantiator(ctxt, beanDescRef); } catch (NoClassDefFoundError error) { return new ErrorThrowingDeserializer(error); } catch (IllegalArgumentException e0) { @@ -262,23 +264,23 @@ public ValueDeserializer buildBeanDeserializer(DeserializationContext ct // instance so... throw InvalidDefinitionException.from(ctxt.getParser(), ClassUtil.exceptionMessage(e0), - beanDesc, null) + beanDescRef, null) .withCause(e0); } - BeanDeserializerBuilder builder = constructBeanDeserializerBuilder(ctxt, beanDesc); + BeanDeserializerBuilder builder = constructBeanDeserializerBuilder(ctxt, beanDescRef); builder.setValueInstantiator(valueInstantiator); // And then setters for deserializing from JSON Object - addBeanProps(ctxt, beanDesc, builder); - addObjectIdReader(ctxt, beanDesc, builder); + addBeanProps(ctxt, beanDescRef, builder); + addObjectIdReader(ctxt, beanDescRef, builder); // managed/back reference fields/setters need special handling... first part - addBackReferenceProperties(ctxt, beanDesc, builder); - addInjectables(ctxt, beanDesc, builder); + addBackReferenceProperties(ctxt, beanDescRef, builder); + addInjectables(ctxt, beanDescRef, builder); final DeserializationConfig config = ctxt.getConfig(); if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - builder = mod.updateBuilder(config, beanDesc, builder); + builder = mod.updateBuilder(config, beanDescRef, builder); } } ValueDeserializer deserializer; @@ -292,7 +294,7 @@ public ValueDeserializer buildBeanDeserializer(DeserializationContext ct // (note that `resolve()` and `createContextual()` called later on) if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - deserializer = mod.modifyDeserializer(config, beanDesc, deserializer); + deserializer = mod.modifyDeserializer(config, beanDescRef, deserializer); } } return (ValueDeserializer) deserializer; @@ -307,12 +309,13 @@ public ValueDeserializer buildBeanDeserializer(DeserializationContext ct */ @SuppressWarnings("unchecked") protected ValueDeserializer buildBuilderBasedDeserializer( - DeserializationContext ctxt, JavaType valueType, BeanDescription builderDesc) + DeserializationContext ctxt, JavaType valueType, + BeanDescription.Supplier builderDescRef) { // Creators, anyone? (to create builder itself) ValueInstantiator valueInstantiator; try { - valueInstantiator = findValueInstantiator(ctxt, builderDesc); + valueInstantiator = findValueInstantiator(ctxt, builderDescRef); } catch (NoClassDefFoundError error) { return new ErrorThrowingDeserializer(error); } catch (IllegalArgumentException e) { @@ -321,25 +324,25 @@ protected ValueDeserializer buildBuilderBasedDeserializer( // instance so... throw InvalidDefinitionException.from(ctxt.getParser(), ClassUtil.exceptionMessage(e), - builderDesc, null); + builderDescRef, null); } final DeserializationConfig config = ctxt.getConfig(); - BeanDeserializerBuilder builder = constructBeanDeserializerBuilder(ctxt, builderDesc); + BeanDeserializerBuilder builder = constructBeanDeserializerBuilder(ctxt, builderDescRef); builder.setValueInstantiator(valueInstantiator); // And then "with methods" for deserializing from JSON Object - addBeanProps(ctxt, builderDesc, builder); - addObjectIdReader(ctxt, builderDesc, builder); + addBeanProps(ctxt, builderDescRef, builder); + addObjectIdReader(ctxt, builderDescRef, builder); // managed/back reference fields/setters need special handling... first part - addBackReferenceProperties(ctxt, builderDesc, builder); - addInjectables(ctxt, builderDesc, builder); + addBackReferenceProperties(ctxt, builderDescRef, builder); + addInjectables(ctxt, builderDescRef, builder); - JsonPOJOBuilder.Value builderConfig = builderDesc.findPOJOBuilderConfig(); + JsonPOJOBuilder.Value builderConfig = builderDescRef.get().findPOJOBuilderConfig(); final String buildMethodName = (builderConfig == null) ? JsonPOJOBuilder.DEFAULT_BUILD_METHOD : builderConfig.buildMethodName; // and lastly, find build method to use: - AnnotatedMethod buildMethod = builderDesc.findMethod(buildMethodName, null); + AnnotatedMethod buildMethod = builderDescRef.get().findMethod(buildMethodName, null); if (buildMethod != null) { // note: can't yet throw error; may be given build method if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(buildMethod.getMember(), config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS)); @@ -349,7 +352,7 @@ protected ValueDeserializer buildBuilderBasedDeserializer( // this may give us more information... if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - builder = mod.updateBuilder(config, builderDesc, builder); + builder = mod.updateBuilder(config, builderDescRef, builder); } } ValueDeserializer deserializer = builder.buildBuilderBased( @@ -358,16 +361,16 @@ protected ValueDeserializer buildBuilderBasedDeserializer( // [JACKSON-440]: may have modifier(s) that wants to modify or replace serializer we just built: if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - deserializer = mod.modifyDeserializer(config, builderDesc, deserializer); + deserializer = mod.modifyDeserializer(config, builderDescRef, deserializer); } } return (ValueDeserializer) deserializer; } protected void addObjectIdReader(DeserializationContext ctxt, - BeanDescription beanDesc, BeanDeserializerBuilder builder) + BeanDescription.Supplier beanDescRef, BeanDeserializerBuilder builder) { - ObjectIdInfo objectIdInfo = beanDesc.getObjectIdInfo(); + ObjectIdInfo objectIdInfo = beanDescRef.get().getObjectIdInfo(); if (objectIdInfo == null) { return; } @@ -376,7 +379,7 @@ protected void addObjectIdReader(DeserializationContext ctxt, SettableBeanProperty idProp; ObjectIdGenerator gen; - ObjectIdResolver resolver = ctxt.objectIdResolverInstance(beanDesc.getClassInfo(), objectIdInfo); + ObjectIdResolver resolver = ctxt.objectIdResolverInstance(beanDescRef.getClassInfo(), objectIdInfo); // Just one special case: Property-based generator is trickier if (implClass == ObjectIdGenerators.PropertyGenerator.class) { // most special one, needs extra work @@ -385,7 +388,7 @@ protected void addObjectIdReader(DeserializationContext ctxt, if (idProp == null) { throw new IllegalArgumentException(String.format( "Invalid Object Id definition for %s: cannot find property with name %s", -ClassUtil.getTypeDescription(beanDesc.getType()), +ClassUtil.getTypeDescription(beanDescRef.getType()), ClassUtil.name(propName))); } idType = idProp.getType(); @@ -394,7 +397,7 @@ protected void addObjectIdReader(DeserializationContext ctxt, JavaType type = ctxt.constructType(implClass); idType = ctxt.getTypeFactory().findTypeParameters(type, ObjectIdGenerator.class)[0]; idProp = null; - gen = ctxt.objectIdGeneratorInstance(beanDesc.getClassInfo(), objectIdInfo); + gen = ctxt.objectIdGeneratorInstance(beanDescRef.getClassInfo(), objectIdInfo); } // also: unlike with value deserializers, let's just resolve one we need here ValueDeserializer deser = ctxt.findRootValueDeserializer(idType); @@ -404,14 +407,14 @@ protected void addObjectIdReader(DeserializationContext ctxt, @SuppressWarnings("unchecked") public ValueDeserializer buildThrowableDeserializer(DeserializationContext ctxt, - JavaType type, BeanDescription beanDesc) + JavaType type, BeanDescription.Supplier beanDescRef) { final DeserializationConfig config = ctxt.getConfig(); // first: construct like a regular bean deserializer... - BeanDeserializerBuilder builder = constructBeanDeserializerBuilder(ctxt, beanDesc); - builder.setValueInstantiator(findValueInstantiator(ctxt, beanDesc)); + BeanDeserializerBuilder builder = constructBeanDeserializerBuilder(ctxt, beanDescRef); + builder.setValueInstantiator(findValueInstantiator(ctxt, beanDescRef)); - addBeanProps(ctxt, beanDesc, builder); + addBeanProps(ctxt, beanDescRef, builder); // (and assume there won't be any back references) // But then let's decorate things a bit @@ -427,7 +430,7 @@ public ValueDeserializer buildThrowableDeserializer(DeserializationConte break; } } - AnnotatedMethod am = beanDesc.findMethod("initCause", INIT_CAUSE_PARAMS); + AnnotatedMethod am = beanDescRef.get().findMethod("initCause", INIT_CAUSE_PARAMS); if (am != null) { // should never be null SettableBeanProperty causeCreatorProp = builder.findProperty(PropertyName.construct("cause")); // [databind#4827] : Consider case where sub-classed `Exception` has `JsonCreator` with `cause` parameter @@ -443,7 +446,7 @@ public ValueDeserializer buildThrowableDeserializer(DeserializationConte } SimpleBeanPropertyDefinition propDef = SimpleBeanPropertyDefinition.construct(ctxt.getConfig(), am, new PropertyName(name)); - SettableBeanProperty prop = constructSettableProperty(ctxt, beanDesc, propDef, + SettableBeanProperty prop = constructSettableProperty(ctxt, beanDescRef, propDef, am.getParameterType(0)); if (prop != null) { // 21-Aug-2011, tatus: We may actually have found 'cause' property @@ -455,7 +458,7 @@ public ValueDeserializer buildThrowableDeserializer(DeserializationConte // update builder now that all information is in? if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - builder = mod.updateBuilder(config, beanDesc, builder); + builder = mod.updateBuilder(config, beanDescRef, builder); } } ValueDeserializer deserializer = builder.build(); @@ -469,7 +472,7 @@ public ValueDeserializer buildThrowableDeserializer(DeserializationConte // may have modifier(s) that wants to modify or replace serializer we just built: if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - deserializer = mod.modifyDeserializer(config, beanDesc, deserializer); + deserializer = mod.modifyDeserializer(config, beanDescRef, deserializer); } } return (ValueDeserializer) deserializer; @@ -487,8 +490,8 @@ public ValueDeserializer buildThrowableDeserializer(DeserializationConte * instance. */ protected BeanDeserializerBuilder constructBeanDeserializerBuilder(DeserializationContext ctxt, - BeanDescription beanDesc) { - return new BeanDeserializerBuilder(beanDesc, ctxt); + BeanDescription.Supplier beanDescRef) { + return new BeanDeserializerBuilder(beanDescRef, ctxt); } /** @@ -499,8 +502,9 @@ protected BeanDeserializerBuilder constructBeanDeserializerBuilder(Deserializati * similar between versions. */ protected void addBeanProps(DeserializationContext ctxt, - BeanDescription beanDesc, BeanDeserializerBuilder builder) + BeanDescription.Supplier beanDescRef, BeanDeserializerBuilder builder) { + final BeanDescription beanDesc = beanDescRef.get(); final ValueInstantiator valueInstantiator = builder.getValueInstantiator(); final SettableBeanProperty[] creatorProps = (valueInstantiator != null) ? valueInstantiator.getFromObjectArguments(ctxt.getConfig()) @@ -540,7 +544,7 @@ protected void addBeanProps(DeserializationContext ctxt, } // Also, do we have a fallback "any" setter? - SettableAnyProperty anySetter = _resolveAnySetter(ctxt, beanDesc, creatorProps); + SettableAnyProperty anySetter = _resolveAnySetter(ctxt, beanDescRef, creatorProps); if (anySetter != null) { builder.setAnySetter(anySetter); } else { @@ -562,11 +566,11 @@ protected void addBeanProps(DeserializationContext ctxt, // Ok: let's then filter out property definitions List propDefs = filterBeanProps(ctxt, - beanDesc, builder, beanDesc.findProperties(), ignored, included); + beanDescRef, builder, beanDesc.findProperties(), ignored, included); // After which we can let custom code change the set if (_factoryConfig.hasDeserializerModifiers()) { for (ValueDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { - propDefs = mod.updateProperties(ctxt.getConfig(), beanDesc, propDefs); + propDefs = mod.updateProperties(ctxt.getConfig(), beanDescRef, propDefs); } } @@ -580,11 +584,11 @@ protected void addBeanProps(DeserializationContext ctxt, if (propDef.hasSetter()) { AnnotatedMethod setter = propDef.getSetter(); JavaType propertyType = setter.getParameterType(0); - prop = constructSettableProperty(ctxt, beanDesc, propDef, propertyType); + prop = constructSettableProperty(ctxt, beanDescRef, propDef, propertyType); } else if (propDef.hasField()) { AnnotatedField field = propDef.getField(); JavaType propertyType = field.getType(); - prop = constructSettableProperty(ctxt, beanDesc, propDef, propertyType); + prop = constructSettableProperty(ctxt, beanDescRef, propDef, propertyType); } else { // NOTE: specifically getter, since field was already checked above AnnotatedMethod getter = propDef.getGetter(); @@ -662,21 +666,21 @@ protected void addBeanProps(DeserializationContext ctxt, // since 2.18 private SettableAnyProperty _resolveAnySetter(DeserializationContext ctxt, - BeanDescription beanDesc, SettableBeanProperty[] creatorProps) + BeanDescription.Supplier beanDescRef, SettableBeanProperty[] creatorProps) { // Look for any-setter via @JsonCreator if (creatorProps != null) { for (SettableBeanProperty prop : creatorProps) { AnnotatedMember member = prop.getMember(); if (member != null && Boolean.TRUE.equals(ctxt.getAnnotationIntrospector().hasAnySetter(ctxt.getConfig(), member))) { - return constructAnySetter(ctxt, beanDesc, member); + return constructAnySetter(ctxt, beanDescRef, member); } } } // else find the regular method/field level any-setter - AnnotatedMember anySetter = beanDesc.findAnySetterAccessor(); + AnnotatedMember anySetter = beanDescRef.get().findAnySetterAccessor(); if (anySetter != null) { - return constructAnySetter(ctxt, beanDesc, anySetter); + return constructAnySetter(ctxt, beanDescRef, anySetter); } // not found, that's fine, too return null; @@ -696,7 +700,7 @@ private boolean _isSetterlessType(Class rawType) { * Note that this will not remove properties that have no setters. */ protected List filterBeanProps(DeserializationContext ctxt, - BeanDescription beanDesc, BeanDeserializerBuilder builder, + BeanDescription.Supplier beanDescRef, BeanDeserializerBuilder builder, List propDefsIn, Set ignored, Set included) @@ -731,10 +735,10 @@ && isIgnorableType(ctxt, property, rawPropertyType, ignoredTypes)) { * and if so add them to bean, to be linked during resolution phase. */ protected void addBackReferenceProperties(DeserializationContext ctxt, - BeanDescription beanDesc, BeanDeserializerBuilder builder) + BeanDescription.Supplier beanDescRef, BeanDeserializerBuilder builder) { // and then back references, not necessarily found as regular properties - List refProps = beanDesc.findBackReferences(); + List refProps = beanDescRef.get().findBackReferences(); if (refProps != null) { for (BeanPropertyDefinition refProp : refProps) { /* @@ -755,7 +759,7 @@ protected void addBackReferenceProperties(DeserializationContext ctxt, */ String refName = refProp.findReferenceName(); builder.addBackReferenceProperty(refName, constructSettableProperty(ctxt, - beanDesc, refProp, refProp.getPrimaryType())); + beanDescRef, refProp, refProp.getPrimaryType())); } } } @@ -765,15 +769,15 @@ protected void addBackReferenceProperties(DeserializationContext ctxt, * constructor {@link tools.jackson.databind.deser.impl.ValueInjector} instances, and add them to builder. */ protected void addInjectables(DeserializationContext ctxt, - BeanDescription beanDesc, BeanDeserializerBuilder builder) + BeanDescription.Supplier beanDescRef, BeanDeserializerBuilder builder) { - Map raw = beanDesc.findInjectables(); + Map raw = beanDescRef.get().findInjectables(); if (raw != null) { for (Map.Entry entry : raw.entrySet()) { AnnotatedMember m = entry.getValue(); builder.addInjectable(PropertyName.construct(m.getName()), m.getType(), - beanDesc.getClassAnnotations(), m, entry.getKey()); + beanDescRef.getClassAnnotations(), m, entry.getKey()); } } } @@ -789,7 +793,7 @@ protected void addInjectables(DeserializationContext ctxt, */ @SuppressWarnings("unchecked") protected SettableAnyProperty constructAnySetter(DeserializationContext ctxt, - BeanDescription beanDesc, AnnotatedMember mutator) + BeanDescription.Supplier beanDescRef, AnnotatedMember mutator) { // find the java type based on the annotated setter method or setter field BeanProperty prop; @@ -836,7 +840,7 @@ protected SettableAnyProperty constructAnySetter(DeserializationContext ctxt, prop, mutator, valueType, ctxt.findRootValueDeserializer(valueType)); } else { - return ctxt.reportBadDefinition(beanDesc.getType(), String.format( + return ctxt.reportBadDefinition(beanDescRef.getType(), String.format( "Unsupported type for any-setter: %s -- only support `Map`s, `JsonNode` and `ObjectNode` ", ClassUtil.getTypeDescription(fieldType))); } @@ -863,12 +867,12 @@ protected SettableAnyProperty constructAnySetter(DeserializationContext ctxt, return SettableAnyProperty.constructForJsonNodeParameter(ctxt, prop, mutator, valueType, ctxt.findRootValueDeserializer(valueType), parameterIndex); } else { - return ctxt.reportBadDefinition(beanDesc.getType(), String.format( + return ctxt.reportBadDefinition(beanDescRef.getType(), String.format( "Unsupported type for any-setter: %s -- only support `Map`s, `JsonNode` and `ObjectNode` ", ClassUtil.getTypeDescription(paramType))); } } else { - return ctxt.reportBadDefinition(beanDesc.getType(), String.format( + return ctxt.reportBadDefinition(beanDescRef.getType(), String.format( "Unrecognized mutator type for any-setter: %s", ClassUtil.nameOf(mutator.getClass()))); } @@ -920,7 +924,7 @@ protected SettableAnyProperty constructAnySetter(DeserializationContext ctxt, * there should be no property based on given definitions. */ protected SettableBeanProperty constructSettableProperty(DeserializationContext ctxt, - BeanDescription beanDesc, BeanPropertyDefinition propDef, + BeanDescription.Supplier beanDescRef, BeanPropertyDefinition propDef, JavaType propType0) { // need to ensure method is callable (for non-public) @@ -929,7 +933,7 @@ protected SettableBeanProperty constructSettableProperty(DeserializationContext // going on; add sanity checks to try to pin down actual problem... // Possibly passing creator parameter? if (mutator == null) { - ctxt.reportBadPropertyDefinition(beanDesc, propDef, "No non-constructor mutator available"); + ctxt.reportBadPropertyDefinition(beanDescRef, propDef, "No non-constructor mutator available"); } JavaType type = resolveMemberAndTypeAnnotations(ctxt, mutator, propType0); // Does the Method specify the deserializer to use? If so, let's use it. @@ -937,11 +941,11 @@ protected SettableBeanProperty constructSettableProperty(DeserializationContext SettableBeanProperty prop; if (mutator instanceof AnnotatedMethod) { prop = new MethodProperty(propDef, type, typeDeser, - beanDesc.getClassAnnotations(), (AnnotatedMethod) mutator); + beanDescRef.getClassAnnotations(), (AnnotatedMethod) mutator); } else { // 08-Sep-2016, tatu: wonder if we should verify it is `AnnotatedField` to be safe? prop = new FieldProperty(propDef, type, typeDeser, - beanDesc.getClassAnnotations(), (AnnotatedField) mutator); + beanDescRef.getClassAnnotations(), (AnnotatedField) mutator); } ValueDeserializer deser = findDeserializerFromAnnotation(ctxt, mutator); if (deser == null) { @@ -1051,8 +1055,8 @@ protected boolean isIgnorableType(DeserializationContext ctxt, BeanPropertyDefin // @since 2.8.11 protected void _validateSubType(DeserializationContext ctxt, JavaType type, - BeanDescription beanDesc) + BeanDescription.Supplier beanDescRef) { - SubTypeValidator.instance().validateSubType(ctxt, type, beanDesc); + SubTypeValidator.instance().validateSubType(ctxt, type, beanDescRef); } } diff --git a/src/main/java/tools/jackson/databind/deser/DeserializerCache.java b/src/main/java/tools/jackson/databind/deser/DeserializerCache.java index a258540c57..f3152ffd40 100644 --- a/src/main/java/tools/jackson/databind/deser/DeserializerCache.java +++ b/src/main/java/tools/jackson/databind/deser/DeserializerCache.java @@ -322,46 +322,46 @@ protected ValueDeserializer _createDeserializer(DeserializationContext c if (type.isAbstract() || type.isMapLikeType() || type.isCollectionLikeType()) { type = config.mapAbstractType(type); } - BeanDescription beanDesc = ctxt.introspectBeanDescription(type); + BeanDescription.Supplier beanDescRef = ctxt.lazyIntrospectBeanDescription(type); // Then: does type define explicit deserializer to use, with annotation(s)? ValueDeserializer deser = findDeserializerFromAnnotation(ctxt, - beanDesc.getClassInfo()); + beanDescRef.getClassInfo()); if (deser != null) { return deser; } // If not, may have further type-modification annotations to check: - JavaType newType = modifyTypeByAnnotation(ctxt, beanDesc.getClassInfo(), type); + JavaType newType = modifyTypeByAnnotation(ctxt, beanDescRef.getClassInfo(), type); if (newType != type) { type = newType; - beanDesc = ctxt.introspectBeanDescription(newType); + beanDescRef = ctxt.lazyIntrospectBeanDescription(newType); } // We may also have a Builder type to consider... - Class builder = beanDesc.findPOJOBuilder(); + Class builder = beanDescRef.get().findPOJOBuilder(); if (builder != null) { return (ValueDeserializer) factory.createBuilderBasedDeserializer( - ctxt, type, beanDesc, builder); + ctxt, type, beanDescRef, builder); } // Or perhaps a Converter? - Converter conv = beanDesc.findDeserializationConverter(); + Converter conv = beanDescRef.get().findDeserializationConverter(); if (conv != null) { // otherwise need to do bit of introspection JavaType delegateType = conv.getInputType(ctxt.getTypeFactory()); // One more twist, as per [databind#288]; probably need to get new BeanDesc if (!delegateType.hasRawClass(type.getRawClass())) { - beanDesc = ctxt.introspectBeanDescription(delegateType); + beanDescRef = ctxt.lazyIntrospectBeanDescription(delegateType); } return new StdConvertingDeserializer(conv, delegateType, - _createDeserializer2(ctxt, factory, delegateType, beanDesc)); + _createDeserializer2(ctxt, factory, delegateType, beanDescRef)); } // Nope, regular deserializer - return (ValueDeserializer) _createDeserializer2(ctxt, factory, type, beanDesc); + return (ValueDeserializer) _createDeserializer2(ctxt, factory, type, beanDescRef); } protected ValueDeserializer _createDeserializer2(DeserializationContext ctxt, - DeserializerFactory factory, JavaType type, BeanDescription beanDesc) + DeserializerFactory factory, JavaType type, BeanDescription.Supplier beanDescRef) { final DeserializationConfig config = ctxt.getConfig(); // If not, let's see which factory method to use @@ -369,11 +369,11 @@ protected ValueDeserializer _createDeserializer2(DeserializationContext ctxt, // 12-Feb-20202, tatu: Need to ensure that not only all Enum implementations get // there, but also `Enum` -- latter wrt [databind#2605], polymorphic usage if (type.isEnumType()) { - return factory.createEnumDeserializer(ctxt, type, beanDesc); + return factory.createEnumDeserializer(ctxt, type, beanDescRef); } if (type.isContainerType()) { if (type.isArrayType()) { - return factory.createArrayDeserializer(ctxt, (ArrayType) type, beanDesc); + return factory.createArrayDeserializer(ctxt, (ArrayType) type, beanDescRef); } if (type.isMapLikeType()) { // 11-Mar-2017, tatu: As per [databind#1554], also need to block @@ -381,13 +381,13 @@ protected ValueDeserializer _createDeserializer2(DeserializationContext ctxt, // Ideally we'd determine it bit later on (to allow custom handler checks) // but that won't work for other reasons. So do it here. // (read: rewrite for 3.0) - JsonFormat.Value format = beanDesc.findExpectedFormat(type.getRawClass()); + JsonFormat.Value format = beanDescRef.get().findExpectedFormat(type.getRawClass()); if (format.getShape() != JsonFormat.Shape.POJO) { MapLikeType mlt = (MapLikeType) type; if (mlt instanceof MapType) { - return factory.createMapDeserializer(ctxt,(MapType) mlt, beanDesc); + return factory.createMapDeserializer(ctxt,(MapType) mlt, beanDescRef); } - return factory.createMapLikeDeserializer(ctxt, mlt, beanDesc); + return factory.createMapLikeDeserializer(ctxt, mlt, beanDescRef); } } if (type.isCollectionLikeType()) { @@ -395,23 +395,23 @@ protected ValueDeserializer _createDeserializer2(DeserializationContext ctxt, * Ideally we'd determine it bit later on (to allow custom handler checks), * but that won't work for other reasons. So do it here. */ - JsonFormat.Value format = beanDesc.findExpectedFormat(type.getRawClass()); + JsonFormat.Value format = beanDescRef.get().findExpectedFormat(type.getRawClass()); if (format.getShape() != JsonFormat.Shape.POJO) { CollectionLikeType clt = (CollectionLikeType) type; if (clt instanceof CollectionType) { - return factory.createCollectionDeserializer(ctxt, (CollectionType) clt, beanDesc); + return factory.createCollectionDeserializer(ctxt, (CollectionType) clt, beanDescRef); } - return factory.createCollectionLikeDeserializer(ctxt, clt, beanDesc); + return factory.createCollectionLikeDeserializer(ctxt, clt, beanDescRef); } } } if (type.isReferenceType()) { - return factory.createReferenceDeserializer(ctxt, (ReferenceType) type, beanDesc); + return factory.createReferenceDeserializer(ctxt, (ReferenceType) type, beanDescRef); } if (JsonNode.class.isAssignableFrom(type.getRawClass())) { - return factory.createTreeDeserializer(config, type, beanDesc); + return factory.createTreeDeserializer(config, type, beanDescRef); } - return factory.createBeanDeserializer(ctxt, type, beanDesc); + return factory.createBeanDeserializer(ctxt, type, beanDescRef); } /** diff --git a/src/main/java/tools/jackson/databind/deser/DeserializerFactory.java b/src/main/java/tools/jackson/databind/deser/DeserializerFactory.java index 369b2ae247..39486ac16b 100644 --- a/src/main/java/tools/jackson/databind/deser/DeserializerFactory.java +++ b/src/main/java/tools/jackson/databind/deser/DeserializerFactory.java @@ -51,7 +51,7 @@ public abstract class DeserializerFactory * for the bean type to deserialize. */ public abstract ValueInstantiator findValueInstantiator(DeserializationContext ctxt, - BeanDescription beanDesc); + BeanDescription.Supplier beanDescRef); /** * Method called to create (or, for completely immutable deserializers, @@ -66,28 +66,28 @@ public abstract ValueInstantiator findValueInstantiator(DeserializationContext c * @param type Type to be deserialized */ public abstract ValueDeserializer createBeanDeserializer(DeserializationContext ctxt, - JavaType type, BeanDescription beanDesc); + JavaType type, BeanDescription.Supplier beanDescRef); /** * Method called to create a deserializer that will use specified Builder * class for building value instances. */ public abstract ValueDeserializer createBuilderBasedDeserializer( - DeserializationContext ctxt, JavaType type, BeanDescription beanDesc, + DeserializationContext ctxt, JavaType type, BeanDescription.Supplier beanDescRef, Class builderClass); public abstract ValueDeserializer createEnumDeserializer(DeserializationContext ctxt, - JavaType type, BeanDescription beanDesc); + JavaType type, BeanDescription.Supplier beanDescRef); public abstract ValueDeserializer createReferenceDeserializer(DeserializationContext ctxt, - ReferenceType type, BeanDescription beanDesc); + ReferenceType type, BeanDescription.Supplier beanDescRef); /** * Method called to create and return a deserializer that can construct * JsonNode(s) from JSON content. */ public abstract ValueDeserializer createTreeDeserializer(DeserializationConfig config, - JavaType type, BeanDescription beanDesc); + JavaType type, BeanDescription.Supplier beanDescRef); /** * Method called to create (or, for completely immutable deserializers, @@ -97,19 +97,19 @@ public abstract ValueDeserializer createTreeDeserializer(DeserializationConfi * @param type Type to be deserialized */ public abstract ValueDeserializer createArrayDeserializer(DeserializationContext ctxt, - ArrayType type, BeanDescription beanDesc); + ArrayType type, BeanDescription.Supplier beanDescRef); public abstract ValueDeserializer createCollectionDeserializer(DeserializationContext ctxt, - CollectionType type, BeanDescription beanDesc); + CollectionType type, BeanDescription.Supplier beanDescRef); public abstract ValueDeserializer createCollectionLikeDeserializer(DeserializationContext ctxt, - CollectionLikeType type, BeanDescription beanDesc); + CollectionLikeType type, BeanDescription.Supplier beanDescRef); public abstract ValueDeserializer createMapDeserializer(DeserializationContext ctxt, - MapType type, BeanDescription beanDesc); + MapType type, BeanDescription.Supplier beanDescRef); public abstract ValueDeserializer createMapLikeDeserializer(DeserializationContext ctxt, - MapLikeType type, BeanDescription beanDesc); + MapLikeType type, BeanDescription.Supplier beanDescRef); /** * Method called to find if factory knows how to create a key deserializer diff --git a/src/main/java/tools/jackson/databind/deser/Deserializers.java b/src/main/java/tools/jackson/databind/deser/Deserializers.java index 7d46cc640c..eb2abe2d38 100644 --- a/src/main/java/tools/jackson/databind/deser/Deserializers.java +++ b/src/main/java/tools/jackson/databind/deser/Deserializers.java @@ -24,13 +24,13 @@ public interface Deserializers * * @param type Type of {@link java.lang.Enum} instances to deserialize * @param config Configuration in effect - * @param beanDesc Definition of the enumeration type that contains class annotations and + * @param beanDescRef Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public ValueDeserializer findEnumDeserializer(Class type, - DeserializationConfig config, BeanDescription beanDesc); + DeserializationConfig config, BeanDescription.Supplier beanDescRef); /** * Method called to locate deserializer for specified JSON tree node type. @@ -42,7 +42,7 @@ public ValueDeserializer findEnumDeserializer(Class type, * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public ValueDeserializer findTreeNodeDeserializer(Class nodeType, - DeserializationConfig config, BeanDescription beanDesc); + DeserializationConfig config, BeanDescription.Supplier beanDescRef); /** * Method called to locate deserializer for specified value type which does not belong to any other @@ -50,13 +50,13 @@ public ValueDeserializer findTreeNodeDeserializer(Class n * * @param type Bean type to deserialize * @param config Configuration in effect - * @param beanDesc Definition of the enumeration type that contains class annotations and + * @param beanDescRef Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public ValueDeserializer findBeanDeserializer(JavaType type, - DeserializationConfig config, BeanDescription beanDesc); + DeserializationConfig config, BeanDescription.Supplier beanDescRef); // // // Then container types @@ -66,7 +66,7 @@ public ValueDeserializer findBeanDeserializer(JavaType type, * * @param refType Specific referential type to deserialize * @param config Configuration in effect - * @param beanDesc Definition of the reference type that contains class annotations and + * @param beanDescRef Definition of the reference type that contains class annotations and * other information typically needed for building deserializers * @param contentTypeDeserializer Possible type deserializer for referenced value * @param contentDeserializer Value deserializer to use for referenced value, if indicated @@ -75,7 +75,7 @@ public ValueDeserializer findBeanDeserializer(JavaType type, * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public ValueDeserializer findReferenceDeserializer(ReferenceType refType, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer contentTypeDeserializer, ValueDeserializer contentDeserializer); /** @@ -88,7 +88,7 @@ public ValueDeserializer findReferenceDeserializer(ReferenceType refType, * * @param type Type of array instances to deserialize * @param config Configuration in effect - * @param beanDesc Definition of the enumeration type that contains class annotations and + * @param beanDescRef Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * @param elementTypeDeserializer If element type needs polymorphic type handling, this is * the type information deserializer to use; should usually be used as is when constructing @@ -100,7 +100,7 @@ public ValueDeserializer findReferenceDeserializer(ReferenceType refType, * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public ValueDeserializer findArrayDeserializer(ArrayType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer); /** @@ -113,7 +113,7 @@ public ValueDeserializer findArrayDeserializer(ArrayType type, * * @param type Type of collection instances to deserialize * @param config Configuration in effect - * @param beanDesc Definition of the enumeration type that contains class annotations and + * @param beanDescRef Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * @param elementTypeDeserializer If element type needs polymorphic type handling, this is * the type information deserializer to use; should usually be used as is when constructing @@ -125,7 +125,7 @@ public ValueDeserializer findArrayDeserializer(ArrayType type, * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public ValueDeserializer findCollectionDeserializer(CollectionType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer); /** @@ -140,7 +140,7 @@ public ValueDeserializer findCollectionDeserializer(CollectionType type, * * @param type Type of instances to deserialize * @param config Configuration in effect - * @param beanDesc Definition of the enumeration type that contains class annotations and + * @param beanDescRef Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * @param elementTypeDeserializer If element type needs polymorphic type handling, this is * the type information deserializer to use; should usually be used as is when constructing @@ -152,7 +152,7 @@ public ValueDeserializer findCollectionDeserializer(CollectionType type, * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public ValueDeserializer findCollectionLikeDeserializer(CollectionLikeType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer); /** @@ -170,7 +170,7 @@ public ValueDeserializer findCollectionLikeDeserializer(CollectionLikeType ty * * @param type Type of {@link java.util.Map} instances to deserialize * @param config Configuration in effect - * @param beanDesc Definition of the enumeration type that contains class annotations and + * @param beanDescRef Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * @param keyDeserializer Key deserializer use, if it is defined via annotations or other configuration; * null if default key deserializer for key type can be used. @@ -184,7 +184,7 @@ public ValueDeserializer findCollectionLikeDeserializer(CollectionLikeType ty * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public ValueDeserializer findMapDeserializer(MapType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer); @@ -205,7 +205,7 @@ public ValueDeserializer findMapDeserializer(MapType type, * * @param type Type of {@link java.util.Map} instances to deserialize * @param config Configuration in effect - * @param beanDesc Definition of the enumeration type that contains class annotations and + * @param beanDescRef Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * @param keyDeserializer Key deserializer use, if it is defined via annotations or other configuration; * null if default key deserializer for key type can be used. @@ -219,7 +219,7 @@ public ValueDeserializer findMapDeserializer(MapType type, * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public ValueDeserializer findMapLikeDeserializer(MapLikeType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer); @@ -255,21 +255,21 @@ public abstract static class Base { @Override public ValueDeserializer findEnumDeserializer(Class type, - DeserializationConfig config, BeanDescription beanDesc) + DeserializationConfig config, BeanDescription.Supplier beanDescRef) { return null; } @Override public ValueDeserializer findTreeNodeDeserializer(Class nodeType, - DeserializationConfig config, BeanDescription beanDesc) + DeserializationConfig config, BeanDescription.Supplier beanDescRef) { return null; } @Override public ValueDeserializer findReferenceDeserializer(ReferenceType refType, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer contentTypeDeserializer, ValueDeserializer contentDeserializer) { return null; @@ -277,14 +277,14 @@ public ValueDeserializer findReferenceDeserializer(ReferenceType refType, @Override public ValueDeserializer findBeanDeserializer(JavaType type, - DeserializationConfig config, BeanDescription beanDesc) + DeserializationConfig config, BeanDescription.Supplier beanDescRef) { return null; } @Override public ValueDeserializer findArrayDeserializer(ArrayType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { return null; @@ -292,7 +292,7 @@ public ValueDeserializer findArrayDeserializer(ArrayType type, @Override public ValueDeserializer findCollectionDeserializer(CollectionType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { return null; @@ -300,7 +300,7 @@ public ValueDeserializer findCollectionDeserializer(CollectionType type, @Override public ValueDeserializer findCollectionLikeDeserializer(CollectionLikeType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { return null; @@ -308,7 +308,7 @@ public ValueDeserializer findCollectionLikeDeserializer(CollectionLikeType ty @Override public ValueDeserializer findMapDeserializer(MapType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { @@ -317,7 +317,7 @@ public ValueDeserializer findMapDeserializer(MapType type, @Override public ValueDeserializer findMapLikeDeserializer(MapLikeType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { diff --git a/src/main/java/tools/jackson/databind/deser/ValueDeserializerModifier.java b/src/main/java/tools/jackson/databind/deser/ValueDeserializerModifier.java index 57aa14031f..49759ee724 100644 --- a/src/main/java/tools/jackson/databind/deser/ValueDeserializerModifier.java +++ b/src/main/java/tools/jackson/databind/deser/ValueDeserializerModifier.java @@ -63,7 +63,7 @@ public abstract class ValueDeserializerModifier * to make at later points. */ public List updateProperties(DeserializationConfig config, - BeanDescription beanDesc, List propDefs) { + BeanDescription.Supplier beanDescRef, List propDefs) { return propDefs; } @@ -76,7 +76,7 @@ public List updateProperties(DeserializationConfig confi * deserializer). Typically changes mostly concern set of properties to deserialize. */ public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, - BeanDescription beanDesc, BeanDeserializerBuilder builder) { + BeanDescription.Supplier beanDescRef, BeanDeserializerBuilder builder) { return builder; } @@ -93,7 +93,7 @@ public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, * node type) */ public ValueDeserializer modifyDeserializer(DeserializationConfig config, - BeanDescription beanDesc, ValueDeserializer deserializer) { + BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { return deserializer; } @@ -108,7 +108,7 @@ public ValueDeserializer modifyDeserializer(DeserializationConfig config, * enum type deserializer instance. */ public ValueDeserializer modifyEnumDeserializer(DeserializationConfig config, - JavaType type, BeanDescription beanDesc, ValueDeserializer deserializer) { + JavaType type, BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { return deserializer; } @@ -117,7 +117,7 @@ public ValueDeserializer modifyEnumDeserializer(DeserializationConfig config, * {@link ReferenceType} deserializer instance. */ public ValueDeserializer modifyReferenceDeserializer(DeserializationConfig config, - ReferenceType type, BeanDescription beanDesc, ValueDeserializer deserializer) { + ReferenceType type, BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { return deserializer; } @@ -130,14 +130,14 @@ public ValueDeserializer modifyReferenceDeserializer(DeserializationConfig co * * @param config Configuration in use * @param valueType Type of the value deserializer is used for. - * @param beanDesc Description f + * @param beanDescRef Description of the type to deserialize * @param deserializer Default deserializer that would be used. * * @return Deserializer to use; either deserializer that was passed * in, or an instance method constructed. */ public ValueDeserializer modifyArrayDeserializer(DeserializationConfig config, - ArrayType valueType, BeanDescription beanDesc, ValueDeserializer deserializer) { + ArrayType valueType, BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { return deserializer; } @@ -146,7 +146,7 @@ public ValueDeserializer modifyArrayDeserializer(DeserializationConfig config * {@link CollectionType} deserializer instance. */ public ValueDeserializer modifyCollectionDeserializer(DeserializationConfig config, - CollectionType type, BeanDescription beanDesc, ValueDeserializer deserializer) { + CollectionType type, BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { return deserializer; } @@ -155,7 +155,7 @@ public ValueDeserializer modifyCollectionDeserializer(DeserializationConfig c * {@link CollectionLikeType} deserializer instance. */ public ValueDeserializer modifyCollectionLikeDeserializer(DeserializationConfig config, - CollectionLikeType type, BeanDescription beanDesc, ValueDeserializer deserializer) { + CollectionLikeType type, BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { return deserializer; } @@ -164,7 +164,7 @@ public ValueDeserializer modifyCollectionLikeDeserializer(DeserializationConf * {@link MapType} deserializer instance. */ public ValueDeserializer modifyMapDeserializer(DeserializationConfig config, - MapType type, BeanDescription beanDesc, ValueDeserializer deserializer) { + MapType type, BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { return deserializer; } @@ -173,7 +173,7 @@ public ValueDeserializer modifyMapDeserializer(DeserializationConfig config, * {@link MapLikeType} deserializer instance. */ public ValueDeserializer modifyMapLikeDeserializer(DeserializationConfig config, - MapLikeType type, BeanDescription beanDesc, ValueDeserializer deserializer) { + MapLikeType type, BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { return deserializer; } diff --git a/src/main/java/tools/jackson/databind/deser/ValueInstantiator.java b/src/main/java/tools/jackson/databind/deser/ValueInstantiator.java index 7b8757eae1..381b9578b8 100644 --- a/src/main/java/tools/jackson/databind/deser/ValueInstantiator.java +++ b/src/main/java/tools/jackson/databind/deser/ValueInstantiator.java @@ -64,7 +64,7 @@ public interface Gettable { * @since 3.0 */ public abstract ValueInstantiator createContextual(DeserializationContext ctxt, - BeanDescription beanDesc); + BeanDescription.Supplier beanDescRef); /* /********************************************************************** @@ -414,7 +414,7 @@ public Base(JavaType type) { @Override public ValueInstantiator createContextual(DeserializationContext ctxt, - BeanDescription beanDesc) + BeanDescription.Supplier beanDescRef) { return this; } @@ -448,9 +448,10 @@ protected Delegating(ValueInstantiator delegate) { } @Override - public ValueInstantiator createContextual(DeserializationContext ctxt, BeanDescription beanDesc) + public ValueInstantiator createContextual(DeserializationContext ctxt, + BeanDescription.Supplier beanDescRef) { - ValueInstantiator d = _delegate.createContextual(ctxt, beanDesc); + ValueInstantiator d = _delegate.createContextual(ctxt, beanDescRef); return (d == _delegate) ? this : new Delegating(d); } diff --git a/src/main/java/tools/jackson/databind/deser/ValueInstantiators.java b/src/main/java/tools/jackson/databind/deser/ValueInstantiators.java index 90f71281d3..a4979a85ec 100644 --- a/src/main/java/tools/jackson/databind/deser/ValueInstantiators.java +++ b/src/main/java/tools/jackson/databind/deser/ValueInstantiators.java @@ -20,13 +20,13 @@ public interface ValueInstantiators * to use or modify that. * * @param config Deserialization configuration in use - * @param beanDesc Additional information about POJO type to be instantiated + * @param beanDescRef Additional information about POJO type to be instantiated * * @return Instantiator to use if custom one wanted, or {@code null} to indicate * "use default instantiator". */ public ValueInstantiator findValueInstantiator(DeserializationConfig config, - BeanDescription beanDesc); + BeanDescription.Supplier beanDescRef); /** * Method called to find the {@link ValueInstantiator} to use for creating @@ -36,7 +36,7 @@ public ValueInstantiator findValueInstantiator(DeserializationConfig config, * passed instance as is (returning null is an error) * * @param config Deserialization configuration in use - * @param beanDesc Additional information about POJO type to be instantiated + * @param beanDescRef Additional information about POJO type to be instantiated * @param defaultInstantiator Instantiator that will be used if no changes are made; * passed to allow custom instances to use annotation-provided information * (note, however, that earlier {@link ValueInstantiators} may have changed it to @@ -46,7 +46,7 @@ public ValueInstantiator findValueInstantiator(DeserializationConfig config, * or a custom variant; cannot be null. */ default ValueInstantiator modifyValueInstantiator(DeserializationConfig config, - BeanDescription beanDesc, ValueInstantiator defaultInstantiator) { + BeanDescription.Supplier beanDescRef, ValueInstantiator defaultInstantiator) { return defaultInstantiator; } @@ -59,7 +59,7 @@ public static class Base implements ValueInstantiators { @Override public ValueInstantiator findValueInstantiator(DeserializationConfig config, - BeanDescription beanDesc) { + BeanDescription.Supplier beanDescRef) { return null; } } diff --git a/src/main/java/tools/jackson/databind/deser/bean/BeanDeserializer.java b/src/main/java/tools/jackson/databind/deser/bean/BeanDeserializer.java index f58ebdba35..26569edd42 100644 --- a/src/main/java/tools/jackson/databind/deser/bean/BeanDeserializer.java +++ b/src/main/java/tools/jackson/databind/deser/bean/BeanDeserializer.java @@ -47,12 +47,12 @@ public class BeanDeserializer /** * Constructor used by {@link BeanDeserializerBuilder}. */ - public BeanDeserializer(BeanDeserializerBuilder builder, BeanDescription beanDesc, + public BeanDeserializer(BeanDeserializerBuilder builder, BeanDescription.Supplier beanDescRef, BeanPropertyMap properties, Map backRefs, HashSet ignorableProps, boolean ignoreAllUnknown, Set includableProps, boolean hasViews) { - super(builder, beanDesc, properties, backRefs, + super(builder, beanDescRef, properties, backRefs, ignorableProps, ignoreAllUnknown, includableProps, hasViews); } diff --git a/src/main/java/tools/jackson/databind/deser/bean/BeanDeserializerBase.java b/src/main/java/tools/jackson/databind/deser/bean/BeanDeserializerBase.java index df7ae7eb72..1bcd7bfece 100644 --- a/src/main/java/tools/jackson/databind/deser/bean/BeanDeserializerBase.java +++ b/src/main/java/tools/jackson/databind/deser/bean/BeanDeserializerBase.java @@ -206,14 +206,14 @@ public abstract class BeanDeserializerBase * contains configuration. */ protected BeanDeserializerBase(BeanDeserializerBuilder builder, - BeanDescription beanDesc, + BeanDescription.Supplier beanDescRef, BeanPropertyMap properties, Map backRefs, Set ignorableProps, boolean ignoreAllUnknown, Set includableProps, boolean hasViews) { - super(beanDesc.getType()); - _beanType = beanDesc.getType(); + super(beanDescRef.getType()); + _beanType = beanDescRef.getType(); _valueInstantiator = builder.getValueInstantiator(); _delegateDeserializer = null; @@ -247,7 +247,7 @@ protected BeanDeserializerBase(BeanDeserializerBuilder builder, ; // Any transformation we may need to apply? - _serializationShape = beanDesc.findExpectedFormat(_beanType.getRawClass()).getShape(); + _serializationShape = beanDescRef.get().findExpectedFormat(_beanType.getRawClass()).getShape(); _needViewProcesing = hasViews; _vanillaProcessing = !_nonStandardCreation diff --git a/src/main/java/tools/jackson/databind/deser/bean/BuilderBasedDeserializer.java b/src/main/java/tools/jackson/databind/deser/bean/BuilderBasedDeserializer.java index 73ec42ece6..6c34914d59 100644 --- a/src/main/java/tools/jackson/databind/deser/bean/BuilderBasedDeserializer.java +++ b/src/main/java/tools/jackson/databind/deser/bean/BuilderBasedDeserializer.java @@ -60,31 +60,32 @@ public class BuilderBasedDeserializer * Constructor used by {@link BeanDeserializerBuilder}. */ public BuilderBasedDeserializer(BeanDeserializerBuilder builder, - BeanDescription beanDesc, JavaType targetType, + BeanDescription.Supplier beanDescRef, JavaType targetType, BeanPropertyMap properties, Map backRefs, Set ignorableProps, boolean ignoreAllUnknown, boolean hasViews) { - this(builder, beanDesc, targetType, properties, backRefs, ignorableProps, ignoreAllUnknown, null, hasViews); + this(builder, beanDescRef, targetType, properties, backRefs, ignorableProps, ignoreAllUnknown, + null, hasViews); } /** * @since 2.12 */ public BuilderBasedDeserializer(BeanDeserializerBuilder builder, - BeanDescription beanDesc, JavaType targetType, + BeanDescription.Supplier beanDescRef, JavaType targetType, BeanPropertyMap properties, Map backRefs, Set ignorableProps, boolean ignoreAllUnknown, Set includableProps, boolean hasViews) { - super(builder, beanDesc, properties, backRefs, + super(builder, beanDescRef, properties, backRefs, ignorableProps, ignoreAllUnknown, includableProps, hasViews); _targetType = targetType; _buildMethod = builder.getBuildMethod(); // 05-Mar-2012, tatu: Cannot really make Object Ids work with builders, not yet anyway if (_objectIdReader != null) { throw new IllegalArgumentException("Cannot use Object Id with Builder-based deserialization (type " - +beanDesc.getType()+")"); + +beanDescRef.getType()+")"); } } diff --git a/src/main/java/tools/jackson/databind/deser/bean/CreatorCollector.java b/src/main/java/tools/jackson/databind/deser/bean/CreatorCollector.java index 0400311fde..2177f5d073 100644 --- a/src/main/java/tools/jackson/databind/deser/bean/CreatorCollector.java +++ b/src/main/java/tools/jackson/databind/deser/bean/CreatorCollector.java @@ -37,7 +37,7 @@ public class CreatorCollector /** * Type of bean being created */ - protected final BeanDescription _beanDesc; + protected final JavaType _beanType; protected final boolean _canFixAccess; @@ -70,8 +70,8 @@ public class CreatorCollector /********************************************************** */ - public CreatorCollector(BeanDescription beanDesc, MapperConfig config) { - _beanDesc = beanDesc; + public CreatorCollector(MapperConfig config, JavaType beanType) { + _beanType = beanType; _canFixAccess = config.canOverrideAccessModifiers(); _forceAccess = config .isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS); @@ -84,9 +84,8 @@ public ValueInstantiator constructValueInstantiator(DeserializationContext ctxt) _creators[C_DELEGATE], _delegateArgs); final JavaType arrayDelegateType = _computeDelegateType(ctxt, _creators[C_ARRAY_DELEGATE], _arrayDelegateArgs); - final JavaType type = _beanDesc.getType(); - StdValueInstantiator inst = new StdValueInstantiator(config, type); + StdValueInstantiator inst = new StdValueInstantiator(config, _beanType); inst.configureFromObjectSettings(_creators[C_DEFAULT], _creators[C_DELEGATE], delegateType, _delegateArgs, _creators[C_PROPS], _propertyBasedArgs); @@ -182,7 +181,7 @@ public void addPropertyCreator(AnnotatedWithParams creator, if (old != null) { throw new IllegalArgumentException(String.format( "Duplicate creator property \"%s\" (index %s vs %d) for type %s ", - name, old, i, ClassUtil.nameOf(_beanDesc.getBeanClass()))); + name, old, i, ClassUtil.nameOf(_beanType.getRawClass()))); } } } @@ -196,23 +195,14 @@ public void addPropertyCreator(AnnotatedWithParams creator, /********************************************************** */ - /** - * @since 2.1 - */ public boolean hasDefaultCreator() { return _creators[C_DEFAULT] != null; } - /** - * @since 2.6 - */ public boolean hasDelegatingCreator() { return _creators[C_DELEGATE] != null; } - /** - * @since 2.6 - */ public boolean hasPropertyBasedCreator() { return _creators[C_PROPS] != null; } diff --git a/src/main/java/tools/jackson/databind/deser/std/StdValueInstantiator.java b/src/main/java/tools/jackson/databind/deser/std/StdValueInstantiator.java index 2ec8f7ae6f..946dee6ca1 100644 --- a/src/main/java/tools/jackson/databind/deser/std/StdValueInstantiator.java +++ b/src/main/java/tools/jackson/databind/deser/std/StdValueInstantiator.java @@ -111,7 +111,7 @@ protected StdValueInstantiator(StdValueInstantiator src) @Override public ValueInstantiator createContextual(DeserializationContext ctxt, - BeanDescription beanDesc) + BeanDescription.Supplier beanDescRef) { return this; } diff --git a/src/main/java/tools/jackson/databind/exc/InvalidDefinitionException.java b/src/main/java/tools/jackson/databind/exc/InvalidDefinitionException.java index d909e50e80..dae4337e11 100644 --- a/src/main/java/tools/jackson/databind/exc/InvalidDefinitionException.java +++ b/src/main/java/tools/jackson/databind/exc/InvalidDefinitionException.java @@ -60,6 +60,11 @@ public static InvalidDefinitionException from(JsonParser p, String msg, return new InvalidDefinitionException(p, msg, bean, prop); } + public static InvalidDefinitionException from(JsonParser p, String msg, + BeanDescription.Supplier beanDescRef, BeanPropertyDefinition prop) { + return new InvalidDefinitionException(p, msg, beanDescRef.get(), prop); + } + public static InvalidDefinitionException from(JsonParser p, String msg, JavaType type) { return new InvalidDefinitionException(p, msg, type); diff --git a/src/main/java/tools/jackson/databind/ext/javatime/JavaTimeInitializer.java b/src/main/java/tools/jackson/databind/ext/javatime/JavaTimeInitializer.java index 6d24f1448b..618e3e680d 100644 --- a/src/main/java/tools/jackson/databind/ext/javatime/JavaTimeInitializer.java +++ b/src/main/java/tools/jackson/databind/ext/javatime/JavaTimeInitializer.java @@ -165,9 +165,9 @@ public void setupModule(JacksonModule.SetupContext context) { context.addValueInstantiators(new ValueInstantiators.Base() { @Override public ValueInstantiator modifyValueInstantiator(DeserializationConfig config, - BeanDescription beanDesc, ValueInstantiator defaultInstantiator) + BeanDescription.Supplier beanDescRef, ValueInstantiator defaultInstantiator) { - JavaType type = beanDesc.getType(); + JavaType type = beanDescRef.getType(); Class raw = type.getRawClass(); // 15-May-2015, tatu: In theory not safe, but in practice we do need to do "fuzzy" matching @@ -181,7 +181,7 @@ public ValueInstantiator modifyValueInstantiator(DeserializationConfig config, // one further complication: we need ZoneId info, not sub-class AnnotatedClass ac; if (raw == ZoneId.class) { - ac = beanDesc.getClassInfo(); + ac = beanDescRef.getClassInfo(); } else { // we don't need Annotations, so constructing directly is fine here // even if it's not generally recommended diff --git a/src/main/java/tools/jackson/databind/ext/javatime/deser/JavaTimeDeserializerModifier.java b/src/main/java/tools/jackson/databind/ext/javatime/deser/JavaTimeDeserializerModifier.java index 815485175f..831900a7f6 100644 --- a/src/main/java/tools/jackson/databind/ext/javatime/deser/JavaTimeDeserializerModifier.java +++ b/src/main/java/tools/jackson/databind/ext/javatime/deser/JavaTimeDeserializerModifier.java @@ -16,7 +16,7 @@ public JavaTimeDeserializerModifier() { } @Override public ValueDeserializer modifyEnumDeserializer(DeserializationConfig config, JavaType type, - BeanDescription beanDesc, ValueDeserializer defaultDeserializer) { + BeanDescription.Supplier beanDescRef, ValueDeserializer defaultDeserializer) { if (type.hasRawClass(Month.class)) { return new OneBasedMonthDeserializer(defaultDeserializer); } diff --git a/src/main/java/tools/jackson/databind/jsontype/impl/SubTypeValidator.java b/src/main/java/tools/jackson/databind/jsontype/impl/SubTypeValidator.java index d08fbdc3a5..f7987fafc5 100644 --- a/src/main/java/tools/jackson/databind/jsontype/impl/SubTypeValidator.java +++ b/src/main/java/tools/jackson/databind/jsontype/impl/SubTypeValidator.java @@ -256,7 +256,7 @@ protected SubTypeValidator() { } public static SubTypeValidator instance() { return instance; } public void validateSubType(DeserializationContext ctxt, JavaType type, - BeanDescription beanDesc) + BeanDescription.Supplier beanDescRef) { // There are certain nasty classes that could cause problems, mostly // via default typing -- catch them here. @@ -298,7 +298,7 @@ public void validateSubType(DeserializationContext ctxt, JavaType type, return; } while (false); - ctxt.reportBadTypeDefinition(beanDesc, + ctxt.reportBadTypeDefinition(beanDescRef, "Illegal type (%s) to deserialize: prevented for security reasons", full); } } diff --git a/src/main/java/tools/jackson/databind/module/SimpleAbstractTypeResolver.java b/src/main/java/tools/jackson/databind/module/SimpleAbstractTypeResolver.java index 30dbf148ff..868797c4b4 100644 --- a/src/main/java/tools/jackson/databind/module/SimpleAbstractTypeResolver.java +++ b/src/main/java/tools/jackson/databind/module/SimpleAbstractTypeResolver.java @@ -82,7 +82,7 @@ public JavaType findTypeMapping(DeserializationConfig config, JavaType type) @Override public JavaType resolveAbstractType(DeserializationConfig config, - BeanDescription typeDesc) { + BeanDescription.Supplier beanDescRef) { // never materialize anything, so: return null; } diff --git a/src/main/java/tools/jackson/databind/module/SimpleDeserializers.java b/src/main/java/tools/jackson/databind/module/SimpleDeserializers.java index 110ba6e830..84d6ebfe57 100644 --- a/src/main/java/tools/jackson/databind/module/SimpleDeserializers.java +++ b/src/main/java/tools/jackson/databind/module/SimpleDeserializers.java @@ -76,7 +76,7 @@ public SimpleDeserializers addDeserializers(Map,ValueDeserializer> d @Override public ValueDeserializer findArrayDeserializer(ArrayType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { return _find(type); @@ -84,14 +84,14 @@ public ValueDeserializer findArrayDeserializer(ArrayType type, @Override public ValueDeserializer findBeanDeserializer(JavaType type, - DeserializationConfig config, BeanDescription beanDesc) + DeserializationConfig config, BeanDescription.Supplier beanDescRef) { return _find(type); } @Override public ValueDeserializer findCollectionDeserializer(CollectionType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { @@ -100,7 +100,7 @@ public ValueDeserializer findCollectionDeserializer(CollectionType type, @Override public ValueDeserializer findCollectionLikeDeserializer(CollectionLikeType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { @@ -109,7 +109,7 @@ public ValueDeserializer findCollectionLikeDeserializer(CollectionLikeType ty @Override public ValueDeserializer findEnumDeserializer(Class type, - DeserializationConfig config, BeanDescription beanDesc) + DeserializationConfig config, BeanDescription.Supplier beanDescRef) { if (_classMappings == null) { return null; @@ -129,7 +129,7 @@ public ValueDeserializer findEnumDeserializer(Class type, @Override public ValueDeserializer findTreeNodeDeserializer(Class nodeType, - DeserializationConfig config, BeanDescription beanDesc) + DeserializationConfig config, BeanDescription.Supplier beanDescRef) { if (_classMappings == null) { return null; @@ -139,7 +139,7 @@ public ValueDeserializer findTreeNodeDeserializer(Class n @Override public ValueDeserializer findReferenceDeserializer(ReferenceType refType, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, TypeDeserializer contentTypeDeserializer, ValueDeserializer contentDeserializer) { // 21-Oct-2015, tatu: Unlikely this will really get used (reference types need more @@ -149,7 +149,7 @@ public ValueDeserializer findReferenceDeserializer(ReferenceType refType, @Override public ValueDeserializer findMapDeserializer(MapType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) @@ -159,7 +159,7 @@ public ValueDeserializer findMapDeserializer(MapType type, @Override public ValueDeserializer findMapLikeDeserializer(MapLikeType type, - DeserializationConfig config, BeanDescription beanDesc, + DeserializationConfig config, BeanDescription.Supplier beanDescRef, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) diff --git a/src/main/java/tools/jackson/databind/module/SimpleValueInstantiators.java b/src/main/java/tools/jackson/databind/module/SimpleValueInstantiators.java index c142e0d151..d6467c6238 100644 --- a/src/main/java/tools/jackson/databind/module/SimpleValueInstantiators.java +++ b/src/main/java/tools/jackson/databind/module/SimpleValueInstantiators.java @@ -12,7 +12,7 @@ public class SimpleValueInstantiators extends ValueInstantiators.Base implements java.io.Serializable { - private static final long serialVersionUID = -8929386427526115130L; + private static final long serialVersionUID = 3L; /** * Mappings from raw (type-erased, i.e. non-generic) types @@ -40,8 +40,8 @@ public SimpleValueInstantiators addValueInstantiator(Class forType, @Override public ValueInstantiator findValueInstantiator(DeserializationConfig config, - BeanDescription beanDesc) + BeanDescription.Supplier beanDescRef) { - return _classMappings.get(new ClassKey(beanDesc.getBeanClass())); + return _classMappings.get(new ClassKey(beanDescRef.getBeanClass())); } } diff --git a/src/test/java/tools/jackson/databind/deser/CustomDeserializersTest.java b/src/test/java/tools/jackson/databind/deser/CustomDeserializersTest.java index 5f55b16b78..e38c3ae6fe 100644 --- a/src/test/java/tools/jackson/databind/deser/CustomDeserializersTest.java +++ b/src/test/java/tools/jackson/databind/deser/CustomDeserializersTest.java @@ -283,7 +283,7 @@ public void setupModule(SetupContext context) context.addDeserializerModifier(new ValueDeserializerModifier() { @Override public ValueDeserializer modifyDeserializer(DeserializationConfig config, - BeanDescription beanDesc, ValueDeserializer deserializer) { + BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { if (deserializer.handledType() == String.class) { ValueDeserializer d = new MyStringDeserializer(deserializer); // just for test coverage purposes... @@ -575,7 +575,7 @@ public void testModifyingCustomDeserializer() throws Exception .setDeserializerModifier(new ValueDeserializerModifier() { @Override public ValueDeserializer modifyDeserializer(DeserializationConfig config, - BeanDescription beanDesc, ValueDeserializer deserializer) { + BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { if (deserializer instanceof DummyDeserializer) { return new DummyDeserializer("FOOBAR", String.class); } diff --git a/src/test/java/tools/jackson/databind/deser/bean/BeanDeserializerModifier4216Test.java b/src/test/java/tools/jackson/databind/deser/bean/BeanDeserializerModifier4216Test.java index 8b8d86ae43..c44f2f1848 100644 --- a/src/test/java/tools/jackson/databind/deser/bean/BeanDeserializerModifier4216Test.java +++ b/src/test/java/tools/jackson/databind/deser/bean/BeanDeserializerModifier4216Test.java @@ -52,7 +52,8 @@ private static SimpleModule getSimpleModuleWithCounter(AtomicInteger counter) { @Override public ValueDeserializer modifyArrayDeserializer(DeserializationConfig config, - ArrayType valueType, BeanDescription beanDesc, ValueDeserializer deserializer) + ArrayType valueType, BeanDescription.Supplier beanDescRef, + ValueDeserializer deserializer) { // Count invocations counter.incrementAndGet(); diff --git a/src/test/java/tools/jackson/databind/deser/bean/BeanDeserializerModifier4356Test.java b/src/test/java/tools/jackson/databind/deser/bean/BeanDeserializerModifier4356Test.java index 875cf75a4c..316ce44c41 100644 --- a/src/test/java/tools/jackson/databind/deser/bean/BeanDeserializerModifier4356Test.java +++ b/src/test/java/tools/jackson/databind/deser/bean/BeanDeserializerModifier4356Test.java @@ -49,7 +49,8 @@ public String getA() { static SimpleModule getSimpleModuleWithDeserializerModifier() { return new SimpleModule().setDeserializerModifier(new ValueDeserializerModifier() { @Override - public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, BeanDescription beanDesc, BeanDeserializerBuilder builder) { + public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, + BeanDescription.Supplier beanDescRef, BeanDeserializerBuilder builder) { for (Iterator properties = builder.getProperties(); properties.hasNext();) { SettableBeanProperty property = properties.next(); if (property.getName().equals("a")) { diff --git a/src/test/java/tools/jackson/databind/deser/bean/BeanDeserializerTest.java b/src/test/java/tools/jackson/databind/deser/bean/BeanDeserializerTest.java index f16e2c2b25..520ebfe245 100644 --- a/src/test/java/tools/jackson/databind/deser/bean/BeanDeserializerTest.java +++ b/src/test/java/tools/jackson/databind/deser/bean/BeanDeserializerTest.java @@ -71,7 +71,7 @@ static class RemovingModifier extends ValueDeserializerModifier @Override public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, - BeanDescription beanDesc, BeanDeserializerBuilder builder) { + BeanDescription.Supplier beanDescRef, BeanDeserializerBuilder builder) { builder.addIgnorable(_removedProperty); return builder; } @@ -85,7 +85,7 @@ static class ReplacingModifier extends ValueDeserializerModifier @Override public ValueDeserializer modifyDeserializer(DeserializationConfig config, - BeanDescription beanDesc, ValueDeserializer deserializer) { + BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { return _deserializer; } } @@ -132,11 +132,11 @@ public ValueDeserializer createContextual(DeserializationContext ctxt, public class Issue476DeserializerModifier extends ValueDeserializerModifier { @Override public ValueDeserializer modifyDeserializer(DeserializationConfig config, - BeanDescription beanDesc, ValueDeserializer deserializer) { - if (Issue476Type.class == beanDesc.getBeanClass()) { + BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { + if (Issue476Type.class == beanDescRef.getBeanClass()) { return new Issue476Deserializer((BeanDeserializer)deserializer); } - return super.modifyDeserializer(config, beanDesc, deserializer); + return super.modifyDeserializer(config, beanDescRef, deserializer); } } public class Issue476Module extends SimpleModule @@ -218,16 +218,18 @@ public Issue1912SubBean deserialize(JsonParser p, DeserializationContext ctxt) public static class Issue1912UseAddOrReplacePropertyDeserializerModifier extends ValueDeserializerModifier { @Override - public ValueDeserializer modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, ValueDeserializer deserializer) { - if (beanDesc.getBeanClass() == Issue1912Bean.class) { + public ValueDeserializer modifyDeserializer(DeserializationConfig config, + BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { + if (beanDescRef.getBeanClass() == Issue1912Bean.class) { return new Issue1912CustomBeanDeserializer((BeanDeserializer) deserializer); } - return super.modifyDeserializer(config, beanDesc, deserializer); + return super.modifyDeserializer(config, beanDescRef, deserializer); } @Override - public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, BeanDescription beanDesc, BeanDeserializerBuilder builder) { - if (beanDesc.getBeanClass() == Issue1912Bean.class) { + public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, + BeanDescription.Supplier beanDescRef, BeanDeserializerBuilder builder) { + if (beanDescRef.getBeanClass() == Issue1912Bean.class) { Iterator props = builder.getProperties(); while (props.hasNext()) { SettableBeanProperty prop = props.next(); @@ -257,8 +259,9 @@ enum EnumABC { A, B, C; } static class ArrayDeserializerModifier extends ValueDeserializerModifier { @Override - public ValueDeserializer modifyArrayDeserializer(DeserializationConfig config, ArrayType valueType, - BeanDescription beanDesc, ValueDeserializer deserializer) { + public ValueDeserializer modifyArrayDeserializer(DeserializationConfig config, + ArrayType valueType, + BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { return (ValueDeserializer) new StdDeserializer(Object.class) { @Override public Object deserialize(JsonParser p, DeserializationContext ctxt) { @@ -271,8 +274,9 @@ public ValueDeserializer modifyArrayDeserializer(DeserializationConfig config static class CollectionDeserializerModifier extends ValueDeserializerModifier { @Override - public ValueDeserializer modifyCollectionDeserializer(DeserializationConfig config, CollectionType valueType, - BeanDescription beanDesc, ValueDeserializer deserializer) { + public ValueDeserializer modifyCollectionDeserializer(DeserializationConfig config, + CollectionType valueType, + BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { return (ValueDeserializer) new StdDeserializer(Object.class) { @Override public Object deserialize(JsonParser p, DeserializationContext ctxt) { @@ -287,8 +291,9 @@ public ValueDeserializer modifyCollectionDeserializer(DeserializationConfig c static class MapDeserializerModifier extends ValueDeserializerModifier { @Override - public ValueDeserializer modifyMapDeserializer(DeserializationConfig config, MapType valueType, - BeanDescription beanDesc, ValueDeserializer deserializer) { + public ValueDeserializer modifyMapDeserializer(DeserializationConfig config, + MapType valueType, + BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { return (ValueDeserializer) new StdDeserializer(Object.class) { @Override public Object deserialize(JsonParser p, DeserializationContext ctxt) { @@ -303,8 +308,9 @@ public ValueDeserializer modifyMapDeserializer(DeserializationConfig config, static class EnumDeserializerModifier extends ValueDeserializerModifier { @Override - public ValueDeserializer modifyEnumDeserializer(DeserializationConfig config, JavaType valueType, - BeanDescription beanDesc, ValueDeserializer deserializer) { + public ValueDeserializer modifyEnumDeserializer(DeserializationConfig config, + JavaType valueType, + BeanDescription.Supplier beanDescRef, ValueDeserializer deserializer) { return (ValueDeserializer) new StdDeserializer(Object.class) { @Override public Object deserialize(JsonParser jp, DeserializationContext ctxt) { @@ -477,8 +483,8 @@ public void testModifyStdScalarDeserializer() throws Exception .setDeserializerModifier(new ValueDeserializerModifier() { @Override public ValueDeserializer modifyDeserializer(DeserializationConfig config, - BeanDescription beanDesc, ValueDeserializer deser) { - if (beanDesc.getBeanClass() == String.class) { + BeanDescription.Supplier beanDescRef, ValueDeserializer deser) { + if (beanDescRef.getBeanClass() == String.class) { return new UCStringDeserializer(deser); } return deser; diff --git a/src/test/java/tools/jackson/databind/deser/creators/EnumCreatorTest.java b/src/test/java/tools/jackson/databind/deser/creators/EnumCreatorTest.java index 9abbab2837..2ae1acc315 100644 --- a/src/test/java/tools/jackson/databind/deser/creators/EnumCreatorTest.java +++ b/src/test/java/tools/jackson/databind/deser/creators/EnumCreatorTest.java @@ -120,9 +120,10 @@ protected enum TestEnum324 static class DelegatingDeserializers extends Deserializers.Base { @Override - public ValueDeserializer findEnumDeserializer(final Class type, final DeserializationConfig config, final BeanDescription beanDesc) + public ValueDeserializer findEnumDeserializer(final Class type, final DeserializationConfig config, + final BeanDescription.Supplier beanDescRef) { - final Collection factoryMethods = beanDesc.getFactoryMethods(); + final Collection factoryMethods = beanDescRef.get().getFactoryMethods(); if (factoryMethods != null) { for (AnnotatedMethod am : factoryMethods) { final JsonCreator creator = am.getAnnotation(JsonCreator.class); diff --git a/src/test/java/tools/jackson/databind/deser/creators/JsonCreatorNoArgs4777Test.java b/src/test/java/tools/jackson/databind/deser/creators/JsonCreatorNoArgs4777Test.java index 6a015029f5..f31c93b22d 100644 --- a/src/test/java/tools/jackson/databind/deser/creators/JsonCreatorNoArgs4777Test.java +++ b/src/test/java/tools/jackson/databind/deser/creators/JsonCreatorNoArgs4777Test.java @@ -29,10 +29,10 @@ static class Instantiators4777 implements ValueInstantiators { @Override public ValueInstantiator modifyValueInstantiator( DeserializationConfig config, - BeanDescription beanDesc, + BeanDescription.Supplier beanDescRef, ValueInstantiator defaultInstantiator ) { - if (beanDesc.getBeanClass() == Foo4777.class) { + if (beanDescRef.getBeanClass() == Foo4777.class) { AnnotatedWithParams dc = defaultInstantiator.getDefaultCreator(); if (!(dc instanceof AnnotatedMethod) || !dc.getName().equals("create")) { @@ -44,7 +44,8 @@ public ValueInstantiator modifyValueInstantiator( } @Override - public ValueInstantiator findValueInstantiator(DeserializationConfig config, BeanDescription beanDesc) { + public ValueInstantiator findValueInstantiator(DeserializationConfig config, + BeanDescription.Supplier beanDescRef) { return null; } } diff --git a/src/test/java/tools/jackson/databind/deser/creators/NullValueViaCreatorTest.java b/src/test/java/tools/jackson/databind/deser/creators/NullValueViaCreatorTest.java index cc847a123c..e6cbd0fc06 100644 --- a/src/test/java/tools/jackson/databind/deser/creators/NullValueViaCreatorTest.java +++ b/src/test/java/tools/jackson/databind/deser/creators/NullValueViaCreatorTest.java @@ -46,7 +46,7 @@ public Contained getNullValue(DeserializationContext ctxt) { protected static class ContainerDeserializerResolver extends Deserializers.Base { @Override public ValueDeserializer findBeanDeserializer(JavaType type, - DeserializationConfig config, BeanDescription beanDesc) + DeserializationConfig config, BeanDescription.Supplier beanDescRef) { if (!Contained.class.isAssignableFrom(type.getRawClass())) { return null; diff --git a/src/test/java/tools/jackson/databind/deser/creators/TestCustomValueInstDefaults.java b/src/test/java/tools/jackson/databind/deser/creators/TestCustomValueInstDefaults.java index 749716ac83..a1130ae8e7 100644 --- a/src/test/java/tools/jackson/databind/deser/creators/TestCustomValueInstDefaults.java +++ b/src/test/java/tools/jackson/databind/deser/creators/TestCustomValueInstDefaults.java @@ -244,15 +244,15 @@ static class BucketInstantiators extends ValueInstantiators.Base @Override public ValueInstantiator modifyValueInstantiator( DeserializationConfig config, - BeanDescription beanDesc, + BeanDescription.Supplier beanDescRef, ValueInstantiator defaultInstantiator) { if (defaultInstantiator instanceof StdValueInstantiator) { - if (beanDesc.getBeanClass() == Bucket.class) { + if (beanDescRef.getBeanClass() == Bucket.class) { return new BucketInstantiator( (StdValueInstantiator) defaultInstantiator); } - if (beanDesc.getBeanClass() == BigBucket.class) { + if (beanDescRef.getBeanClass() == BigBucket.class) { return new BigBucketInstantiator( (StdValueInstantiator) defaultInstantiator); } @@ -360,8 +360,8 @@ public void setupModule(SetupContext context) { context.addValueInstantiators(new ValueInstantiators.Base() { @Override public ValueInstantiator modifyValueInstantiator(DeserializationConfig config, - BeanDescription beanDesc, ValueInstantiator defaultInstantiator) { - if (beanDesc.getBeanClass() == ClassWith32Props.class) { + BeanDescription.Supplier beanDescRef, ValueInstantiator defaultInstantiator) { + if (beanDescRef.getBeanClass() == ClassWith32Props.class) { return new VerifyingValueInstantiator((StdValueInstantiator) defaultInstantiator); } diff --git a/src/test/java/tools/jackson/databind/module/TestCustomEnumKeyDeserializer.java b/src/test/java/tools/jackson/databind/module/TestCustomEnumKeyDeserializer.java index a95468e8b1..80014bb465 100644 --- a/src/test/java/tools/jackson/databind/module/TestCustomEnumKeyDeserializer.java +++ b/src/test/java/tools/jackson/databind/module/TestCustomEnumKeyDeserializer.java @@ -240,7 +240,7 @@ public void testCustomEnumValueAndKeyViaModifier() throws IOException module.setDeserializerModifier(new ValueDeserializerModifier() { @Override public ValueDeserializer modifyEnumDeserializer(DeserializationConfig config, - final JavaType type, BeanDescription beanDesc, + final JavaType type, BeanDescription.Supplier beanDescRef, final ValueDeserializer deserializer) { return new ValueDeserializer() { @Override diff --git a/src/test/java/tools/jackson/databind/module/TestTypeModifiers.java b/src/test/java/tools/jackson/databind/module/TestTypeModifiers.java index ba90993a04..0eb6780730 100644 --- a/src/test/java/tools/jackson/databind/module/TestTypeModifiers.java +++ b/src/test/java/tools/jackson/databind/module/TestTypeModifiers.java @@ -57,8 +57,10 @@ public ValueSerializer findCollectionLikeSerializer(SerializationConfig confi }); context.addDeserializers(new SimpleDeserializers() { @Override - public ValueDeserializer findCollectionLikeDeserializer(CollectionLikeType type, DeserializationConfig config, - BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) + public ValueDeserializer findCollectionLikeDeserializer(CollectionLikeType type, + DeserializationConfig config, + BeanDescription.Supplier beanDescRef, TypeDeserializer elementTypeDeserializer, + ValueDeserializer elementDeserializer) { if (CollectionMarker.class.isAssignableFrom(type.getRawClass())) { return new MyCollectionDeserializer(); @@ -66,8 +68,9 @@ public ValueDeserializer findCollectionLikeDeserializer(CollectionLikeType ty return null; } @Override - public ValueDeserializer findMapLikeDeserializer(MapLikeType type, DeserializationConfig config, - BeanDescription beanDesc, KeyDeserializer keyDeserializer, + public ValueDeserializer findMapLikeDeserializer(MapLikeType type, + DeserializationConfig config, + BeanDescription.Supplier beanDescRef, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, ValueDeserializer elementDeserializer) { if (MapMarker.class.isAssignableFrom(type.getRawClass())) { diff --git a/src/test/java/tools/jackson/databind/tofix/NodeContext2049Test.java b/src/test/java/tools/jackson/databind/tofix/NodeContext2049Test.java index 14151019cf..033201059e 100644 --- a/src/test/java/tools/jackson/databind/tofix/NodeContext2049Test.java +++ b/src/test/java/tools/jackson/databind/tofix/NodeContext2049Test.java @@ -55,7 +55,8 @@ public Object createUsingDefault(DeserializationContext ctxt) throws JacksonExce } @Override - public ValueInstantiator createContextual(DeserializationContext ctxt, BeanDescription beanDesc) { + public ValueInstantiator createContextual(DeserializationContext ctxt, + BeanDescription.Supplier beanDescRef) { return this; } @@ -69,8 +70,8 @@ static class ParentSettingDeserializerModifier extends ValueDeserializerModifier private static final long serialVersionUID = 1L; @Override - public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, BeanDescription beanDesc, - BeanDeserializerBuilder builder) { + public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, + BeanDescription.Supplier beanDescRef, BeanDeserializerBuilder builder) { for (Iterator propertyIt = builder.getProperties(); propertyIt.hasNext(); ) { SettableBeanProperty property = propertyIt.next(); builder.addOrReplaceProperty(property.withValueDeserializer(new ParentSettingDeserializerContextual()), false); From 6dcc6ceafeac30e87e90b4226fcc404c019ef18b Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 14 Apr 2025 20:21:45 -0700 Subject: [PATCH 2/3] ... --- .../tools/jackson/databind/deser/BasicDeserializerFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/tools/jackson/databind/deser/BasicDeserializerFactory.java b/src/main/java/tools/jackson/databind/deser/BasicDeserializerFactory.java index a2edea8c98..89ec5fb1c6 100644 --- a/src/main/java/tools/jackson/databind/deser/BasicDeserializerFactory.java +++ b/src/main/java/tools/jackson/databind/deser/BasicDeserializerFactory.java @@ -600,7 +600,7 @@ protected SettableBeanProperty constructCreatorProperty(DeserializationContext c // Note: contextualization of typeDeser _should_ occur in constructor of CreatorProperty // so it is not called directly here SettableBeanProperty prop = CreatorProperty.construct(name, type, property.getWrapperName(), - typeDeser, beanDescRef.get().getClassAnnotations(), param, index, injectable, + typeDeser, beanDescRef.getClassAnnotations(), param, index, injectable, metadata); ValueDeserializer deser = findDeserializerFromAnnotation(ctxt, param); if (deser == null) { From d50723e71b71fafb37e019abc6528ee15ccd034c Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Mon, 14 Apr 2025 20:45:53 -0700 Subject: [PATCH 3/3] Test renaming --- .../{TestSimpleTypes.java => SimpleTypeSerializationTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/test/java/tools/jackson/databind/ser/{TestSimpleTypes.java => SimpleTypeSerializationTest.java} (99%) diff --git a/src/test/java/tools/jackson/databind/ser/TestSimpleTypes.java b/src/test/java/tools/jackson/databind/ser/SimpleTypeSerializationTest.java similarity index 99% rename from src/test/java/tools/jackson/databind/ser/TestSimpleTypes.java rename to src/test/java/tools/jackson/databind/ser/SimpleTypeSerializationTest.java index eb296240d0..e4c4c2d3e2 100644 --- a/src/test/java/tools/jackson/databind/ser/TestSimpleTypes.java +++ b/src/test/java/tools/jackson/databind/ser/SimpleTypeSerializationTest.java @@ -12,7 +12,7 @@ * Unit tests for verifying serialization of simple basic non-structured * types; primitives (and/or their wrappers), Strings. */ -public class TestSimpleTypes +public class SimpleTypeSerializationTest extends DatabindTestUtil { private final ObjectMapper MAPPER = new ObjectMapper();