You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Aaron Digulla (JIRA)" <ji...@apache.org> on 2017/02/16 15:53:41 UTC

[jira] [Updated] (LANG-1311) TypeUtils.toString() can't handle int[]

     [ https://issues.apache.org/jira/browse/LANG-1311?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Aaron Digulla updated LANG-1311:
--------------------------------
    Priority: Minor  (was: Major)

> TypeUtils.toString() can't handle int[]
> ---------------------------------------
>
>                 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
>            Priority: Minor
>   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)