On Wed, 24 Sep 2025 17:37:59 GMT, Naoto Sato <[email protected]> wrote:
> Fixing `CompactNumberFormat.clone()` to clone mutable reference objects. The
> bug was caused by accessing the shared objects concurrently which resulted in
> an illegal state on parsing. There are other reference fields that are
> shared, but the contents of those fields (such as prefix/suffix) are
> constants/read-only, so they may be shared.
test/jdk/java/text/Format/CompactNumberFormat/TestClone.java line 62:
> 60: } catch (ParseException pe) {
> 61: throw new RuntimeException(pe);
> 62: }
Can replace the try/catch with
`assertDoesNotThrow(() -> assertEquals(num,
clone.parse(String.valueOf(num)).intValue()));`
test/jdk/java/text/Format/CompactNumberFormat/TestClone.java line 77:
> 75: private static Stream<Arguments> referenceFields() throws
> ClassNotFoundException {
> 76: return Stream.of(
> 77: Arguments.of("decimalFormat", DecimalFormat.class),
We should also include `Arguments.of("symbols", DecimalFormatSymbols.class)` as
an entry.
test/jdk/java/text/Format/CompactNumberFormat/TestClone.java line 87:
> 85: @MethodSource("referenceFields")
> 86: void whiteBoxTest(String fieldName, Class<?> type) throws Throwable {
> 87: var original= NumberFormat.getCompactNumberInstance(Locale.US,
> NumberFormat.Style.SHORT);
Suggestion:
var original = NumberFormat.getCompactNumberInstance(Locale.US,
NumberFormat.Style.SHORT);
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27475#discussion_r2377012157
PR Review Comment: https://git.openjdk.org/jdk/pull/27475#discussion_r2377017033
PR Review Comment: https://git.openjdk.org/jdk/pull/27475#discussion_r2377018396