RFR: 8358880: Performance of parsing with DecimalFormat can be improved
Chen Liang
liach at openjdk.org
Mon Jun 9 17:16:04 UTC 2025
On Wed, 4 Jun 2025 23:59:38 GMT, Johannes Graham <duke at openjdk.org> wrote:
>> src/java.base/share/classes/java/text/DigitList.java line 198:
>>
>>> 196: }
>>> 197: long pow10 = Math.powExact(10L, Math.max(0, decimalAt - count));
>>> 198: return Math.multiplyExact(v, pow10);
>>
>> These two methods throw ArithmeticException. This needs to be rethrown as NumberFormatException.
>
> This one is a little odd. The parse methods that call `getLong` are not supposed to throw `NumberFormatException` either. So wherever `getLong` is called, it must be preceded by a check to `fitsIntoLong`, which should avoid any exceptions here. That said, rethrowing as NFE would avoid new surprises. What do you think?
I will leave this question to I18N reviewers, who are ultimately in charge of DigitList.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25644#discussion_r2127673711
More information about the core-libs-dev
mailing list