RFR: 8368775: Remove outdated comment in OutlineTextRenderer
Daniel Gredler
dgredler at openjdk.org
Fri Sep 26 16:26:45 UTC 2025
On Fri, 26 Sep 2025 11:23:03 GMT, Daniel Gredler <dgredler at openjdk.org> wrote:
> Until [JDK-4138921](https://bugs.openjdk.org/browse/JDK-4138921), `TextLayout` did not accept empty strings in the constructor. This limitation has been removed. However, there is a guard condition in `OutlineTextRenderer` which checks for an empty string before trying to use `TextLayout` which explicitly calls out this limitation in a code comment. We should remove the out-of-date comment but leave the check in as an optimization (see discussion in PR #26947).
> You can use str.isEmpty() here.
I was actually going for consistency with all of the other optimizations of this type, which all use a length check. I can change it to `isEmpty` if you feel strongly about it, though.
> Do we actually call this method with an empty string?
I do think it's possible, e.g. from `SunGraphics2D.drawString(String, int, int)` and `SunGraphics2D.drawString(String, float, float)` when the font doesn't have layout attributes, or a few other places when `OutlineTextRenderer.drawChars(...)` delegates to `OutlineTextRenderer.drawString(...)`.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27523#issuecomment-3339470355
More information about the client-libs-dev
mailing list