RFR: 8271623: Omit enclosing instance fields from inner classes that don't use it
liach
github.com+7806504+liach at openjdk.java.net
Tue Aug 3 07:02:32 UTC 2021
On Tue, 3 Aug 2021 03:19:13 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:
> This change omits the synthetic `this$0` field from inner classes that do not access any enclosing instance state.
I hope we have a test case that ensures the field is not erroneously removed when this nested class doesn't use the field, but another nested class within this nested class does. An example:
public class Second {
int t = 3;
public static void main(String... a) {
var q = new Second();
var p = q.new Third().new Fourth();
q.t = 6;
p.print();
}
public class Third {
public class Fourth {
public void print() {
System.out.println(Second.this.t);
}
}
}
}
-------------
PR: https://git.openjdk.java.net/jdk/pull/4966
More information about the compiler-dev
mailing list