commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Reopened] (IO-343) org.apache.commons.io.comparator Javadoc is inconsistent with real code
Date Wed, 17 Apr 2013 23:17:17 GMT

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

Sebb reopened IO-343:
---------------------


The change is *not binary compatible*.

I just compiled the following code against IO 2.4:

{code}
public class CompTest {
    public static void main(String[] a) {
        Comparator<File> comparator = DefaultFileComparator.DEFAULT_COMPARATOR;
    }
}
{code}

This runs fine against IO-2.4, but when run with 2.5-SNAPSHOT it fails with:

{code}
Exception in thread "main" java.lang.NoSuchFieldError: DEFAULT_COMPARATOR
        at CompTest.main(CompTest.java:8)
{code}

I think this is because the loader looks for the exact field type when trying to find a field.
This is similar to the binary incompatibility that results from changing a method return type
from void to int or long.

The code is source-compatible.
                
> org.apache.commons.io.comparator Javadoc is inconsistent with real code
> -----------------------------------------------------------------------
>
>                 Key: IO-343
>                 URL: https://issues.apache.org/jira/browse/IO-343
>             Project: Commons IO
>          Issue Type: Bug
>    Affects Versions: 2.4
>            Reporter: Igor Lash
>            Priority: Minor
>             Fix For: 2.5
>
>         Attachments: patch.txt
>
>
> Package org.apache.commons.io.comparator has a lot of inconsistent JavaDocs. 
> For example this class org.apache.commons.io.comparator.NameFileComparator
> http://svn.apache.org/viewvc/commons/proper/io/trunk/src/main/java/org/apache/commons/io/comparator/NameFileComparator.java?view=markup
> has JavaDocs
>  List&lt;File&gt; list = ...
>  NameFileComparator.NAME_COMPARATOR.sort(list); ....
>  File[] array = ...
>  NameFileComparator.NAME_INSENSITIVE_REVERSE.sort(array);
> but this will not work because all static members of NameFileComparator declared as Comparator<File>
for example 
>  public static final Comparator<File> NAME_REVERSE = new ReverseComparator(NAME_COMPARATOR);
> public static final Comparator<File> NAME_INSENSITIVE_REVERSE = new ReverseComparator(NAME_INSENSITIVE_COMPARATOR);
> and Comparator class doesn't have the sort() method.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message