[ 
https://issues.apache.org/jira/browse/OWB-893?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13744753#comment-13744753
 ] 

Arjan Tijms commented on OWB-893:
---------------------------------

After some digging I found the following method in Weld 2.0.0sp1 in the class 
{{org.jboss.weld.resolution.BeanTypeAssignabilityRules}}:

{code}
    @Override
    protected boolean areActualTypeArgumentsMatching(ActualTypeHolder 
requiredType, Type[] otherActualTypeArguments) {
        if (requiredType.getActualTypeArguments().length == 0) {
            /*
             * A parameterized bean type is considered assignable to a raw 
required type if the raw types are identical and
             * all type parameters of the bean type are either unbounded type 
variables or java.lang.Object.
             */
            return 
isArrayOfUnboundedTypeVariablesOrObjects(otherActualTypeArguments);
        } else if (otherActualTypeArguments.length == 0) {
            /*
             * 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.
             */
            return 
isArrayOfUnboundedTypeVariablesOrObjects(requiredType.getActualTypeArguments());
        } else {
            return super.areActualTypeArgumentsMatching(requiredType, 
otherActualTypeArguments);
        }
    }
{code}

Because of the second {{if}} the workaround with the raw return type of the 
producer doesn't work on this particular version of Weld; it only works if the 
injection point in my example is declared as {{ParamValue<Object>}} or 
{{ParamValue<?>}}, but it was declared as {{ParamValue<String>}} and thus it 
fails.

So unfortunately, this is again a different rule than Weld 1.x, OWB 1.8.1 and 
OWB 1.2.1-SNAPSHOT use.
                
> OpenWebBeans 1.2.1 fails when injecting generic value holder
> ------------------------------------------------------------
>
>                 Key: OWB-893
>                 URL: https://issues.apache.org/jira/browse/OWB-893
>             Project: OpenWebBeans
>          Issue Type: Bug
>          Components: Injection and Lookup
>    Affects Versions: 1.2.1
>            Reporter: Arjan Tijms
>
> In OmniFaces we're using a producer method with the following signature:
> {code}
> @Produces
> @Param
> public <V> ParamValue<V> produce(InjectionPoint injectionPoint)
> {code}
> Injection then takes place into a bean as follows:
> {code}
> @Inject @Param
> private ParamValue<String> text1;
> {code}
> {{@Param}} is a qualifier with only non-binding attributes.
> See 
> [RequestParameterProducer|https://code.google.com/p/omnifaces/source/browse/src/org/omnifaces/cdi/param/RequestParameterProducer.java]
>  and 
> [Param|https://code.google.com/p/omnifaces/source/browse/src/org/omnifaces/cdi/Param.java]
> This works in all versions of Weld that we tested on and in OpenWebBeans 
> 1.1.8 (TomEE 1.5.2.). Unfortunately it does not work with OpenWebBeans 
> 1.2.1-SNAPSHOT (TomEE 1.6.0-SNAPSHOT).
> The problem seems to be that 1.2.1 has added an additional check in 
> {{org.apache.webbeans.util.GenericsUtil.satisfiesDependency}} that wasn't 
> there before:
> {code}
> return ClassUtil.isSame(injectionPointRawType, beanRawType)? 
> isAssignableFrom(injectionPointType, beanType): false;
> {code}
> The problem is with {{isAssignableFrom}}, because the producer is always seen 
> as producing a {{ParamValue<Object}}. The actual values at the point of 
> evaluation with the above given injection example where:
> {noformat}
> injectionPoint = ParamValue<class java.lang.String> 
> beanType = ParamValue<class java.lang.Object>
> {noformat}
> Those are not directly assignable so the injection fails.
> Is OmniFaces doing something wrong here, is this check to strict, or should 
> the producer type not be seen as {{ParamValue<Object>}}?

--
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