2 Replies Latest reply on Jan 31, 2018 6:06 PM by ljnelson

    With CDI-256 resolved, should it be possible to fire events with type parameters?

    ljnelson

      My title above is probably bad.

       

      CDI-256 seems to have fixed up some Event-related inconsistencies in early CDI specification versions.

       

      That led me to believe that in CDI 2.0 in a class, Foo<T>, I could now (finally?) do something like:

      final Event<Object> e = beanManager.getEvent(); final TypeLiteral<Bar<T>> typeLiteral = new TypeLiteral<Bar<T>>() {}; final Event<Bar<T>> broadcaster = e.select(typeLiteral); broadcaster.fireAsync(someConformantPayload);

      This compiles, but I get a runtime exception:

      Exception in thread "Thread-3" org.jboss.weld.exceptions.IllegalArgumentException: WELD-000819: Cannot provide an event type parameterized with a type parameter com.foo.Bar<T>at org.jboss.weld.event.ObserverNotifier$EventTypeCheck.apply(ObserverNotifier.java:246) at org.jboss.weld.event.ObserverNotifier$EventTypeCheck.apply(ObserverNotifier.java:237) at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.lambda$null$0(ReentrantMapBackedComputingCache.java:55) at org.jboss.weld.util.LazyValueHolder$1.computeValue(LazyValueHolder.java:32) at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:46) at org.jboss.weld.util.cache.ReentrantMapBackedComputingCache.getValue(ReentrantMapBackedComputingCache.java:72) at org.jboss.weld.event.ObserverNotifier.checkEventObjectType(ObserverNotifier.java:230) at org.jboss.weld.event.EventImpl.selectEvent(EventImpl.java:171)

      Weld 3.0.2.Final if it matters.