Google
 

« AOL PC = $299         The bug hunt has finished! »

Huntin down a String bug in Java VM

Posted December 23, 2003 – 8:28 pm by Yakov Shafranovich in Programming

We have been hunting out a nasty bug in our code involving processing of large XML files via Java String, StringBuffer and byte[]. We finally narrowed it down to the following line:

byte[] byteArray = largeString.getBytes();

which fails with:

java.nio.BufferOverflowException
 at java.nio.charset.CoderResult.throwException(CoderResult.java:259)
 at java.lang.StringCoding$CharsetSE.encode(StringCoding.java:340)
 at java.lang.StringCoding.encode(StringCoding.java:374)
 at java.lang.StringCoding.encode(StringCoding.java:380)
 at java.lang.String.getBytes(String.java:590)

and guess what, it fails, and its now our code either :( After doing some head scratching and checking around Sun’s site, this came out to be a JVM bug # 4949631.P.S. As I was searching through the Sun’s bug site, it was really sad to see the same bug being mentioned over and over, and being closed because the submitters could not provide normal code to reproduce it. Good thing to keep in mind when submitting bug reports.

Tags: ,

Permalink | Trackback URL | This post has

  1. One Response to “Huntin down a String bug in Java VM”

  2. java.nio.BufferOverflowException
    at java.nio.charset.CoderResult.throwException(CoderResult.java:259)
    at java.lang.StringCoding$CharsetSE.encode(StringCoding.java:338)
    at java.lang.StringCoding.encode(StringCoding.java:372)
    at java.lang.StringCoding.encode(StringCoding.java:378)
    at java.lang.String.getBytes(String.java:608)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.init(FileOutputStream.java:176)
    at java.io.FileOutputStream.init(FileOutputStream.java:131)

    However, I dont think this file is very large.

    By Vanhentenryk on Apr 6, 2004

Sorry, comments for this entry are closed at this time.