[
https://issues.jboss.org/browse/CDI-455?page=com.atlassian.jira.plugin.sy...
]
Lucas Ventura Carro commented on CDI-455:
-----------------------------------------
As [~jharting] told in the mailing list, type safety cannot be guaranteed. But this will
happen if the {{TypeLiteral}} has the raw and parameterized types as arguments. But IMHO
the usual use case is that raw type is fixed, but not the parameterized types of it.
In example, following [this of
guice|http://luisfsgoncalves.wordpress.com/2010/09/08/generic-bindings-wi...], CDI
{{TypeLiteral}} could be built as:
{code}
new TypeLiteral(ChocolateEater.class, argument.getClass()){}
{code}
And efectively, type safety would be lost. But if we know that we will have an static
{{ChocolateEater}} but a dynamic {{Chocolate}} parameter, we can have type safety and the
{{TypeLiteral}} could be built as:
{code}
new TypeLiteral<ChocolateEater<? extends Chocolate>>(argument.getClass()){}
{code}
I'm I correct?
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-wi...].
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)