You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Cergey Chaulin (JIRA)" <ji...@apache.org> on 2019/07/02 17:01:00 UTC

[jira] [Comment Edited] (OWB-1292) StackOverflowError in GenericsUtil.satisfiesDependency with parametrized type

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

Cergey Chaulin edited comment on OWB-1292 at 7/2/19 5:00 PM:
-------------------------------------------------------------

[~romain.manni-bucau]

Hi, again

Is FooImpl supposed to be injected ? I created the [issue about this |htps://issues.jboss.org/browse/WELD-2588 in WELD Jira - the guys said that FooImpl is not eligible for injection. Their explanation is as follows:

 
{code:java}
The condition for assignability starts with - A parameterized bean type is considered assignable to a parameterized required type if they have identical raw type and for each parameter:
Identical raw type means you will actually be matching a required type of GenericFoo<Long> and a bean type of GenericFoo<T extends Comparable<T>> (not FooImpl).
The condition for assignability then continues with - 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
Upper bound of required type is Long; upper bound of bean type parameter is Comparable<T>. Now, is Long assignable to Comparable<T>? I don't think so, it would be assignable to Comparable<Long> but T can stand for any type and Long is simply too specific in this case.

{code}
 


was (Author: cossack5):
[~romain.manni-bucau]

Hi, again

Is FooImpl supposed to be injected ? I created the [issue about this |[https://issues.jboss.org/browse/WELD-2588]] in WELD Jira - the guys said that FooImpl is not eligible for injection. Their explanation is as follows:

 
{code:java}
The condition for assignability starts with - A parameterized bean type is considered assignable to a parameterized required type if they have identical raw type and for each parameter:
Identical raw type means you will actually be matching a required type of GenericFoo<Long> and a bean type of GenericFoo<T extends Comparable<T>> (not FooImpl).
The condition for assignability then continues with - 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
Upper bound of required type is Long; upper bound of bean type parameter is Comparable<T>. Now, is Long assignable to Comparable<T>? I don't think so, it would be assignable to Comparable<Long> but T can stand for any type and Long is simply too specific in this case.

{code}
 

> StackOverflowError in GenericsUtil.satisfiesDependency with parametrized type
> -----------------------------------------------------------------------------
>
>                 Key: OWB-1292
>                 URL: https://issues.apache.org/jira/browse/OWB-1292
>             Project: OpenWebBeans
>          Issue Type: Bug
>          Components: Core
>            Reporter: Cergey Chaulin
>            Assignee: Romain Manni-Bucau
>            Priority: Major
>             Fix For: 2.0.12
>
>
> When trying to inject parametrized bean to concrete required type (like the one below), StackOverflowError occures in GenericsUtil.satisfiesDependency
> {code:java}
> interface GenericFoo<T extends Comparable<T>> {
>     T someMethod();
> }
> class FooImpl<T extends Comparable<T>> implements GenericFoo<T> {
>     @Override
>     public T someMethod() {
>         return null;
>     }
> }
> class Bar {
>   GenericFoo<Long> foo;
> }{code}
> Code to reproduce:
> {code:java}
>   //creating injection point of GenericFoo<Long>
>   ParameterizedType injectionPointType = new OwbParametrizedTypeImpl(null, GenericFoo.class, Long.class);
>   CoreReflectionFactory factory = CoreReflectionFactory.make(GenericFoo.class, ClassScope.make(GenericFoo.class));
>   //constructing parametrized type manually
>   TypeVariable<?> t = factory.makeTypeVariable("T", new FieldTypeSignature[]{
>           ClassTypeSignature.make(Collections.singletonList(
>                   SimpleClassTypeSignature.make(Comparable.class.getName(), false,
>                           new TypeArgument[]{TypeVariableSignature.make("T")})))
>   });
>   ParameterizedType beanType = new OwbParametrizedTypeImpl(null, GenericFoo.class, t);
>   GenericsUtil.satisfiesDependency(false, false, injectionPointType, beanType);
> {code}
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)