This method does a similar job to JSE 6.0's Arrays.copyOf() method
@param <U> The type of input array
@param objectArray The array to copy
@return A copy of the input, of component type U
15612
public static <U> U[] copyOf(U[] objectArray) {

    	Class<?> arrayClass = objectArray.getClass();
        @SuppressWarnings("unchecked") Class<U> componentClass = (Class<U>) arrayClass.getComponentType();

        @SuppressWarnings("unchecked") U[] copy = (U[]) Array.newInstance(componentClass, objectArray.length);
        System.arraycopy(objectArray, 0, copy, 0, objectArray.length);
        return copy;
    }
517767
public static Object[] toObjectArray(Object o) {

        Class clas = o.getClass().getComponentType();

        if (null == clas) return null;

        Object[] arr;

        if (clas == Boolean.TYPE) {
            boolean[] src = (boolean[]) o;
            arr = new Object[src.length];
            for (int i = 0; i < src.length; i++)
                arr[i] = new Boolean(src[i]);
        } else if (clas == Character.TYPE) {
            char[] src = (char[]) o;
            arr = new Object[src.length];
            for (int i = 0; i < src.length; i++)
                arr[i] = new Character(src[i]);
        } else if (clas == Byte.TYPE) {
            byte[] src = (byte[]) o;
            arr = new Object[src.length];
            for (int i = 0; i < src.length; i++)
                arr[i] = new Byte(src[i]);
        } else if (clas == Short.TYPE) {
            short[] src = (short[]) o;
            arr = new Object[src.length];
            for (int i = 0; i < src.length; i++)
                arr[i] = new Short(src[i]);
        } else if (clas == Integer.TYPE) {
            int[] src = (int[]) o;
            arr = new Object[src.length];
            for (int i = 0; i < src.length; i++)
                arr[i] = new Integer(src[i]);
        } else if (clas == Long.TYPE) {
            long[] src = (long[]) o;
            arr = new Object[src.length];
            for (int i = 0; i < src.length; i++)
                arr[i] = new Long(src[i]);
        } else if (clas == Float.TYPE) {
            float[] src = (float[]) o;
            arr = new Object[src.length];
            for (int i = 0; i < src.length; i++)
                arr[i] = new Float(src[i]);
        } else if (clas == Double.TYPE) {
            double[] src = (double[]) o;
            arr = new Object[src.length];
            for (int i = 0; i < src.length; i++)
                arr[i] = new Double(src[i]);
        } else {
            arr = (Object[]) o;
        }
        return arr;
    }
204450
public static Object duplicateArray(Object source) {

        int size = Array.getLength(source);
        Object newarray =
            Array.newInstance(source.getClass().getComponentType(), size);

        System.arraycopy(source, 0, newarray, 0, size);

        return newarray;
    }
1008438
public static char[] copyOf(char[] charArray) {

    	char[] copy = new char[charArray.length];
        System.arraycopy(charArray, 0, copy, 0, charArray.length);
        return copy;
    }
203789
public static double[][] array_clone(double[][] a) {
        if(a == null) {
            return a;
        }
        double[][] copy = new double[a.length][];
        for(int i=0;i<a.length;i++) {
            copy[i] = Arrays.copyOf(a[i], a[i].length);
        }
        return copy;
    }
309674
function copy(object) {
  // a quick copy
  var copy = {};
  for (var i in object) {
    copy[i] = object[i];
  }
  return copy;
}
438325
public static Class<?> getComponentType(Object array) {
		return null == array ? null : array.getClass().getComponentType();
	}
368017
private static Object[] toObjectArray(Object primitiveArray) {
        if (primitiveArray == null) {
            throw new NullPointerException();
        }
        
        if (primitiveArray instanceof Object[]) {
            return (Object[]) primitiveArray;
        }

        if (primitiveArray instanceof Collection) {
            return ((Collection) primitiveArray).toArray();
        }
          
        Class clazz = primitiveArray.getClass();
        if (!clazz.isArray()) {
            return null;
        }

        int length = Array.getLength(primitiveArray);
        Object[] array = new Object[length];
        for (int i = 0; i < length; i++) {
            array[i] = Array.get(primitiveArray, i);
        }

        return array;
    }
