apache / netbeans

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

Move method refactoring leads to changes in calling relationships. #7801

Open assdfsdafasfa opened 2 days ago

assdfsdafasfa commented 2 days ago

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.

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.

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