Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8263754: HexFormat 'fromHex' methods should be static #3205

Closed

Conversation

@RogerRiggs
Copy link
Contributor

@RogerRiggs RogerRiggs commented Mar 25, 2021

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);


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8263754: HexFormat 'fromHex' methods should be static

Reviewers

Download

To checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3205/head:pull/3205
$ git checkout pull/3205

To update a local copy of the PR:
$ git checkout pull/3205
$ git pull https://git.openjdk.java.net/jdk pull/3205/head

@RogerRiggs
Copy link
Contributor Author

@RogerRiggs RogerRiggs commented Mar 25, 2021

/csr

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Mar 25, 2021

👋 Welcome back rriggs! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

@openjdk openjdk bot commented Mar 25, 2021

@RogerRiggs has indicated that a compatibility and specification (CSR) request is needed for this pull request.
@RogerRiggs this pull request must refer to an issue in JBS to be able to link it to a CSR request. To refer this pull request to an issue in JBS, please use the /issue command in a comment in this pull request.

@openjdk
Copy link

@openjdk openjdk bot commented Mar 25, 2021

@RogerRiggs The following labels will be automatically applied to this pull request:

  • core-libs
  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Mar 25, 2021

Webrevs

Copy link
Member

@cl4es cl4es left a comment

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?

@@ -4580,10 +4579,10 @@ private CertificateExtensions createV3Extensions(
data = new byte[value.length() / 2 + 1];
int pos = 0;
for (char c: value.toCharArray()) {
if (!hexFmt.isHexDigit(c)) {
if (!HexFormat.isHexDigit(c)) {

This comment has been minimized.

@cl4es

cl4es Mar 25, 2021
Member

hexFmt created on line 4576 appears to be unused after this.

This comment has been minimized.

@RogerRiggs

RogerRiggs Mar 25, 2021
Author Contributor

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.

This comment has been minimized.

@cl4es

cl4es Mar 25, 2021
Member

Hmm, I missed that unfortunate detail. It looks mis-matched to have fromHex* be static while toHex* variants aren't.

@@ -819,7 +819,7 @@ private static String stripOutSeparators(String value) {
char[] chars = value.toCharArray();
StringBuilder hexNumber = new StringBuilder();
for (int i = 0; i < chars.length; i++) {
if (hex.isHexDigit(chars[i])) {
if (HexFormat.isHexDigit(chars[i])) {

This comment has been minimized.

@cl4es

cl4es Mar 25, 2021
Member

hex left unused.

@@ -503,13 +502,13 @@ private static Byte getEmbeddedHexPair(int c1, Reader in)
throws IOException {

HexFormat hex = HexFormat.of();

This comment has been minimized.

@cl4es

cl4es Mar 25, 2021
Member

hex left unused.

@naotoj
naotoj approved these changes Mar 25, 2021
Copy link
Member

@naotoj naotoj left a comment

Looks good (with the suggestions by Claes).

@openjdk openjdk bot removed the csr label Mar 26, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 26, 2021

@RogerRiggs This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8263754: HexFormat 'fromHex' methods should be static

Reviewed-by: redestad, naoto, chegar

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 13 new commits pushed to the master branch:

  • 4e74de4: 8264111: (fs) Leaking NativeBuffers in case of errors during UnixUserDefinedFileAttributeView.read/write
  • 57115fa: 8189198: Add "forRemoval = true" to Applet API deprecations
  • b8122d6: 8264220: jdk/javadoc/doclet/testRelatedPackages/TestRelatedPackages.java fails to compile
  • 507b690: 8264126: Remove TRAPS/THREAD parameter for class loading functions
  • f3eed05: 8263928: Add JAWT test files for mac
  • 4fbb7c2: 8263472: Specification of JComponent::updateUI should document that the default implementation does nothing
  • e47dfb8: 8264062: Use the blessed modifier order in jdk.jfr
  • 5a930c4: 8264135: UnsafeGetStableArrayElement should account for different JIT implementation details
  • bb354b9: 8264166: OopStorage should support specifying MEMFLAGS for allocations
  • 41657b1: 8261551: Remove special CDS handling in Metaspace::allocate
  • ... and 3 more: https://git.openjdk.java.net/jdk/compare/2a5e0dd3609d2fcbfa1898a093f45f72e83fdd9d...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Mar 26, 2021
@cl4es
cl4es approved these changes Mar 26, 2021
@RogerRiggs
Copy link
Contributor Author

@RogerRiggs RogerRiggs commented Mar 29, 2021

/integrate

@openjdk openjdk bot closed this Mar 29, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Mar 29, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 29, 2021

@RogerRiggs Since your change was applied there have been 42 commits pushed to the master branch:

  • a5d7de2: 8263404: RsaPrivateKeySpec is always recognized as RSAPrivateCrtKeySpec in RSAKeyFactory.engineGetKeySpec
  • 128c0c9: 8248418: jpackage fails to extract main class and version from app module linked in external runtime
  • fd45694: 8264344: Outdated links in JavaComponentAccessibility.m
  • f17ea9e: 8262899: TestRedirectLinks fails
  • 963f1fc: 8264309: JFR: Improve .jfc parser
  • 364cce1: 8264332: Use the blessed modifier order in jdk.charsets
  • fbbd98b: 8264029: Replace uses of StringBuffer with StringBuilder in java.base
  • 019080e: 8264268: Don't use oop types for derived pointers
  • 3516c26: 8263591: Two C2 compiler phases with the name "after matching"
  • 3caea47: 8262739: String inflation C2 intrinsic prevents insertion of anti-dependencies
  • ... and 32 more: https://git.openjdk.java.net/jdk/compare/2a5e0dd3609d2fcbfa1898a093f45f72e83fdd9d...master

Your commit was automatically rebased without conflicts.

Pushed as commit 8cf1c62.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants