Integrated: 8365077: java.awt.font.NumericShaper violates equals/hashCode contract

Phil Race prr at openjdk.org
Fri Oct 17 18:00:15 UTC 2025


On Mon, 13 Oct 2025 17:53:44 GMT, Phil Race <prr at openjdk.org> wrote:

> The problem here is that NumericShaper can be constructed either using Range enum members
> or a bitmask.
> And the bitmask can represent the same (equal) NumericShaper as one constructed using
> the equivalent Range enum members and "boolean equals(Object)" handles this and there
> is support in the Range enum for a Set<Range> for this which is used by equals.
> 
> However the hashCode() does not have similar support and is quite different.
> The fix adds support for this.
> If the instance has a Set<Range> then use this new support, which will return
> the same hash as if it was constructed using a mask. In cases where this is not
> possible because Range instances  have no mask equivalent there is no issue
> because these cannot be equal either.
> 
> 
> EASTERN_ARABIC over-rides ARABIC and there was an inconsistency in that
> when constructed with Ranges this ARABIC is removed but this isn't the case
> for when constructed with masks. 
> I had to fix that so that the hashes would be the same.
> 
> I also made one variable final that should have been final all along.
>  
> A test is provided.

This pull request has now been integrated.

Changeset: 0103f216
Author:    Phil Race <prr at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/0103f21635f00d7b4ece0d667cc5c276613d41ff
Stats:     110 lines in 2 files changed: 100 ins; 8 del; 2 mod

8365077: java.awt.font.NumericShaper violates equals/hashCode contract

Reviewed-by: kizune, psadhukhan

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

PR: https://git.openjdk.org/jdk/pull/27774


More information about the client-libs-dev mailing list