JDK-8321180 : Condition for non-latin1 string size too large exception is off by one
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-12-01
  • Updated: 2023-12-18
  • Resolved: 2023-12-12
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 23
23 b02Fixed
Related Reports
Relates :  
Relates :  
Description
The compact strings implementation of java.lang.String in StringUTF16.newBytesFor checks the length of non-latin1 strings against MAX_LENGTH. 
The exception message says "should be less than" is correct but does not match the code.
If the length is exactly MAX_LENGTH the array cannot be allocated, throwing java.lang.OutOfMemoryError: Requested array size exceeds VM limit
Comments
Changeset: 4fb5c128 Author: Roger Riggs <rriggs@openjdk.org> Date: 2023-12-12 20:55:17 +0000 URL: https://git.openjdk.org/jdk/commit/4fb5c12813c6d447709d3fef690387ddab0e8dae
12-12-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17008 Date: 2023-12-06 23:31:26 +0000
06-12-2023