Generic code can be freely used with raw types when attempting to preserve compatibility between non-generic legacy code and newer generic code. However, using raw types with generic code will cause most Java compilers to issue "unchecked" warnings. When generic and non-generic code is used correctly, these warnings are not catastrophic, but the same warnings are issued when potentially unsafe operations are performed. If generic and non-generic code must be used together, these warnings should not be simply ignored.
According to [JLS 05] section 4.8 "Raw Types":
The use of raw types is allowed only as a concession to compatibility of legacy code. The use of raw types in code written after the introduction of genericity into the Java programming language is strongly discouraged. It is possible that future versions of the Java programming language will disallow the use of raw types.
If a parameterized type tries to access an object that is not of the parameterized type, heap pollution results. For instance, consider the code snippet below.
...
However, one should not rely on unchecked warnings to implement this rule. According to [JLS 05] section 4.12.2.1 "Heap Pollution":
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.
...