RFR: 8357286: (bf) Remove obsolete instanceof checks in CharBuffer.append

Brian Burkhalter bpb at openjdk.org
Wed Jun 11 15:32:30 UTC 2025


On Wed, 11 Jun 2025 08:40:00 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Remove some instanceof checks which are vestigial now that `CharSequence` itself defines `getChars(int,int,char[],int)`.
>
> src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template line 297:
> 
>> 295:         checkSession();
>> 296: 
>> 297:         Objects.checkFromToIndex(start, end, csq.length());
> 
> The append(CharSequence) methods are specified to append "null" when the CharSequence is null so append(null, 0, 0) will need to be handled here.

Based on code inspection, it looks like that error might have already been possible but did not turn up before.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25739#discussion_r2140494453


More information about the nio-dev mailing list