RFR: 8377568: DataBuffer constructors and methods do not specify required exceptions

Phil Race prr at openjdk.org
Tue Feb 17 19:26:20 UTC 2026


This fix updates DataBuffer subclasses to actually adhere to their stated specifications by rejecting certain invalid parameters for constructors and getters and setters.
A new egression test for each of the constructor and getter/setter cases is supplied.

No existing regression tests fail with this change, and standard demos work.

Problems caused by these changes are most likely to occur if the client has a bug such that 
- a client uses the constructors that accept an array and then supplies a "size" that is greater than the array.
- a client uses the constructors that accept an array and then supplies a "size" that is less than the array and then uses getter/setters that are within the array but outside the range specified by size. 

Since very few clients (and just one case in the JDK that I found) even use these array constructors the changes are unlikely to make a difference to clients.

A CSR will be submitted.

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

Commit messages:
 - 8377568
 - 8377568

Changes: https://git.openjdk.org/jdk/pull/29766/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29766&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8377568
  Stats: 1546 lines in 9 files changed: 1520 ins; 2 del; 24 mod
  Patch: https://git.openjdk.org/jdk/pull/29766.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29766/head:pull/29766

PR: https://git.openjdk.org/jdk/pull/29766


More information about the client-libs-dev mailing list