Question

I'm astonished that the Apache Commons Collections project still hasn't got around to making their library generics-aware. I really like the features provided by this library, but the lack of support for generics is a big turn-off. There is a Lavalabs fork of Commons Collections which does support generics, which seems to claim backward compatibility, but when I tried updating to this version, my web application failed to start (in JBoss).

My questions are:

  • Whether anyone has successfully updated from Commons Collections to the fork mentioned above
  • If Commons Collections has any plans to add support for generics

BTW, I'm aware of Google collections, but am reluctant to use it until the API stabilises.

Cheers, Don

Was it helpful?

Solution

There are contributions. Checkout the jira's

There is also a JDK5 branch.

We do would like to add generics and update Commons Collections to 1.5 (and 1.6). The biggest problem is how to address backwards compatibility. And people have very different opinions there. For some of the Commons components the newer JDK almost asks for a rewrite for the new JDKs IMHO.

During ApacheCon I felt the urge across several people to get this moving though. It's just a big task.

Feel free to show up on dev@commons.apache.org

cheers, Torsten

OTHER TIPS

Consider Google Collections. From their Javalobby interview:

[Google Collections is] built with Java 5 features: generics, enums, covariant return types, etc. When writing Java 5 code, you want a collections library that takes full advantage of the language. In addition, we put enormous effort into making the library complete, robust, and consistent with the JDK collection classes.

Given that the last word in Jakarta's own internal debate was in Dec 07, I would say that Apache will not embrace generics, leaving the field open for something Java5 friendly like Google Collections.

I say, bite the bullet and switch to google-collections, at least for new code.

I know you're concerned about stability, but the google-collections library is VERY close to stable for 1.0 release -- hang out on the dev list or watch their reported issues, they are already very very cautious about changes, especially breaking ones. Any incompatibilities between the current release and the (seemingly imminent) 1.0 final are going to be extremely tiny.

Also, if you're worried about stability, pick a version (e.g. the current one, 1.0 RC4), and... just don't upgrade. Sure, you won't get any new features, but commons-collections hasn't been updated in a meaningful way in several years, so are you really any worse off? At least you're frozen on something with generics and (IMHO) a much better API.

The general BC problem is that package org.apache.commons.collections has been renamed to org.apache.commons.collections15. I don't know the reason of this change. Try to rename it back, recompile the library and run your application again.

I have found this issue using Clirr tool on commons-collections-3.2.1.jar (from Apache) and collections-generic-4.01.jar (from Lavalabs).

I can't imagine what reason you can have to don't use google collections. It's quite simple to use that library.

For my work i use both, apache collections and google collections.

can you explain more about why you can't use google collections?

regards

There's a genericised port of Commons Collections 3.1 available here, which we've been using for a few years now. Does the job nicely, and since it's based strictly on the existing Commons source, it has a stable API.

It could use updating to conform to Commons Collections 3.2, though.

Have a read on the collection blog, it provide the completed understanding of the collection framework. http://tech.konnectingtheworld.com/2010/09/a-note-on-java-collections/

If you feel that you query has not been answered, get in touch with me. I shall try to provide you the information as much as I can.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top