Re: RFR: 8263754: HexFormat 'fromHex' methods should be static [v2]
On Fri, 26 Mar 2021 14:39:47 GMT, Roger Riggs 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); > > Roger Riggs has updated the pull request incrementally with one additional > commit since the last revision: > > Remove unused HexFormat instances Marked as reviewed by redestad (Reviewer). - PR: https://git.openjdk.java.net/jdk/pull/3205
Re: RFR: 8263754: HexFormat 'fromHex' methods should be static [v2]
> 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); Roger Riggs has updated the pull request incrementally with one additional commit since the last revision: Remove unused HexFormat instances - Changes: - all: https://git.openjdk.java.net/jdk/pull/3205/files - new: https://git.openjdk.java.net/jdk/pull/3205/files/050495a9..042dc18b Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk=3205=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk=3205=00-01 Stats: 7 lines in 4 files changed: 0 ins; 7 del; 0 mod Patch: https://git.openjdk.java.net/jdk/pull/3205.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/3205/head:pull/3205 PR: https://git.openjdk.java.net/jdk/pull/3205
Re: RFR: 8263754: HexFormat 'fromHex' methods should be static
On Thu, 25 Mar 2021 20:08:14 GMT, Roger Riggs 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); Marked as reviewed by chegar (Reviewer). - PR: https://git.openjdk.java.net/jdk/pull/3205
Re: RFR: 8263754: HexFormat 'fromHex' methods should be static
On Thu, 25 Mar 2021 21:50:46 GMT, Roger Riggs wrote: >> 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. Hmm, I missed that unfortunate detail. It looks mis-matched to have `fromHex*` be static while `toHex*` variants aren't. - PR: https://git.openjdk.java.net/jdk/pull/3205
Re: RFR: 8263754: HexFormat 'fromHex' methods should be static
On Thu, 25 Mar 2021 21:05:47 GMT, Claes Redestad 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
Re: RFR: 8263754: HexFormat 'fromHex' methods should be static
On Thu, 25 Mar 2021 20:08:14 GMT, Roger Riggs 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); Looks good (with the suggestions by Claes). - Marked as reviewed by naoto (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/3205
Re: RFR: 8263754: HexFormat 'fromHex' methods should be static
On Thu, 25 Mar 2021 20:08:14 GMT, Roger Riggs 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); I like the direction. There are a number of orphaned HexFormat instances that can be cleaned up. I might have missed a few. Do you intend to do the same thing with the toHexDigit methods? src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java line 822: > 820: StringBuilder hexNumber = new StringBuilder(); > 821: for (int i = 0; i < chars.length; i++) { > 822: if (HexFormat.isHexDigit(chars[i])) { `hex` left unused. 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. src/java.base/share/classes/sun/security/x509/AVA.java line 504: > 502: throws IOException { > 503: > 504: HexFormat hex = HexFormat.of(); `hex` left unused. - Changes requested by redestad (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/3205
RFR: 8263754: HexFormat 'fromHex' methods should be static
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); - Commit messages: - 8263754: HexFormat 'fromHex' methods should be static Changes: https://git.openjdk.java.net/jdk/pull/3205/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk=3205=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8263754 Stats: 47 lines in 5 files changed: 0 ins; 8 del; 39 mod Patch: https://git.openjdk.java.net/jdk/pull/3205.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/3205/head:pull/3205 PR: https://git.openjdk.java.net/jdk/pull/3205