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

Dianshu Liao updated LANG-1771:
-------------------------------
    Attachment: Screenshot 2025-05-01 at 5.43.19 pm.png

>  Incorrect output from ClassUtils.getCanonicalName when input is "[String" in 
> version 3.18.0-SNAPSHOT
> -----------------------------------------------------------------------------------------------------
>
>                 Key: LANG-1771
>                 URL: https://issues.apache.org/jira/browse/LANG-1771
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: 3.18.0
>         Environment: MacOS Sequoia Version 15.3.2
> JDK 8
>  
>            Reporter: Dianshu Liao
>            Priority: Major
>             Fix For: 3.18.0
>
>         Attachments: Screenshot 2025-05-01 at 5.43.19 pm.png
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> In org.apache.commons.lang3.ClassUtils, the method "private static String 
> getCanonicalName(String className)" produces incorrect output for certain 
> malformed array class name strings.
>  
> Steps to Reproduce:
> package org.apache.commons.lang3;
> import org.apache.commons.lang3.ClassUtils;
> import org.apache.commons.lang3.StringUtils;
> import org.junit.Test;
> import java.lang.reflect.Method;
> import static org.junit.Assert.assertEquals;
>  
> public class testClassUtils {
>  
> @Test(timeout = 4000)
> public void testGetCanonicalName() {
> try {
> // Accessing the private static method using reflection
> Method method = ClassUtils.class.getDeclaredMethod("getCanonicalName", 
> String.class);
> method.setAccessible(true);
>  
> String input2 = "[String";
> String expectedOutput2 = "String[]";
> String actualOutput2 = (String) method.invoke(null, input2);
> assertEquals(expectedOutput2, actualOutput2);
>  
>  
>  
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
>  
> }
>  
>  
> Expected Result:
> actualOutput2 is "String[]"
>  
> Actual Results:
> actualOutput2 is "short[]"
>  
> Additional Information:
> This issue seems only occurs with input "[String".
>  
> Other inputs like: "[I" → returns "int[]" (correct)
> "Ljava.lang.String;" → returns "java.lang.String" (correct)
>  
> *Version Affected:* {{3.18.0-SNAPSHOT}}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to