In the compact string implementation of non-latin1 (UTF16) strings the length 
is constrained by VM implementation limit on the size a byte array that can be 
allocated. To produce a useful exception the implementation checks the string 
size against the maximum byte array size. The exception message is correct

"UTF16 String size is " + len + ", should be less than or equal to " + 
MAX_LENGTH

The code should match the message, otherwise the exception thrown is: 

java.lang.OutOfMemoryError: Requested array size exceeds VM limit

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

Commit messages:
 - 8321180: Condition for non-latin1 string size too large is off by one

Changes: https://git.openjdk.org/jdk/pull/17008/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17008&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8321180
  Stats: 129 lines in 2 files changed: 119 ins; 7 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/17008.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/17008/head:pull/17008

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

Reply via email to