RFR: 4138921: TextLayout handling of empty strings [v2]
Daniel Gredler
dgredler at openjdk.org
Wed Sep 10 09:33:21 UTC 2025
On Wed, 3 Sep 2025 20:11:24 GMT, Daniel Gredler <dgredler at openjdk.org> 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...
>
> Daniel Gredler has updated the pull request incrementally with one additional commit since the last revision:
>
> Remove unnecessary call to text.first()
@mrserb I've removed the unnecessary call to `text.first()`. Is there anything else that caught your eye, or are you comfortable marking as reviewed? Thanks!
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26947#issuecomment-3274120060
More information about the client-libs-dev
mailing list