Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8321180

Condition for non-latin1 string size too large exception is off by one

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 23
    • None
    • core-libs
    • None
    • b02

      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

            rriggs Roger Riggs
            rriggs Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: