RFR: 8374610: Make ByteArrayOutputStream.ensureCapacity(int) protected
Alan Bateman
alanb at openjdk.org
Tue Jan 13 08:21:47 UTC 2026
On Mon, 12 Jan 2026 22:13:06 GMT, Daniel Gredler <dgredler at openjdk.org> wrote:
> ByteArrayOutputStream.ensureCapacity(int) is currently private. It would be useful if it were protected, so that it can be more easily extended by subclasses.
>
> Mailing list discussion: https://mail.openjdk.org/pipermail/core-libs-dev/2026-January/156983.html
Subclasses have access to the protected buf/count fields so it's not clear that there is a strong case for adding this. I think it would be useful to hear more on how this might be used. BAOS is more of an implementation class, is extending it the right thing for the examples that you have in mind? Is the issue more about trying to size a byte[] that is close to the MAX_VALUE limit?
What is the reason that the existing methods are not re-specified to use it?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29180#issuecomment-3742748336
More information about the core-libs-dev
mailing list