340350
public static int[][] copyOf(final int[][] nums) {
        final int[][] copy = new int[nums.length][];

        for (int i = 0; i < copy.length; i++) {
            final int[] member = new int[nums[i].length];
            System.arraycopy(nums[i], 0, member, 0, nums[i].length);
            copy[i] = member;
        }

        return copy;
    }
1292520
public static Object toWrapperArray(Object array) {
    if (!array.getClass().isArray()) {
      throw new IllegalArgumentException("Must give array object.");
    }
    if (isPrimitiveArray(array.getClass())) {
      int length = Array.getLength(array);
      Object newArray = Array.newInstance(toWrapper(array.getClass().getComponentType()), length);
      for (int i = 0; i < length; i++) {
        Array.set(newArray, i, toWrapper(Array.get(array, i)));
      }
      return newArray;
    } else if (array.getClass().getComponentType().isArray()) {
      int length = Array.getLength(array);
      Object newArray = Array.newInstance(toWrapperArray(array.getClass().getComponentType()), length);
      for (int i = 0; i < length; i++) {
        Array.set(newArray, i, toWrapperArray(Array.get(array, i)));
      }
      return newArray;
    }
    return array;
  }
196773
private static Object[] toObjectArray(Object val){
        if (val instanceof Object[])
            return (Object[])val;
        int arrayLength = java.lang.reflect.Array.getLength(val);
        Object[] outputArray = new Object[arrayLength];
        for(int i = 0; i < arrayLength; ++i){
            outputArray[i] = java.lang.reflect.Array.get(val, i);
        }
        return outputArray;
    }
115084
@SuppressWarnings("unchecked")
    public static <T> T[] cloneArray(T[] original) {
        if (original == null) {
            return null;
        }

        try {
            Class<?> clazz = original.getClass().getComponentType();
            T[] copy = (T[]) Array.newInstance(clazz, original.length);
            if (copy.length != 0) {
                Constructor<T> copyConstructor = (Constructor<T>) clazz.getConstructor(clazz);
                int i = 0;
                for (T t : original) {
                    copy[i++] = copyConstructor.newInstance(t);
                }
            }
            return copy;
        } catch (Exception e) {
            throw new RuntimeException("Cannot copy array. Does its type have a copy-constructor? " + original, e);
        }
    }
358872
public static boolean[] copyOf(boolean[] booleanArray) {

    	boolean[] copy = new boolean[booleanArray.length];
        System.arraycopy(booleanArray, 0, copy, 0, booleanArray.length);
        return copy;
    }
170314
public static ByteBuf copiedBuffer(char[] array, Charset charset) {
        if (array == null) {
            throw new NullPointerException("array");
        }
        return copiedBuffer(array, 0, array.length, charset);
    }
388151
private Object convertArrayToArray(Object array) {
		final Class<?> valueComponentType = ArrayUtil.getComponentType(array);

		if (valueComponentType == targetComponentType) {
			return array;
		}

		final int len = ArrayUtil.length(array);
		final Object result = Array.newInstance(targetComponentType, len);

		final ConverterRegistry converter = ConverterRegistry.getInstance();
		for (int i = 0; i < len; i++) {
			Array.set(result, i, converter.convert(targetComponentType, Array.get(array, i)));
		}
		return result;
	}
502006
function clone(obj) {
    if (Array.isArray(obj)) {
        return obj.map(clone);
    } else if (typeof obj === 'object') {
        var copy = {};
        Object.keys(obj).forEach(function (key) {
            copy[key] = clone(obj[key]);
        });
        return copy;
    }
    return obj;
}
560441
public static short[] copyOf(short[] shortArray) {

    	short[] copy = new short[shortArray.length];
        System.arraycopy(shortArray, 0, copy, 0, shortArray.length);
        return copy;
    }