On Mon, 29 Jun 2026 18:13:28 GMT, Justin Lu <[email protected]> wrote:
>> src/java.base/share/classes/java/util/Locale.java line 3344:
>>
>>> 3342: * string using {@link Double#parseDouble(String)}. As a
>>> result, some
>>> 3343: * non-RFC 2616 forms of otherwise in range values, such as
>>> one with a leading
>>> 3344: * sign, may be accepted.
>>
>> I'd spell out the accepted deviations explicitly, such as a leading sign,
>> more than three fractional digits, and scientific notation
>
> I kept it vague on purpose because I think it is simpler to defer to
> `Double.parseDouble` rather than commit to a concrete list which would mostly
> rehash the lexical syntax rules defined in `Double.valueOf`. For example, I
> would also have to list that hex syntax and floating-point suffixes are
> allowed. What do you think?
Defering is fine. Maybe saying "spell out" was too strong, but I would include
typical deviations. I think noting 3+ fractions and scientific is useful.
BTW, the IAE error message differs for eg, "3.0e0" vs "Infinity":
jshell> Locale.LanguageRange.parse("en;q=3.0e0")
| Exception java.lang.IllegalArgumentException: weight=3.0 for language range
"en". It must be between 0.0 and 1.0.
vs.
jshell> Locale.LanguageRange.parse("en;q=Infinity")
| Exception java.lang.IllegalArgumentException: weight="infinity" for language
range "en"
Both are accepted by `Double.parseDouble()`, invalid syntax from RFC point, and
out-of-bounds. I would expect a consistency here
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31697#discussion_r3493890699