Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4516036

CharBuffer.charAt method incorrectly throws IndexOutOfBoundsException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.0
    • core-libs
    • None
    • sparc
    • solaris_7

      This test case demonstrates that CharBuffer.charAt throws IndexOutOfBoundsException for indexes that should be well within the buffer.

      import java.nio.*;
      import java.nio.charset.*;

      public class Test
      {
          public static void main(String[] args) throws Exception {
              char[] someChars = new char[5];
              for (int i=0; i<5; i++)
                  someChars[i] = (char)(97 + i);
              CharBuffer cb = CharBuffer.wrap(someChars);
              char c = cb.charAt(1);
          }
      }

            mr Mark Reinhold
            mmcclosksunw Michael Mccloskey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: