@@ -699,9 +699,15 @@ public JavaType constructType(Type type) {
699
699
}
700
700
701
701
public JavaType constructType (Type type , TypeBindings bindings ) {
702
+ // 15-Jun-2020, tatu: To resolve (parts of) [databind#2796], need to
703
+ // call _fromClass() directly if we get `Class` argument
704
+ if (type instanceof Class <?>) {
705
+ JavaType resultType = _fromClass (null , (Class <?>) type , bindings );
706
+ return _applyModifiers (type , resultType );
707
+ }
702
708
return _fromAny (null , type , bindings );
703
709
}
704
-
710
+
705
711
public JavaType constructType (TypeReference <?> typeRef )
706
712
{
707
713
// 19-Oct-2015, tatu: Simpler variant like so should work
@@ -1274,51 +1280,58 @@ protected JavaType _findWellKnownSimple(Class<?> clz) {
1274
1280
* as Java typing returned from <code>getGenericXxx</code> methods
1275
1281
* (usually for a return or argument type).
1276
1282
*/
1277
- protected JavaType _fromAny (ClassStack context , Type type , TypeBindings bindings )
1283
+ protected JavaType _fromAny (ClassStack context , Type srcType , TypeBindings bindings )
1278
1284
{
1279
1285
JavaType resultType ;
1280
1286
1281
1287
// simple class?
1282
- if (type instanceof Class <?>) {
1288
+ if (srcType instanceof Class <?>) {
1283
1289
// Important: remove possible bindings since this is type-erased thingy
1284
- resultType = _fromClass (context , (Class <?>) type , EMPTY_BINDINGS );
1290
+ resultType = _fromClass (context , (Class <?>) srcType , EMPTY_BINDINGS );
1285
1291
}
1286
1292
// But if not, need to start resolving.
1287
- else if (type instanceof ParameterizedType ) {
1288
- resultType = _fromParamType (context , (ParameterizedType ) type , bindings );
1293
+ else if (srcType instanceof ParameterizedType ) {
1294
+ resultType = _fromParamType (context , (ParameterizedType ) srcType , bindings );
1289
1295
}
1290
- else if (type instanceof JavaType ) { // [databind#116]
1296
+ else if (srcType instanceof JavaType ) { // [databind#116]
1291
1297
// no need to modify further if we already had JavaType
1292
- return (JavaType ) type ;
1298
+ return (JavaType ) srcType ;
1293
1299
}
1294
- else if (type instanceof GenericArrayType ) {
1295
- resultType = _fromArrayType (context , (GenericArrayType ) type , bindings );
1300
+ else if (srcType instanceof GenericArrayType ) {
1301
+ resultType = _fromArrayType (context , (GenericArrayType ) srcType , bindings );
1296
1302
}
1297
- else if (type instanceof TypeVariable <?>) {
1298
- resultType = _fromVariable (context , (TypeVariable <?>) type , bindings );
1303
+ else if (srcType instanceof TypeVariable <?>) {
1304
+ resultType = _fromVariable (context , (TypeVariable <?>) srcType , bindings );
1299
1305
}
1300
- else if (type instanceof WildcardType ) {
1301
- resultType = _fromWildcard (context , (WildcardType ) type , bindings );
1306
+ else if (srcType instanceof WildcardType ) {
1307
+ resultType = _fromWildcard (context , (WildcardType ) srcType , bindings );
1302
1308
} else {
1303
1309
// sanity check
1304
- throw new IllegalArgumentException ("Unrecognized Type: " +((type == null ) ? "[null]" : type .toString ()));
1310
+ throw new IllegalArgumentException ("Unrecognized Type: " +((srcType == null ) ? "[null]" : srcType .toString ()));
1305
1311
}
1306
1312
// 21-Feb-2016, nateB/tatu: as per [databind#1129] (applied for 2.7.2),
1307
1313
// we do need to let all kinds of types to be refined, esp. for Scala module.
1308
- if (_modifiers != null ) {
1309
- TypeBindings b = resultType .getBindings ();
1310
- if (b == null ) {
1311
- b = EMPTY_BINDINGS ;
1312
- }
1313
- for (TypeModifier mod : _modifiers ) {
1314
- JavaType t = mod .modifyType (resultType , type , b , this );
1315
- if (t == null ) {
1316
- throw new IllegalStateException (String .format (
1317
- "TypeModifier %s (of type %s) return null for type %s" ,
1318
- mod , mod .getClass ().getName (), resultType ));
1319
- }
1320
- resultType = t ;
1314
+ return _applyModifiers (srcType , resultType );
1315
+ }
1316
+
1317
+ protected JavaType _applyModifiers (Type srcType , JavaType resolvedType )
1318
+ {
1319
+ if (_modifiers == null ) {
1320
+ return resolvedType ;
1321
+ }
1322
+ JavaType resultType = resolvedType ;
1323
+ TypeBindings b = resultType .getBindings ();
1324
+ if (b == null ) {
1325
+ b = EMPTY_BINDINGS ;
1326
+ }
1327
+ for (TypeModifier mod : _modifiers ) {
1328
+ JavaType t = mod .modifyType (resultType , srcType , b , this );
1329
+ if (t == null ) {
1330
+ throw new IllegalStateException (String .format (
1331
+ "TypeModifier %s (of type %s) return null for type %s" ,
1332
+ mod , mod .getClass ().getName (), resultType ));
1321
1333
}
1334
+ resultType = t ;
1322
1335
}
1323
1336
return resultType ;
1324
1337
}
0 commit comments