Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-20 Thread Roger Riggs
Hi Vincent, This looks good. The doc for HEXDUMP_FORMATTER should include an example of the formatting. Its easier to see it than to reconstruct it from the example code. like:       61 62 63 64 65 66 67 68  69 6a 6b 6c 6d 6e 6f 70 |abcdefghijklmnop|     0010  71 72 73 74 75 76 77

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-12 Thread Vincent Ryan
FYI I’ve updated the webrev/javadoc with latest edits including the 2 new ByteBuffer methods: http://cr.openjdk.java.net/~vinnie/8170769/webrev.09/

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-12 Thread Vincent Ryan
Thanks for your proposal. Comments below. > On 12 Dec 2018, at 02:35, Stuart Marks wrote: > > > > On 12/11/18 1:21 PM, Vincent Ryan wrote: >> My preference is for PrintStream rather than Writer, for the same reason as >> Roger: it’s more convenient >> for handling System.out. Does that

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-11 Thread Stuart Marks
On 12/11/18 1:21 PM, Vincent Ryan wrote: My preference is for PrintStream rather than Writer, for the same reason as Roger: it’s more convenient for handling System.out. Does that address your concern? PrintStream is fine with me. I cannot simply cast 8859-1 characters into UTF-8 because

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-11 Thread Roger Riggs
Hi Vincent, I have no new inclinations about relative vs absolute, maybe someone else has use cases that will tip the balance. HexFormat.java:  - line 264: I think you can safely just append the (char) (byte[i] & 0xff). (to avoid sign extension).    Creating a string for each char seems

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-11 Thread Vincent Ryan
Thanks for your review Alan. I believe I’ve addressed your concerns in this latest webrev/javadoc: http://cr.openjdk.java.net/~vinnie/8170769/webrev.08/

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-11 Thread Vincent Ryan
Thanks Roger. I believe that all but one of your concerns are addressed in this latest webrev/javadoc: http://cr.openjdk.java.net/~vinnie/8170769/webrev.08/

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-11 Thread Vincent Ryan
Thanks for your review Stuart. My preference is for PrintStream rather than Writer, for the same reason as Roger: it’s more convenient for handling System.out. Does that address your concern? I cannot simply cast 8859-1 characters into UTF-8 because UTF-8 is multi-byte charset so some 0x8X

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-11 Thread Roger Riggs
Ho Vincent, On 12/11/2018 11:34 AM, Vincent Ryan wrote: Responses in-line. Its really nice/necessary that examples can be copy/pasted and compile.  - dumpAsStream(ByteBuffer, from, to, chunk, Formatter) may be confusing because it    is using the relative methods of ByteBuffer, but the

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-11 Thread Roger Riggs
Hi Stuart, The APIs for streams of characters bifurcated a bit between PrintStream and Writers. Many common use cases would like to direct the output to System.out/err which are PrintStreams.  Hence, I lean toward PrintStream that can be used directly. $.02, Roger On 12/10/2018 09:11 PM,

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-11 Thread Vincent Ryan
Responses in-line. > On 10 Dec 2018, at 21:38, Roger Riggs wrote: > > Hi Vincent, > > On 12/10/2018 03:59 PM, Vincent Ryan wrote: >> Comments in-line. >> Thanks. >> >>> On 10 Dec 2018, at 16:59, Roger Riggs >> > wrote: >>> >>> Hi, >>> >>> Looks good, though

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-11 Thread Alan Bateman
On 08/12/2018 01:18, Vincent Ryan wrote: Here’s the latest version that addresses all the current open issues: webrev: http://cr.openjdk.java.net/~vinnie/8170769/webrev.07/ javadoc:

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-10 Thread Stuart Marks
On 12/7/18 10:22 AM, Vincent Ryan wrote: I'm not convinced that the overloads that send output to an OutputStream pull their weight. They basically wrap the OutputStream in a PrintStream, which conveniently doesn't declare IOException, making it easy to use from a lambda passed to

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-10 Thread Roger Riggs
Hi Vincent, On 12/10/2018 03:59 PM, Vincent Ryan wrote: Comments in-line. Thanks. On 10 Dec 2018, at 16:59, Roger Riggs > wrote: Hi, Looks good, though some points to clarify. - The methods that use ByteBuffers should be clear that accesses to the

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-10 Thread Vincent Ryan
Comments in-line. Thanks. > On 10 Dec 2018, at 16:59, Roger Riggs wrote: > > Hi, > > Looks good, though some points to clarify. > > - The methods that use ByteBuffers should be clear that accesses to the > ByteBuffers >are relative and use and modify the position and ByteBuffer

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-10 Thread Roger Riggs
Hi, Looks good, though some points to clarify. - The methods that use ByteBuffers should be clear that accesses to the ByteBuffers    are relative and use and modify the position and ByteBuffer exceptions may be thrown. - The methods that write output (Strings) to an output stream might be

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-07 Thread Vincent Ryan
Here’s the latest version that addresses all the current open issues: webrev: http://cr.openjdk.java.net/~vinnie/8170769/webrev.07/ javadoc: http://cr.openjdk.java.net/~vinnie/8170769/javadoc.07/api/java.base/java/util/HexFormat.html

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-07 Thread Vincent Ryan
Even shorter. I’ll add that instead. Thanks. > On 7 Dec 2018, at 19:04, Roger Riggs wrote: > > Hi, > > I don't think this is performance sensitive and less code is better. > > Use java.lang.Character.digit(ch, 16) to convert the char to an int. > > Roger > > On 12/07/2018 01:49 PM, Kasper

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-07 Thread Roger Riggs
Hi, I don't think this is performance sensitive and less code is better. Use java.lang.Character.digit(ch, 16) to convert the char to an int. Roger On 12/07/2018 01:49 PM, Kasper Nielsen wrote: Hi, I don't know if performance is an issue. But if it is, I think it world make sense to use a

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-07 Thread Vincent Ryan
I’ll add that replacement method. Thanks. > On 7 Dec 2018, at 18:49, Kasper Nielsen wrote: > > Hi, > > I don't know if performance is an issue. But if it is, I think it world make > sense to use a precompute array. And replace > > private static int hexToBinary(char ch) { > if ('0' <= ch

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-07 Thread Kasper Nielsen
Hi, I don't know if performance is an issue. But if it is, I think it world make sense to use a precompute array. And replace private static int hexToBinary(char ch) { if ('0' <= ch && ch <= '9') { return ch - '0'; } if ('A' <= ch && ch <= 'F') { return ch - 'A' + 10;

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-07 Thread Vincent Ryan
Thanks for your review Stuart. Comments below. > On 6 Dec 2018, at 02:18, Stuart Marks wrote: > > Hi Vinnie, > > Roger Riggs wrote: >>> The 'forEachOrdered' should not be necessary and may raise questions about >>> why. >>> if there's no good reason, use 'forEach’. > > Using

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-05 Thread Stuart Marks
Hi Vinnie, Roger Riggs wrote: The 'forEachOrdered' should not be necessary and may raise questions about why. if there's no good reason, use 'forEach’. Using forEachOrdered() is necessary. The dumpAsStream() method produces a stream; presumably it has a defined order that's the same as its

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-03 Thread Roger Riggs
Hi Vincent, On 12/02/2018 05:54 PM, Vincent Ryan wrote: Thanks for the thorough review. Responses in-line. On 26 Nov 2018, at 19:49, Roger Riggs > wrote: Hi, Thanks for updating this proposal.  Some comments on the javadoc/spec. The class name Hex isn't very

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-12-02 Thread Vincent Ryan
Thanks for the thorough review. Responses in-line. > On 26 Nov 2018, at 19:49, Roger Riggs wrote: > > Hi, > > Thanks for updating this proposal. Some comments on the javadoc/spec. > > The class name Hex isn't very evocative of its function. > HexFormat would convey a more complete idea

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-11-26 Thread Roger Riggs
Hi, Thanks for updating this proposal.  Some comments on the javadoc/spec. The class name Hex isn't very evocative of its function. HexFormat would convey a more complete idea as to its function and be similar to to the existing DecimalFormat and NumberFormat classes though they do not share

