Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-736

Observer resolution - assignability clarification

    XMLWordPrintable

Details

    • Clarification
    • Resolution: Obsolete
    • Major
    • 2.1 (Discussion)
    • 2.0.SP1
    • Resolution
    • None

    Description

      Recently we came up across an observer resolution issue which concerns 10.3.1. Assignability of type variables, raw and parameterized types.

      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:

      public interface QualifiedEvent<T> {
       // some methods
      }
      
      public class EventImpl implements QualifiedEvent { //NOTE - implements raw type
       // some method impls
      }
      

      Here is observer code:

          void listenForChildEvent(@Observes QualifiedEvent<Bar> foo) {
            // stuff going on here...
          }
      

      And your event type is:

      new EventImpl(clazz);
      

      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, where it says:

      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. That way the spec will behave coherently and the above observer/event assignability should not work.

      Side note - for the sample above to work, you would need to change the observed types to QualifiedEvent<?>.

      Attachments

        Activity

          People

            Unassigned Unassigned
            manovotn Matěj Novotný
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: