Request for sponsor: JDK-8221430: StringBuffer(CharSequence) constructor truncates when -XX:-CompactStrings specified

Andrew Leonard andrew_m_leonard at uk.ibm.com
Mon Mar 25 22:45:44 UTC 2019


Hi Ivan,
I think I see what you're saying, you mean we also need to correct this 
line in AbstractStringBuilder
constructor:
value = (coder == LATIN1)
                ? new byte[capacity] : StringUTF16.newBytesFor(capacity);
to be maybe:
value = (COMPACT_STRINGS && coder == LATIN1)
                ? new byte[capacity] : StringUTF16.newBytesFor(capacity);

The passed in coder stills need to be correct, since with COMPACT_STRINGS 
a string could be UTF16 if
it cannot be compacted, so it's more than just a hint isn't it?

Thanks
Andrew

Andrew Leonard
Java Runtimes Development
IBM Hursley
IBM United Kingdom Ltd
Phone internal: 245913, external: 01962 815913
internet email: andrew_m_leonard at uk.ibm.com 




From:   Ivan Gerasimov <ivan.gerasimov at oracle.com>
To:     Andrew Leonard <andrew_m_leonard at uk.ibm.com>, 
core-libs-dev at openjdk.java.net
Date:   25/03/2019 22:20
Subject:        Re: Request for sponsor: JDK-8221430: 
StringBuffer(CharSequence) constructor truncates when -XX:-CompactStrings 
specified



Hi Andrew!

Thanks for finding this bug!

Your fix solves the problem.

However, I think the main issue is that the constructor 
AbstractStringBuilder(byte,int,int) is now broken:  as you discovered, 
it allows to create a string buffer with the coder LATIN1 when 
COMPACT_STRINGS is false.

Wouldn't it make sense to rename the argument of the constructor to, 
say, coderHint, and then either use it as the coder if 
COMPACT_STRINGS==true, or discard it otherwise.

What do you think?

With kind regards,
Ivan

On 3/25/19 12:45 PM, Andrew Leonard wrote:
> Hi,
> Please can I request a sponsor for this fix to a JDK-13 regression?
>
> Patch with jtreg testcase here:
> 
https://urldefense.proofpoint.com/v2/url?u=http-3A__cr.openjdk.java.net_-7Ealeonard_8221430_webrev.00_&d=DwIC-g&c=jf_iaSHvJObTbx-siA1ZOg&r=NaV8Iy8Ld-vjpXZFDdTbgGlRTghGHnwM75wUPd5_NUQ&m=dSyZ3Lfm50uqPEMhbRsyUW8TP_-2bGVkewnWt3wUJUE&s=bUl6dk1cPu349mQ06PdWcF-OC50wYFkmMSC6W3HNvl4&e=

>
> bug: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.openjdk.java.net_browse_JDK-2D8221430&d=DwIC-g&c=jf_iaSHvJObTbx-siA1ZOg&r=NaV8Iy8Ld-vjpXZFDdTbgGlRTghGHnwM75wUPd5_NUQ&m=dSyZ3Lfm50uqPEMhbRsyUW8TP_-2bGVkewnWt3wUJUE&s=JZXGlJ2wpJFaZb3MKCiTM7xzJGzqXDWRE14oRo5Mhgw&e=

>
> Many thanks
> Andrew
>
> Andrew Leonard
> Java Runtimes Development
> IBM Hursley
> IBM United Kingdom Ltd
> Phone internal: 245913, external: 01962 815913
> internet email: andrew_m_leonard at uk.ibm.com
>
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number
> 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 
3AU
>

-- 
With kind regards,
Ivan Gerasimov





Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


More information about the core-libs-dev mailing list