Is there a generic Collections library wrapping non-generic Collections?

121 Views Asked by At

I have to work was a little bit outdated JVM which supports only Java 1.4. I would like to use generics in my code, which is possible according to this article http://www.ibm.com/developerworks/java/library/j-jtp02277/index.html. Unfortunately, Collections classes in our library are not generic and they cannot be replaced (which means I cannot use http://download.oracle.com/otndocs/jcp/jsr14-2.4-ea-demo-oth-JPR/). An obvious solution is to write generic wrappers for all main classes - ArrayList, HashMap, HashSet and create generic interfaces Map, etc. This is quite a work to do, so I am wondering if there might be already a library which provides this functionality.

1

There are 1 best solutions below

2
On

Can you compile your code for a JVM 1.4?

If your code is compiled for Java5 (6 or 7) you'll probably get a "bad version in class file" -Error.

If you use any compiled library, all have to be compiled for Java 1.4.