code: @SuppressWarnings("unchecked")
    public static <D, T extends D> Class<T> uglyCastIntoSubclass(Class<D> cls) {
      return (Class<T>) cls;
    }
docs: Cast the (erased) generics onto a class.
  <p>
  Note: this function is a hack - notice that it would allow you to up-cast
  any class! Still it is preferable to have this cast in one place than in
  dozens without any explanation.
  <p>
  The reason this is needed is the following: There is no
  <code>Class&lt;Set&lt;String&gt;&gt;.class</code>.
  This method allows you to do
  <code>Class&lt;Set&lt;String&gt;&gt; setclass = uglyCastIntoSubclass(Set.class);</code>
  <p>
  We can't type check at runtime, since we don't have T.
  
  @param cls Class type
  @param <D> Base type
  @param <T> Supertype
  @return {@code cls} parameter, but cast to {@code Class<T>}