[cdi-dev] [JBoss JIRA] (CDI-436) Specialization requirements do not allow parameterized types to be specialized

Matus Abaffy (JIRA) issues at jboss.org
Wed Apr 30 05:54:34 EDT 2014


    [ https://issues.jboss.org/browse/CDI-436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12964631#comment-12964631 ] 

Matus Abaffy commented on CDI-436:
----------------------------------

Actually, if X<...> specializes Y<...>, then bean X cannot have some "more general" bean type than bean Y (otherwise it could not extend it, or override it in the case of producer methods). So if X has a bean type U that is assignable from (more general than) bean type T of Y, then U and T must really be the same. Just not necessarily equal in the java sense.
                
> Specialization requirements do not allow parameterized types to be specialized
> ------------------------------------------------------------------------------
>
>                 Key: CDI-436
>                 URL: https://issues.jboss.org/browse/CDI-436
>             Project: CDI Specification Issues
>          Issue Type: Bug
>    Affects Versions: 1.2.Final
>            Reporter: Matus Abaffy
>
> {quote}
> Formally, a bean X is said to specialize another bean Y if either:
> ...
> Furthermore, X must have all the bean types of Y. If X does not have some bean type of Y, the container automatically detects the problem and treats it as a definition error.
> {quote}
> The tricky part about having all the bean types is that two parameterized types might not equal (in the java sense) even though they "are the same". That's because of the inequality between type variables. Example:
> {code}
> class Foo<T> {}
> {code}
> {code}
> class Bar<T> extends Foo<T> {}
> {code}
> Bar seems to have all the bean types of Foo, but it does not. Foo<T> from class Bar is not equal to Foo<T> from class Foo.
> I suppose the intention of the spec. was that if bean X specializes bean Y, then for each bean type T of Y, X must have a bean type U that is assignable from T.

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


More information about the cdi-dev mailing list