[cdi-dev] Is a wildcard type an unresolved type variable or not

Martin Kouba mkouba at redhat.com
Thu Feb 25 05:30:44 EST 2016

Hi all,

This follows up on my last message to cdi-dev: "Type variable check for 
Event.select() and Event.fire()".

After I spend some time searching I have to rephrase the question: 
Should a wildcard type be considered an unresolved type variable or not? 
Of course, in the scope of events. I believe the spec is not clear here. 
See also "10.1. Event types and qualifier types" and "10.2.1. The Event 

There is CDI-494 which assumes a wildcard type _is_ an unresolved type 
variable [1].

 From the TCK point of view - there is only 
FireEventTest.testTypeVariableEventTypeFails() which assumes that a type 
variable resolved to a wildcard (inferred from the Event injection 
point) is unresolvable - see also CDITCK-510 [2].

Note that in CDI 1.0 the container cannot use the Event specified type 
to infer the parameterized type.

The current behavior
Weld 1 allows to pass a wildcard to Event.select() but Event.fire() is 
problematic (e.g. the snippet [3] does fail).

Weld 2+ is imho overly strict here and throws IllegalArgumentException 
whenever a type variable is resolved to a wildcard type (Event.select(), 

The latest OWB seems to support this, but it does not always infer the 
parameterized type consistently (e.g. the TCK test mentioned above is 
passing even if it's possible to resolve the type variable to the 
wildcard type).


I'm no expert on generics but I think we shouldn't treat wildcard types 
as unresolved type variables, i.e. reject CDI-494 and clarify the 
snippet [3] and similar should work. At least I cannot see any problem. 
But maybe I'm missing somethig.

Thanks for feedback,




Event<Object> event;
public void testSelectSubtypeWithWildcard() {
   List<String> updatedList = new ArrayList<>();
   Event<List<?>> child = event.select(new TypeLiteral<List<?>>() {});

More information about the cdi-dev mailing list