[ 
http://issues.ops4j.org/browse/QI-306?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13727#action_13727
 ] 

Rickard Öberg commented on QI-306:
----------------------------------

Note that the injection itself cannot realistically differentiate @Uses with 
generics, so the injection is likely to be meaningless. In other words, if you 
do this:
{code}
@Uses Class<SomeClass> classInjection;
{code}
and then builder.use(someClass,anotherClass).newInstance(), there's no way for 
the injection mechanism to know which class should be injected at what point, 
since the genericinfo is not there. So to allow generic in @Uses might give the 
developer hope which is misplaced. I would suggest we drop this issue.

> Exception thrown when @Using on complex generic types
> -----------------------------------------------------
>
>                 Key: QI-306
>                 URL: http://issues.ops4j.org/browse/QI-306
>             Project: Qi4j
>          Issue Type: Bug
>          Components: Core Runtime
>    Affects Versions: 1.2
>         Environment: Any.
>            Reporter: Stanislav Muhametsin
>             Fix For: 1.3
>
>         Attachments: ComplexUsesGenericTypesTest.java
>
>
> When using @Uses -injection with more complex generics-usage scenario, an 
> exception (org.qi4j.api.common.InvalidApplicationException: Could not 
> register <object class>, which is caused by class cast exception) is thrown 
> during bootstrapping. The inner exception is thrown at  
> org.qi4j.runtime.injection.DependencyModel , on line 204, in method 
> extractInjectionClass . Testcase attached.
> {code}
> public class ComplexUsesGenericTypesTest extends AbstractQi4jTest
> {
>     public static class AbstractTestObject<ClassType, RealClassType extends 
> ClassType>
>     {
>         @Uses
>         private Class<RealClassType> clazz;
>         public void printClazz()
>         {
>             LoggerFactory.getLogger( this.getClass() ).debug( "Clazz: " + 
> this.clazz );
>         }
>     }
>     public static class TestObject extends AbstractTestObject<TestObject, 
> TestObject>
>     {
>     }
>     public void assemble( ModuleAssembly module )
>         throws AssemblyException
>     {
>         module.addObjects( TestObject.class );
>     }
>     @Test
>     public void performTest()
>     {
>         ObjectBuilder<TestObject> builder = 
> this.objectBuilderFactory.newObjectBuilder( TestObject.class );
>         builder.use( TestObject.class );
>         builder.newInstance().printClazz();
>     }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.ops4j.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to