RFR: 8313809: String template fails with java.lang.StringIndexOutOfBoundsException if last fragment is UTF16

Jim Laskey jlaskey at openjdk.org
Tue Aug 8 19:20:34 UTC 2023


On Tue, 8 Aug 2023 18:56:53 GMT, Claes Redestad <redestad at openjdk.org> wrote:

>> The last fragment of a string template does not get it's coder added to the mix.
>
> src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java line 1129:
> 
>> 1127:         }
>> 1128: 
>> 1129:         initialLengthCoder -= lastFragment.length();
> 
> Nit: Could leverage the fact that the last fragment will always be at `fragments.get(ttypes.length)` here and simplify above (remove `lastFragment`, move `initialLengthCoder` back to L1122)

Changing

> test/jdk/java/lang/template/T8313809.java line 27:
> 
>> 25:  * @test
>> 26:  * @bug 8313809
>> 27:  * @summary String template fails with java.lang.StringIndexOutOfBoundsException if the string contains euro symbol.
> 
> Perhaps could use the same phrasing as the bug summary?

Changing

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15195#discussion_r1287548392
PR Review Comment: https://git.openjdk.org/jdk/pull/15195#discussion_r1287548475


More information about the core-libs-dev mailing list