code: public static <T> Object castToArray(final Class<T> type, final Object val) throws DevFailed {
  	Object result = null;
  	final Object array1D = val;
  	if (val == null || type.isAssignableFrom(val.getClass())) {
  	    result = val;
  	} else {
  	    LOGGER.debug("converting {} to {}", val.getClass().getCanonicalName(), type.getCanonicalName());
  	    final Class<?> typeConv = Array.newInstance(type, 0).getClass();
  	    final Transmorph transmorph = new Transmorph(creatConv());
  	    try {
  		result = transmorph.convert(array1D, typeConv);
  	    } catch (final ConverterException e) {
  		LOGGER.error("convertion error", e);
  		throw DevFailedUtils.newDevFailed(e);
  	    }
  	}
  	return result;
      }
docs: Convert an array of primitives or Objects like double[][] or Double[] into the requested type. 2D array will be
  converted to a 1D array
  
  @param <T>
  @param type
  the componant type
  @param val
  @return
  @throws DevFailed