scijava-common icon indicating copy to clipboard operation
scijava-common copied to clipboard

GenericUtils.getClass cannot handle generic array parameters

Open ctrueden opened this issue 10 years ago • 2 comments

The following test (when added to GenericUtilsTest) fails, but should pass.

    /** Test illustrating a probable bug in the generics reflection logic. */
    @Test
    public void testGenericArrayParameter() {
        @SuppressWarnings("unused")
        class Struct {

            private List<int[]> list;
        }
        final Type listType = type(Struct.class, "list");
        final Type paramType =
            GenericUtils.getTypeParameter(listType, List.class, 0);
        final Class<?> paramClass = GenericUtils.getClass(paramType);
        assertSame(int[].class, paramClass);
    }

ctrueden avatar Jun 22 '15 18:06 ctrueden

@imagejan have you tested whether your fix resolves this ?

NicoKiaru avatar Jan 19 '21 14:01 NicoKiaru

I didn't test, but GenericUtils is deprecated in favor of Types now, so the test added in #416 should cover the case here, too...

imagejan avatar Jan 19 '21 14:01 imagejan