RFR: 4138921: TextLayout handling of empty strings
Phil Race
prr at openjdk.org
Wed Sep 24 18:04:52 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?
These are all useful optimizations. I would leave them. Just remove the IAE comment as you suggest.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26947#issuecomment-3330073706
More information about the client-libs-dev
mailing list