@@ -1508,24 +1508,29 @@ protected PropertyName _findConstructorName(Annotated a)
15081508 protected TypeResolverBuilder <?> _findTypeResolver (MapperConfig <?> config ,
15091509 Annotated ann , JavaType baseType )
15101510 {
1511+ // since 2.16 : backporting {@link JsonTypeInfo.Value} from 3.0
1512+ final AnnotationIntrospector ai = config .getAnnotationIntrospector ();
1513+ JsonTypeInfo .Value typeInfo = ai .findPolymorphicTypeInfo (config , ann );
1514+
1515+ JsonTypeInfo info = _findAnnotation (ann , JsonTypeInfo .class );
1516+
15111517 // First: maybe we have explicit type resolver?
15121518 TypeResolverBuilder <?> b ;
1513- JsonTypeInfo info = _findAnnotation (ann , JsonTypeInfo .class );
15141519 JsonTypeResolver resAnn = _findAnnotation (ann , JsonTypeResolver .class );
15151520
15161521 if (resAnn != null ) {
1517- if (info == null ) {
1522+ if (typeInfo == null ) {
15181523 return null ;
15191524 }
15201525 // let's not try to force access override (would need to pass
15211526 // settings through if we did, since that's not doable on some platforms)
15221527 b = config .typeResolverBuilderInstance (ann , resAnn .value ());
15231528 } else { // if not, use standard one, if indicated by annotations
1524- if (info == null ) {
1529+ if (typeInfo == null ) {
15251530 return null ;
15261531 }
15271532 // bit special; must return 'marker' to block use of default typing:
1528- if (info . use () == JsonTypeInfo .Id .NONE ) {
1533+ if (typeInfo . getIdType () == JsonTypeInfo .Id .NONE ) {
15291534 return _constructNoTypeResolverBuilder ();
15301535 }
15311536 b = _constructStdTypeResolverBuilder ();
@@ -1537,26 +1542,26 @@ protected TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> config,
15371542 if (idRes != null ) {
15381543 idRes .init (baseType );
15391544 }
1540- b = b .init (info . use (), idRes );
1545+ b = b .init (typeInfo . getIdType (), idRes );
15411546 // 13-Aug-2011, tatu: One complication; external id only works for properties;
15421547 // so if declared for a Class, we will need to map it to "PROPERTY"
15431548 // instead of "EXTERNAL_PROPERTY"
1544- JsonTypeInfo .As inclusion = info . include ();
1549+ JsonTypeInfo .As inclusion = typeInfo . getInclusionType ();
15451550 if (inclusion == JsonTypeInfo .As .EXTERNAL_PROPERTY && (ann instanceof AnnotatedClass )) {
15461551 inclusion = JsonTypeInfo .As .PROPERTY ;
15471552 }
15481553 b = b .inclusion (inclusion );
1549- b = b .typeProperty (info . property ());
1550- Class <?> defaultImpl = info . defaultImpl ();
1554+ b = b .typeProperty (typeInfo . getPropertyName ());
1555+ Class <?> defaultImpl = typeInfo . getDefaultImpl ();
15511556
15521557 // 08-Dec-2014, tatu: To deprecate `JsonTypeInfo.None` we need to use other placeholder(s);
15531558 // and since `java.util.Void` has other purpose (to indicate "deser as null"), we'll instead
15541559 // use `JsonTypeInfo.class` itself. But any annotation type will actually do, as they have no
15551560 // valid use (cannot instantiate as default)
1556- if (defaultImpl != JsonTypeInfo .None .class && !defaultImpl .isAnnotation ()) {
1561+ if (defaultImpl != null && defaultImpl != JsonTypeInfo .None .class && !defaultImpl .isAnnotation ()) {
15571562 b = b .defaultImpl (defaultImpl );
15581563 }
1559- b = b .typeIdVisibility (info . visible ());
1564+ b = b .typeIdVisibility (typeInfo . getIdVisible ());
15601565 return b ;
15611566 }
15621567
0 commit comments