RFR: 8374610: Make ByteArrayOutputStream.ensureCapacity(int) protected

Alan Bateman alanb at openjdk.org
Tue Jan 13 15:16:06 UTC 2026


On Tue, 13 Jan 2026 11:00:26 GMT, Daniel Gredler <dgredler at openjdk.org> wrote:

> > it would be useful to hear more on how this might be used
> 
> As an example, imagine a subclass which wants to add a fast `writeLong` method. With `ensureCapacity` available, this is as simple as:

Is your real concern with buf.length getting close to Integer.MAX_VALUE?

Aside from writeLong, could you list out the methods that you've since in BAOS subclasses. I'm wondering if BAOS should implement some of the methods defined by DataOutput to avoid needing to subclass (as BAOS is more of an implementation class).

-------------

PR Comment: https://git.openjdk.org/jdk/pull/29180#issuecomment-3744887083


More information about the core-libs-dev mailing list