RFR: 8374610: Make ByteArrayOutputStream.ensureCapacity(int) protected [v2]

Alan Bateman alanb at openjdk.org
Sat Jan 17 20:11:04 UTC 2026


On Sat, 17 Jan 2026 17:19:58 GMT, Daniel Gredler <dgredler at openjdk.org> wrote:

> Thanks for the feedback, I've pushed a revision which I think addresses most of it. 

BAOS dates from JDK 1.0 and we have to assume that there are subclasses doing wild things. We can't assume that subclasses use buf + count, they might accumulate in the bytes off-heap or under the couch. So I think it will require working through the compatibility issues to see if it make sense to re-specify the existing methods or not. 

Separately, Jai ran a corpus analysis to get more data on BAOS subclasses with an "ensureCapacity" method. Some of these are non-public so would run into both a source and binary compatibility issue with the current proposal. More analysis is required but it may be that any proposal here will need to use a different name.

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

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


More information about the core-libs-dev mailing list