Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.4, 3.5
-
None
-
Patch
Description
TypeUtils.toString() doesn't handle primitive and Object arrays correctly.
Specifically, these tests will fail:
assertEquals("int[]", TypeUtils.toString(int[].class)); assertEquals("java.lang.Integer[]", TypeUtils.toString(Integer[].class));
If you declare a field with type List<String>[], then you can add this test:
assertEquals("java.util.List<java.lang.String>[]", TypeUtils.toString(field.getGenericType()));
This patch fixes the issue:
private static String classToString(final Class<?> c) { // begin patch if (c.isArray()) { return toString(c.getComponentType()) + "[]"; } // end patch final StringBuilder buf = new StringBuilder();