Reified generics in Java
Neal Gafter post a blog entry
about adding reified generics to Java.
I likethat proposal mostly because
developpers will have the choice betweeen reified or not reified
generics.
About the syntax, i think it's better to use an anotation
than to re-use the keyword class. Annotating a type variable
is not currently allowed but it seems that the upcoming
JSR 308
will allow that.
class ArrayList<<strong>@Reified</strong> E> {
...
}instead of
class ArrayList<<strong>class</strong> E> {
...
}
The big question is why tagging the type variable
and not the parametrized type.
I'm not sure that allowing to declare on a same parametrized type
refied type variable and non refied is a good idea,
because i don't see a use case.
class HashMap<@Reified K,V> {
}
Here, HashMap is not refiable because V
is not refiable. So what is the need of half reified type ?
Else, i not sure about the fact that allowing reified generics
requires to change collection interfaces.
Allowing reified interfaces will just allow safe cast/instanceof,
i wonder if it worth all problems linked to the introduction
of a new collection hierarchy.
It's perhaps up to a collection implementor to decide if a
collection implentation will use or not reified generics.
To end, i've recently read a paper of Mirko Viroli about
how to represent wildcard types at compiler level
but i'am not aware of any work about that at VM level.
Rémi
- Login or register to post comments
- Printer-friendly version
- forax's blog
- 1615 reads





