RFR: 4138921: TextLayout handling of empty strings [v2]
Daniel Gredler
dgredler at openjdk.org
Wed Sep 3 20:11:24 UTC 2025
> `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()
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/26947/files
- new: https://git.openjdk.org/jdk/pull/26947/files/2f3f2fbd..5f6b3ef5
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=26947&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=26947&range=00-01
Stats: 1 line in 1 file changed: 0 ins; 1 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/26947.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/26947/head:pull/26947
PR: https://git.openjdk.org/jdk/pull/26947
More information about the client-libs-dev
mailing list