Heap pollution occurs when a variable of a parameterized type references an object that is not of that parameterized type. (For more information on heap pollution, see The Java Language Specification (JLS), §4.12.2., "Variables of Reference Type," [JLS 2014]).
Mixing generically typed code with raw typed code is one common source of heap pollution. Generic types were unavailable prior to Java 5, so popular interfaces such as the Java Collection Framework relied on raw types. Mixing generically typed code with raw typed code allowed developers to preserve compatibility between nongeneric legacy code and newer generic code but also gave rise to heap pollution. Heap pollution can occur if the program performs some operation involving a raw type that would give rise to a compile-time unchecked warning.
...
Item 23, "Don't Use Raw Types in New Code" | |
[Bloch 2007] | |
Puzzle 88, "Raw Deal" | |
Section 8.3, "Avoid Casting by Using Generics" | |
| |
[JLS 2005] | Chapter 5, "Conversions and Promotions" |
Topic 3, "Coping with Legacy" | |
Chapter 8, "Effective Generics" | |
"Principle of Indecent Exposure" | |
"Create a Checked Collection" | |
"Heap Pollution" |
...