Revert "TAP5-2560: Error in GenericsUtils affecting property access"
authorThiago H. de Paula Figueiredo <thiago@arsmachina.com.br>
Wed, 16 Jan 2019 18:46:20 +0000 (16:46 -0200)
committerThiago H. de Paula Figueiredo <thiago@arsmachina.com.br>
Wed, 16 Jan 2019 18:46:20 +0000 (16:46 -0200)
This reverts commit 310d9f997a605fc006ce5a03595c9d3ec71a282e.

commons/src/main/java/org/apache/tapestry5/ioc/internal/util/GenericsUtils.java

index abbb767..9bf4d00 100644 (file)
 
 package org.apache.tapestry5.ioc.internal.util;
 
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.GenericDeclaration;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.lang.reflect.WildcardType;
-import java.util.ArrayList;
+import java.lang.reflect.*;
 import java.util.LinkedList;
-import java.util.List;
 
 /**
  * Static methods related to the use of JDK 1.5 generics.
@@ -377,7 +367,15 @@ public class GenericsUtils
         }
 
         Class theClass = asClass(containingType);
-        addGenericSuperclasses(theClass, typeVariableOwner, stack);
+        Type genericSuperclass = theClass.getGenericSuperclass();
+        while (genericSuperclass != null && // true for interfaces with no superclass
+                !theClass.equals(Object.class) &&
+                !theClass.equals(typeVariableOwner))
+        {
+            stack.addFirst(genericSuperclass);
+            theClass = asClass(genericSuperclass);
+            genericSuperclass = theClass.getGenericSuperclass();
+        }
 
         int i = getTypeVariableIndex(typeVariable);
         Type resolved = typeVariable;
@@ -402,34 +400,6 @@ public class GenericsUtils
         return ((TypeVariable) resolved).getBounds()[0];
     }
 
-
-    private static void addGenericSuperclasses(Class theClass, final Class typeVariableOwner, final LinkedList<Type> stack) {
-        Type genericSuperclass = theClass.getGenericSuperclass();
-        while (genericSuperclass != null && // true for interfaces with no superclass
-                !theClass.equals(Object.class) &&
-                !theClass.equals(typeVariableOwner))
-        {
-            stack.addFirst(genericSuperclass);
-            theClass = asClass(genericSuperclass);
-            genericSuperclass = theClass.getGenericSuperclass();
-        }
-        for (Type type : theClass.getGenericInterfaces()) {
-            stack.add(type);
-        }
-        for (Class implementedInterface : getAllImplementedInterfaces(theClass)) {
-            addGenericSuperclasses(implementedInterface, typeVariableOwner, stack);
-        }
-    }
-    
-    private static List<Class> getAllImplementedInterfaces(Class theClass) {
-        List<Class> list = new ArrayList<>();
-        for (Class implementedInterface : theClass.getInterfaces()) {
-            list.add(implementedInterface);
-            list.addAll(getAllImplementedInterfaces(implementedInterface));
-        }
-        return list;
-    }
-
     /**
      * @param type           - something like List&lt;T>[] or List&lt;? extends T>[] or T[]
      * @param containingType - the shallowest type in the hierarchy where type is defined.