swpalmer-cl opened a new issue, #6139:
URL: https://github.com/apache/netbeans/issues/6139
### Apache NetBeans version
Apache NetBeans 18
### What happened
I had an inner class that I wanted to move to it's own top-level class. It
in turn had some nested classes. Something like this:
```
private class MyClassA {
private static record IdAndPrefex(String id, String prefix) {}
private static class Request {
// more fields and methods
}
// various fields and methods
}
```
After moving to the outter level (with warnings about some fields that would
not be accissible - I would fix that later) the result was this:
```
private class MyClassA {
private static class IdAndPrefex {
}
private static class Request {
// more fields and methods
}
// various fields and methods
}
```
The record was converted as a static class and the fields were lost.
### How to reproduce
Start with:
```
import java.util.Collection;
import java.util.List;
public class BugTest {
class Inner {
private static record NumberAndLetter(int number, String letter) {}
private Collection<NumberAndLetter> things = List.of(new
NumberAndLetter(1, "a"),new NumberAndLetter(2, "b"));
public void doStuff() {
things.forEach(System.out::println);
}
}
}
```
Refactor to move ```Inner``` to an outer level.
The result is:
```
class Inner {
private final BugTest outer;
Inner(final BugTest outer) {
this.outer = outer;
}
private static class NumberAndLetter {
}
private Collection<NumberAndLetter> things = List.of(new
NumberAndLetter(1, "a"), new NumberAndLetter(2, "b"));
public void doStuff() {
things.forEach(System.out::println);
}
}
```
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
Ubuntu 22.04
### JDK
17.0.7
### Apache NetBeans packaging
Apache NetBeans provided installer
### Anything else
_No response_
### Are you willing to submit a pull request?
No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists