apache / apache/netbeans

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

Open
#6,725 2 comments 0 reactions 0 assignees View on GitHub
Java kind:bug Maven
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 19 - 31 rc2

### What happened

![image](https://github.com/apache/netbeans/assets/114367/12ba062f-374e-4b71-a0d1-3138e4a2d38c)

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:
```java
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:
```java
public class RefreshBug {
// see unit test
public static void rename1() {
System.out.println("Hello There!");
}
}
```
module-info.java
```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

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with RefreshBugTest, RefreshBug, and module-info.java in a Maven project, using the reported rename operation with module-info.java enabled. Start by running the clean build and then renaming the method; done means the editor refreshes without error annotations before another rebuild is required.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.