More support for offset and length in methods operating on byte arrays

Pavel Rappo pavel.rappo at oracle.com
Thu Dec 14 19:57:09 UTC 2023



> On 14 Dec 2023, at 06:10, Magnus <magnus.eriksson at gmail.com> wrote:
> 
> In the java libraries there are many methods that operate on byte arrays that do not allow you to specify offset and length for the relevant data instead forcing you to copy the relevant part to new arrays before using the methods reducing performance - I am for instance struggling with this in java.util.Base64 where the Encoders and Decoders lack a length parameter (also an offset would have been great even though I don't need that in my case). 

Re: java.util.Base64. Encoder and Decoder also seem to be able to work with ByteBuffer. If you have an array, you can cheaply create a ByteBuffer wrapper around that array. The now-backing array would be read or written though from the specific position and up to the specific limit. Would that help?

-Pavel



More information about the core-libs-dev mailing list