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

8251989: Hex formatting and parsing utility #482

Closed
wants to merge 33 commits into from
Closed
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c1bb451
8251989: Hex formatting and parsing utility
RogerRiggs Sep 2, 2020
3170b49
Various code review comments, rename UpperCase and LowerCase methods …
RogerRiggs Oct 13, 2020
e7edf07
temp updates
RogerRiggs Oct 14, 2020
1892eca
Merge branch 'master' into 8251989-hex-formatter
RogerRiggs Oct 14, 2020
ec334db
Added assertions to testVariableLength and samples
RogerRiggs Oct 14, 2020
59bdb07
Cleanup of javadoc markup
RogerRiggs Oct 15, 2020
880cebb
Merge branch 'master' into 8251989-hex-formatter
RogerRiggs Oct 15, 2020
bad80cb
Expanded test coverage and fixed related bugs; Added static imports f…
RogerRiggs Oct 16, 2020
450bfaf
Test enhancements from Chris Hegarty
RogerRiggs Oct 16, 2020
d9f2b6e
Merge branch 'master' into 8251989-hex-formatter
RogerRiggs Oct 16, 2020
1d2c26f
Correct length of StringBuilder in formatHex;
RogerRiggs Oct 19, 2020
0a47544
Review comment updates, in the example code, and to describe the char…
RogerRiggs Oct 21, 2020
2b493d3
Review comment updates to class javadoc
RogerRiggs Oct 22, 2020
94e6061
- Added @see and @link references to Integer.toHexString and Long.toH…
RogerRiggs Oct 26, 2020
2aeab7d
The HexFormat API indexing model for array and string ranges is changed
RogerRiggs Oct 27, 2020
80a7118
Merge branch 'master' into 8251989-hex-formatter
RogerRiggs Oct 27, 2020
552d308
Merge branch 'master' into 8251989-hex-formatter
RogerRiggs Nov 2, 2020
1d36cfb
Merge branch 'master' into 8251989-hex-formatter
RogerRiggs Nov 24, 2020
b19d282
Clarified that suffix() and prefix() methods do not return null, inst…
RogerRiggs Nov 25, 2020
cad6a70
Addressed review comments on use of formatted hexadecimal strings, up…
RogerRiggs Nov 27, 2020
29f9bf7
Merge branch 'master' into 8251989-hex-formatter
RogerRiggs Nov 27, 2020
a1ce9d7
Clarified hexadecimal characters used in converting from characters t…
RogerRiggs Nov 30, 2020
bbcb213
Review comment updates:
RogerRiggs Dec 1, 2020
892d08e
Increased memory to 4G for the test and add diagnostic info for OOME
RogerRiggs Dec 1, 2020
a137740
Clarify that the fromHexDigits does not use the uppercase parameter.
RogerRiggs Dec 2, 2020
848c7a6
Clarify that the fromHexDigit method does not use the prefix, suffix,…
RogerRiggs Dec 2, 2020
0a8088b
Add class level clarification of use of uppercase for primitive conve…
RogerRiggs Dec 2, 2020
9ddda60
Merge branch 'master' into 8251989-hex-formatter
RogerRiggs Dec 4, 2020
af7b1fa
Added @apiNote to fromHexDigits methods to link and compare to simila…
RogerRiggs Dec 5, 2020
044d463
Clarified parsing of hex as unsigned in fromHexDigits methods.
RogerRiggs Dec 9, 2020
8a6d379
Merge branch 'master' into 8251989-hex-formatter
RogerRiggs Dec 9, 2020
b9e288f
Merge branch 'master' into 8251989-hex-formatter
RogerRiggs Dec 15, 2020
4866a0a
Correct typos in fromHexDigits methods javadoc
RogerRiggs Dec 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/java.base/share/classes/java/lang/Integer.java
Original file line number Diff line number Diff line change
@@ -264,10 +264,18 @@ public static String toUnsignedString(int i, int radix) {
* <blockquote>
* {@code Integer.toHexString(n).toUpperCase()}
* </blockquote>
* <p>
Copy link

@Marcono1234 Marcono1234 Oct 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Marcono1234, thanks for making a comment in an OpenJDK project!

All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user Marcono1234 for the summary.

If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.

Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use.

* @apiNote
* The {@link java.util.HexFormat} class provides formatting and parsing
* of byte arrays and primitives to return a string or adding to an {@link Appendable}.
* {@code HexFormat} formats and parses uppercase or lowercase hexadecimal characters,
* with leading zeros and for byte arrays includes for each byte
* a delimiter, prefix, and suffix.
*
* @param i an integer to be converted to a string.
* @return the string representation of the unsigned integer value
* represented by the argument in hexadecimal (base&nbsp;16).
* @see java.util.HexFormat
* @see #parseUnsignedInt(String, int)
* @see #toUnsignedString(int, int)
* @since 1.0.2
8 changes: 8 additions & 0 deletions src/java.base/share/classes/java/lang/Long.java
Original file line number Diff line number Diff line change
@@ -299,11 +299,19 @@ private static BigInteger toUnsignedBigInteger(long i) {
* <blockquote>
* {@code Long.toHexString(n).toUpperCase()}
* </blockquote>
* <p>
Copy link

@Marcono1234 Marcono1234 Oct 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Marcono1234, thanks for making a comment in an OpenJDK project!

All comments and discussions in the OpenJDK Community must be made available under the OpenJDK Terms of Use. If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please Use "Add GitHub user Marcono1234 for the summary.

If you are not an OpenJDK Author, Committer or Reviewer, simply check the box below to accept the OpenJDK Terms of Use for your comments.

Your comment will be automatically restored once you have accepted the OpenJDK Terms of Use.

* @apiNote
* The {@link java.util.HexFormat} class provides formatting and parsing
* of byte arrays and primitives to return a string or adding to an {@link Appendable}.
* {@code HexFormat} formats and parses uppercase or lowercase hexadecimal characters,
* with leading zeros and for byte arrays includes for each byte
* a delimiter, prefix, and suffix.
*
* @param i a {@code long} to be converted to a string.
* @return the string representation of the unsigned {@code long}
* value represented by the argument in hexadecimal
* (base&nbsp;16).
* @see java.util.HexFormat
* @see #parseUnsignedLong(String, int)
* @see #toUnsignedString(long, int)
* @since 1.0.2
15 changes: 4 additions & 11 deletions src/java.base/share/classes/java/lang/module/Resolver.java
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.HexFormat;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -475,25 +476,17 @@ private void checkHashes() {
if (actualHash == null)
findFail("Unable to compute the hash of module %s", dn);
if (!Arrays.equals(recordedHash, actualHash)) {
HexFormat hex = HexFormat.of();
findFail("Hash of %s (%s) differs to expected hash (%s)" +
" recorded in %s", dn, toHexString(actualHash),
toHexString(recordedHash), descriptor.name());
" recorded in %s", dn, hex.formatHex(actualHash),
hex.formatHex(recordedHash), descriptor.name());
}
}
}

}
}

private static String toHexString(byte[] ba) {
StringBuilder sb = new StringBuilder(ba.length * 2);
for (byte b: ba) {
sb.append(String.format("%02x", b & 0xff));
}
return sb.toString();
}


/**
* Computes the readability graph for the modules in the given Configuration.
*
Loading