commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shevek (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-819) EnumUtils.generateBitVector needs a "? extends"
Date Tue, 11 Sep 2012 02:32:08 GMT

    [ https://issues.apache.org/jira/browse/LANG-819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13452658#comment-13452658
] 

Shevek commented on LANG-819:
-----------------------------

Officially:

http://docs.oracle.com/javase/tutorial/extra/generics/morefun.html etc etc etc

>From Google:

http://stackoverflow.com/questions/1368166/what-is-a-difference-between-super-e-and-extends-e
http://www.javabeat.net/2008/09/using-super-in-generics-java-5-0/
http://www.coderanch.com/t/417919/java-programmer-SCJP/certification/Generic-declarations-super-Vs-extends
etc etc etc - the internet is filthy with this stuff.

See also the javadocs for guice, guava, and other competing libraries - they're maintained
by a group of people who are highly formally trained and very aware of type semantics, and
they tend to get this stuff very much correct.

Basically, people NEED to use ? extends and ? super wherever appropriate, especially in things
like transformer and predicate libraries and implementations, otherwise the only way to usefully
use polymorphism is to have hard casts, which defeats the entire purpose of using generics.
Serializer libraries tend to be notoriously badly written, and defeat the purpose of their
own attempted type safety.

Commons should be audited for this kind of thing overall.
                
> EnumUtils.generateBitVector needs a "? extends"
> -----------------------------------------------
>
>                 Key: LANG-819
>                 URL: https://issues.apache.org/jira/browse/LANG-819
>             Project: Commons Lang
>          Issue Type: Bug
>    Affects Versions: 3.0.1
>            Reporter: Shevek
>            Priority: Minor
>
>     public static <E extends Enum<E>> long generateBitVector(Class<E>
enumClass, Iterable<E> values) {
> Should be Iterable<? extends E>.
> This is because although no subclasses of E can exist, the "? extends" is a common idiom
for marking the collection as readonly, or not "owned" by the current object.

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