Make ByteArrayOutputStream.ensureCapacity(int) protected?
Daniel Gredler
djgredler at gmail.com
Mon Jan 5 12:15:16 UTC 2026
Hi,
I was recently looking at subclassing `ByteArrayOutputStream` in an
application so that I could add a fast VarHandle-based `writeLong(long)`
method (writing 8 bytes to the byte array in one go). The
internal `ByteArrayOutputStream` buffer is protected, so no issue there,
but `ensureCapacity(int)` is private rather than protected, and uses the
internal `ArraysSupport` class, so it's not even easy to copy/paste as
duplicate code in the subclass. Similar `ensureCapacity` methods in
`ArrayList` and `StringBuilder` are public. Would a PR adjusting the
visibility of this method from private to protected be accepted?
Take care,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20260105/dd7341a1/attachment-0001.htm>
More information about the core-libs-dev
mailing list