- 
    CSR 
- 
    Resolution: Approved
- 
     P4 P4
- 
    None
- 
        minimal
- 
        Since this is only a spec clarification, the risk is minimal.
- 
        Java API
- 
        SE
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] - csr of
- 
                    JDK-8230531 API Doc for CharsetEncoder.maxBytesPerChar() should be clearer about BOMs -           
- Closed
 
-