JDK-8361299 : (bf) CharBuffer.getChars(int,int,char[],int) violates pre-existing specification
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 25,26
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2025-07-02
  • Updated: 2025-07-28
  • Resolved: 2025-07-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 25 JDK 26
25Fixed 26 b06Fixed
Related Reports
CSR :  
Causes :  
Relates :  
Relates :  
Relates :  
Description
The specification of CharBuffer [1] states:

"The methods defined by CharSequence operate relative to the current position of the buffer when they are invoked."

The method CharBuffer.getChars [2] is however specified to be an

"Absolute bulk get method. "

and interprets the source index parameters to be absolute. The implementation is consistent with this.

To adhere to the previously existing specification, the getChars method should be specified to be a

"Relative bulk get method. "

and the implementation modified accordingly.

[1] https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/nio/CharBuffer.html
[2] https://download.java.net/java/early_access/jdk25/docs/api/java.base/java/nio/CharBuffer.html#getChars(int,int,char%5B%5D,int)
Comments
A pull request was submitted for review. Branch: jdk25 URL: https://git.openjdk.org/jdk/pull/26227 Date: 2025-07-09 20:34:00 +0000
09-07-2025

Changeset: 6249259c Branch: master Author: Brian Burkhalter <bpb@openjdk.org> Date: 2025-07-09 16:15:21 +0000 URL: https://git.openjdk.org/jdk/commit/6249259c8050f280fb1c489e816f09d5cd72a54b
09-07-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/26104 Date: 2025-07-02 20:24:19 +0000
02-07-2025

Running the attached class "CB" yields: $ java CB Exception in thread "main" java.lang.RuntimeException: i != q at CB.main(CB.java:34)
02-07-2025