javaintellij-ideahotswap

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


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


Solution

  • 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!