JEP 254: Compact Strings - length limits

Xueming Shen xueming.shen at
Tue Sep 6 18:04:51 UTC 2016

On 9/6/16, 10:09 AM, Tim Ellison wrote:
> Has it been noted that while JEP 254 reduces the space occupied by one
> byte per character strings, moving from a char[] to byte[]
> representation universally means that the maximum length of a UTF-16
> (two bytes per char) string is now halved?
Hi Tim,

Yes, it's a known "limit" given the nature of the approach. It is not 
to be an "incompatible change",  because the max length the String class and
the corresponding buffer/builder classes can support is really an 
details, not a spec requirement. The conclusion from the discussion back 
was this is  something we can trade off for the benefits we gain from 
the approach.
Do we have a real use case that impacted by this change?

> Since the goal is "preserving full compatibility", this has been missed
> by failing to allow for UTF-16 strings of length greater than
> Integer.MAX_VALUE / 2.
> Regards,
> Tim

More information about the core-libs-dev mailing list