Re: RFR: 8170769 Provide a simple hexdump facility for binary data

2018-11-26 Thread Sean Mullan
The API link should be http://cr.openjdk.java.net/~vinnie/8170769/javadoc.06/api/java.base/java/util/Hex.htm --Sean On 11/23/18 9:51 AM, Vincent Ryan wrote: Hello, Please review this proposal for a new API to conveniently generate and display binary data using hexadecimal string

RFR: 8170769 Provide a simple hexdump facility for binary data

2018-11-23 Thread Vincent Ryan
Hello, Please review this proposal for a new API to conveniently generate and display binary data using hexadecimal string representation. It supports both bulk and stream operations and it can also generate the well-known hexdump format [1]. This latest revision addresses review comments

Re: [11] RFR: 8170769 Provide a simple hexdump facility for binary data

2018-05-10 Thread Roger Riggs
Hi, On 5/9/2018 6:49 PM, Vincent Ryan wrote: Thanks Roger for your comments. The main motivator for this class is to provide a basic hex. encoder/decoder for smaller amounts of binary data and to provide a hexdump encoder for larger amounts of binary data, while recognising the need to cater

Re: [11] RFR: 8170769 Provide a simple hexdump facility for binary data

2018-05-10 Thread Vincent Ryan
> On 10 May 2018, at 01:08, Weijun Wang wrote: > > > >> On May 10, 2018, at 6:49 AM, Vincent Ryan wrote: >> >>> >>> - As Max observes, being able to supply the delimiters might be a good >>> addition. (I'm thinking IP addresses too). >>

Re: [11] RFR: 8170769 Provide a simple hexdump facility for binary data

2018-05-09 Thread Weijun Wang
> On May 10, 2018, at 6:49 AM, Vincent Ryan wrote: > >> >> - As Max observes, being able to supply the delimiters might be a good >> addition. (I'm thinking IP addresses too). > > Sure. Add another toHexString method that takes a delimiter character? Good idea.

Re: [11] RFR: 8170769 Provide a simple hexdump facility for binary data

2018-05-09 Thread Vincent Ryan
Thanks for your comments Max. > On 9 May 2018, at 03:34, Weijun Wang wrote: > > Nice tool. > > However, I am not sure how toFormattedHexString() and toPrintableString() are > useful, seems only for providing a customizable dump format which is, > actually, not very

Re: [11] RFR: 8170769 Provide a simple hexdump facility for binary data

2018-05-09 Thread Vincent Ryan
Thanks Roger for your comments. The main motivator for this class is to provide a basic hex. encoder/decoder for smaller amounts of binary data and to provide a hexdump encoder for larger amounts of binary data, while recognising the need to cater for custom formats too. The class does not

Re: [11] RFR: 8170769 Provide a simple hexdump facility for binary data

2018-05-09 Thread Roger Riggs
Hi Vinnie, On the API and spec, a few comments:  - Expanding the printable string from ASCII to ISO-8859-1 would make it a bit more useful in more cases.    That might suggest using the Charset converter to do the work (less optimized but more functional). - There is no API support for

Re: [11] RFR: 8170769 Provide a simple hexdump facility for binary data

2018-05-08 Thread Weijun Wang
Nice tool. However, I am not sure how toFormattedHexString() and toPrintableString() are useful, seems only for providing a customizable dump format which is, actually, not very customizable. For me, toHexString and fromHexString are of course the most useful methods. As for dump, I can only

[11] RFR: 8170769 Provide a simple hexdump facility for binary data

2018-05-03 Thread Vincent Ryan
Hello, Please review this proposal for a new API to conveniently generate and display binary data using hex string representation. It supports both bulk and stream operations and it can also generate the well-known hexdump format [1]. Thanks Bug:

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-12 Thread Paul Sandoz
> On 11 Dec 2016, at 06:04, Vincent Ryan wrote: > > Unfortunately this feature has arrived a little too late so I’m withdrawing > it from consideration for JDK 9. > Thanks again to those who took time to review it. > +1 to defer to 10 (and review comments are of

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-11 Thread Vincent Ryan
Unfortunately this feature has arrived a little too late so I’m withdrawing it from consideration for JDK 9. Thanks again to those who took time to review it. > On 10 Dec 2016, at 01:02, Vincent Ryan wrote: > > Thanks to those who provided review comments. > > I

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-10 Thread Andrej Golovnin
Hi Vincent, 177 public static Stream dumpToStream(byte[] bytes, int fromIndex, 178 int toIndex) { 179 Objects.requireNonNull(bytes); 180 Arrays.rangeCheck(bytes.length, fromIndex, toIndex); 181 182 return StreamSupport.stream( 183

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-10 Thread Bernd Eckenfels
Hello, i would agree that a hexdumper is too specific for java.base module. But what about hex encoding and parsing (similiar to java.util.Base64. Since java.xml.bind is no longer in the base modules an alternative for DataTypeConverter in SE is missing. Gruss Bernd --

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-10 Thread Roger Riggs
Hi Vinnie, I think this doesn't belong in the java.base module; it doesn't add enough value for a average developer and it is not essential to the core. I don't have another module suggestion but would suggest looking elsewhere. $.02, Roger On 12/9/2016 8:02 PM, Vincent Ryan wrote:

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-09 Thread Vincent Ryan
Thanks to those who provided review comments. I have incorporated most of them and updated the webrev: http://cr.openjdk.java.net/~vinnie/8170769/webrev.01/ The main changes are to tighten up the javadoc spec and to add three additional methods to support byte array ranges. The total number

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-09 Thread Vincent Ryan
Thanks for your review comments Paul. Responses below. > On 8 Dec 2016, at 20:08, Paul Sandoz wrote: > > Hi, > > It may take a few iterations to get the API settled. > > There are other byte sources we may want to consider such as InputStream and > ByteBuffer. I’d

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-09 Thread Vincent Ryan
Thanks for your review comments Alan. Responses below. > On 8 Dec 2016, at 19:44, Alan Bateman wrote: > > On 07/12/2016 16:32, Vincent Ryan wrote: > >> A hexdump facility has been available for many, many years via an >> unsupported class: sun.misc.HexDumpEncoder. >>

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-08 Thread Paul Sandoz
Hi, It may take a few iterations to get the API settled. There are other byte sources we may want to consider such as InputStream and ByteBuffer. Comments below. Paul. > On 7 Dec 2016, at 08:32, Vincent Ryan wrote: > > A hexdump facility has been available for

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-08 Thread Alan Bateman
On 07/12/2016 16:32, Vincent Ryan wrote: A hexdump facility has been available for many, many years via an unsupported class: sun.misc.HexDumpEncoder. Although that class was always unsupported, it was still accessible. That accessibility changes with Jigsaw so I’m proposing a very simple

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-08 Thread Vincent Ryan
> On 8 Dec 2016, at 12:10, Vincent Ryan wrote: > > >> On 8 Dec 2016, at 07:22, David Holmes wrote: >> >> On 8/12/2016 2:32 AM, Vincent Ryan wrote: >>> A hexdump facility has been available for many, many years via an >>> unsupported class:

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-08 Thread Vincent Ryan
> On 8 Dec 2016, at 07:22, David Holmes wrote: > > On 8/12/2016 2:32 AM, Vincent Ryan wrote: >> A hexdump facility has been available for many, many years via an >> unsupported class: sun.misc.HexDumpEncoder. >> Although that class was always unsupported, it was still

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-08 Thread Vincent Ryan
> On 8 Dec 2016, at 10:41, Ulf Zibis wrote: > > Hi, > > I would prefer a "normal" class instead a convolut of static methods. Via a > normal constructor, we could pass some custom parameters e.g. > capital/uppercase letters for "abcdef", prefix a header line, width of

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-08 Thread Ulf Zibis
Hi, I would prefer a "normal" class instead a convolut of static methods. Via a normal constructor, we could pass some custom parameters e.g. capital/uppercase letters for "abcdef", prefix a header line, width of the index counter, bytes per line, i.e. have all the parameters, you have

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-08 Thread Vincent Ryan
> On 8 Dec 2016, at 09:34, Volker Simonis wrote: > > Hi Vincent, > > the bug is closed and can't be looked at outside Oracle. > Can you please make it visible for everybody. Sorry. I’ve just corrected that. > > Also, this is a change of the public API so it

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-08 Thread Volker Simonis
Hi Vincent, the bug is closed and can't be looked at outside Oracle. Can you please make it visible for everybody. Also, this is a change of the public API so it requires a CCC request/approval. Finally, this seems to be clearly a feature and not a bug so it requires an FC extension request [1]

Re: [9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-07 Thread David Holmes
On 8/12/2016 2:32 AM, Vincent Ryan wrote: A hexdump facility has been available for many, many years via an unsupported class: sun.misc.HexDumpEncoder. Although that class was always unsupported, it was still accessible. That accessibility changes with Jigsaw so I’m proposing a very simple

[9] RFR 8170769: Provide a simple hexdump facility for binary data

2016-12-07 Thread Vincent Ryan
A hexdump facility has been available for many, many years via an unsupported class: sun.misc.HexDumpEncoder. Although that class was always unsupported, it was still accessible. That accessibility changes with Jigsaw so I’m proposing a very simple replacement in a new and supported class: