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

Sven Linstaedt (JIRA) issues at jboss.org
Mon Oct 10 05:13:00 EDT 2016


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

Sven Linstaedt commented on CDI-455:
------------------------------------

At first I thought of {{TypeLiteral}} being a workaround for java's type erasure. Extending it by being able to create one from an unknown {{java.lang.Class}} with given type parameters or even {{java.lang.reflect.Type}} just to be able to "reuse" all existing APIs that accept a {{TypeLiteral}} smells like a dirty trick, as the benefit of type safety as mentioned before is lost.

Secondly we have a bunch of existing APIs, that are meant to be used with "dynamic types". Most of them reside in {{javax.enterprise.inject.spi.BeanManager}} like {{BeanManager#getBeans}} or {{BeanManager#getReference}}. If there is a need to extend something, it may be more suitable to extend these APIs.

> 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
>
> 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
(v6.4.11#64026)


More information about the cdi-dev mailing list