On Mon, 2 Mar 2026 21:17:38 GMT, Marius Hanl <[email protected]> wrote:
>> modules/javafx.graphics/src/main/java/com/sun/javafx/css/parser/CssNumberParser.java
>> line 42:
>>
>>> 40: * returns a long value less than {@link Integer#MIN_VALUE} to
>>> indicate failure.
>>> 41: */
>>> 42: public static long tryParseInt(String s, int start, int end, int
>>> radix) {
>>
>> This code is taken from `Integer.parseInt(String, int, int, int)` in the
>> JDK, and modified to return `Long.MIN_VALUE` instead of throwing
>> `NumberFormatException`.
>
> I wonder if we really should do that. Whenever something in the JDK changes,
> we may need to port it to our Integer parsing as well.
> Can't we just do the same as we do with `Double`:
>
>
> try {
> return Double.parseDouble(s.substring(start, end));
> } catch (NumberFormatException _) {
> return Double.NaN;
> }
>
> But with `Integer`?
The entire premise of this PR is to not use exceptions for flow control. In
addition to that, what could possibly change with a very short algorithm that
parses an int?
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/2093#discussion_r2874768855