The absence of parametrized types and arguments at runtime is sold under the grandiose rubric of "type erasure" in standard Java documentation.

The pitch is essentially that "generic type information is erased by the compiler in order to ensure 'backward binary compatibility' with versions of Java earlier that Java 5.0"

However, it appears to me that this could be misleading and that it would be clearer to say that the compiler IGNORES generic type information when it generates byte code (if this is indeed the case).

Two questions:

  1. Can anyone come up with a concise example where a generic type GENERATES differently to the equivalent raw type?
  2. Why is the extent of type erasure so complete that it allows heap pollution and DEFERRED runtime exceptions? If the purpose of type erasure were just for backward compatibility, it needn't go as far as allowing heap pollution and could throw the runtime exception at that point.

Many thanks.