At the OpenWebBeans list we are currently discussing handling of generics in CDI.
public class Baz<T> {
}
public class Qux extends Baz<String> {
}
@Vetoed
public class Bar<T1, T2> {
@Inject
private Baz<T1> baz;
@Inject
private Baz<List<T2>> t2BazList;
}
@RequestScoped
public class Foo extends Bar<String, Qux> {
}
public class Producer {
@Produces
@Amazing
public String produceString() {
return "ok";
}
@Produces
public String[] produceStringArray() {
return new String[0];
}
@Produces
public Baz<Baz<Qux>> produceBazBazQux() {
return new Baz();
}
}
The class Bar has some more injection points, but that does not matter.
Due to the TCK this deployment should work, but I don't know how.
Question: Is Baz a Bean (I suppose so) and may it be injected into Bean Foo, more precisely into the second injection point of class Bar?
- If yes, it also should be injected into the first injection point, right? This would lead to an AmbiguousResolutionException since Qux may also be injected into the first injection point.
- If no, the deployment should fail with a UnsatisfiedResolutionException since there is no Bean that can be injected into that injection point.
Is this a bug in the TCK and if not, how is this supposed to work?