apache / apache/netbeans

“Move method refactoring” causes the method call relationship to change

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

Description

### Apache NetBeans version

Apache NetBeans 25

### What happened

When the "Move Method" refactoring is performed using NetBeans, it causes changes to the code's behavior.

### Language / Project Type / NetBeans Component

_No response_

### How to reproduce

Select the m() method in class C, select the move method refactoring, move it to class B, before refactoring, the f() method calls the m() method of class A, after refactoring, the f() method calls the m() method of class B。
```java
class A {
void m(Object m) {
System.out.println("A");
}
}

class B extends A {
void k(String m) {
System.out.println("B");
}

void f() {
m("1");
}
}

class C {
B b;
// move m() to class B
void m(String m) {
System.out.println("B");
}
}
```
Code after refactoring:
```java
class A {
void m(Object m) {
System.out.println("A");
}
}

class B extends A {
void k(String m) {
System.out.println("B");
}

void f() {
m("1");
}

// move m() to class B
void m(String m) {
System.out.println("B");
}
}
class C {
B b;
}
```

### Did this work correctly in an earlier version?

Apache NetBeans 25

### Operating System

windows11

### JDK

17

### Apache NetBeans packaging

Apache NetBeans platform

### Anything else

_No response_

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Java example in the issue with NetBeans 25 and the Move Method refactoring. Trace the refactoring entry point and its method-resolution or call-update handling; done means moving C.m(String) to B does not change f() from calling A.m(Object) to calling B.m(String).

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.