javagenerics

Is there a non-type-erased generics extension to the Java Compiler available as a 3rd party compiler extension?


I'm becoming increasingly frustrated with the limits of type-erased Java generics. I was wondering if there was a custom Java Compiler that provided a full version of generics without the quirks associated with type-erasure?


Solution

  • It is not just a compiler change that would be required. I think it would also be necessary to change the JVM implementation in ways that are incompatible with the JVM spec, and the Java class libraries in ways that are incompatible with the current APIs.

    For example, the semantics of the checkcast instruction change significantly, as must the objects returned by the Object.getClass() operation.

    In short, the end result would not be "Java" any more and would be of little interest to the vast majority of Java developers. And any code developed using the new tools/JVM/libraries would be tainted.

    Now if Sun/Oracle were proposing / making this change ... that would be interesting.