docs: public static <T> Class<T> getTypeParameter(Class<?> klass, Class<? super T> bound) {
          Type t = requireNonNull(klass);
          while (t instanceof Class<?>) {
              t = ((Class<?>) t).getGenericSuperclass();
          }
          /* This is not guaranteed to work for all cases with convoluted piping
           * of type parameters: but it can at least resolve straight-forward
           * extension with single type parameter (as per [Issue-89]).
           * And when it fails to do that, will indicate with specific exception.
           */
          if (t instanceof ParameterizedType) {
              // should typically have one of type parameters (first one) that matches:
              for (Type param : ((ParameterizedType) t).getActualTypeArguments()) {
                  if (param instanceof Class<?>) {
                      final Class<T> cls = determineClass(bound, param);
                      if (cls != null) {
                          return cls;
                      }
                  } else if (param instanceof TypeVariable) {
                      for (Type paramBound : ((TypeVariable<?>) param).getBounds()) {
                          if (paramBound instanceof Class<?>) {
                              final Class<T> cls = determineClass(bound, paramBound);
                              if (cls != null) {
                                  return cls;
                              }
                          }
                      }
                  } else if (param instanceof ParameterizedType) {
                      final Type rawType = ((ParameterizedType) param).getRawType();
                      if (rawType instanceof Class<?>) {
                          final Class<T> cls = determineClass(bound, rawType);
                          if (cls != null) {
                              return cls;
                          }
                      }
                  }
              }
          }
          throw new IllegalStateException("Cannot figure out type parameterization for " + klass.getName());
      }