Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring 'Move members' mistreats record the same way as described in issue #7044 #8290

Open
homberghp opened this issue Mar 3, 2025 · 0 comments
Labels
kind:bug Bug report or fix needs:triage Requires attention from one of the committers

Comments

@homberghp
Copy link
Contributor

homberghp commented Mar 3, 2025

Apache NetBeans version

Apache NetBeans 24

What happened

When you try to pull up a record (static) member of the record type, refactoring drops the record information.

Context; School extends Institute.
Pull up member Student to institute

The code in class School

    record Student(int id, String name, LocalDate dob, String... grades) implements Serializable {

        Student    {
            // ensure valid id
            assert id > 0;
            assert name != null && !name.isBlank();
            assert dob.isAfter(LocalDate.EPOCH);
        }

        String gradesAsString() {
            return Arrays.toString(grades);
        }
    }

After pull up Student to Institute:

class Institute {
    class Student implements Serializable {

        private final int id;
        private final String name;
        private final LocalDate dob;
        private final String[] grades;

        Student(int id, String name, LocalDate dob, String... grades) {
            super();
            // ensure valid id
            assert id > 0;
            assert name != null && !name.isBlank();
            assert dob.isAfter(LocalDate.EPOCH);
        }

        String gradesAsString() {
            return Arrays.toString(grades);
        }
    }
}

Language / Project Type / NetBeans Component

j17 netbeans 25 and earlier

How to reproduce

recordast.zip

Unpack the zip file, open resulting project with netbeans, and try to refactor the teacher or student class by pull up to super (institute).
Resulting code is wrong because no longer A RECORD and incomplete (constructor does not initialize final fields).

Did this work correctly in an earlier version?

No / Don't know

Operating System

ubuntu 24.04

JDK

17

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

I am working on #7044, in PR but my solution is not yet complete, because it is quite hard to find the relevant places where the distinction should be made between normal classes and records.

I'm currently working on #7044 and create a PR, nut that should be held up until it is complete.

Are you willing to submit a pull request?

Yes

@homberghp homberghp added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix needs:triage Requires attention from one of the committers
Projects
None yet
Development

No branches or pull requests

1 participant