JDK-8148847 : javadoc for CharsetEncoder.maxBytesPerChar() should be made clearer
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 9
  • Priority: P5
  • Status: Resolved
  • Resolution: Won't Fix
  • Submitted: 2016-02-02
  • Updated: 2019-09-26
  • Resolved: 2019-09-26
Related Reports
Cloners :  
Relates :  
Description
Javadoc currently states:

--------------------------------
public final float CharsetEncoder.maxBytesPerChar()
Returns the maximum number of bytes that will be produced for each character of input. 
This value may be used to compute the worst-case size of the output buffer required for a given input sequence.
--------------------------------

This may be misinterpreted, as it may be not clear what CHARACTERs this sentence is about.
If they were Unicode code-points, UTF8Encoder.maxBytesPerChar() should return 4.0.
However, as the statement is in fact about Java characters, it correctly returns 3.0.


Comments
The definition of "character" in these CharsetEncoder/CharsetDecoder classes are clarified in their class description as ���sixteen-bit Unicode character.��� as per Mark's comment in core-libs mailing list: https://mail.openjdk.java.net/pipermail/core-libs-dev/2019-September/062613.html
26-09-2019