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

API Doc for CharsetEncoder.maxBytesPerChar() should be clearer about BOMs

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 14
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Since this is only a spec clarification, the risk is minimal.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Clarify the method description of java.nio.charset.CharsetEncoder#maxBytesPerChar() method with regard to content-independent prefix/suffix output bytes.

      Problem

      An implementation of CharsetEncoder.maxBytesPerChar(), which does not account for content-independent prefix/suffix bytes, could end up insufficient output buffer size calculation, which leads to BufferOverflowException.

      Solution

      Modify the method description by explicitly mentioning the accountancy of content-independent prefix/suffix.

      Specification

      Change the paragraph in the method description of java.nio.charset.Charset$Coder$ from:

       * Returns the maximum number of $otype$s that will be produced for each
       * $itype$ of input.  This value may be used to compute the worst-case size
       * of the output buffer required for a given input sequence.

      to:

        * Returns the maximum number of $otype$s that will be produced for each
        * $itype$ of input.  This value may be used to compute the worst-case size
        * of the output buffer required for a given input sequence. This value
        * accounts for any necessary content-independent prefix or suffix
      #if[encoder]
        * $otype$s, such as byte-order marks.
      #end[encoder]
      #if[decoder]
        * $otype$s.
      #end[decoder] 

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                naoto Naoto Sato
                Reporter:
                webbuggrp Webbug Group
                Reviewed By:
                Alan Bateman, Mark Reinhold, Martin Buchholz
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: