commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pascal Schumacher (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LANG-1311) TypeUtils.toString() doesn't handle primitive and Object arrays correctly
Date Fri, 17 Feb 2017 17:28:42 GMT

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

Pascal Schumacher updated LANG-1311:
------------------------------------
    Summary: TypeUtils.toString() doesn't handle primitive and Object arrays correctly  (was:
TypeUtils.toString() can't handle int[])

> 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
>            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)

Mime
View raw message