Hot Swap in my IntelliJ doesn't work. What is wrong?

758 views Asked by At

I tried to use the hot swap function in IntelliJ. I followed this video.I changed some code in a method. Then, I clicked rebuild, and in the popped up dialog, I clicked "reload", it only shown a dialog above the debug tab, telling me to stop the debug session. It did not change my running program. What's wrong?

This is the screenshot: It told me to stop debug session

screenshot of problem

I tried to follow the video. I expect my program will change while it's running, but it didn't.

Here's my video showing what did I do: video

2

There are 2 answers

0
romanv-jb On BEST ANSWER

In the video you are changing the method that is already being executed (main), if you create another method and call it from main HotSwap will work as you expect it to work.

For more info see HotSwap Limitations section.

DCEVM can help you get around the limitations of the default HotSwap implementation. You can check this Plugin, for instance.

Hope this helps!

2
aspGG On

Java IDEs and VMs support a feature called HotSwapping. It allows you to update the version of a class while the virtual machine is running, without needing to redeploy the webapp, restart, or otherwise interrupt your debugging session. (source: source)

Basically hot-swap updates your classes by reloading. As output says:

8 classes reloaded

Your classes should be updated.