Recent convert to Intellij. Eclipse has a feature in the debugger, "Primitive Display Options", which has the debugger render primitives in hex and ascii values.
Since everything has been a breeze in Intellij so far, I figured this would be a no brainer, but after an hour and a number of non-functional data type renders later, I find myself ready to crawl back to eclipse. I made a few renderers that worked, but only for objects, so I can only conclude that renderers seem to not work for primitives. Can someone point me in the right direction here?
Edit: I've seen the option to select hex in the default render, but I am hoping for something more than a solution that requires 2 clicks for every variable.
This is similar to Andy's solution, but does not require you to define the
Hex
class (which he even does not mention). Only works for Java8 projects (that is, not on Android currently).You have to provide a custom data type renderer using the following expression for
byte[]
(see Andy's answer):It will format the data such that "01020304 05060708 09", i.e. grouped by four and separated by spaces. Only first 80 bytes are displayed, ellipsis is added if there are more.
You can also try DeltaHex Editor plugin for IntelliJ based IDEs which can show window with typical hex + text preview for byte array in debugger.
Plugin is available in Settings/Plugins/Browse repositories/Search for DeltaHex
With IDEA 2016.3 it's finally possible to define custom Java Data Type Renderers for primitive types (including arrays).
https://www.jetbrains.com/idea/whatsnew/#v2016-3
My solution was to provide a custom data type renderer using the following expression for
byte[]
:new String(Hex.encode(this));
.This works by default as long as the data type renderer is enabled (maintains state across application restarts, etc.). You can add more elaborate String formatting if you wish (I usually have a utility class which does further formatting and I just invoke it from the DTR expression field).
There is an option (checkbox) to permanently change all primitives to display as Hex under the options for Data Views. See:
Settings > Build, Execution, Deployment > Debugger > Data Views > Java >
"Show hex value for primitives"
For integral values (that is, neither floating-point values nor booleans), you can view them as a hexadecimal value by right-clicking on the primitive in the debugger, and selecting "View As" -> "Hex".
By default, the Data Type Renderer feature only works with objects, and the only realistic way to represent a primitive is either as its integral value or in hex, so I think this is a happy compromise.