RFR: 8263754: HexFormat 'fromHex' methods should be static
Roger Riggs
rriggs at openjdk.java.net
Thu Mar 25 21:53:28 UTC 2021
On Thu, 25 Mar 2021 21:05:47 GMT, Claes Redestad <redestad at openjdk.org> wrote:
>> A number of HexFormat methods converting from strings to numbers do not use delimiter, prefix, suffix, and uppercase parameters and would be more convenient if the methods were static.
>>
>> These APIs were added early in JDK 17 and are being updated before GA.
>> This PR updates existing uses in the JDK but there may be compiler warnings in non-JDK source files.
>>
>> public boolean isHexDigit(int);
>> public int fromHexDigit(int);
>> public int fromHexDigits(java.lang.CharSequence);
>> public int fromHexDigits(java.lang.CharSequence, int, int);
>> public long fromHexDigitsToLong(java.lang.CharSequence);
>> public long fromHexDigitsToLong(java.lang.CharSequence, int, int);
>
> src/java.base/share/classes/sun/security/tools/keytool/Main.java line 4582:
>
>> 4580: int pos = 0;
>> 4581: for (char c: value.toCharArray()) {
>> 4582: if (!HexFormat.isHexDigit(c)) {
>
> `hexFmt` created on line 4576 appears to be unused after this.
The toHexDigit methods need access to the uppercase/lowercase distinction.
So there is no plan to change them.
I'll amend to include the above and re-check for uncaught uses.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3205
More information about the core-libs-dev
mailing list