You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Gurkan Erdogdu (JIRA)" <ji...@apache.org> on 2010/07/29 16:55:18 UTC

[jira] Commented: (OWB-431) Generic Type Inheritance not resolved correctly

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

Gurkan Erdogdu commented on OWB-431:
------------------------------------

Please look at spec section, 5.2.3

1- the required type parameter is an actual type, the bean type parameter is a type variable and the actual type is as-
signable to the upper bound, if any, of the type variable, or

2- the required type parameter and the bean type parameter are both type variables and the upper bound of the required
type parameter is assignable to the upper bound, if any, of the bean type parameter.

In above example : 

Bean Type Parameter       : T extends Bc
Actual Required Type Parameter : Dc

According to the 1), We check "Dc is addignable to Bc", answer :  false 

Same for 2. 

Seems that code is correct.



> Generic Type Inheritance not resolved correctly
> -----------------------------------------------
>
>                 Key: OWB-431
>                 URL: https://issues.apache.org/jira/browse/OWB-431
>             Project: OpenWebBeans
>          Issue Type: Bug
>          Components: Injection and Lookup
>    Affects Versions: 1.0.0-alpha-1
>         Environment: standard OWB configuration
>            Reporter: Bill Wigger
>            Assignee: Gurkan Erdogdu
>            Priority: Minor
>             Fix For: 1.0.0-alpha-2
>
>         Attachments: ClassUtilPatch.txt, ClassUtilPatch2.txt
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> WebBean is defined as:
> @Named
> public class MethodTypeProduces1<T extends Bc> {
> 	@Produces @Dependent @Named("ProMethodParameterized3") ArrayList<T> methodPT3() {
> and injected as:
> @Named
> @Dependent
> public class ProMethodTestGroup3A {
> 	public @Inject @Dependent @Named("ProMethodParameterized3") ArrayList<Dc> pt3;
>         
> with BC extending DC as follows:
> public class Bc extends Dc implements Fi {
> gives this error:
> Jul 28, 2010 9:26:51 AM org.apache.webbeans.config.BeansDeployer deploy
> SEVERE: 
> Throwable occurred: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [java.util.ArrayList] is not found with the qualifiers [@javax.inject.Named(value=ProMethodParameterized3)] for injection into Field Injection Point, field name :  pt3, Bean Owner : [Name:proMethodTestGroup3A,WebBeans Type:MANAGED,API Types:[com.ibm.jcdi.test.ProMethodTestGroup3A,java.lang.Object],Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default,javax.inject.Named]]
> 	at org.apache.webbeans.container.ResolutionUtil.checkResolvedBeans(ResolutionUtil.java:121)
> 	at org.apache.webbeans.container.InjectionResolver.checkInjectionPoints(InjectionResolver.java:185)
> 	at org.apache.webbeans.container.BeanManagerImpl.validate(BeanManagerImpl.java:1025)
> injection should be checked/resolved here in org.apache.webbeans.util.ClassUtil,  but this method returns false
>     public static boolean checkRequiredTypeIsClassAndBeanTypeIsVariable(Type beanTypeArg, Type requiredTypeArg)
>     {
>         Class<?> clazzRequiredType = (Class<?>)requiredTypeArg;
>         TypeVariable<?> tvBeanTypeArg = (TypeVariable<?>)beanTypeArg;
>         Type tvBound = tvBeanTypeArg.getBounds()[0];
>         if(tvBound instanceof Class)
>         {
>             Class<?> clazzTvBound = (Class<?>)tvBound;
>             if(clazzTvBound != Object.class)
>             {
>                 if(!clazzTvBound.isAssignableFrom(clazzRequiredType))
>                 {
>                     return false;
>                 }                                    
>             }            
>         }
>         return true;
>     }
> But since clazzTvBound is Bc  and classRequiredType is Dc
> Bc.isAssignableFrom(Dc) returns false,  so the ! is true,  and the function returns false.
> fix seems to simply go back to the old code in this routine, this code was changeed on 4/28, and
> I can't see why is was changed.
> But the check needs to verify that the required class can be assigned from the given bean class, as follows:
>         if(tvBound instanceof Class)
>         {
>             Class<?> clazzTvBound = (Class<?>)tvBound;
>             if(clazzRequiredType.isAssignableFrom(clazzTvBound))
>             {
>                 return true;
>             }                    
>         }
>         return false;
> There is also a similar incorrect injection exception using the above example, but with an injection of:
> public class TG4 <T extends Dc> {
> 	public @Inject @Dependent @Named("ProMethodParameterized3") ArrayList<T> ptT;
> I think the line of code in error here is in the method: 
> (same class as in the previous problem: org.apache.webbeans.util.ClassUtil)
> public static boolean checkBeanTypeAndRequiredIsTypeVariable(Type beanTypeArg, Type requiredTypeArg)
> where:    
> if(clazzTvBeanBound.isAssignableFrom(clazzTvRequiredBound))
> should be replaced with:
> (clazzTvRequiredBound.isAssignableFrom(clazzTvBeanBound))

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.