Vscode-java-debug: "Cannot find any changed classes for hot replace!"

Created on 29 Jul 2020  ·  18Comments  ·  Source: microsoft/vscode-java-debug

[provide a description of the issue]

Environment
  • Operating System: macOS Catalina 10.15.6
  • JDK version:
    openjdk 11.0.8 2020-07-14
    OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
    OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode)
  • Visual Studio Code version: 1.47.2
  • Java extension version: Java Extension Pack v0.9.1
  • Java Debugger extension version: Debugger for Java v0.27.1
Steps To Reproduce
  1. git clone https://github.com/maxstreifeneder/HotCode-Replace
  2. mvn compile
  3. set a Breakpoint in com.maxstreifeneder.hotreload.handlers.test.HelloController.java, Line 11.
  4. Start Debugger: Run -> Start Debugging
  5. Open a Browser and hit localhost:8080/hotreload
  6. You will be prompted with a Password prompt. Take the user + password from the log output:
    image
  7. Debugger will stop.
  8. Change Line 11 to System.out.println("hotreload");
  9. Press the "Hot Code Replace" Button in the Debugger Tools.
    image

  10. "Cannot find any changed classes for hot replace!" will appear.

[attach a sample project reproducing the error]
https://github.com/maxstreifeneder/HotCode-Replace

Current Result

"Cannot find any changed classes for hot replace!" when trying to use the Hot Code Replacement

Expected Result

Changed code in VS Code will be pushed to the running application using the debugging capabilities

Additional Informations
bug

Most helpful comment

@ijazfx @maxstreifeneder Could you have a try on a private fix? https://raw.githubusercontent.com/testforstephen/vscode-test/master/vscode-java-debug-0.27.2.vsix

This private fix is built against Java 11, you need update your JDK to 11 when you try it.

All 18 comments

i can reproduce it. Thanks for the detailed steps.

I'm facing same issue. HCR not working as expected and after each change I've to restart the program.

The root cause for the original issue is the changed class is contained by multiple projects, and the debugger doesn't handle well during dedup.

@ijazfx What's your scenario? Are you working on a multi module maven projects?

Yes I've basically a complete framework which itself is a multi-module maven project. Then I've another project which is itself a multi-module maven project and this project uses some of the components from the framework project.
I looked at the code of the extension and found this, could it be the reason it is triggered only on "auto" setting?
if (hcrEvent.body.changeType === HcrChangeType.BUILD_COMPLETE) { if (getHotReloadFlag() === "auto") { return vscode.window.withProgress({ location: vscode.ProgressLocation.Window }, (progress) => { progress.report({ message: "Applying code changes..." }); return hcrEvent.session.customRequest("redefineClasses"); }); } }

@ijazfx @maxstreifeneder Could you have a try on a private fix? https://raw.githubusercontent.com/testforstephen/vscode-test/master/vscode-java-debug-0.27.2.vsix

This private fix is built against Java 11, you need update your JDK to 11 when you try it.

Yes it is working as expected. I wasn't able to test all the scenarios but a quick test revealed fast manual HCR.

@testforstephen kindly confirm one thing. Changed resources such as .css, .js are not detected and hence requires restart of the application.

Correct, the debugger only supports Java code hot reloading. It doesn't have the knowledge of your application background.

Okay, thanks for the fix though.

@testforstephen works for me! thanks a lot for your quick response and fix - couldn't be any better :-)

I am encountering this issue too but the fix doesn't work. After applying the fix I get the error No delegateCommandHandler for vscode.java.validateLaunchConfig

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

Visual Studio Code version: 1.46.1
Java extension version: Java Extension Pack v0.9.1

@Nintorac Could you share the log file?
F1 -> Java: Open Java language server log file

I tried updating to Visual Studio Code version: 1.47.3 and still get errors.

Logs here https://pastebin.com/qLZGaAer

java.version=9.0.4

Oh, you're still using an old vscode-java version and JDK 9. My private fix is built against Java 11. Could you try to update to JDK 11?

And if you still need build your project against to JDK 1.8, then you can try "java.configuration.runtimes" setting as below.

    "java.home": "C:\\AdoptOpenJDK\\jdk-11.0.8.10-hotspot",
    "java.configuration.runtimes": [
        {
          "default": true,
          "name": "JavaSE-1.8",
          "path": "C:\\Java\\openjdk8u181-b13",
        }
    ]

Yup, that works. Thanks +1

FYI for others: I had to remove the project from the workspace and restart vscode to get this error to stop.
Java Debugger v.0.36

I was having this issue in spring boot project. The build job status was building the project fine.
The language server for java logs stated an error in duplicate entry. I opened the .classpath file and removed the duplicate entry. Then the hot code replace started working

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spottedmahn picture spottedmahn  ·  6Comments

dgileadi picture dgileadi  ·  3Comments

PG-practice picture PG-practice  ·  3Comments

bsaby picture bsaby  ·  8Comments

mojo2012 picture mojo2012  ·  5Comments