RFR: 4138921: TextLayout handling of empty strings
Daniel Gredler
dgredler at openjdk.org
Wed Sep 24 17:06:02 UTC 2025
On Sat, 20 Sep 2025 21:23:06 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:
>>> I don't think it is high profile enough to need a release note.
>>
>> OK, sounds good.
>>
>>> I was hoping I could push that problem listing (it is an internal thing) right at the same time you pushed
>>
>> Ah, I'm sorry -- I didn't realize you meant that level of coordination!
>
> Hi @gredler, can you please take a look to [this](https://github.com/openjdk/jdk/blob/cc65836d00de7041e7d32e7f15d98108b1ae47a0/src/java.desktop/share/classes/sun/java2d/pipe/OutlineTextRenderer.java#L76) code in OutlineTextRenderer:
>
> if ("".equals(str)) {
> return; // TextLayout constructor throws IAE on "".
> }
> TextLayout tl = new TextLayout(str, g2d.getFont(),
> g2d.getFontRenderContext());
>
> Do we still need it after this patch?
@mrserb Probably not needed, but there are quite a few of these guard conditions, and I'm not sure whether it's best to leave them in as optimizations, or if it's best to simplify the code by removing them. Here's a list, let me know what you think. Maybe we leave it in but remove the IAE comment?
Other reviewers, please feel free to chime in as well.
https://github.com/openjdk/jdk/blob/f993f90c86f89eb0c7f42ebecb45a68eae0bd9ea/src/java.desktop/share/classes/sun/java2d/pipe/OutlineTextRenderer.java#L76
https://github.com/openjdk/jdk/blob/f993f90c86f89eb0c7f42ebecb45a68eae0bd9ea/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java#L2928
https://github.com/openjdk/jdk/blob/f993f90c86f89eb0c7f42ebecb45a68eae0bd9ea/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java#L2957
https://github.com/openjdk/jdk/blob/f993f90c86f89eb0c7f42ebecb45a68eae0bd9ea/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java#L2985
https://github.com/openjdk/jdk/blob/f993f90c86f89eb0c7f42ebecb45a68eae0bd9ea/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java#L2997
https://github.com/openjdk/jdk/blob/f993f90c86f89eb0c7f42ebecb45a68eae0bd9ea/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java#L3036
https://github.com/openjdk/jdk/blob/f993f90c86f89eb0c7f42ebecb45a68eae0bd9ea/src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java#L3074
https://github.com/openjdk/jdk/blob/f993f90c86f89eb0c7f42ebecb45a68eae0bd9ea/src/java.desktop/share/classes/sun/font/FontDesignMetrics.java#L465
https://github.com/openjdk/jdk/blob/f993f90c86f89eb0c7f42ebecb45a68eae0bd9ea/src/java.desktop/share/classes/sun/font/FontDesignMetrics.java#L491
https://github.com/openjdk/jdk/blob/f993f90c86f89eb0c7f42ebecb45a68eae0bd9ea/src/java.desktop/share/classes/sun/print/PathGraphics.java#L567
https://github.com/openjdk/jdk/blob/f993f90c86f89eb0c7f42ebecb45a68eae0bd9ea/src/java.desktop/share/classes/sun/print/PSPathGraphics.java#L155
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26947#issuecomment-3329884998
More information about the client-libs-dev
mailing list