On Fri, 3 Apr 2026 14:29:51 GMT, Daniel Gredler <[email protected]> wrote:
> A couple of classes in the `sun.font` package could use additional > immutability guarantees: > > - The `ExtendedTextSourceLabel` class needs to be immutable (and not > extendable as a mutable subclass) so that the optimization (returning `this`) > in `ExtendedTextSourceLabel.getSubset(int, int, int)` is safe. This was > brought up in the review for > [JDK-8356814](https://bugs.openjdk.org/browse/JDK-8356814). > > - The `SDKey`/`SDCache` cache in `GlyphLayout$SDCache` also benefits from > immutable components. `SDKey` is already immutable, but `SDCache` could > benefit at least from some shallow immutability. > > Note that part of making the cached attributes in `ExtendedTextSourceLabel` > final involved the deletion of the unused constructor, and folding of the > `finishInit()` method into the sole remaining constructor. > > No regressions seen locally in `make test > TEST="jtreg:test/jdk/java/awt/font"` or `make test > TEST="jtreg:test/jdk/java/awt/Graphics2D/DrawString"` on Linux/Windows/macOS. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). This pull request has now been integrated. Changeset: fb246066 Author: Daniel Gredler <[email protected]> URL: https://git.openjdk.org/jdk/commit/fb2460663c68dc909107b3bb39d322db2038ae79 Stats: 37 lines in 2 files changed: 7 ins; 20 del; 10 mod 8381623: Additional immutability in sun.font: ExtendedTextSourceLabel, GlyphLayout Reviewed-by: serb, prr ------------- PR: https://git.openjdk.org/jdk/pull/30565
