Why Sun Should Open Source Java

Posted by Trejkaz Sun, 14 May 2006 23:49:00 GMT

In the software I develop at work, we extract data (and metadata) from all manner of different locations. Mail messages, office documents, and more recently, disk images. Extraction from disk images is a particularly interesting one, because it starts to become impractical to extract every file to the temp directory and process them from there.

So we went through a redesign such that many of our data handlers can handle arbitrary chunks of data which may not be ordinary files. Sometimes they come from a byte array, sometimes they come as a sub-slice of a larger chunk of data, and sometimes they come by gluing together multiple slices of data.

The data API we use is basically a cross between a RandomAccessFile and a ByteBuffer (in fact we have implementations which use each of these as a means of getting the data from a normal file) but supporting long indexes. Java’s MappedByteBuffer, amazingly, only supports int, which would mean not being able to process files larger than 2GB. Your 64-bit hardware is useless – Java won’t map past the first 2GB. (Sorry Sun, but disk images are much larger than 2GB, and we still need random access. This is why we have to write our own APIs for this stuff.)

A few parts of our system are still forced to extract files to disk, and largely there is nothing we can do about these. But I thought I would try to at least do something about handling zip files, as it’s fairly normal to encounter large zip files, and copying the files to the temp directory starts to become a serious overhead as the files become larger.

The ZipFile class in Java is, unfortunately, very limited. It can only take a File, and the data we’re processing is very rarely a real file. Ideally, I would hope to pass in something like a ByteBuffer, and we could make an implementation of a byte buffer backed by our own API.

So the only thing you can do in this situation is create a bug report (well, a feature request) and hope that Sun does something about it. But this is what happens.

It’s bad enough that they won’t even consider improving their API. But what really irks me is that they would assume we don’t need random access, when both of the suggested constructors I put forward allow random access. They didn’t even contact me to confirm this – just closed the bug at their own convenience.

So forget all the fluff about open source philosophy you will find on other sites. The real reason Sun needs to open source Java is so that bugs get fixed. That’s all the reason they need.

Tags , ,  | 4 comments