You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2013/04/08 19:41:15 UTC
[jira] [Commented] (CODEC-141) Generics warnings for
StringEncoderComparator
[ https://issues.apache.org/jira/browse/CODEC-141?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13625584#comment-13625584 ]
Sebb commented on CODEC-141:
----------------------------
Agreed it should ideally implement Comparator<String>.
Unfortunately it's not possible to do so without breaking binary compat., as it's not possible to provide both
public int compare(String, String) // needed to implement Comparator<String>
and
public int compare(Object, Object) // needed to ensure binary compat.
The compiler reports a name clash, as they have the same erasure.
This problem arises in part because StringEncoder extends Encoder.
> Generics warnings for StringEncoderComparator
> ---------------------------------------------
>
> Key: CODEC-141
> URL: https://issues.apache.org/jira/browse/CODEC-141
> Project: Commons Codec
> Issue Type: Bug
> Reporter: Sebb
> Attachments: CODEC-141.patch
>
>
> The StringEncoderComparator class currently extends the raw type Comparator.
> I think it should extend Comparator<Object>, as it implements compare(Object, Object).
> Although it is documented as being a String comparator, some StringEncoder implementations also support other types such as byte[].
> Secondly, its compare() method currently casts the stringEncoder.encode() results to Comparable.
> This might as well be String, as that is what a StringEncoder is supposed to do.
> If a class cast exception occurs, then this is a bug in the provided StringEncoder (and casting to Comparable would likely also fail).
--
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