Skip to content

"Move Field" refactoring into interface causes syntax error #9798

Open

Description

@jherkel

Apache NetBeans version

Apache NetBeans 31

What happened

There is a problem with "Move" or "Pull Up" refactoring when not initialized field is moved to interface. i.e

public interface I {

    class C implements I {
        boolean value;
    }
}

Language / Project Type / NetBeans Component

Java

How to reproduce

public interface I {

class C implements I {
    boolean value;
}

}

Did this work correctly in an earlier version?

No / Don't know

Operating System

Fedora Silverblue 45

JDK

Openjdk 27 x64

Apache NetBeans packaging

Other

Anything else

No response

Are you willing to submit a pull request?

Yes

Activity

  1. added
    kind:bugBug report or fix
    needs:triageRequires attention from one of the committers
    on Nov 12, 2026
  2. wrprice commented on Nov 14, 2026

    @wrprice
    Contributor

    On NB32-rc3:

    • Move refactoring will not proceed because it refuses to move member to parent class, suggests Pull Up instead.
    • Pull Up moves field to parent interface but dialog warns that original default access member is not public.

    After pull-up there is a valid syntax error that = is expected. IMO this is not a bug. Java interfaces cannot declare non-static fields. When the member is pulled-up it is implicitly made public static final and therefore must have a value assigned to it.

  3. jherkel commented on Nov 14, 2026

    @jherkel
    ContributorAuthor

    If you check test for Move refactoring you can see use case.

  4. wrprice commented on Nov 14, 2026

    @wrprice
    Contributor

    In the original issue description, you don't state what the exact syntax error is or why you think it's incorrect. What's the expected result you'd consider correct? My response was based on the info provided and what I could see of real behavior.

    If you're referencing an existing test case, please provide a link and don't make me chase it down.

  5. wrprice commented on Nov 14, 2026

    @wrprice
    Contributor

    Chased it down anyway, looks like referencing PR #9802

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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