You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Pascal Schumacher (JIRA)" <ji...@apache.org> on 2017/02/17 17:36:42 UTC
[jira] [Resolved] (LANG-1311) TypeUtils.toString() doesn't handle
primitive and Object arrays correctly
[ https://issues.apache.org/jira/browse/LANG-1311?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pascal Schumacher resolved LANG-1311.
-------------------------------------
Resolution: Fixed
Assignee: Pascal Schumacher
Fix Version/s: 3.6
Patch applied. Thanks!
{code}assertEquals("java.util.List<java.lang.String>[]", TypeUtils.toString(field.getGenericType()));{code} worked on current master and most probably on 3.5 (even before applying the patch).
> TypeUtils.toString() doesn't handle primitive and Object arrays correctly
> -------------------------------------------------------------------------
>
> Key: LANG-1311
> URL: https://issues.apache.org/jira/browse/LANG-1311
> Project: Commons Lang
> Issue Type: Bug
> Components: lang.reflect.*
> Affects Versions: 3.4, 3.5
> Reporter: Aaron Digulla
> Assignee: Pascal Schumacher
> Priority: Minor
> Fix For: 3.6
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> TypeUtils.toString() doesn't handle primitive and Object arrays correctly.
> Specifically, these tests will fail:
> {code}
> assertEquals("int[]", TypeUtils.toString(int[].class));
> assertEquals("java.lang.Integer[]", TypeUtils.toString(Integer[].class));
> {code}
> If you declare a field with type {{List<String>[]}}, then you can add this test:
> {code}
> assertEquals("java.util.List<java.lang.String>[]", TypeUtils.toString(field.getGenericType()));
> {code}
> This patch fixes the issue:
> {code}
> private static String classToString(final Class<?> c) {
> // begin patch
> if (c.isArray()) {
> return toString(c.getComponentType()) + "[]";
> }
> // end patch
>
> final StringBuilder buf = new StringBuilder();
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)