Saturday, June 28, 2008

Can't extend ByteBuffer

java.nio.ByteBuffer is not extensible and this really sucks badly. I didn't realize that till today when I thought to write a custom ByteBuffer implementation and then realized that all the constructors had only package visibility.

The thing is that there are many good reasons why you would want a custom implementation of ByteBuffer . Maybe you want to proxy over another ByteBuffer for example; have an optimized view over a larger ByteBuffer to reduce data copying.

It seems that I was not the only one to feel this way. Check out

It appears that not just a few people, but also whole frameworks like Apache MINA have gone ahead and constructed their own ByteBuffer replacements. Check out which is extensible.