Re: in praise of generics
On 4/1/12 6:33 PM, Roedy Green wrote:
I set myself the task of debugging GenJar, the ant task that includes
just what is needed in the jar.
I used IntelliJ inspector. It wanted me of course to generify the
project. I did as it requested. The neat thing was, if I guessed
incorrectly the type of some Collection, the compiler swatted me
instantly. Sometimes I needed some baser class.
The whole think went lickety split. I remember doing a similar task
in the days before generics, trying vainly to guess just what each
collection was supposed to hold. It was a nightmare dealing with
somebody else's undocumented code.
Generics may be squirrely if you do something fancy, but for simple
collections of a single type they are very straight forward.
I think I have found the main GenJar bug. The programmer presumed
File.list would return new String[0] not null for an empty directory.
IntelliJ inspector pointed it out.
Actually, From the JavaDoc, it will return null if it is *not* a
directory. An empty directory will still return an empty array.