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

Alan Bateman alanb at openjdk.org
Fri Jan 16 16:27:49 UTC 2026


On Fri, 16 Jan 2026 12:42:25 GMT, Daniel Gredler <dgredler at openjdk.org> wrote:

> True. I'll tweak the PR to address this and see how it looks.

Thanks. It would need to be specified so that it's clear that the method is not a "hook" to expand the capacity, it's simply a connivance method for subclasses override the existing methods or adding new write methods that are not based on the write methods in the superclass.

> What would you think about renaming the method to `setMinCapacity` in order to reduce conflict risk? Roger's point about reduced visibility conflicts is a good one, given the established use of the `ensureCapacity` name.

I think it would be useful some static analysis to get a sense for how many libraries extend BAOS and have their own ensureCapacity method.

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

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


More information about the core-libs-dev mailing list