[cdi-dev] Events and Type Variables in CDI 1.1
Arne Limburg
arne.limburg at openknowledge.de
Sun May 4 16:24:07 EDT 2014
Hi Jozef,
In this case the type variable can be resolved to a wildcard type. Should this be legal or not? For now, I find to wording in the spec that forbids the event type to resolve to a wildcard type. So this may be a spec issue AND a tck issue. Shall I create a ticket for it?
Cheers,
Arne
Von: Jozef Hartinger <jharting at redhat.com<mailto:jharting at redhat.com>>
Datum: Freitag, 2. Mai 2014 16:20
An: Arne Limburg <arne.limburg at openknowledge.de<mailto:arne.limburg at openknowledge.de>>
Cc: "cdi-dev at lists.jboss.org<mailto:cdi-dev at lists.jboss.org>" <cdi-dev at lists.jboss.org<mailto:cdi-dev at lists.jboss.org>>
Betreff: Re: [cdi-dev] Events and Type Variables in CDI 1.1
Hi,
I think this is a spec issue. The spec should make it clearer that a "resolvable type variable" means a type variable that can be resolved to a reference type other than a type variable.
Jozef
On 04/30/2014 09:32 PM, Arne Limburg wrote:
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
_______________________________________________
cdi-dev mailing list
cdi-dev at lists.jboss.org<mailto:cdi-dev at lists.jboss.org>https://lists.jboss.org/mailman/listinfo/cdi-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20140504/1c2c340c/attachment-0001.html
More information about the cdi-dev
mailing list