Refactoring 'Move members' mistreats record the same way as described in issue #7044
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 935
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 17
Description
### 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
```java
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:
```java
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](https://github.com/user-attachments/files/19053718/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
Contributor guide
Research direction
Start with the NetBeans Move Members refactoring, reproduce the pull-up operation using the attached recordast.zip project, and inspect how it handles Java record types. Done means pulling Student to Institute preserves it as a record and produces complete, valid code rather than a class with uninitialized final fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100