## Nasty Bug in Java 1.5 Generics

From: "andrew cooke" <andrew@...>

Date: Sat, 18 Nov 2006 19:48:39 -0300 (CLST)

Hit this bug at work last week -
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6199662 - when the
build on a multi-processor machine failed (on single processor development
machines it works fine).

The code itself was not that complex - I had a base class for messages
that threw a parameterised exception.  The exception's generic type was
being deleted too early and the compiler was complaining that "Exception"
(the type erased to) was not being handled.

What surprised me (assuming I have my JRE release names straight) is that
this is not fixed for 1.5, but left to 1.6.  It's a pretty basic problem -
that it's not fixed in 1.5 suggests (as does my experience at work looking
at other people's code) that people are not using generics anything like
as much as they could.

Incidentally, Evan "fixed" the problem by changing the directory in which
code compiled.  So either that was sufficient to change the ordering of
compilation, or we hit lucky, or I misunderstood the above.  Whether
that's a good fix or not, I'm not sure - compiling our "release" code with
a 1.6 RC compiler doesn't seem that good an idea either.  I guess I will
avoid changing the library until we release, if possible....  :o(

Andrew