Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8143863

arrays sometimes need hexadecimal dumps


    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:


      If an array is being used as a backing store for some other data structure, it is often more useful to get a hex dump of the array's contents than a decimal dump.

      So, please add Arrays.toHexString, parallel to Arrays.toString, which will print integral values using Integer.toHexString. The most applicable types are arrays of char, byte, short, int, and long. The types float and double have toHexString methods, and so the array versions should be included for those also. The type boolean (by a pun) could be rendered as 0 or 1 under the hex rubric; this is useful as a way to get a compact numeric dump of a boolean array.

      For arrays of references it is possible to define a meaningful toHexString: Boxed primitives would be displayed using hex, and embedded arrays would be recursively treated this way. But, such a thing seems complicated and not very useful.

      So it appears that we want Arrays.toHexString only for arrays of primitives.

      Part of the functionality of deepToString can take an untyped object reference, classify it as a primitive array, and run the appropriate overloading on that primitive array.

      It would be useful to have this dynamically typed version of Arrays.toString, in both decimal and hex forms, as an extra overloading.


          Issue Links



              • Assignee:
                jrose John Rose
              • Votes:
                0 Vote for this issue
                8 Start watching this issue


                • Created: