On Tue, 26 Aug 2025 17:40:12 GMT, Daniel Gredler <[email protected]> wrote:
> `TextLayout` should deal more gracefully with zero length strings. Currently
> the exception listed below is the one that is thrown.
>
> `new TextLayout("", f, new FontRenderContext(null, false, false));`
>
>> Exception in thread "main" java.lang.IllegalArgumentException: Zero length
>> string passed to TextLayout constructor.
>> at java.lang.Throwable.<init>(Compiled Code)
>> at java.lang.Exception.<init>(Compiled Code)
>> at java.lang.RuntimeException.<init>(Compiled Code)
>> at java.lang.IllegalArgumentException.<init>(Compiled Code)
>> at java.awt.font.TextLayout.<init>(Compiled Code)
>> at test.main(Compiled Code)
>
> **REVIEWER NOTE:** Please check the empty-string `TextLayout` behavior
> documented in `TextLayoutConstructorTest` carefully; a badly-behaving empty
> `TextLayout` is probably worse than a `TextLayout` which doesn't allow empty
> strings...
This pull request has now been integrated.
Changeset: 5730e908
Author: Daniel Gredler <[email protected]>
URL:
https://git.openjdk.org/jdk/commit/5730e908c636ad57e6bbc5a1b64ce88245c38788
Stats: 369 lines in 4 files changed: 339 ins; 7 del; 23 mod
4138921: TextLayout handling of empty strings
Reviewed-by: prr, serb
-------------
PR: https://git.openjdk.org/jdk/pull/26947