On Fri, 26 Jun 2026 18:53:59 GMT, Justin Lu <[email protected]> wrote:
>> src/java.base/share/classes/java/util/Locale.java line 3217:
>>
>>> 3215: public LanguageRange(String range, double weight) {
>>> 3216: Objects.requireNonNull(range);
>>> 3217: if (weight < MIN_WEIGHT || weight > MAX_WEIGHT ||
>>> Double.isNaN(weight)) {
>>
>> Since the constructor now throws `IllegalArgumentException` for `NaN`
>> weights, this should also be specified in the `@throws` tag, as `NaN` does
>> not satisfy either `NaN < MIN_WEIGHT` or `NaN > MAX_WEIGHT`.
>
> How about updating the `@throws` wording to be
>
> ` ... or if the given {@code weight} is not between {@code MIN_WEIGHT} and
> {@code MAX_WEIGHT}, inclusive.`
>
> which would cover the NaN case without having to explicitly call it out.
That wording is technically fine, but I would still prefer to call out `NaN`
explicitly. `NaN` is unordered, so it is a different case from an ordinary
out-of-range value, and it is the specific edge case being fixed here.
How about:
... or if the given {@code weight} is {@code NaN}, less than {@code
MIN_WEIGHT}, or greater than {@code MAX_WEIGHT}.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31697#discussion_r3483558808