@@ -630,47 +630,47 @@ protected void _addCreators(Map<String, POJOPropertyBuilder> props)
630
630
631
631
// First, resolve explicit annotations for all potential Creators
632
632
// (but do NOT filter out DISABLED ones yet!)
633
- List <PotentialCreator > ctors = _collectCreators (_classDef .getConstructors ());
633
+ List <PotentialCreator > constructors = _collectCreators (_classDef .getConstructors ());
634
634
List <PotentialCreator > factories = _collectCreators (_classDef .getFactoryMethods ());
635
635
636
636
final PotentialCreator canonical ;
637
637
638
638
// Find and mark "canonical" constructor for Records.
639
639
// Needs to be done early to get implicit names populated
640
640
if (_isRecordType ) {
641
- canonical = JDK14Util .findCanonicalRecordConstructor (_config , _classDef , ctors );
641
+ canonical = JDK14Util .findCanonicalRecordConstructor (_config , _classDef , constructors );
642
642
} else {
643
643
// !!! TODO: fetch Canonical for Kotlin, Scala, via AnnotationIntrospector?
644
644
canonical = null ;
645
645
}
646
646
647
647
// Next: remove creators marked as explicitly disabled
648
- _removeDisabledCreators (ctors );
648
+ _removeDisabledCreators (constructors );
649
649
_removeDisabledCreators (factories );
650
650
651
- final PotentialCreators collector = new PotentialCreators (ctors , factories );
651
+ final PotentialCreators collector = new PotentialCreators ();
652
652
// and use annotations to find explicitly chosen Creators
653
653
if (_useAnnotations ) { // can't have explicit ones without Annotation introspection
654
654
// Start with Constructors as they have higher precedence:
655
- _addExplicitlyAnnotatedCreators (collector , collector . constructors , props , false );
655
+ _addExplicitlyAnnotatedCreators (collector , constructors , props , false );
656
656
// followed by Factory methods (lower precedence)
657
- _addExplicitlyAnnotatedCreators (collector , collector . factories , props ,
657
+ _addExplicitlyAnnotatedCreators (collector , factories , props ,
658
658
collector .hasPropertiesBased ());
659
659
}
660
660
661
661
// If no Explicitly annotated creators found, look
662
662
// for ones with explicitly-named ({@code @JsonProperty}) parameters
663
663
if (!collector .hasPropertiesBased ()) {
664
664
// only discover constructor Creators?
665
- _addCreatorsWithAnnotatedNames (collector , collector . constructors );
665
+ _addCreatorsWithAnnotatedNames (collector , constructors );
666
666
}
667
667
668
668
// But if no annotation-based Creators found, find/use canonical Creator
669
669
// (JDK 17 Record/Scala/Kotlin)
670
670
if (!collector .hasPropertiesBased ()) {
671
671
// for Records:
672
- if ((canonical != null ) && ctors .contains (canonical )) {
673
- ctors .remove (canonical );
672
+ if ((canonical != null ) && constructors .contains (canonical )) {
673
+ constructors .remove (canonical );
674
674
collector .addPropertiesBased (_config , canonical , "canonical" );
675
675
}
676
676
}
@@ -701,7 +701,7 @@ private void _removeDisabledCreators(List<PotentialCreator> ctors)
701
701
Iterator <PotentialCreator > it = ctors .iterator ();
702
702
while (it .hasNext ()) {
703
703
// explicitly prevented? Remove
704
- if (it .next ().creatorMode == JsonCreator .Mode .DISABLED ) {
704
+ if (it .next ().creatorMode () == JsonCreator .Mode .DISABLED ) {
705
705
it .remove ();
706
706
}
707
707
}
@@ -719,14 +719,14 @@ private void _addExplicitlyAnnotatedCreators(PotentialCreators collector,
719
719
720
720
// If no explicit annotation, skip for now (may be discovered
721
721
// at a later point)
722
- if (ctor .creatorMode == null ) {
722
+ if (ctor .creatorMode () == null ) {
723
723
continue ;
724
724
}
725
725
it .remove ();
726
726
727
727
Boolean propsBased = null ;
728
728
729
- switch (ctor .creatorMode ) {
729
+ switch (ctor .creatorMode () ) {
730
730
case DELEGATING :
731
731
propsBased = false ;
732
732
break ;
@@ -795,7 +795,9 @@ private void _addCreatorsWithAnnotatedNames(PotentialCreators collector,
795
795
private void _addCreatorParams (Map <String , POJOPropertyBuilder > props ,
796
796
PotentialCreator ctor )
797
797
{
798
- for (int i = 0 , len = ctor .paramCount (); i < len ; ++i ) {
798
+ final int paramCount = ctor .paramCount ();
799
+ final BeanPropertyDefinition [] propertyDefs = new BeanPropertyDefinition [paramCount ];
800
+ for (int i = 0 ; i < paramCount ; ++i ) {
799
801
final AnnotatedParameter param = ctor .param (i );
800
802
final PropertyName explName = ctor .explicitName (i );
801
803
PropertyName implName = ctor .implicitName (i );
@@ -818,8 +820,10 @@ private void _addCreatorParams(Map<String, POJOPropertyBuilder> props,
818
820
POJOPropertyBuilder prop = (implName == null )
819
821
? _property (props , explName ) : _property (props , implName );
820
822
prop .addCtor (param , hasExplicit ? explName : implName , hasExplicit , true , false );
823
+ propertyDefs [i ] = prop ;
821
824
_creatorProperties .add (prop );
822
825
}
826
+ ctor .assignPropertyDefs (propertyDefs );
823
827
}
824
828
825
829
/*
0 commit comments