Chitika

Thursday, April 28, 2005

String bug

Apparently, there is a bug in the Sun JDK 1.4.2 or lower implementation of java.lang.String. This bug has been identified as 4310930, 4546734, 4637640, 4724129 in Sun's Bug Database. I've come across this bug while reading Charles Miller's post, when he was having trouble with the OutOfMemoryError in his JDBC code.

Please download this source code to see what I'm talking about. Try to run the source code, and continue until you reach the OutOfMemoryError state, as seen in my own trial here. Then, change the source code to the working alternatives, and test them out (see my result here).

This bug has been fixed in JDK 5.0 release, but I believe most of us are still working with Sun JDK 1.4.2 or lower. So I guess this is a problem that we must be very careful with.

1 comment:

  1. I do not think it is a bug. It is a feature one has to be aware of. There are other things in programming languages that may cause unexpected behavior; one has to learn to deal with them properly

    ReplyDelete