code: @Deprecated
      @SuppressWarnings("unchecked")
      public static <T> T valueOf(Class<T> type, String value, typeinfo annotation) {
          if (type.equals(String.class)) {
              return type.cast(value);
          } else {
              try {
                  Class<?> boxed = boxPrimitive(type);
                  try {
                      return (T)boxed.getMethod("valueOf", String.class).invoke(null, value);
                  } catch (NoSuchMethodException x) {
                      try {
                          return (T)boxed.getMethod("valueOf", Class.class, String.class).invoke(null, annotation != null ? annotation.value()[0] : type, value);
                      } catch (NoSuchMethodException y) {
                          return (T)boxed.getConstructor(String.class).newInstance(value);
                      }
                  }
              } catch (Exception x) {
                  throw new IllegalArgumentException(x.getMessage(), x);
              }
          }
      }
docs: Converts a String representation into a value of a given type. Conversion attempts are made in the following order:
  <ol>
  <li>Try to invoke {@code public static SomeClass valueOf(String text)}.</li>
  <li>Try to invoke {@code public static SomeClass valueOf(Class<SomeClass> type, String text)},
  or {@code public static SomeClass<T, V, ...> valueOf(Class<T> type1, Class<V> type2, ..., String text)} if a @typeinfo annotation exists to
  give argument types {@code T}, {@code V}, ...</li>
  <li>Try to invoke {@code <init>(String text)}.</li>
  </ol>
  
  @param <T> the target class
  @param type the target class
  @param value the string to convert
  @param annotation an optional typeinfo annotation containing type arguments to {@code type}, which should be a generic type in this case
  @return the converted value
  @throws IllegalArgumentException if all conversion attempts fail