Does anyone know whether it is possible to save the state of an object while debugging?
I would like to compare the state of an object in two different execution cycles.
Bonus Question: Anyone with experience in writing IntelliJ plugins? Does the IntelliJ SDK allow to access debug values in debug mode? Read them out of IntelliJ cache and write them to disk?
Manage breakpoints To do this, go to Settings/Preferences | Build, Execution, Deployment | Debugger and select Drag to the editor or click with middle mouse button. Clicking a breakpoint will then enable or disable it.
This action is bound to Numpad * key ( * ) by default and opens the whole object tree. Then you select all the elements of opened object tree with shift and copy them to clipboard. You can also use ctrl/cmd-A to select all variables and then copy them.
Select a variable or a property of a complex object in the Debug window, press F2 or right-click and choose Set Value... from the context menu, and then specify a new value and press Enter .
Drop Frame within the debugger pops the current stack frame and puts control back out to the calling method, resetting any local variables. This is very useful to repeatedly step through a function, but be warned: field mutations or global state changes will remain.
As a very simple solution you can use the Fully Expand Tree Node action for objects in Variables or Watches views. This action is bound to Numpad * key (*) by default and opens the whole object tree. Then you select all the elements of opened object tree with shift and copy them to clipboard.
To expand on Josep's answer, your best bet is to import Google's Gson library into your project and run:
Gson gson = new Gson(); gson.toJson(yourObject);
Then copy the value from the result.
Here's an example on IntelliJ IDEA:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With