RFR: 8315968: Consolidate java.util.Digits and StringLatin1::PACKED_DIGITS [v2]

Roger Riggs rriggs at openjdk.org
Sun Sep 10 18:13:47 UTC 2023


On Sun, 10 Sep 2023 17:59:10 GMT, 温绍锦 <duke at openjdk.org> wrote:

>> Some codes in core libs are duplicated, including:
>> java.util.DecimalDigits::DIGITS -> java.lang.StringLatin1.PACKED_DIGITS
>> java.util.DecimalDigits::size -> java.lang.Long.stringSize
>> 
>> We can reduce duplication through JavaLangAccess, which is also needed in other places, such as:
>> https://github.com/openjdk/jdk/pull/15555
>
> 温绍锦 has updated the pull request incrementally with one additional commit since the last revision:
> 
>   move java.util.DecimalDigits to jdk.internal.util.DecimalDigits

This would cleaner and easier to review, if you moved the classes together and did not refactor the functions. Only include the dependencies. Update the functions in a separate PR.  (We can retitle the issue to match).

src/java.base/share/classes/java/lang/Long.java line 45:

> 43: import static java.lang.String.UTF16;
> 44: 
> 45: import static jdk.internal.util.DecimalDigits.stringSize;

Please don't use static import for methods. It makes it much harder to find where they come from.

src/java.base/share/classes/java/util/Digits.java line 36:

> 34:  * @since 21
> 35:  */
> 36: sealed interface Digits permits HexDigits, OctalDigits {

Don't break up the trio, move all three classes and the interface to jdk.internal.util.
I don't see the value in the INSTANCE values but keep it intact.

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

Changes requested by rriggs (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/15651#pullrequestreview-1618893492
PR Review Comment: https://git.openjdk.org/jdk/pull/15651#discussion_r1320839379
PR Review Comment: https://git.openjdk.org/jdk/pull/15651#discussion_r1320839614


More information about the core-libs-dev mailing list