Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Generically typed code can be freely used with raw types when attempting to preserve compatibility between non-generic legacy code and newer generic code. Using raw types with generic code causes most Java compilers to issue "unchecked" warnings but still compile the code. When generic and non-generic types are used together correctly, these warnings can be ignored; at other times, these warnings can denote potentially unsafe operations.

According to the Java Language Specification [JLS 2005], §4.8 "Raw types"

...

It is insufficient to rely on unchecked warnings alone to detect violations of this guideline. According to the Java Language Specification JLS [JLS 2005], §4.12.2.1, "Heap Pollution"

Wiki Markup
Note that this does not imply that heap pollution only occurs if an unchecked warning actually occurred. It is possible to run a program where some of the binaries were compiled by a compiler for an older version of the Java programming language, or by a compiler that allows the unchecked warnings to suppressed _\[sic\]_. This practice is unhealthy at best.

...