When evaluating object initialization, toString nullPointerException appear.
Method threw 'java.lang.NullPointerException' exception. Cannot evaluate XXXX.toString()
Code example which recreates this issue:
Car car = carUtils.objectMapper.readValue(new File(pathTo("carProperties.json")), Car.class);
Why is that happens? is the evaluation done using toSting() invocations?
The solution was simply to uncheck "Enable 'toString()' object view" -> Apply -> re-enable the same option -> apply and they're back!
You can use ⌘N (macOS), or Alt+Insert (Windows/Linux) for the Generate menu and then select Constructor , Getter , Setter or Getter and Setter .
I have discovered the root cause for this behavior.
You can choose in what way IntelliJ evaluation will display the data: the result can be the Object or toString evaluation. Therefore the error i had experienced, View as->toString was used, while not all the objects had toString implemented. Hope it will help someone in the future.
You can update the display type for a variable by right clicking on the variable (inside the variables window of the debugger) and clicking on 'View as'
If you don't want to update it manually each time, you can change it in IntelliJ properties following this steps
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