JDK-8170769 : Provide a simple hexdump facility for binary data
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 9
  • Priority: P3
  • Status: In Progress
  • Resolution: Unresolved
  • Submitted: 2016-12-05
  • Updated: 2020-04-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbd_majorUnresolved
Related Reports
CSR :  
Duplicate :  
Relates :  
Relates :  
Description
Provide a human-readable representation of binary data by transforming a byte array into a string in hexdump [1] format.

This capability has been available for many years via an unsupported class: sun.misc.HexDumpEncoder. Since JDK 9 that class is no longer directly accessible.


____
[1] http://linuxcommand.org/man_pages/hexdump1.html
Comments
The most recent core-libs-dev review threads seem to be these: https://mail.openjdk.java.net/pipermail/core-libs-dev/2018-November/056836.html https://mail.openjdk.java.net/pipermail/core-libs-dev/2018-December/057035.html A summary of my main concerns is here: http://mail.openjdk.java.net/pipermail/core-libs-dev/2018-December/057358.html Briefly, a set of static methods doesn't seem to me to be the right shape for the API. Either it should be recast to be made more general, or it should be simplified. An additional point (which I don't think I mentioned in the email) is that the chunk size comes from the wrong place. In webrev.09 (and in previous versions, I believe) it's specified by the caller. However, it's really a property of the Formatter function -- such functions have a preferred chunk size. You can see this if you use the default formatter with different chunk sizes. If it's not too far off the default, it kinda sorta works, but outside a particular range, it stops working. On the other hand, if you were to specify a completely different formatter that works with a different chunk size, it relies on the caller to provide that chunk size. You can see this in the current proposal; the three methods that take a formatter argument also take a chunkSize argument. The preferred chunk size for a formatter could be provided as a default method, and possibly a factory method that could be provided that produces a Formatter with a particular chunk size, married to a lambda that implements the formatting.
03-04-2019

See additional discussion in JDK-8143863.
01-06-2017

Some useful implementation snippets might be found in JDK-8042990.
08-12-2016

A hex dumper in the public API is welcome but I have concerns that we are rushing this a bit, I'd prefer that the API be reviewed by several people before deciding whether this is suitable to integrate at this time.
08-12-2016

FC request approved by lead. Replacement for useful sun.misc feature encapsulated by Jigsaw. Implementation borrowed from existing, well-tested implementation.
08-12-2016

http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-December/045286.html
08-12-2016

Here's the prototype API: Webrev: http://cr.openjdk.java.net/~vinnie/8170769/webrev.00/
08-12-2016

FC Extension Request Remaining work: - CCC approval - Design (done) - Implementation (done) - Test (done) Risk: low. The utility is provided by a new class (java.util.HexDump). Justification: Recent Jigsaw changes to enforce strong encapsulation have rendered the existing (unsupported) sun.misc.HexDumpEncoder class inaccessible, by default. This new class restores the ability to easily display binary data. Popular Java libraries like Apache Commons also support such a utility. Completion estimate: 22 Dec 2016
08-12-2016