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

Remove BufWriter::asByteBuffer

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 23
    • core-libs
    • None
    • source, binary
    • minimal
    • Changes to a preview API have minimal risk.
    • Java API
    • SE

    Description

      Summary

      Remove the BufWriter::asByteBuffer public API.

      Problem

      BufWriter::asByteBuffer exposes the backing array of the BufWriter in an inconsistent way: without resizing, it reflects the changes to the array, but once the backing array has been resized, the buffer is no longer up-to-date.

      Solution

      Remove the BufWriter::asByteBuffer API. Users who wish to access the content of a BufWriter can use BufWriter::copyTo(byte[], int).

      Specification

      --- a/src/java.base/share/classes/java/lang/classfile/BufWriter.java
      +++ b/src/java.base/share/classes/java/lang/classfile/BufWriter.java
      @@ -192,11 +191,6 @@ public sealed interface BufWriter
            */
           int size();
      
      -    /**
      -     * {@return a {@link java.nio.ByteBuffer ByteBuffer} view of the bytes in the buffer}
      -     */
      -    ByteBuffer asByteBuffer();
      -
           /**
            * Copy the contents of the buffer into a byte array.
            *

      Attachments

        Issue Links

          Activity

            People

              liach Chen Liang
              liach Chen Liang
              Adam Sotona
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: