Chapter 5. Reification

By the time that generics were introduced to Java, eight years after version 1.0 shipped, there were many millions of lines of code already in use in commercial applications. It is a tribute to the design of generics that the introduction was so successful, resulting in gradual generification of all major libraries and most client code within a few years, without major compatibility problems. How this was achieved is described in [Link to Come]. The key to its success was erasure, without which Java as we know it today could not exist. Legacy code makes no distinction between List<Integer> and List<String> and List<List<String>>, so erasing parameter types is essential to easing evolution and promoting compatibility between legacy code and new code. But everything comes at a cost, and in this chapter we must settle our debts.

The Oxford English Dictionary defines reify thus: “To convert mentally into a thing; ...

Get Java Generics and Collections, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.