RFR 8251989: Hex formatting and parsing

Raffaello Giulietti raffaello.giulietti at gmail.com
Thu Sep 3 20:27:16 UTC 2020


Hi Roger,


In Formatter

(1) The javadoc reads: "Returns up to sixteen [...]" rather than 
"Returns sixteen [...]", similar to the other toHex() methods.
(2) equals() and hashCode() are missing.


In Parser

(1) In methods fromHex(), isHex(), xxxFromHex(), you probably meant 
"static" rather than "final" ;-)
(2) In the javadoc for isHex() please use "non negative" or ">= 0", as 
"positive" means > 0 to most ears.
(3) equals() and hashCode() are missing.


Greetings
Raffaello



> Please review the updated API in the Javadoc.
> http://cr.openjdk.java.net/~rriggs/hex-formatter/java.base/java/util/Hex.html
> 
> A few offline contacts encouaged me to explore expanding the support
> for formatting and parsing of primitive types.
> Adding formatting toHex methods and [arsing fromHex methods makes the
> API easier to use.
> 
> For example, there are a number of protocols that need to escape char 
> values
> as hex. For symmetry across the primitive types, byte, char, short, int, 
> and long
> methods are added.
> 
> The handling of invalid digits was changed to consistently throw
> IllegalArgumentException; it is unlikely that encoding and decoding
> run into invalid characters and the previous technique requiring the caller
> to check the value for negative numbers is error prone.
> 
> There is some danger of proliferating methods yet, so not all combinations
> are included.  Feedback welcome.
> 
> With the API still shifting, the implemention is not ready to review.
> 
> Thanks, Roger



More information about the core-libs-dev mailing list