Mark Struberg commented on DELTASPIKE-405:

Jozef, I'd like to sum up/reiterate the stuff I already told you and Pete on 
the CDI EG list, on google hangout and I think also in a few CDI and DELTASPIKE 
jira tickets.

In CDI-1.0 the following rules regarding generics cases get handled and are 
defined to satisfy the injection point:

1. you have a generic injection point ('required type') and a generic bean
IP: @Inject Stable<Horse> stable;
bean: @Produces Stable<Horse> ...

2. you have a raw injection point and a generic bean, e.g
IP: @Inject Stable stable;
bean: @Produces Stable<Horse> ..

3. you have a raw injection point ('required type') and a generic _unbound_ or 
erased bean
IP: @Inject Stable stable;
bean: @Produces <PET> Stable<PET> ..

Those cases are defined in 5.2.3 (in CDI-1.1: ยง5.2.4). And they do clearly 
*not* cover (and thus disallow) the following case:
IP: @Inject Stable<Horse>
bean: @Produces <PET> Stable<PET> ..

Why is it disallowed according to my interpretation? Simply because the spec 
wording of this paragraph is: a bean with a parameterized bean type is only 
available for injection into an injection point if [taxative list of cases]. 

But what was *not* defined in CDI-1-1 is the other way around: under which 
rules is a raw or unbound bean type assignable to a generic type. This one is 
exactly the question we have here:
IP: @Inject Stable<Horse>
bean: @Produces Stable
Thus in OWB and also in Weld-1.x standard Java casting rules did apply which 
perfectly work in this case. And this is exactly what we also did for 

Funnily the CDI-1.1 spec EXPLICITLY shows the following example in this very 
"For example, Dao is eligible for injection to any injection point of type 
@Default Dao<Order>, @Default Dao<User>, @Default Dao<?>, @Default Dao<?extends 
Persistent> or @Default Dao<X extends Persistent> where X is a type variable."

But isn't this exactly our case?

Sadly there is another sentence which got added to CDI-1.1 just a few lines 
below the example:
"A raw bean type is considered assignable to a parameterized required type if 
the raw types are identical and all type parameters of the required type are 
either unbounded type variables or java.lang.Object"
But this one does completely contradict the sample above, isn't?

Please feel free to point me to some details I might have overlooked or 

> producer for JsfMessage<T> does not match CDI-1.1 rules 
> --------------------------------------------------------
>                 Key: DELTASPIKE-405
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-405
>             Project: DeltaSpike
>          Issue Type: Bug
>          Components: JSF-Module
>    Affects Versions: 0.4
>            Reporter: Mark Struberg
>            Assignee: Mark Struberg
>             Fix For: 0.5
> Some containers don't find the JsfMessageProducer as it is of a generic type 
> <T>.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to