code: public static Class<?> getGenericClass(Class<?> cls, int i) {
          try {
              ParameterizedType parameterizedType;
              if (cls.getGenericInterfaces().length > 0
                      && cls.getGenericInterfaces()[0] instanceof ParameterizedType) {
                  parameterizedType = ((ParameterizedType) cls.getGenericInterfaces()[0]);
              } else if (cls.getGenericSuperclass() instanceof ParameterizedType) {
                  parameterizedType = (ParameterizedType) cls.getGenericSuperclass();
              } else {
                  parameterizedType = null;
              }
              if (parameterizedType != null) {
                  Object genericClass = parameterizedType.getActualTypeArguments()[i];
                  if (genericClass instanceof ParameterizedType) { // 处理多级泛型
                      return (Class<?>) ((ParameterizedType) genericClass).getRawType();
                  } else if (genericClass instanceof GenericArrayType) { // 处理数组泛型
                      Class<?> componentType = (Class<?>) ((GenericArrayType) genericClass).getGenericComponentType();
                      if (componentType.isArray()) {
                          return componentType;
                      } else {
                          return Array.newInstance(componentType, 0).getClass();
                      }
                  } else if (genericClass instanceof Class) {
                      return (Class<?>) genericClass;
                  }
              }
          } catch (Exception e) {
          }
          if (cls.getSuperclass() != null && cls.getSuperclass() != Object.class) {
              return getGenericClass(cls.getSuperclass(), i);
          } else {
              throw new IllegalArgumentException(cls.getName() + " generic type undefined!");
          }
      }
docs: <p>getGenericClass.</p>
  
  @param cls a {@link java.lang.Class} object.
  @param i a int.
  @return a {@link java.lang.Class} object.