@@ -199,7 +199,7 @@ private static Type scanSuperTypes(TypeVariable<?> typeVar, Type srcType, Class<
199
199
for (int i = 0 ; i < parentTypeVars .length ; i ++) {
200
200
if (typeVar .equals (parentTypeVars [i ])) {
201
201
Type actualType = parentAsType .getActualTypeArguments ()[i ];
202
- return actualType instanceof TypeVariable <?> ? (( TypeVariable <?>) actualType ). getBounds ()[ 0 ] : actualType ;
202
+ return actualType instanceof TypeVariable <?> ? Object . class : actualType ;
203
203
}
204
204
}
205
205
}
@@ -231,37 +231,9 @@ private static ParameterizedType translateParentTypeVars(ParameterizedType srcTy
231
231
newParentArgs [i ] = parentTypeArgs [i ];
232
232
}
233
233
}
234
- if (noChange && !(parentType instanceof ParameterizedTypeImpl ))
235
- noChange = false ;
236
- return noChange ? parentType
237
- : new ParameterizedTypeImpl ((Class <?>) parentType .getRawType (), parentType .getOwnerType (), newParentArgs );
238
- }
239
-
240
- private static Type canonicalize (Type type ) {
241
- if (type instanceof ParameterizedType ) {
242
- ParameterizedType p = (ParameterizedType ) type ;
243
- return new ParameterizedTypeImpl ((Class <?>) p .getRawType (), p .getOwnerType (), p .getActualTypeArguments ());
244
- } else if (type instanceof GenericArrayType ) {
245
- GenericArrayType g = (GenericArrayType ) type ;
246
- return new GenericArrayTypeImpl (g .getGenericComponentType ());
247
- } else if (type instanceof WildcardType ) {
248
- WildcardType w = (WildcardType ) type ;
249
- return new WildcardTypeImpl (w .getLowerBounds (), w .getUpperBounds ());
250
- } else {
251
- return type ;
252
- }
253
- }
254
-
255
- private static Type [] canonicalizeTypes (Type [] types ) {
256
- if (types == null || types .length == 0 ) {
257
- return new Type [0 ];
258
- }
259
- int length = types .length ;
260
- Type [] canonicalizedTypes = new Type [length ];
261
- for (int i = 0 ; i < length ; i ++) {
262
- canonicalizedTypes [i ] = canonicalize (types [i ]);
263
- }
264
- return canonicalizedTypes ;
234
+ return noChange
235
+ ? parentType
236
+ : new ParameterizedTypeImpl ((Class <?>) parentType .getRawType (), parentType .getOwnerType (), newParentArgs );
265
237
}
266
238
267
239
private TypeParameterResolver () {
@@ -277,9 +249,9 @@ static class ParameterizedTypeImpl implements ParameterizedType {
277
249
278
250
ParameterizedTypeImpl (Class <?> rawType , Type ownerType , Type [] actualTypeArguments ) {
279
251
super ();
280
- this .rawType = ( Class <?>) canonicalize ( rawType ) ;
281
- this .ownerType = canonicalize ( ownerType ) ;
282
- this .actualTypeArguments = canonicalizeTypes ( actualTypeArguments ) ;
252
+ this .rawType = rawType ;
253
+ this .ownerType = ownerType ;
254
+ this .actualTypeArguments = actualTypeArguments ;
283
255
}
284
256
285
257
@ Override
@@ -317,23 +289,22 @@ public String toString() {
317
289
StringBuilder s = new StringBuilder ();
318
290
if (ownerType != null ) {
319
291
s .append (ownerType .getTypeName ()).append ("$" );
320
- if (ownerType instanceof ParameterizedTypeImpl ) {
321
- // remove prefixes that do not contain generic information
322
- s .append (rawType .getName ().replace (((ParameterizedTypeImpl ) ownerType ).rawType .getName () + "$" , "" ));
323
- } else {
324
- s .append (rawType .getSimpleName ());
325
- }
292
+ s .append (rawType .getSimpleName ());
326
293
} else {
327
294
s .append (rawType .getName ());
328
295
}
329
- s .append ("<" );
330
- for (int i = 0 ; i < actualTypeArguments .length ; i ++) {
331
- if (i > 0 ) {
332
- s .append (", " );
296
+ int argLength = actualTypeArguments .length ;
297
+ if (argLength > 0 ) {
298
+ s .append ("<" );
299
+ for (int i = 0 ; i < argLength ; i ++) {
300
+ if (i > 0 ) {
301
+ s .append (", " );
302
+ }
303
+ s .append (actualTypeArguments [i ].getTypeName ());
333
304
}
334
- s .append (actualTypeArguments [ i ]. getTypeName () );
305
+ s .append (">" );
335
306
}
336
- return s .append ( ">" ). toString ();
307
+ return s .toString ();
337
308
}
338
309
}
339
310
@@ -344,8 +315,8 @@ static class WildcardTypeImpl implements WildcardType {
344
315
345
316
WildcardTypeImpl (Type [] lowerBounds , Type [] upperBounds ) {
346
317
super ();
347
- this .lowerBounds = canonicalizeTypes ( lowerBounds ) ;
348
- this .upperBounds = canonicalizeTypes ( upperBounds ) ;
318
+ this .lowerBounds = lowerBounds ;
319
+ this .upperBounds = upperBounds ;
349
320
}
350
321
351
322
@ Override
@@ -396,7 +367,7 @@ static class GenericArrayTypeImpl implements GenericArrayType {
396
367
397
368
GenericArrayTypeImpl (Type genericComponentType ) {
398
369
super ();
399
- this .genericComponentType = canonicalize ( genericComponentType ) ;
370
+ this .genericComponentType = genericComponentType ;
400
371
}
401
372
402
373
@ Override
0 commit comments