[cdi-dev] [JBoss JIRA] (CDI-502) Clarify "contains" meaning in "Legal bean types" specification.

Tomasz Krakowiak (JIRA) issues at jboss.org
Wed Jan 28 15:24:49 EST 2015


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

Tomasz Krakowiak commented on CDI-502:
--------------------------------------

Thanks for quick reply, [~jozed].

I struggling to understand how. I can't find in "5.2.4. Assignability of raw and parameterized types" anything that would disallow it.
I'm not sure what "actual type". But assuming that it doesn't exclude wildcard types I think that rule
{quote}
the required type parameter is a wildcard, the bean type parameter is an actual type and the actual type is assignable to the upper bound, if any, of the wildcard and assignable from the lower bound, if any, of the wildcard
{quote}
covers it.

h6. A little off the topic - I think I found a bug there
If I understand correctly "5.2.4. Assignability of raw and parameterized types" (http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#assignable_parameters) indicates that bean type {{List<Optional<Object>>}} is assignable to required type {{List<Optional<? extends Object>>}} (which are not assignable to each other in Java language and wildcards are allowed in required types).

> Clarify "contains" meaning in "Legal bean types" specification.
> ---------------------------------------------------------------
>
>                 Key: CDI-502
>                 URL: https://issues.jboss.org/browse/CDI-502
>             Project: CDI Specification Issues
>          Issue Type: Clarification
>          Components: Beans, Inheritance and Specialization
>            Reporter: Tomasz Krakowiak
>
> CDI 1.1, section 2.2.1. Legal bean types says:
> {quote}
> A parameterized type that contains a wildcard type parameter is not a legal bean type.
> {quote}
> Does it means direct containment or deep/recursive containment?
> I understand this is clearly illegal:
> {code}
> @Produces
> List<?> produceList(){
> //...
> }
> {code}
> But, are those two bean definitions legal:
> {code}
> @Produces
> List<Optional<?>> produceList(){
> //...
> }
> {code}
> {code}
> // Bean types: MyList, List<Optional<?>>, Object
> // or
> // Bean types: MyList, Object
> @Dependent
> MyList extends List<Optional<?>> {
> //...
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.11#6341)


More information about the cdi-dev mailing list