public static Object[] toArray(Object arrayObj) {
        if (arrayObj == null) {
            return null;
        }

        if (!arrayObj.getClass().isArray()) {
            throw new ClassCastException("'arrayObj' is not an array, can't cast to Object[]");
        }

        int length = Array.getLength(arrayObj);
        Object[] array = new Object[length];
        if (length > 0) {
            for (int i = 0; i < length; ++i) {
                array[i] = Array.get(arrayObj, i);
            }
        }
        return array;
    }
@Test
    public void testToArray() {
        Assertions.assertNull(ArrayUtils.toArray(null));

        Object obj = new String[]{"1", "2", "3"};
        Object[] array = ArrayUtils.toArray(obj);
        Assertions.assertArrayEquals(new String[]{"1", "2", "3"}, array);

        Object obj1 = new String[]{};
        Object[] array1 = ArrayUtils.toArray(obj1);
        Assertions.assertArrayEquals(new String[]{}, array1);
    }