commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [commons-lang] verhas commented on a change in pull request #449: documentation related to the issue LANG-696
Date Tue, 08 Oct 2019 15:46:05 GMT
verhas commented on a change in pull request #449: documentation related to the issue LANG-696
URL: https://github.com/apache/commons-lang/pull/449#discussion_r332590295
 
 

 ##########
 File path: src/test/java/org/apache/commons/lang3/ClassUtilsTest.java
 ##########
 @@ -513,20 +516,34 @@ public void test_getShortCanonicalName_Object() {
 
     @Test
     public void test_getShortCanonicalName_String() {
+        assertEquals("", ClassUtils.getShortCanonicalName((String)null));
+        assertEquals("Map.Entry", ClassUtils.getShortCanonicalName(java.util.Map.Entry.class.getName()));
+        assertEquals("Entry", ClassUtils.getShortCanonicalName(java.util.Map.Entry.class.getCanonicalName()));
         assertEquals("ClassUtils", ClassUtils.getShortCanonicalName("org.apache.commons.lang3.ClassUtils"));
         assertEquals("ClassUtils[]", ClassUtils.getShortCanonicalName("[Lorg.apache.commons.lang3.ClassUtils;"));
         assertEquals("ClassUtils[][]", ClassUtils.getShortCanonicalName("[[Lorg.apache.commons.lang3.ClassUtils;"));
         assertEquals("ClassUtils[]", ClassUtils.getShortCanonicalName("org.apache.commons.lang3.ClassUtils[]"));
         assertEquals("ClassUtils[][]", ClassUtils.getShortCanonicalName("org.apache.commons.lang3.ClassUtils[][]"));
         assertEquals("int[]", ClassUtils.getShortCanonicalName("[I"));
+        assertEquals("int[]", ClassUtils.getShortCanonicalName(int[].class.getCanonicalName()));
+        assertEquals("int[]", ClassUtils.getShortCanonicalName(int[].class.getName()));
         assertEquals("int[][]", ClassUtils.getShortCanonicalName("[[I"));
         assertEquals("int[]", ClassUtils.getShortCanonicalName("int[]"));
         assertEquals("int[][]", ClassUtils.getShortCanonicalName("int[][]"));
 
-        // Inner types
+        // this is to demonstrate that the documentation and the naming of the methods
+        // uses the class name and canonical name totally mixed up, which cannot be
+        // fixed without backward compatibility break
+        assertEquals("int[]", int[].class.getCanonicalName());
+        assertEquals("[I", int[].class.getName());
+
+        // Inner types... the problem is that these are not canonical names, classes with
this name do not even have canonical name
         assertEquals("ClassUtilsTest.6", ClassUtils.getShortCanonicalName("org.apache.commons.lang3.ClassUtilsTest$6"));
         assertEquals("ClassUtilsTest.5Named", ClassUtils.getShortCanonicalName("org.apache.commons.lang3.ClassUtilsTest$5Named"));
         assertEquals("ClassUtilsTest.Inner", ClassUtils.getShortCanonicalName("org.apache.commons.lang3.ClassUtilsTest$Inner"));
+        // demonstrating what a canonical name is... it is a bigger issue to clean this up
+        assertEquals("org.apache.commons.lang3.ClassUtilsTest$10", new org.apache.commons.lang3.ClassUtilsTest(){}.getClass().getName());
 
 Review comment:
   done as requested

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message