Java Generics in action
Abstract
Since version 5, Java supports the definition of generic classes, generic interfaces and generic methods. Even before their final release, the new language constructs were praised by some and criticized by others. For reasons of backward compatibility, Java erases all information related to genericity at runtime. This talk starts with a critical view on type erasure, pinpoints potential dangers in developing generic classes and interfaces, and illustrates how it might jeopardize client code. We then focus on wild cards that serve two different purposes in the language. First of all, we discuss how wild cards support restricted genericity in a rather elegant way. We then explain why type erasure complicates polymorphic assignments by imposing wild cards on variable declarations.