Java needs an immutable byte array wrapper

Andrew Haley aph at redhat.com
Thu Jan 26 09:19:48 UTC 2017


On 12/11/16 16:45, Keith Turner wrote:
> While trying to design an API for Fluo, its become clear to me that
> Java could really benefit from an immutable byte array wrapper.
> Something like java.lang.String except for byte arrays instead of char
> arrays.  It would be nice if this new type interoperated well with
> byte[], String, ByteBuffer, InputStream, OutputStream etc.
> 
> I wrote the following blog post about my experiences with this issue
> while designing an API for Fluo.
> 
> http://fluo.apache.org/blog/2016/11/10/immutable-bytes/
> 
> Is there any reason something like this should not be added to Java?

Apart from bulking up core Java and its specification and TCK even
more, no.

But aren't we looking at this in the wrong way?  I would have thought
the Right Thing would be to make Protobuf’s ByteString into a library
in its own right.

Andrew.


More information about the discuss mailing list