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.

Marked as reviewed by prr (Reviewer).

-------------

PR Review: https://git.openjdk.org/jdk/pull/30565#pullrequestreview-4095758434

Reply via email to