@@ -880,11 +880,8 @@ protected void _addExplicitPropertyCreator(DeserializationContext ctxt,
880
880
*/
881
881
}
882
882
name = candidate .findImplicitParamName (i );
883
- // Must be injectable or have name; without either won't work
884
- if ((name == null ) && (injectId == null )) {
885
- ctxt .reportBadTypeDefinition (beanDesc ,
886
- "Argument #%d has no property name, is not Injectable: can not use as Creator %s" , i , candidate );
887
- }
883
+ _validateNamedPropertyParameter (ctxt , beanDesc , candidate , i ,
884
+ name , injectId );
888
885
}
889
886
properties [i ] = constructCreatorProperty (ctxt , beanDesc , name , i , param , injectId );
890
887
}
@@ -949,6 +946,11 @@ protected void _addExplicitAnyCreator(DeserializationContext ctxt,
949
946
// 13-Sep-2020, tatu: since we are configured to prefer Properties-style,
950
947
// any name (explicit OR implicit does):
951
948
paramName = candidate .paramName (0 );
949
+ // [databind#2977]: Need better exception if name missing
950
+ if (paramName == null ) {
951
+ _validateNamedPropertyParameter (ctxt , beanDesc , candidate , 0 ,
952
+ paramName , injectId );
953
+ }
952
954
break ;
953
955
954
956
case REQUIRE_MODE :
@@ -1126,6 +1128,24 @@ protected boolean _handleSingleArgumentCreator(CreatorCollector creators,
1126
1128
return false ;
1127
1129
}
1128
1130
1131
+ // Helper method to check that parameter of Property-based creator either
1132
+ // has name or is marked as Injectable
1133
+ //
1134
+ // @since 2.12.1
1135
+ protected void _validateNamedPropertyParameter (DeserializationContext ctxt ,
1136
+ BeanDescription beanDesc ,
1137
+ CreatorCandidate candidate , int paramIndex ,
1138
+ PropertyName name , JacksonInject .Value injectId )
1139
+ throws JsonMappingException
1140
+ {
1141
+ // Must be injectable or have name; without either won't work
1142
+ if ((name == null ) && (injectId == null )) {
1143
+ ctxt .reportBadTypeDefinition (beanDesc ,
1144
+ "Argument #%d of constructor %s has no property name (and is not Injectable): can not use as property-based Creator" ,
1145
+ paramIndex , candidate );
1146
+ }
1147
+ }
1148
+
1129
1149
// 01-Dec-2016, tatu: As per [databind#265] we cannot yet support passing
1130
1150
// of unwrapped values through creator properties, so fail fast
1131
1151
protected void _reportUnwrappedCreatorProperty (DeserializationContext ctxt ,
0 commit comments