code: @SuppressWarnings("unchecked")
      public static <T> T[] newArrayInstance(T[] template, int length) {
          return newArrayInstance((Class<T>) template.getClass().getComponentType(), length);
      }
docs: Creates a new array instance in a type safe way.
  @param template The original array
  @param length The length of the new array
  @param <T> The base type of the new array
  @return The new array