@@ -252,12 +252,16 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo
252252 throws JsonMappingException
253253 {
254254 final CreatorCollectionState ccState ;
255+ final boolean findImplicit ;
255256
256257 {
257258 final DeserializationConfig config = ctxt .getConfig ();
258259 // need to construct suitable visibility checker:
259260 final VisibilityChecker <?> vchecker = config .getDefaultVisibilityChecker (beanDesc .getBeanClass (),
260261 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 ());
261265
262266 // 24-Sep-2014, tatu: Tricky part first; need to merge resolved property information
263267 // (which has creator parameters sprinkled around) with actual creator
@@ -274,7 +278,7 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo
274278 }
275279
276280 // Start with explicitly annotated factory methods
277- _addExplicitFactoryCreators (ctxt , ccState );
281+ _addExplicitFactoryCreators (ctxt , ccState , findImplicit );
278282
279283 // constructors only usable on concrete types:
280284 if (beanDesc .getType ().isConcrete ()) {
@@ -296,16 +300,16 @@ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationCo
296300 // TODO: look for `@JsonCreator` annotated ones, throw explicit exception?
297301 ;
298302 } 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 ()) {
302306 _addImplicitConstructorCreators (ctxt , ccState , ccState .implicitConstructorCandidates ());
303307 }
304308 }
305309 }
306310 // 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 ()) {
309313 _addImplicitFactoryCreators (ctxt , ccState , ccState .implicitFactoryCandidates ());
310314 }
311315 return ccState .creators .constructValueInstantiator (ctxt );
@@ -418,7 +422,7 @@ protected void _addRecordConstructor(DeserializationContext ctxt, CreatorCollect
418422 */
419423
420424 protected void _addExplicitConstructorCreators (DeserializationContext ctxt ,
421- CreatorCollectionState ccState )
425+ CreatorCollectionState ccState , boolean findImplicit )
422426 throws JsonMappingException
423427 {
424428 final BeanDescription beanDesc = ccState .beanDesc ;
@@ -444,7 +448,7 @@ protected void _addExplicitConstructorCreators(DeserializationContext ctxt,
444448 }
445449 if (creatorMode == null ) {
446450 // let's check Visibility here, to avoid further processing for non-visible?
447- if (vchecker .isCreatorVisible (ctor )) {
451+ if (findImplicit && vchecker .isCreatorVisible (ctor )) {
448452 ccState .addImplicitConstructorCandidate (CreatorCandidate .construct (intr ,
449453 ctor , creatorParams .get (ctor )));
450454 }
@@ -623,7 +627,7 @@ protected void _addImplicitConstructorCreators(DeserializationContext ctxt,
623627 */
624628
625629 protected void _addExplicitFactoryCreators (DeserializationContext ctxt ,
626- CreatorCollectionState ccState )
630+ CreatorCollectionState ccState , boolean findImplicit )
627631 throws JsonMappingException
628632 {
629633 final BeanDescription beanDesc = ccState .beanDesc ;
@@ -638,7 +642,7 @@ protected void _addExplicitFactoryCreators(DeserializationContext ctxt,
638642 final int argCount = factory .getParameterCount ();
639643 if (creatorMode == null ) {
640644 // Only potentially accept 1-argument factory methods
641- if ((argCount == 1 ) && vchecker .isCreatorVisible (factory )) {
645+ if (findImplicit && (argCount == 1 ) && vchecker .isCreatorVisible (factory )) {
642646 ccState .addImplicitFactoryCandidate (CreatorCandidate .construct (intr , factory , null ));
643647 }
644648 continue ;
0 commit comments