Skip to content

"Cannot find any changed classes for hot replace!" #855

Closed
microsoft/java-debug
#345

Description

[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

Activity

  1. testforstephen commented on Jul 30, 2020

    @testforstephen
    Contributor

    i can reproduce it. Thanks for the detailed steps.

  2. ijazfx commented on Jul 30, 2020

    @ijazfx

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

  3. testforstephen commented on Jul 30, 2020

    @testforstephen
    Contributor

    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.

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

  4. ijazfx commented on Jul 30, 2020

    @ijazfx

    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"); }); } }

  5. testforstephen commented on Jul 30, 2020

    @testforstephen
    Contributor
  6. testforstephen commented on Jul 30, 2020

    @testforstephen
    Contributor

    Farrukh Ijaz (@ijazfx) Max Streifeneder (@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.

  7. ijazfx commented on Jul 30, 2020

    @ijazfx

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

  8. ijazfx commented on Jul 31, 2020

    @ijazfx

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

  9. testforstephen commented on Jul 31, 2020

    @testforstephen
    Contributor

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

  10. ijazfx commented on Jul 31, 2020

    @ijazfx

    Okay, thanks for the fix though.

  11. maxstreifeneder commented on Jul 31, 2020

    @maxstreifeneder
    Author

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

  12. Nintorac commented on Jul 31, 2020

    @Nintorac

    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

  13. testforstephen commented on Jul 31, 2020

    @testforstephen
    Contributor

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

  14. Nintorac commented on Jul 31, 2020

    @Nintorac

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

    Logs here https://pastebin.com/qLZGaAer

  15. testforstephen commented on Jul 31, 2020

    @testforstephen
    Contributor

    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",
            }
        ]
    
  16. Nintorac commented on Jul 31, 2020

    @Nintorac

    Yup, that works. Thanks +1

  17. MTyson commented on Jun 2, 2021

    @MTyson

    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

  18. ahmednrana commented on Jul 15, 2021

    @ahmednrana

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions