A "Heap Pollution" as in Non-Reifiable Types (The Java™ Tutorials > Learning the Java Language > Generics (Updated))
Why is it called that way?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
Heap pollution simply implies that you have "bad stuff" in your heap. It is an analogy to (for example) water pollution which is where you have "bad stuff" in the water.
Specifically, the bad stuff here is objects of type
A where you ought to have objects of type
B ... according to the static typing. Some hole in the static typing is allowing the bad stuff to leak into the heap ... where it is liable to cause damage (e.g. unexpected
ClassCastExceptions) at runtime.
It is not a particularly good analogy, but it is the terminology that the Java folks coined ... and they have (in effect) defined it in the page that you linked to, and probably other places.
But still - there should be a reason / mnemonic device behind that name.
Why should there be? There are lots of words and phrases in use in English where nobody really knows the origin or the reasoning. Or where the origin is known, but is illogical. For example, the supposed origin of the term "bug" referring to a flaw in a computer program. Or the current meaning of the term "quantum leap" in popular culture. Or the word "gay".
(But, in the case of "heap pollution", the source >>is<< known, and the reasoning behind the choice of the term >>is<< self evident ... to people from the same linguistic and cultural background as the authors.)
It is funny but even google does not seem to know why.
Not really. It just means that nobody had previously thought to ask for a definition in a place that Google indexes. The usage is restricted to the Java programming (as far as I am aware), and the analogy is obvious ... to most people who would use the term.
8 years later, this is still the only page that tries to answer the "why" question. I guess, "self evident" covers it adequately :-)