You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
mbien
added
Java
[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)
and removed
needs:triage
Requires attention from one of the committers
labels
Jun 29, 2023
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:
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:
The record was converted as a static class and the fields were lost.
How to reproduce
Start with:
Refactor to move
Inner
to an outer level.The result is:
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
The text was updated successfully, but these errors were encountered: