apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.69k stars 853 forks source link

Editor does not notice code changes until project is rebuilt in modular java projects #6725

Open mbien opened 1 year ago

mbien commented 1 year ago

Apache NetBeans version

Apache NetBeans 19, 20

What happened

image

Have a class and a unit test for the class in a maven project which has a module-info.java

Now rename the method name of the tested class, this will successfully rename it in the test and everywhere else, however the editor will show errors until the project is rebuilt.

The error will always show up on the test file, no matter if the code change was initiated from the test (e.g via rename refactoring) or from the actual class.

As soon module-info is removed or commented out it works as expected, the editor refreshes after ~1s and notices code updates - no error annotations are shown.

How to reproduce

test:

import org.junit.jupiter.api.Test;

public class RefreshBugTest {
    @Test
    public void refreshBug() {
        // 1) rename method -> editor should refresh as expected, no errors should show up
        // 2) uncomment module-info contents, clean build, rename again -> editor does not refresh until rebuild
        RefreshBug.rename1();
    }
}

class:

public class RefreshBug {
    // see unit test
    public static void rename1() {
        System.out.println("Hello There!");
    }
}

module-info.java

// uncomment to trigger the bug
//module test.module {
//    requires java.base;
//}

Did this work correctly in an earlier version?

No / Don't know

Operating System

linux

JDK

JDK 21

Apache NetBeans packaging

Apache NetBeans binary zip

Are you willing to submit a pull request?

Maybe

FurmigaHumana commented 1 year ago

I noticed the editor also won't acknowledge new files if there is any project or profiler running (Dont even has to be the same project im editing), but as soon as I close everything it triggers a "background scanning" and the changes update.

mbien commented 1 year ago

The profiler is likely pausing IO to not influence the measurements. This issue here is something else and specific to java modules.