RFR: 8366400: JCK test api/java_text/DecimalFormat/Parse.html fails after JDK-8363972

Naoto Sato naoto at openjdk.org
Tue Sep 2 17:04:46 UTC 2025


On Fri, 29 Aug 2025 23:59:54 GMT, Justin Lu <jlu at openjdk.org> wrote:

> This PR addresses a JCK test failure of an unexpected SIOOBE during DecimalFormat parsing. During the char by char comparison in `matchAffix`, the minimum of the length of the parsed String and the PP index + affix length are iterated on. The parse position index needs to be checked to not be negative to ensure that we do not index the String below 0. Taking the minimum of those two previously mentioned values already guarantees that we do not index the String above the length.

test/jdk/java/text/Format/NumberFormat/LenientParseTest.java line 172:

> 170:         assertNull(assertDoesNotThrow(() -> new DecimalFormat().parse("1", new ParsePosition(-1))));
> 171:     }
> 172: 

Thanks for writing the invalid case test. As Alan suggested, maybe we could provide more edge case tests.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27014#discussion_r2316676697


More information about the core-libs-dev mailing list