Java – Why do some projects not use generics

java

I've been looking at a number of OSS java projects and a number of them still have not adopted generics. They're using raw types (e.g. List foo) instead of generic types (e.g. List<string> foo). Other projects have only begun using generics in the last few years even thought they've been around for a long time.

I'm interested to know why people and projects eschew the use of generics when there appears (to me) to be now downside in using them instead of rawtypes. For those of you who use java, but not generics, what (if anything) would make you switch?

Best Answer

Some projects have to run on older JVMs. For example, some projects might not even be able to use assert yet (introduced in Java 1.4), because they still need to work on Java 1.3 JVMs.

Another factor is simply inertia: If code was already written, and performs fine without adding the use of generics, there's little reason to take the risk in changing the code. But today, there are several automatic tools to help you migrate your Java code to use generics.

Related Topic