On 9/22/2013 5:17 AM, Remi Forax wrote:
I fail to see a problem here. In fact this is a good case why such
method is necessary - if generics get reified in Java 9 and designers
of EnumSet decide to remove redundant elementType field, all software
depending on existence of this field will break. If on the other hand
there was a getElementType() method in Java 8, it could be safely
changed to obtain element type through whatever new mechanism is
available and existing software using getElementType() keeps working
correctly.

There is a lot of code that cast to T or to EnumSet<T> that will start to fail at runtime if generics are reified. One possible way to avoid that is to create a new collection API, another is to try to reuse existing implementations with an opt-in mecanism. In the later case, the same class will be seen refiied or not depending on how the collection is created, so enabling reification will be done incrementally in that case. getElementType is a way to export a refied type, it will add burden to mixed mode implementation.

Are Reified Generics officially part of JDK9? (I hope so!) Is there an official announcement/link to that respect?

Thanks,
Gili

Reply via email to