code: public static Object toComponentTypeArray(Object val, Class<?> componentType) {
          if (val != null) {
              int len = Array.getLength(val);
              Object arr = Array.newInstance(componentType, len);
              for (int i = 0; i < len; i++) {
                  Array.set(arr, i, Array.get(val, i));
              }
              return arr;
          } else {
              return null;
          }
      }
docs: Converts an array of objects to an array of the specified component type.
  
  @param val an array of objects to be converted
  @param componentType the {@code Class} object representing the component type of the new array
  @return an array of the objects with the specified component type