@@ -252,12 +252,16 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo
252
252
throws JsonMappingException
253
253
{
254
254
final CreatorCollectionState ccState ;
255
+ final boolean findImplicit ;
255
256
256
257
{
257
258
final DeserializationConfig config = ctxt .getConfig ();
258
259
// need to construct suitable visibility checker:
259
260
final VisibilityChecker <?> vchecker = config .getDefaultVisibilityChecker (beanDesc .getBeanClass (),
260
261
beanDesc .getClassInfo ());
262
+ // 18-Sep-2020, tatu: Although by default implicit introspection is allowed, 2.12
263
+ // has settings to prevent that either generally, or at least for JDK types
264
+ findImplicit = config .getConstructorDetector ().allowImplicitCreators (beanDesc .getBeanClass ());
261
265
262
266
// 24-Sep-2014, tatu: Tricky part first; need to merge resolved property information
263
267
// (which has creator parameters sprinkled around) with actual creator
@@ -274,7 +278,7 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo
274
278
}
275
279
276
280
// Start with explicitly annotated factory methods
277
- _addExplicitFactoryCreators (ctxt , ccState );
281
+ _addExplicitFactoryCreators (ctxt , ccState , findImplicit );
278
282
279
283
// constructors only usable on concrete types:
280
284
if (beanDesc .getType ().isConcrete ()) {
@@ -296,16 +300,16 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo
296
300
// TODO: look for `@JsonCreator` annotated ones, throw explicit exception?
297
301
;
298
302
} else {
299
- _addExplicitConstructorCreators (ctxt , ccState );
300
- if (! ccState .hasExplicitFactories () && ! ccState . hasExplicitConstructors ()
301
- && ccState .hasImplicitConstructorCandidates ()) {
303
+ _addExplicitConstructorCreators (ctxt , ccState , findImplicit );
304
+ if (ccState .hasImplicitConstructorCandidates ()
305
+ && ! ccState .hasExplicitFactories () && ! ccState . hasExplicitConstructors ()) {
302
306
_addImplicitConstructorCreators (ctxt , ccState , ccState .implicitConstructorCandidates ());
303
307
}
304
308
}
305
309
}
306
310
// and finally, implicitly found factory methods if nothing explicit found
307
- if (! ccState .hasExplicitFactories () && ! ccState . hasExplicitConstructors ()
308
- && ccState .hasImplicitFactoryCandidates ()) {
311
+ if (ccState .hasImplicitFactoryCandidates ()
312
+ && ! ccState .hasExplicitFactories () && ! ccState . hasExplicitConstructors ()) {
309
313
_addImplicitFactoryCreators (ctxt , ccState , ccState .implicitFactoryCandidates ());
310
314
}
311
315
return ccState .creators .constructValueInstantiator (ctxt );
@@ -418,7 +422,7 @@ protected void _addRecordConstructor(DeserializationContext ctxt, CreatorCollect
418
422
*/
419
423
420
424
protected void _addExplicitConstructorCreators (DeserializationContext ctxt ,
421
- CreatorCollectionState ccState )
425
+ CreatorCollectionState ccState , boolean findImplicit )
422
426
throws JsonMappingException
423
427
{
424
428
final BeanDescription beanDesc = ccState .beanDesc ;
@@ -444,7 +448,7 @@ protected void _addExplicitConstructorCreators(DeserializationContext ctxt,
444
448
}
445
449
if (creatorMode == null ) {
446
450
// let's check Visibility here, to avoid further processing for non-visible?
447
- if (vchecker .isCreatorVisible (ctor )) {
451
+ if (findImplicit && vchecker .isCreatorVisible (ctor )) {
448
452
ccState .addImplicitConstructorCandidate (CreatorCandidate .construct (intr ,
449
453
ctor , creatorParams .get (ctor )));
450
454
}
@@ -623,7 +627,7 @@ protected void _addImplicitConstructorCreators(DeserializationContext ctxt,
623
627
*/
624
628
625
629
protected void _addExplicitFactoryCreators (DeserializationContext ctxt ,
626
- CreatorCollectionState ccState )
630
+ CreatorCollectionState ccState , boolean findImplicit )
627
631
throws JsonMappingException
628
632
{
629
633
final BeanDescription beanDesc = ccState .beanDesc ;
@@ -638,7 +642,7 @@ protected void _addExplicitFactoryCreators(DeserializationContext ctxt,
638
642
final int argCount = factory .getParameterCount ();
639
643
if (creatorMode == null ) {
640
644
// Only potentially accept 1-argument factory methods
641
- if ((argCount == 1 ) && vchecker .isCreatorVisible (factory )) {
645
+ if (findImplicit && (argCount == 1 ) && vchecker .isCreatorVisible (factory )) {
642
646
ccState .addImplicitFactoryCandidate (CreatorCandidate .construct (intr , factory , null ));
643
647
}
644
648
continue ;
0 commit comments