code: public static Class<?> erasure(Type type)
     {
        if (type instanceof ParameterizedType)
        {
           return erasure(((ParameterizedType)type).getRawType());
        }
        if (type instanceof TypeVariable<?>)
        {
           return erasure(((TypeVariable<?>)type).getBounds()[0]);
        }
        if (type instanceof WildcardType)
        {
           return erasure(((WildcardType)type).getUpperBounds()[0]);
        }
        if (type instanceof GenericArrayType)
        {
           return Array.newInstance(erasure(((GenericArrayType)type).getGenericComponentType()), 0).getClass();
        }
  
        // Only type left is class
        return (Class<?>)type;
     }
docs: Erases a type according to the JLS type erasure rules
  
  @param t type to erase
  @return erased type