Skip to content

Move method refactoring error due to calling the instantiation and invocation of internal classes #7310

@DongChunHao

Description

@DongChunHao

Apache NetBeans version

Apache NetBeans 21

What happened

When I select "myMethod()" and perform the move method refactoring, and i click "OK", a syntax error:

class OriginalClass {
TargetClass c;
protected class ProtectedInnerClass {
void innerMethod() {
// Some logic here
}
}

public void myMethod() {
    ProtectedInnerClass inner = new ProtectedInnerClass();
    inner.innerMethod();
}

}
// TargetClass.java
class TargetClass {
}

refactoring result:
image

Expected result: Check for grammar errors before and after refactoring, and if so, provide error prompts

Language / Project Type / NetBeans Component

No response

How to reproduce

When I select "myMethod()" and perform the move method refactoring, and i click "OK", a syntax error:

class OriginalClass {
TargetClass c;
protected class ProtectedInnerClass {
void innerMethod() {
// Some logic here
}
}

public void myMethod() {
    ProtectedInnerClass inner = new ProtectedInnerClass();
    inner.innerMethod();
}

}
// TargetClass.java
class TargetClass {
}

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows11

JDK

20

Apache NetBeans packaging

Apache NetBeans platform

Anything else

No response

Are you willing to submit a pull request?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:bugBug report or fixneeds:triageRequires attention from one of the committers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions