RFR: 8370160: NumericShaper allows illegal ranges
Phil Race
prr at openjdk.org
Sun Oct 19 15:19:01 UTC 2025
On Sat, 18 Oct 2025 21:23:54 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:
>> This is a follow-on to 8365077: java.awt.font.NumericShaper violates equals/hashCode contract
>>
>> The factory method to construct a contextual shaper from a bitmask will happily store illegal, unspecified bits.
>> So there are still ways to create instances which violate the contract.
>>
>> This isn't possible with the enum approach. We should align these two. And we should document it.
>>
>> Additionally the behaviour of eliminating an value which is of lesser precedence is also something we should specify.
>>
>> CSR : https://bugs.openjdk.org/browse/JDK-8370161
>
> src/java.desktop/share/classes/java/awt/font/NumericShaper.java line 1534:
>
>> 1532: private NumericShaper(int key, int mask) {
>> 1533: this.key = key;
>> 1534: this.mask = mask & (CONTEXTUAL_MASK | ALL_RANGES);
>
> Note that this will accept the CONTEXTUAL_MASK even if it was provided by the app. It is unclear whether we should discard it in that case or not.
This is always added by the implementation when constructing a contextual shaper.
So when we get here it is always part of the mask argument.
The only path that gets here without a contextual shaper bit set is the single range case.
But it the app has set that there an IAE is thrown, so it can't happen.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27884#discussion_r2443358823
More information about the client-libs-dev
mailing list