[cdi-dev] [JBoss JIRA] (CDI-455) Allow building of TypeLiteral's with dynamic types

Martin Kouba (JIRA) issues at jboss.org
Mon Sep 25 04:39:01 EDT 2017


    [ https://issues.jboss.org/browse/CDI-455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13467709#comment-13467709 ] 

Martin Kouba commented on CDI-455:
----------------------------------

I think we should add {{Event.select()}} and {{Instance.select()}} variants which also accept {{java.lang.reflect.Type}}. The argument should be checked at runtime and {{IllegalArgumentException}} should be thrown if the type is not a subtype of the event/required type.

Also the trick with {{ChocolateEater}} described above would only work for simple parameterized types and not for more complex use cases.

> Allow building of TypeLiteral's with dynamic types
> --------------------------------------------------
>
>                 Key: CDI-455
>                 URL: https://issues.jboss.org/browse/CDI-455
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>            Reporter: Lucas Ventura Carro
>             Fix For: 2.1 (Discussion)
>
>
> It could be useful the building of {{TypeLiteral}}'s, but using dynamic types. This way, the types can be indicated at runtime and not in compile. This functionality is "doable" as it is done at [Guice|https://github.com/google/guice], a similar injection framework, and as [this post shows|http://luisfsgoncalves.wordpress.com/2010/09/08/generic-bindings-with-guice/].



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the cdi-dev mailing list