[cdi-dev] Events and Type Variables in CDI 1.1

Arne Limburg arne.limburg at openknowledge.de
Wed Apr 30 15:32:35 EDT 2014


Hi,

I found an issue in either the spec or the tck, which I would like to discuss:
The TCK-Test org.jboss.cdi.tck.tests.event.fires.FireEventTest.testTypeVariableEventTypeFails
uses the following bean to fire an event by calling the method fireWithTypeVariable()


public class Bar {


    @Inject

    private Event<Foo<? extends Number>> event;


    public <T extends Number> void fireWithTypeVariable() {

        event.fire(new Foo<T>());

    }


}

The TCK expects this test to fail because of the type variable in the instance created by new Foo<T>()
However, the spec states in 10.3.1 „If the container is unable to resolve the parameterized type of the event object, it uses the specified type to infer the parameterized type of the event types.“
Imho in this case the container is able to resolve T to "? extends Number“ and the spec does not prohibit an event to have a wildcard type. So since T is not unresolvable, this test case should not expect the container to throw an exception. If we consider T not to be resolved, because it resolves to a wildcard type, we should mention this somewhere in the spec. Or am I missing something?

Cheers,
Arne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20140430/dc39b4af/attachment.html 


More information about the cdi-dev mailing list