RFR: 8374610: Make ByteArrayOutputStream.ensureCapacity(int) protected [v2]
Daniel Gredler
dgredler at openjdk.org
Sat Jan 17 17:24:16 UTC 2026
On Sat, 17 Jan 2026 17:17:23 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
>
> Daniel Gredler has updated the pull request incrementally with one additional commit since the last revision:
>
> Update per latest feedback
Thanks for the feedback, I've pushed a revision which I think addresses most of it. The two existing write methods will now call subclass-provided `ensureCapacity` methods. The test verifies this behavior. I've added some subclassing advice to the class-level JavaDoc, let me know if it meets the needs. I've added a "since" tag to the JavaDoc for the existing (promoted) method, because this will be the first time that it is visible to users. The handling of non-positive input does not change, subclasses are trusted to validate input before calling `ensureCapacity` or face the consequences (possible OOME).
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29180#issuecomment-3764123759
More information about the core-libs-dev
mailing list