On Wed, 4 Jun 2025 23:15:37 GMT, Chen Liang <li...@openjdk.org> wrote:

>> This PR replaces construction of intermediate strings to be parsed with more 
>> direct manipulation of numbers. It also has a more streamlined mechanism of 
>> handling `Long.MIN_VALUE` when parsing longs by using 
>> `Long.parseUnsignedLong`
>> 
>> As a small side-effect it also eliminates the use of a cached StringBuilder 
>> in DigitList.
>> 
>> Testing:
>> - GHA
>> - Local run of tier 2 and jtreg:jdk/java/text
>> - New benchmark: DecimalFormatParseBench
>
> 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?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25644#discussion_r2127637333

Reply via email to