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

Jaikiran Pai jpai at openjdk.org
Wed Jun 11 07:40:27 UTC 2025


On Wed, 11 Jun 2025 00:38:51 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Remove some instanceof checks which are vestigial now that `CharSequence` itself defines `getChars(int,int,char[],int)`.

Hello Brian, it looks like the Basic.java test has caught a genuine issue with this change:


java.lang.NullPointerException: Cannot invoke "java.lang.CharSequence.length()" because "csq" is null
	at java.base/java.nio.HeapCharBuffer.append(HeapCharBuffer.java:297)
	at java.base/java.nio.HeapCharBuffer.append(HeapCharBuffer.java:48)
	at Basic.test(Basic.java:340)
	at Basic.main(Basic.java:382)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:335)
	at java.base/java.lang.Thread.run(Thread.java:1474)

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

PR Comment: https://git.openjdk.org/jdk/pull/25739#issuecomment-2961571788


More information about the nio-dev mailing list