On Thu, 11 Sep 2025 02:14:37 GMT, Vicente Romero <[email protected]> wrote:
> Recent fix for [JDK-8359370](https://bugs.openjdk.org/browse/JDK-8359370) > introduced a minor bug. This code should be accepted by javac: > > class SuperClass<T> { > public SuperClass(Object o) {} > } > > class Sub<T> extends SuperClass<T> { > public Sub() { > super(new Object() { > void foo() { > getClass(); > } > }); > } > } > > > but it is currently rejected as the `getClass` invocation is considered to be > an invocation of an instance method of class `Sub` thanks guys for the review test/langtools/tools/javac/SuperInit/SuperInitFails.java line 195: > 193: int i = new SuperInitFails(){ > 194: void foo() { > 195: System.err.println(xx); // this one is OK, xx field in > the anonymous class Suggestion: System.err.println(xx); // this one is OK, reading field `xx` in the anonymous class test/langtools/tools/javac/SuperInit/SuperInitFails.java line 197: > 195: System.err.println(xx); // this one is OK, reading > field `xx` in the anonymous class > 196: } > 197: }.xx; // this one is OK, too, field of a fully constructed class Suggestion: }.xx; // this one is OK too, field of a fully constructed class ------------- PR Comment: https://git.openjdk.org/valhalla/pull/1567#issuecomment-3285063582 PR Review Comment: https://git.openjdk.org/valhalla/pull/1567#discussion_r2342180019 PR Review Comment: https://git.openjdk.org/valhalla/pull/1567#discussion_r2342181644
