class ObjectArrayConverter extends AbstractObjectConverter<Object[]> {

    @Override
    public Object[] convert(Object[] data, boolean isVarargs, Class<?>[] parameterTypes) {
        Object[] result;
        if (isVarargs) {
            result = new Object[parameterTypes.length];

            int lastArgIdx = parameterTypes.length - 1;
            if (lastArgIdx >= 0) {
                System.arraycopy(data, 0, result, 0, lastArgIdx);
            }
            result[lastArgIdx] = convertVararg(data, parameterTypes[lastArgIdx].getComponentType(), lastArgIdx);

        } else {
            result = data;
        }
        checkIfArgumentsMatchParameterTypes(result, parameterTypes);
        return result;
    }

}

class ObjectArrayConverterTest {

    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "Mockito rule needs no further configuration")
    @Rule
    public MockitoRule mockitoRule;
    @InjectMocks
    private ObjectArrayConverter underTest;

    @Test
    public void testConvertShouldNotForwardArrayIfVarargsIsArrayOfArray() {

        // Given:
        Object[] data = new Object[] { new int[] { 1, 2 } };
        Class<?>[] parameterTypes = new Class<?>[] { int[].class };

        // When:
        Object[] result = underTest.convert(data, true, parameterTypes);

        // Then:
        assertThat(result).isEqualTo(new int[][] { { 1, 2 } });
    }

}