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

CharBuffer.array() causing java.lang.UnsupportedOperationException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • 8u25
    • 8u25
    • core-libs
    • x86
    • os_x

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS X 10.10.1

      A DESCRIPTION OF THE PROBLEM :
      When creating CharBuffer using ByteBuffer.asCharBuffer(), the instance of the ByteBufferAsCharBufferB is created and it has memeber
      protected final ByteBuffer bb
      Which is filled with the buffer bytes, but when calling array() method on it (method from the super class), the array method check if the member hb from the super class in not null, but it's null then the exception is thrown.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      CharBuffer cBuffer = ByteBuffer.wrap(...byte array).asCharBuffer();
      cBuffer.array();

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected char array
      ACTUAL -
      java.lang.UnsupportedOperationException is thrown.

      Caused by: java.lang.UnsupportedOperationException
      at java.nio.CharBuffer.array(CharBuffer.java:994)


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.UnsupportedOperationException is thrown.

      Caused by: java.lang.UnsupportedOperationException
      at java.nio.CharBuffer.array(CharBuffer.java:994)


      REPRODUCIBILITY :
      This bug can be reproduced always.

            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: