apache / apache/netbeans

Move method refactoring leads to changes in calling relationships.

Open
#7,801 0 comments 0 reactions 0 assignees View on GitHub
Java 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 23

### What happened

When the m() method in the selection class C performs a move method refactoring into A.B, resulting in a change in the calling relationship. Before refactoring, k() calls the m() method in class A. After refactoring, the method m() in class C moving to class B is called.
```java
class A {
privatevoid m() {
System.out.println("Method m() in Class A");
}
class B {
void k() {
m(); // Calls method m() from Class A
}
}
}
class C {
static A.B b; // A static reference to Class B inside Class A
publicvoid m() {
System.out.println("Method m() in Class C");
}
}
```

### Language / Project Type / NetBeans Component

_No response_

### How to reproduce

Select m() in class C, click move, select A.B, and perform the refactoring.
```java
class A {
privatevoid m() {
System.out.println("Method m() in Class A");
}
class B {
void k() {
m(); // Calls method m() from Class A
}
}
}
class C {
static A.B b; // A static reference to Class B inside Class A
publicvoid m() {
System.out.println("Method m() in Class C");
}
}
```

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

No / Don't know

### Operating System

Windows11

### JDK

20

### Apache NetBeans packaging

Apache NetBeans provided installer

### Anything else

_No response_

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

No

Contributor guide

Open the contributing guide

Research direction

Reproduce the move method refactoring described: move m() from class C into A.B and inspect how k() resolves its call before and after the move. Start with the move operation and calling-relationship handling; done means k() still calls the intended method after refactoring, with a regression test covering the example.

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.