On Tue, 26 Aug 2025 17:40:12 GMT, Daniel Gredler <dgred...@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... Several JCK tests for TextLayout constructor fail (surprise !) They all fail because they use a null FRC. We need a CSR for this anyway but I'll need to co-ordinate problem listing those tests as part of this bug so we don't see failures as soon as it is pushed. src/java.desktop/share/classes/java/awt/font/TextLine.java line 839: > 837: > 838: if (result == null) { > 839: result = new Rectangle2D.Float(Float.MAX_VALUE, > Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE); That's interesting. I'd have assumed what you changed it to would be the answer in such. a case ? Why was it like this ? Perhaps it was never possible before and this was intended to 'flag a problem' ?? src/java.desktop/share/classes/java/awt/font/TextLine.java line 934: > 932: > 933: if (!requiresBidi) { > 934: requiresBidi = Bidi.requiresBidi(chars, 0, characterCount); This doesn't change anything, does it ? So why is the change made ? This - and white space changes - make it look like there are more changes than there really are. src/java.desktop/share/classes/sun/font/TextLabelFactory.java line 122: > 120: int limit) { > 121: > 122: if (start > limit || start < lineStart || limit > lineLimit) { Why is this change needed ? I'm supposing that for zero length start==limit==0 but we get here because TextLine calls it in a do { ... } block so will call it at least once, and I wonder if that should change ? So why did you do it this way ? ------------- PR Review: https://git.openjdk.org/jdk/pull/26947#pullrequestreview-3166753411 PR Review Comment: https://git.openjdk.org/jdk/pull/26947#discussion_r2308701015 PR Review Comment: https://git.openjdk.org/jdk/pull/26947#discussion_r2308698669 PR Review Comment: https://git.openjdk.org/jdk/pull/26947#discussion_r2308697022