Skip to main content

Raw type, rare type and preparing the future

Posted by forax on November 4, 2008 at 6:49 AM PST

We live in a post-generics world,
recently, October 30th, 2008,
J2SE 1.4.2 retires
has reach its
End Of Service Life.

I think it's a coincidence but Maurizio Cimadamore
decide to introduce
a long requested feature in javac,
it now emit a warning for all usages of raw types
(a parameterized type without '<>').

And frankly, we (all Java developers) seem not ready for that.
To take an example, just after putback that change into jdk
workspace, the Xlint:rawtypes
was disable by default when the JDK is compiled
) because it generates too many warnings.

Only JMX Team takes time to
browse its workspace and remove all raw types
bug 6763639

Though we was warned by the JLS (4.8)

  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

we are not ready :(

So why should we remove those warnings. To prepare the future.
Lot of people whine (and i'm one of those) because
are not reify at runtime
. But generics
can't be reified
until you're code contains raw types.
So to prepare the future, please fix all these raw type
warnings in your code.



Related Topics >>


I disagree that it is easy. If all you are doing is using generic classes written by someone else (e.g. the collection classes), then that isn't hard. However properly generifying your own code can be quite difficult.

Forget warnings. Javac should begin issuing *errors* for raw types. Developers have had over half a decade to migrate, and doing so is easy. Let's make the jump already!