[cdi-dev] [JBoss JIRA] (CDI-736) Observer resolution - assignability clarification

Martin Kouba (JIRA) issues at jboss.org
Tue Sep 18 03:52:00 EDT 2018


     [ https://issues.jboss.org/browse/CDI-736?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Kouba updated CDI-736:
-----------------------------
    Fix Version/s: 2.1 (Discussion)


> Observer resolution - assignability clarification
> -------------------------------------------------
>
>                 Key: CDI-736
>                 URL: https://issues.jboss.org/browse/CDI-736
>             Project: CDI Specification Issues
>          Issue Type: Clarification
>          Components: Resolution
>    Affects Versions: 2.0.SP1
>            Reporter: Matej Novotny
>             Fix For: 2.1 (Discussion)
>
>
> Recently we came up across an observer resolution issue which concerns [10.3.1. Assignability of type variables, raw and parameterized types|http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#observers_assignability].
> What happens when you are trying to assign a non-parameterized subclass to a parameterized superclass?
> Here is a bit of code, we have following two classes:
> {code}
> public interface QualifiedEvent<T> {
>  // some methods
> }
> public class EventImpl implements QualifiedEvent { //NOTE - implements raw type
>  // some method impls
> }
> {code}
> Here is observer code:
> {code}
>     void listenForChildEvent(@Observes QualifiedEvent<Bar> foo) {
>       // stuff going on here...
>     }
> {code}
> And your event type is:
> {code}
> new EventImpl(clazz);
> {code}
> In this scenario, the spec is IMO unclear on what should happen in this particular case.
> Looking at other parts of spec, we already have this covered in, for instance, [delegate injection point assignability|http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#delegate_assignable_parameters], where it says:
> bq. A raw bean type is considered assignable to a parameterized delegate type if the raw types are identical and all type parameters of the delegate type are either unbounded type variables or java.lang.Object.
> I think we should add a similar sentence to  [10.3.1. Assignability of type variables, raw and parameterized types|http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#observers_assignability].



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the cdi-dev mailing list