RFR: JDK-8021560,(str) String constructors that take ByteBuffer

Alan Bateman Alan.Bateman at oracle.com
Sat Feb 17 07:02:38 UTC 2018


On 16/02/2018 21:56, Stuart Marks wrote:
> :
>
> Seems like an argument that this function is in the wrong location.
>
> (Not joking.)
>
> I think CharBuffer.toString() is actually quite obscure. I note that 
> most of the Buffer classes have toString() methods that report the 
> *status* of the buffer, e.g.
>
>     java.nio.HeapByteBuffer[pos=0 lim=1000 cap=1000]
>
> Compared to other Buffers' toString() methods, CharBuffer is the 
> outlier: its toString() produces only the contents of the CharBuffer 
> without any meta-information. This is rather surprising.
toString() is specified by CharSequence so the CharBuffer implementation 
has to return a String containing the characters in the buffer.

-Alan


More information about the core-libs-dev mailing list