@@ -199,7 +199,7 @@ private static Type scanSuperTypes(TypeVariable<?> typeVar, Type srcType, Class<
199199 for (int i = 0 ; i < parentTypeVars .length ; i ++) {
200200 if (typeVar .equals (parentTypeVars [i ])) {
201201 Type actualType = parentAsType .getActualTypeArguments ()[i ];
202- return actualType instanceof TypeVariable <?> ? (( TypeVariable <?>) actualType ). getBounds ()[ 0 ] : actualType ;
202+ return actualType instanceof TypeVariable <?> ? Object . class : actualType ;
203203 }
204204 }
205205 }
@@ -231,37 +231,9 @@ private static ParameterizedType translateParentTypeVars(ParameterizedType srcTy
231231 newParentArgs [i ] = parentTypeArgs [i ];
232232 }
233233 }
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 );
265237 }
266238
267239 private TypeParameterResolver () {
@@ -277,9 +249,9 @@ static class ParameterizedTypeImpl implements ParameterizedType {
277249
278250 ParameterizedTypeImpl (Class <?> rawType , Type ownerType , Type [] actualTypeArguments ) {
279251 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 ;
283255 }
284256
285257 @ Override
@@ -317,23 +289,22 @@ public String toString() {
317289 StringBuilder s = new StringBuilder ();
318290 if (ownerType != null ) {
319291 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 ());
326293 } else {
327294 s .append (rawType .getName ());
328295 }
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 ());
333304 }
334- s .append (actualTypeArguments [ i ]. getTypeName () );
305+ s .append (">" );
335306 }
336- return s .append ( ">" ). toString ();
307+ return s .toString ();
337308 }
338309 }
339310
@@ -344,8 +315,8 @@ static class WildcardTypeImpl implements WildcardType {
344315
345316 WildcardTypeImpl (Type [] lowerBounds , Type [] upperBounds ) {
346317 super ();
347- this .lowerBounds = canonicalizeTypes ( lowerBounds ) ;
348- this .upperBounds = canonicalizeTypes ( upperBounds ) ;
318+ this .lowerBounds = lowerBounds ;
319+ this .upperBounds = upperBounds ;
349320 }
350321
351322 @ Override
@@ -396,7 +367,7 @@ static class GenericArrayTypeImpl implements GenericArrayType {
396367
397368 GenericArrayTypeImpl (Type genericComponentType ) {
398369 super ();
399- this .genericComponentType = canonicalize ( genericComponentType ) ;
370+ this .genericComponentType = genericComponentType ;
400371 }
401372
402373 @ Override
0 commit comments